7 C! y& t4 ^3 B0 {- / RevApp.cpp : Defines the class behaviors for the application.4 T, v" h2 G# _8 o6 E
- //
; b$ q+ b8 Z1 h - 3 |" |+ ] w) d8 ?7 B
- #include "stdafx.h"
% a3 {3 Z5 O- A- x; e: j ]$ L3 K l - ' L+ p) I4 {: q: D1 Z
- //#define UNICODE
# ?6 R1 l( c/ |+ _0 k - //#include <gdiplus.h>% H- }' g4 L: b- X! N: v! Z9 b# g0 X& M
- //using namespace Gdiplus;7 G( `5 b! S0 ^# J
6 T8 i; N, p& G$ @( q- #include "RevApp.h"& f; U7 D! G1 p
- #include "RevAppDlg.h"
3 G- v3 r" O0 N* l - 8 ^/ c+ n7 {0 \
- #pragma warning(disable:4786)
# C X. i5 y2 H( ^5 b - #include <map>
9 Y# i, w6 t- _5 K3 S$ L - #include <list>
7 N* o: X7 n- t b - #include <direct.h>% u6 G6 d8 c4 q, y6 m/ s
+ S: C$ L" h' U* r0 h5 V) H, A- #ifdef _DEBUG
" I# g+ h+ k8 Q! k- s - #define new DEBUG_NEW
8 Z) i& Y/ ]: f - #undef THIS_FILE
: _$ L% L+ u9 J - static char THIS_FILE[] = __FILE__;+ J2 }& i4 X5 W$ ^& X
- #endif2 t4 c0 O$ I+ @4 l
- #include "SkinResDef.h"% C; t# \' I) P, i/ b
- #include "ChangeBG.h"
4 v8 ]- z1 L+ h. E% a - #include "AFXINET.H"- x4 G0 Y- a% S2 a7 H% [( O
- + w R# ^ U3 H" p
- #define TRADITIONAL_CHINESE 0$ B7 ?+ q- ~- \* e
- #define SIMPLIFY_CHINESE 1, Z# ?& Q! ~8 [. w& Z5 B
- #define ENGLISH 2" R8 ?' t7 J7 v& W' s
- int m_iLanguage = ENGLISH;
) a( \9 J& D) K0 A - /////////////////////////////////////////////////////////////////////////////
7 i# z+ v7 w0 S* j, L, ?6 D' T2 {* w - // CRevAppApp
; j+ M8 f& @' {! P( w4 T, B6 }+ F) s# u - + J3 K" s; z |" H# J
- BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)0 j$ s M( x- ~/ B u
- //{{AFX_MSG_MAP(CRevAppApp)/ o, l: O0 m* N- j5 ^: }
- // NOTE - the ClassWizard will add and remove mapping macros here.& R: U: ?0 c9 B% `
- // DO NOT EDIT what you see in these blocks of generated code!, e4 q- l5 q0 p. G' \& p* }
- //}}AFX_MSG
0 g' u c' D/ @9 B$ U) T+ V3 V- B' } - //ON_COMMAND(ID_HELP, CWinApp::OnHelp)9 Y4 K) o8 e/ o4 @& H2 _- l
- END_MESSAGE_MAP()% P" c3 a4 ^9 J" S
2 D# X8 F2 K4 v% ]# a. ?- /////////////////////////////////////////////////////////////////////////////
5 H) z% P) x }/ U* F - // CRevAppApp construction
* Z+ s1 d8 m+ N8 R2 G X
, i$ H3 A7 E; o- _. K8 |5 F( z& l- CRevAppApp::CRevAppApp(): k- R, U0 F. o5 Y2 D
- {
/ M* J4 J3 R9 |8 y - // TODO: add construction code here,
& u* P1 U+ \+ o - // Place all significant initialization in InitInstance
$ o/ ^9 h5 O h7 Z9 u. K( _ - bDisplayIsBig5=FALSE;
c7 y% |9 E7 D3 s7 T8 m! { - bRestartUpdater=FALSE;
6 Y6 q, \2 Y A. N6 { - bFinishUpdated=FALSE;8 B9 Q3 p$ h( m; t7 W( v4 `0 p
- if(GetACP()==950) bDisplayIsBig5=TRUE;
3 b y+ b0 P2 k, q. V3 V+ k8 \ - InitChangeDataBig52GBKS();
2 J, L1 n4 q! W. g, e: B o. F - InitChangeDataGBKS2Big5();: t+ P" b# [: D9 B
- //1 `7 C6 l, ~% i# S7 J
- bClickRunExe = FALSE;$ S$ R4 E* G: w1 A( n6 L
- //0 D; X7 \7 w% v' y
- }
9 o% w2 Y2 x* I- ~9 u( C4 F k
5 z. `5 a3 E8 v- CRevAppApp::~CRevAppApp()) y% ~2 C; K: ]; ~
- {" ~& S. w- E1 z* z" z2 F! L
- // TODO: add construction code here,
- ]* U# l: J3 p- S2 ? - // Place all significant initialization in InitInstance7 Z' p: W' G& B( H' I
- EndChangeData();! ?2 q+ y, j4 `9 `# f; }" ]6 b
- }. U' g9 w$ n/ C z& o
9 v! c, z1 h5 T! z$ {- /////////////////////////////////////////////////////////////////////////////
0 \& Z4 w$ ]+ o% m - // The one and only CRevAppApp object2 a4 a: o( R/ t0 k
- ) G! u$ @ r# m9 Y
- CRevAppApp theApp;' i9 L- J/ @ S1 W& {
- m# ]; t8 w2 \' ~9 d J. G- char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)
: C( @" @9 y$ d+ U - {. g d Z: A' O( r8 c( p
- int iEOF=0;
+ N* a4 g4 p1 W- O - char szTempName[MAX_PATH];
: f" r( a7 E) ]4 Q' L- i" q4 i - *szFileName=0;. j/ |: F' t9 m/ ]5 a8 q
- iEOF=fscanf(fp,"%s",szTempName); J$ y% A: C2 z) g
- if(strlen(szTempName)>=1&&szTempName[0]=='(')1 q$ v* Y s. o6 }* T) z4 {
- {
( d9 c4 |" J+ ]0 \, z( _ - strcpy(szFileName,&szTempName[1]);! a* } Y( B1 ~
- while(!strchr(szTempName,')')&&iEOF!=EOF)
' M. v y+ Y4 m I/ r" H* ~ - {/ H6 D! d- z q, J! H- ~3 {
- iEOF=fscanf(fp,"%s",szTempName);2 f# n5 k6 N: z: D& N4 Y# z
- strcat(szFileName," ");& c+ I0 U- v% K' d
- strcat(szFileName,szTempName);
& S y+ I0 K; B' }# a - }
' G" w" F. u7 |" ~ - if(strlen(szFileName)>=1); R0 P H [: y/ H' O6 X
- {. A ^2 n4 _0 Y" ^: l
- szFileName[strlen(szFileName)-1]=0;# C7 I) c8 H6 [) n8 J* U! x
- }
% b! M2 m3 m- ~4 z% Z - }0 s) f4 D6 W/ G: ], Y
- return szFileName;
G1 W( Y2 X) r" o4 ]0 C3 G - }
, u, K! q, N- N$ i, c8 J
" X5 N, N: F' U4 C) E5 l& t7 A' w- bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)2 f8 W0 E5 \7 H: h
- {
' y3 \3 _. u1 J# j5 R2 T, V - FILE *fp;4 P) B0 }5 k0 e1 Z; w
- char *key=NULL;8 t" Q5 `( e$ i
- char version[MAX_PATH];
) w3 o* [4 J, a+ [4 P - LPUPDATEFILE file,olds;
+ f9 J3 ?- m% F& t5 |+ U7 K - std::map<CString,LPUPDATEFILE>::iterator p;
5 e5 t& L4 T# O& q$ k - $ a2 f- b6 w! Z
- UpdateList.clear();: t l6 Q' l; W* d; L/ B
- UpdateFile.clear();
$ d) p/ c7 D% A, L3 J5 B3 V - if(GetFileAttributes(filename)==-1) return false;
" k8 u- e: M% ^6 K3 X( q - if(!(fp=fopen(filename,"r"))) return false;
( U- [: H* a8 @3 o+ t/ F. o - fscanf(fp,"%s",version);" E' F R, N0 \! M! e R3 }% v
- if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }- K! F/ R" M/ k) Y3 j1 K( E6 N
- while(fscanf(fp,"%s",version)!=EOF)
) n4 V( k5 I# F; ^- O6 F; S8 H: X" r - {: ?7 l3 j7 U. G3 j7 I7 t3 l" V
- file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));5 c8 ~ [! A% }" h# L% q: O
- fscanf(fp,"%s",file->path);
! @/ M( y2 c# A9 p+ _ - ReadFileNames(fp,file->file);$ |' q0 X9 z/ S5 r
- strcpy(file->full,".");8 Z' |6 K) J2 B, r; l) e) S
- strcat(file->full,file->path);2 j- M( C4 q0 ?' Q U- N
- strcat(file->full,file->file);: i, t( l7 d [- g; o
- if((p=UpdateFile.find(file->full))==UpdateFile.end())( K4 O0 Y; ~# ?: P) R
- {
X' H6 Y+ i+ Q$ w' Z/ g2 N" C - file->vers=(float)atof(version);& J+ ]/ A5 K( c6 x7 _- d% c5 h$ C
- UpdateList.push_back(file->full);
; q$ i- R" F: l2 p- T - UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));/ H: h: ^% u7 J( J M7 m. C7 C! u
- }
8 t4 Q# Y( o0 V6 ]) ], i - else' b6 E8 k. M# e
- {3 b0 S! M3 r- I f9 {
- olds=(*p).second;
' L/ F+ E; `! J4 n4 ^$ l( G - if(olds->vers<(float)atof(version))
! Q* @. a. e$ A, s' R - {
$ f# `! t1 x" ?- F6 p( w - olds->vers=(float)atof(version);
H4 S: j) b+ o2 A- |( }) V3 a - }( ~3 _' b7 F+ T4 T% D
- free(file);
" M H6 h2 v$ F) l, c( [# Z - }) D+ W8 p7 D! E
- }
3 B& b3 T2 e0 g6 }2 K - fclose(fp);
7 l) @: i" o; A( ]. f - return true;
% p5 q* h' R3 `! G& v$ g - }( f) y$ s& o# Y' u9 \
- ; ~0 Y- U2 M% i6 z' x( R1 D
- DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)
8 m' U6 F/ r; `$ }" e4 E5 \4 K - {, ]8 V6 a' D3 e( K
- TCHAR szFull[MAX_PATH];
T3 ~' a+ g- U* S6 S5 g! o - TCHAR *token,*inter;' E% ^8 h/ v' t: F# J9 I+ h
- *szPath=0;0 e3 E# ~3 p! u( v
- strcpy(szFull,szFullPath);
: p& @1 |' o6 l7 a* k$ q# H; j( S - token=strtok(szFull,"\\/");
% @1 e7 ^! W+ B - inter=token;
& J8 u+ s% i$ S - while(token=strtok(NULL,"\\/"))
4 U% Z9 Q, d4 v1 S, s6 m+ K - {
/ e( Y/ T e; N/ n4 z - strcat(szPath,inter);; y2 v' C e( z8 a( [& ?
- strcat(szPath,"\");
8 ]' l6 I7 ^: S/ V4 V9 i+ s( R - inter=token;' |2 d, Q% z9 i1 w" @1 }( A
- }
. g' U5 Z+ b( B! f! r S - return strlen(szPath);
% ]8 M' A7 e% r' Y; o6 D& W - }0 ~0 r+ m1 K% @! V# M. e
- 7 t ~' v) [) q' t
- void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)
; P |3 c1 a3 s - {
9 L! b1 h8 e9 e4 a - DWORD attrib=GetFileAttributes(Target);
/ N1 w, N# W/ U& ]" U - if(attrib!=-1)
! }) ^6 i% \4 m$ o9 j! F - {
" w# z! {- ~0 m; V - if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))
1 l$ d' W7 D8 Q! k+ ]. p - {7 Q( `9 R+ m; J
- attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);) ?" E+ I$ g3 \" f
- SetFileAttributes(Target,attrib);
w* C" |6 L5 w6 D0 z - }
) s6 ^; e" v1 x - }
5 X# L8 ~8 J! w E7 a; a4 R - CopyFile(Source,Target,Erase);
& l7 }3 C1 M$ K( ^; ~5 H! X6 M - }3 Y& S, w W$ S
- $ N; e* S- m: S; a: z- k1 [0 F
- void CRevAppApp::Fprintf(char *FileName,char *message, ...)
H; s ], N. t3 }0 m; u6 J. z8 t - {
* y4 e/ J8 T5 q - FILE *fp;
* m& |% C; }0 y& R1 L" ~ - char szBuffer[8192];' G! A, s9 L! D" G! Z
- va_list argptr;: P8 {; r) e, i4 y" G) w& V. n4 D
- / e+ n, i9 n7 L, Z
- va_start(argptr,message);
1 d% F2 r; A. a - vsprintf(szBuffer,message,argptr);
$ G: {" ]( b/ r# l) p t# Q7 z - va_end(argptr);# m# x; R# H( |5 D" }
- fp=fopen(FileName,"a");' D+ ~% T8 e0 N* a, e; q# A
- if(fp)3 D& J* \# X0 R6 V5 k" R5 W+ [; j
- {
1 ^4 q- i/ o" B; d- c& c4 E4 t: L - fprintf(fp,szBuffer);
' K+ k8 h' P0 J; O - fclose(fp);
6 J1 n' O& R+ d$ Z# C* i* E - _flushall();
2 |4 Y9 Z l: ^ - }
+ E) j8 e5 `, X( ] - }
4 o6 \( v1 H. b - 9 J9 _% i$ e V$ @1 G) ^( Y( ?$ U
- BOOL CRevAppApp::Fclearf(char *FileName)
* z" B/ ~* f1 Z' C3 e* N5 A - {3 A4 r. X' @; c# t# z+ W
- FILE *fp;
2 O9 s9 w1 O6 @ p3 R, `6 ^& l: N2 L - DWORD attrib;6 m4 f; l7 ^; ~! p) E/ K
- attrib=GetFileAttributes(FileName);5 U/ c3 M3 _" h$ W! T! D" `
- if(attrib!=-1)
5 e% t2 g0 i; r7 L - {
# {, G2 x e) ?1 w9 P& W: @& M/ U - attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);( P* Z& q4 @4 o1 \
- if(!SetFileAttributes(FileName,attrib))) T+ m; u! r3 O H; Y( i- D1 {. B
- {
. l2 z' `% Y4 u$ |1 U3 p3 | - return FALSE;
6 a0 l' O8 t5 J0 H, j( N, t - }: I& g& i% s$ L! |
- }
5 g" _# [ p, W: F5 y - fp=fopen(FileName,"wb");( g- V* F7 t, U
- if(fp)
. o1 Q; K# U1 L" j - {
7 ]7 ~. C O) Z# i2 D, } - fclose(fp);2 a. L( O6 D0 O* J
- }
9 _$ D6 W8 g/ \/ I5 d% w - return TRUE;
' I) m' C; Z, Y. ?+ P - }3 Z9 H/ z: ]1 c
" d8 z! x( A) [% \+ S* k- `- BOOL CRevAppApp::UpdateLocalVersion(void)
1 c. L; e) a6 n! ^1 y& J6 U: q - {
: X& m4 c% t7 t m - char filename[MAX_PATH];
C, [, j: c/ E7 g- v" s; e! C) @4 S - LPUPDATEFILE file,olds;. k% Q6 c6 `* q; H' S2 I
- std::map<int,CString>::iterator i;+ C( l; k# P( j H: K+ a" Y
- std::map<CString,LPUPDATEFILE>::iterator p;. I" n) X% z( M! R2 b' a* I
- std::list<CString>::iterator l;$ o! W9 M+ S; W7 c0 o; `/ N! p- [
- 8 E ?. L5 ~* y E1 v$ W% i4 Z
- if(bFirstUpdate)' H0 B" m$ f u" l; U) G
- {4 g( F: Z3 c. }, }, G% c
- dwCurrFile=0;- u7 S: C+ ~, U# J2 ~
- bFirstUpdate=FALSE;. x5 B9 h! K8 R% |( `5 k, d3 k5 n
- if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())/ B9 Z: I( Q; w$ U- q7 b
- {% B# q# {4 l' \/ Y9 @
- dwTotalFiles=UpdateLocal.size();
7 J) t7 d- ?1 V: b - dwDownLoaded=0;
. c' R) f) M# D. v1 W2 X* Y - bSilentStep=FALSE;2 S6 O. |; O" b% G/ g! m6 ^
- bCompressed=TRUE;
; Z9 J ^' O9 L) G. q7 j: o1 h - strExtLocal.Empty();5 [4 s5 N& s' W, V* S: x6 w' s* s0 d
- strFullName=(*i).second;% k6 t$ T; X% o' J4 P: K3 F' o
- dwProgramState=AP_CONNECT;. a* e" ?/ X: r# y f9 b7 x
- return TRUE;1 n3 q- ~1 R9 \) ^" V
- }' W! H6 I {) m
- }
! a( ^' x. L! V9 A$ M/ q3 t& H - else if(bRestartUpdater==FALSE). c F0 I" ]9 w% l, q% w& r/ F" s
- {4 l! b( x4 b# {2 \
- if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())
. D% p# d/ t; Z& t l# s - {
0 m* F6 ?9 G$ X$ T8 o& x - file=(*p).second;9 t7 j$ L' O- j; [8 l0 {* D* N& V* @
- if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end()); l+ ^3 W7 w. w+ T
- {% b" f3 O. y" \0 s
- olds=(*p).second;
9 q5 m/ N% s, c" z - olds->vers=file->vers;
) {6 Y" g5 [0 l6 o0 y - }
( M6 |9 K4 o- a' [' O - else/ o; |8 a1 e1 b' V7 G" i1 f, P1 ^
- {8 X% ^! Y' K$ U
- olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
! E; _9 h7 y0 o( Y- m$ Z$ T - memcpy(olds,file,sizeof(UPDATEFILE));; |6 E* n0 \4 H p& v" d
- UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));! G, D1 k2 Q; i$ L
- }
4 ^( }! g3 m+ ]- I( r7 v) A, L - if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");; ]) k( Q) b8 a8 F# x3 G1 i
- sprintf(filename,"(%s)",file->file);
* k& {" O: L c- t @ - Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
: v" l O" D4 B+ a - if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }$ ^, f/ w" m. ^6 V9 y
- }" y+ S( C) H( I$ k) ^
- dwCurrFile++;. D- P. r& U) E F! X" F2 j
- if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())- T& N9 V) ^/ @7 W) }- K
- {3 w8 H5 c* |8 m4 }
- bSilentStep=FALSE;/ c" R3 [5 c5 A. E" ?! |! q% u
- bCompressed=TRUE;
' J) S$ {% R6 l/ P; q; p - strExtLocal.Empty();" m5 R6 L1 q {% T
- strFullName=(*i).second;
# P) u- t8 n) w/ r6 o - dwProgramState=AP_CONNECT;
, o( N5 S! O' E p& x2 g) G* C8 S - return TRUE;7 _- S& b+ M$ ~, r& A
- }
' G# G; m# v4 C, b$ t6 p- y - if(!bRestartUpdater)
2 \+ ]: Q, {; [" t3 i3 W! | - {
+ q* ~" U2 m; _8 `' r* m: Z - int iCurrSize,iFileSize;2 F/ J' {8 _6 f3 x
- iCurrSize=0;
1 L4 a" }# u8 X. |4 A8 ~ - iFileSize=UpdateList2.size();
# \# ]5 ^0 t, h, y5 P8 Y$ f6 K' ~ - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝戈い.....");
* P' ^9 b! P- Z/ Q% @4 s2 L+ s - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新资料列表回存中.....");9 | d3 m) E# }. R) @+ m: ~5 d3 {
- else dlg->m_ListText.AddString("saving updated files.....");
4 x9 w6 [6 b2 g8 C* X2 f! l - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);. W2 ] V+ y5 F0 Z+ \$ h/ J
- Fclearf(".\\update.dat");1 U, r5 n0 ?$ [, Z
- Fprintf(".\\update.dat","Bloodyf\n");
& g7 _6 {+ B1 G* f' O# r - for(l=UpdateList2.begin();l!=UpdateList2.end();l++)
9 |: \. n: F2 U5 O3 G6 W. ]5 z; j - {) O" a7 P$ i0 k8 g/ S$ \, h* H+ M9 \
- if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())
$ [, ]8 Y+ h9 y0 L; }/ ] - {, i l( i' B% e8 z' o- Y- h
- file=(*p).second;2 W0 T' @+ C9 x4 S# [& m( [
- sprintf(filename,"(%s)",file->file);
6 n6 t! q: \# r4 D/ R4 w - Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);2 f9 n u4 M% q( h$ ]) _
- iCurrSize++;2 u' S2 `4 r# _/ ]; C
- dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));
; j( z$ V2 }0 ?' a' e2 M7 X& B - }5 V9 i( K$ J0 w. H' Q
- }
, q0 y0 ]. u. Q) d3 x - unlink(".\\update.txt");
* D& G( h% ~8 Q - unlink(".\\update.tmp");4 J" P) q0 T% s. Q- |
- Fclearf(".\\checkversion.dat");
: ]7 }: L! X1 `2 I - Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);0 `; c8 M5 Z+ y1 n3 ?
- if(UpdateLocal.size())
$ X7 M. P' p7 N* ]. r B - {4 n1 O# Q; q1 U3 H
- UpdateLocal.clear();
( r+ o; i1 I5 A" t4 z' J- I - }, a \* l" K3 C
- if(UpdateFile3.size())
/ ]! Y' V0 |/ c4 K( k - {
) ]& l% ~4 a# \& C - for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)2 k0 a& N: X3 `7 o& s& O
- {( m1 x" U6 {* |/ Q: n( i- v
- file=(*p).second;
( d, `- Y9 e+ Y% o; \% F - free(file);
- N3 b) C# c( D6 F( y - }
2 n4 K% c( F+ F2 M/ A5 V3 c - UpdateFile3.clear();
3 @7 p' j6 S& F# l - UpdateList3.clear();: C; k+ [5 f2 M s4 \
- }
' G$ c V# W+ R! E/ P - if(UpdateFile2.size())
% V0 ]# [' i' E4 J - {
9 e# g- M4 r+ Q: h4 \/ F - for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
: }" Z8 d+ v' A# t - {
8 {2 z9 G8 a# e, u9 y% W [ - file=(*p).second;1 ^: F9 t9 A9 e: u" J6 ~
- free(file);% G; R; {5 P: Z# _5 a
- }1 p" o1 H+ _5 ~
- UpdateFile2.clear();/ k4 ^2 d2 A9 E0 t7 C' g' J
- UpdateList2.clear();# M: K) Z) J, A# [3 E/ P. K
- }3 A' b6 {. K) Z8 Q9 e9 H, w
- if(UpdateFile1.size())
j- m) W+ W* V5 ?8 J - {
( w! e* o5 Z8 C5 A - for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
" a6 h( p" P, c! I `$ H. u - {' b' J) ^' I+ z% s' x
- file=(*p).second;
" F: O' |8 g( ]8 z# k3 f: k - free(file);- I0 j* m. r! Q* G2 J
- }1 h: R6 E8 U2 V3 B9 M' h
- UpdateFile1.clear();2 e4 }) c- z# B' G0 R2 S
- UpdateList1.clear();* x4 {1 w5 s+ \0 \6 X
- }
, i/ T, C+ o: R3 f7 Z+ e9 [ - dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
5 p: u& E" Z1 Z* N; s1 R" `3 R1 { - }/ Z( [; r, S1 s& N1 O% ^
- }
7 G. x) r* e6 g6 y, Q: ~' H - return FALSE;" L& ^4 K& M# ]+ }# W% P
- }
+ S" P) L5 y$ {" j8 X& N( D - + p% T+ e* r7 u
- void CRevAppApp::ClearAll(void)
/ q/ B3 c/ A2 m# b3 c% O - {8 H$ o8 i, l' F% D$ S
- LPUPDATEFILE file;
2 _) i& L: l6 ~# z - std::map<CString,LPUPDATEFILE>::iterator p;
* Q* _7 }: g: ?3 U }2 g4 [1 Y
- i7 C" e& V# G7 K2 E- if(UpdateLocal.size())3 z- D, F5 C% k" z
- {
4 a8 X7 f& p0 x) _% E - UpdateLocal.clear();2 r1 N0 ^) b; T
- }& j1 J% y/ {: H2 N
- if(UpdateFile3.size())8 L- r8 Q- R# \$ m" m
- {; G7 R- W: f; v& q' ^' s! v+ `
- for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)
+ g" H, V2 t, n' ] - {
0 z' B! J( B w0 i' k" E* C) w: Z# x - file=(*p).second;, b! A ^% N. H
- free(file);
2 f Z. Q, v5 d - }) }- o1 S' Y- b2 e6 Q z
- UpdateFile3.clear();6 K; b. Q$ ~1 n9 t3 U
- UpdateList3.clear();0 j# C! L# U( I5 |9 G! E6 G7 g
- }- r6 w5 U; f$ `$ G
- if(UpdateFile2.size())
* d7 @, C* ~6 }9 N: Y% m2 ~ - {* {3 [1 p3 y$ h; w ]8 v( S
- for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)9 { j: C$ P/ q7 W# U
- {2 W* D" E/ K. l2 W
- file=(*p).second;
; c& `" E* \! M6 g5 V& ] - free(file);
1 s- M% T% M8 ]2 R - }& q! V) ~5 i9 T- c! b% ]
- UpdateFile2.clear();
M& `+ q7 M: G4 D& f1 V - UpdateList2.clear();! U& U. x7 r8 `% f
- }
9 n& I5 s+ k. g3 [; S7 V - if(UpdateFile1.size())
! R7 Q6 G1 W. R* @4 E4 B - {. u8 x, |0 \7 M8 s# X* e
- for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++): w4 v7 Y P7 a! j3 f
- {
- h2 Z3 P, X9 e8 C$ Z8 Z - file=(*p).second;* u/ e# Y8 [$ Q4 X
- free(file);; ?* L) E, d+ Q" p
- }( Q8 ^4 S0 h# m$ K. n1 V
- UpdateFile1.clear();
2 `, P% } {% A, ]4 I; H( Y9 N - UpdateList1.clear();9 w; g- f* n- }$ g4 j3 c
- }3 }- P# d5 |% R Z
- } , I X5 g8 X; W, Z* g
- ! q; w8 {/ J# g8 I3 r
- BOOL CRevAppApp::CheckLocalVersion(void)) u5 _- }( [5 ?7 F: M! F
- {
9 j# }2 o. y. L; i3 r' _ - int c;
+ O1 I" c$ }+ [$ F3 J t2 s - LPUPDATEFILE file1,file2;
. T4 R/ i: y. t7 R8 e# z. E - std::map<CString,LPUPDATEFILE>::iterator i,p;, k% n( p$ ^7 |, r7 z7 K S
- std::list<CString>::iterator l;( b; z2 a: t7 E) `7 F' i
1 j. T- ?: C& f, W( X# l# c- s- UpdateLocal.clear();
# F3 `8 f8 ~3 ` - LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
+ t! s \7 T6 I1 N( v - LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);2 |- O; l- @0 C! h# Y$ W! K5 Q
- LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);. F* N8 k- Y% I- p4 g
- // if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
* K8 m( B, J, j" q- ^ - if(UpdateFile3.size()), R1 Q0 v) ~$ f u9 }
- {
' ?/ {$ ]1 x5 C4 h& A" k. {4 } - for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)) N6 Y. E1 A1 o6 Q
- {
, D$ k, P. N1 b' i0 N3 F - file2=(LPUPDATEFILE)(*i).second;- d; e2 b. n$ v2 s* e
- if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())6 l1 `8 k4 |! t3 H8 e' W1 `1 }
- {7 p9 \. ^' @0 i
- file1=(LPUPDATEFILE)(*p).second;6 G8 l0 \" [/ Z' j; |) W
- file1->vers=file2->vers;5 [/ p) q: B2 m" r, d6 ~
- }( m8 P- e8 s6 Z* `% g1 W. m
- else
' g" t0 Z+ H) ]1 N. f: e - {7 w( j x/ M5 F, C% T/ L" a
- file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
& @5 D6 U Z# M0 @ - memcpy(file1,file2,sizeof(UPDATEFILE));/ X3 B% T' {- L+ v
- UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));
6 a0 d; @/ G5 i& ` - }
. h; j2 I; S2 d/ q - }
4 j* ?9 J' C+ m5 j4 b - }
- @5 g, [& s" k- p* v( r - for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)( t2 H1 Y. G! g
- {
. j7 E" t" @# s& Y/ H6 l3 X# ]. } - if((i=UpdateFile2.find(*l))!=UpdateFile2.end())
$ ~' c4 f+ Q) V - {
8 K1 G; a( f# j; @ - file2=(LPUPDATEFILE)(*i).second;
+ O4 C1 k, W* H3 t7 K0 N) V2 V - if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
; U/ W0 s3 i5 j" L0 T5 [ - {
7 w2 d. E$ m9 O$ a3 s - file1=(LPUPDATEFILE)(*p).second;$ x: \; ?% l, t9 H, f0 q6 k. \
- if(file1->vers!=file2->vers)
( Y) X+ ~/ r3 a L - {6 k' G* E7 x( x! N$ {- H* \0 _- }
- UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
. t, m0 b9 G1 F3 ? - c++;
6 q0 k% q j) y) m - }. L# |. L9 _& p
- }4 Y- t- m2 I) _5 _* R
- else
# }6 k& e- b/ p - {! p) h2 {5 F! q& @% ?4 D
- UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));5 t7 f3 X0 o' v0 B/ W/ }
- c++;
* ~5 m* J, }8 P' \0 z7 R - }
. n/ h* A: i$ \+ V; z8 K - }; i2 X% W0 o K, {1 a2 Q' I) s& U
- }
# Q2 C1 H$ A E, y/ t - unlink(".\\DownLoad\\update.txt");
. C% Y7 h' A. I% ~# w1 l- k0 [ - if(UpdateLocal.size()) return TRUE;
/ U9 t5 |% }2 I# d* U - else return FALSE;
! p1 o" W ~- X1 D - }
3 f$ g5 L- c2 a4 H# k - 7 N' Q7 b- ?1 a/ r, x6 D6 B& w% x
- #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"
7 i9 y2 f, R+ v& ]" S - #define DEFAULT_REG_URL "www.wgs.com.cn"! o" N+ O3 W- D) m
- & {" q9 E- u& v' P* @ s$ ~6 @
- " M# C, \ v& W9 z- e1 U" r
: x" |# s1 p, b6 x) F6 b: d- BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)
% e. E7 P4 |3 Q. J3 Y4 o. V9 ?- d; S - {( D0 p! B' M$ H# d. w
- DWORD dwType=AFX_INET_SERVICE_HTTP;
9 \* X# ^/ I' t( N {! k5 }1 n0 ^ - if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)( O3 x6 B" o @& e
- {* o; N6 @3 Y* v
- char szLanguage[50];8 H9 {6 P. u" r: k
- GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");5 [ j8 h, i/ e% h$ @
- if(!strnicmp("BIG",szLanguage,3)) m_iLanguage=TRADITIONAL_CHINESE;
- |' x, D. `& W" Y/ e% V$ z - else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
' z5 V2 D6 E1 Q* A4 v* @' M - else m_iLanguage=ENGLISH;$ u3 n7 ?1 I9 M! w+ p2 J+ G
- char szRegister[100];0 a2 i& t* K3 z
- GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");1 Q7 s: k% A, Q" [
- strRegsName=szRegister;. m$ r6 W! w( q5 x3 h& Z
- char szPatchURL[100];: w! _$ F9 w6 z8 O
- GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
4 f) n) d2 o8 Q9 a2 ?0 @- U - AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort); x3 N6 M$ v# ]4 O& s# S
- }
1 w1 _# {6 ?+ P/ P! \* I) \! @$ ` - else
3 b0 T1 y. o3 B( _ - {
% j, p$ \4 b$ A7 u6 l" ] - AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);) h& e. } T7 Y- z5 O" C
- strRegsName=DEFAULT_REG_URL;/ V9 r& I g4 F
- }2 J8 _4 d7 o3 k( [: t3 B5 N
- if(GetFileAttributes("hosts.ini")!=-1)5 b2 G+ q! p" L: [ l
- {# x$ U0 w8 v! }
- char szIP[50];2 y! `+ j8 d6 O; R/ V
- char szDIR[300];8 h9 b7 B4 Q) c+ E" d% b
- if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))7 A) g+ h# b8 K) Q( u; f: o
- { k$ p7 X8 x5 I+ L( [0 R
- wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");# C" W, N3 e; e, G& h
- GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");
4 S( p6 H( d: g1 @# C - strHostName=szIP;
! Y9 a! G1 f: _& h$ s0 h5 V - strHostPath.Format("/%s",szDIR);
* G* C1 Z: Q% u5 s8 c. P - }
" H! J" ~' o* C6 ^; C, w - else
. V0 @% R n7 I! }' `' V - {
. I; v" v% [' I6 V9 U - if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)
: T6 q2 R7 h% {, N - {
; m: d. M5 d8 S/ z: `7 D/ ^ - char szLanguage[50];
, P3 p. d! v* T- V - GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");3 k& p* F" h) Z+ E
- if(!strnicmp("BIG",szLanguage,3)) m_iLanguage=TRADITIONAL_CHINESE;
# E3 }5 ?' t) H - else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;+ \5 [8 R! r3 K- S
- else m_iLanguage=ENGLISH;
! G0 d# \' M" T( o5 u - char szRegister[100];
3 W9 `7 J+ ^1 w% g; W9 R1 Y5 L+ l5 m - GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
, W0 g: U. G9 w0 ` - strRegsName=szRegister;3 q! W5 p2 e. e, h% G; _7 V" r! V$ M" v
- char szPatchURL[100];
3 u! q1 |' {% ]% l. M _: k- B - GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");+ Z+ @0 x9 X7 W1 z6 g n, p
- AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);6 O8 \ {' d. j% M
- } R9 }/ \! [+ a% W4 x0 |
- else
1 s8 E7 w0 ?& l3 w! r" t& T - {! ^. k9 E0 ~9 u
- AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);8 U1 W* y6 F1 `4 [
- strRegsName=DEFAULT_REG_URL;
4 F3 ?/ W% @1 d. J" D0 p9 g - }
3 W- J- U9 V( ]( j5 h2 | - }
; L0 O" s4 [ K t+ N - }" l& `4 a5 l9 X5 A
- return true;
* H8 m% z* z% J, [1 s- }8 I8 y - }
5 r* F1 X! B: S; ~* U1 T; a/ z - * X, P" i9 _, Q t9 R1 N
- #include ".\ZLib\unzip.h"
( M( Z0 ]+ D( K9 m0 d t: a. h - extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
j: y2 W1 f7 Y' I( O - /////////////////////////////////////////////////////////////////////////////: |* u/ r; [2 }
- // CRevAppApp initialization1 _5 w* G$ [% }. s) N. `, t* d5 e
: A9 P6 q; ]& v) l; i+ f0 G- BOOL CRevAppApp::InitInstance()3 B1 R" x& h" E6 j: R, r
- {
8 n/ Z- A5 W+ f3 i/ \" I2 P# g: { - TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];8 V" C& w$ \- n- b$ T# v
/ Y$ m7 m9 ]0 Y5 b6 O Q" x- GetModuleFileName(NULL,szPathSource,MAX_PATH);
! H7 f: f) v% g - if(GetCurrentDirectory(MAX_PATH,szPath))
D( z" ^/ U0 Z1 R2 L - {8 Z" k& _" K, k3 Q
- if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");
, W: `0 \ b" m" q: @+ E( U - GetPathFromFullPath(szPathTarget,szPathSource);+ G! C% W0 q3 q) w) G. J
- if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))& I6 G2 s. b, Y w
- {
8 T# x' y8 m% Y) g/ l" A2 O& _ - strcpy(szPath,szPathTarget);
6 V+ J+ a. r1 R' n# i - SetCurrentDirectory(szPath);
' d9 k' ~- Q. K( g e - }/ X& N/ i1 G8 [
- }) B; Y! S/ K4 I+ l' r J. c
- #ifdef _DEBUG
! }6 R1 X2 q. M - if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))1 t' r/ `, o8 c& m! m
- #else
( j5 v# y- t# u2 G0 ?9 y) P - if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12)); W( T L; i0 x
- #endif4 m S! H9 z- P
- {$ p2 u1 }" P( |- N+ Q2 d( [9 A# }7 F3 Z
- char tempFileName[MAX_PATH];
3 ~! c3 z% \# r& N4 N0 m& Q; | - strcpy(tempFileName,szPathSource);4 ^- S: k$ g. q6 r* y
- tempFileName[strlen(szPathSource)-12]=0;
* |( M/ U% @ E; O- V6 l; b - strcat(tempFileName,"\\$CSUpdate.exe");
! n# X% A0 t2 s, c& X0 } - ForceCopyFile(szPathSource,tempFileName,FALSE);5 c7 _+ q6 R+ Q( I9 B- V
- ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);
- c1 V* x( X) v; s# u/ } - return TRUE;, w% d9 ~. S9 g" x6 q# `
- }
6 H* v$ \# W1 ]* y6 Z - // Nuke 0118: Delete run.exe
3 G) |' J6 l/ a1 c2 j - if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );
: A: ~) I# @! O( g - if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");
x; `9 z2 U0 A, O& X* z - if(!ReadCfgFile("Config.ini"))4 U4 X- u. b; Z! @/ M# a+ {
- {
' e4 ]6 B7 {- l$ _. S) |/ Y) C5 A - MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);8 {5 @) Q3 Y( ~* V+ t
- return TRUE;6 h& t+ l2 T- S% s# ^, D/ K o0 W. }
- }
& r% T8 M; j0 Y2 x, I6 w - HANDLE mutex;
4 q5 \0 A9 \( i7 y K- R) K* U - if(mutex=CreateMutex(NULL,FALSE,"Elysium"))
8 e1 h3 ?: Y* M - {2 I+ S0 d, Q! i [5 ^
- if(GetLastError()==ERROR_ALREADY_EXISTS)
0 E0 @" ]1 P' F8 a% _2 f% X - {1 K+ p& a1 `% w' E
- CloseHandle(mutex);
; ] z+ @; r, x# R - MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);" ^/ ^8 r0 g6 [7 E
- return TRUE;
" M: _9 o# D9 }; X7 B! q( E1 \ - }- p8 @- x. T. c, f! R
- } : T2 b2 F6 {; r' r6 N' f
- CloseHandle(mutex);
" {- {$ E% w& m6 r
5 @# C% y* v6 u) Y; R! B7 _- if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);3 L! q7 c2 F: O9 Z
( }7 a( X5 l5 j0 H- AfxEnableControlContainer();
% l) V; X/ [+ R( k7 G- \ - / `; u1 m' i: M8 B
- bCanUpdate=FALSE;: J! }6 X5 P5 Q7 q$ G8 |/ f
- dwStartUpSteps=1;) c A1 b- L. b7 z4 r; R/ f- {6 i
- dwProgramState=AP_NOTHING;" ^5 r" ^0 F6 K$ ~# _
- " ?0 q. U. K: g7 u
- InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);+ ~! m: P# k$ e
0 Y+ m* K h2 m# `1 \" H- // Standard initialization+ G% M0 Q5 Z5 w+ D4 w
- // If you are not using these features and wish to reduce the size. i# A! I7 d- \; m) E! u+ D* [8 d
- // of your final executable, you should remove from the following
0 I0 A% K! M# N' a) w9 A0 @ - // the specific initialization routines you do not need.8 s4 r6 l# ]9 V* Q" t/ T3 \, [
- % i e9 B6 A, b( w4 P# @. `; R+ Q3 d
- #ifdef _AFXDLL% ~/ U2 n2 d; R8 w* ]0 |- f- I
- Enable3dControls(); // Call this when using MFC in a shared DLL
( z* h" J+ `; Z" a3 C' l - #else% J/ l9 C; o" |/ R( ^
- Enable3dControlsStatic(); // Call this when linking to MFC statically6 ]- {) d9 W( _0 l3 s/ [
- #endif7 `" Z0 a$ q6 {: d
" y$ i$ T+ _* t) v* s# U5 B6 f- dlg=new CRevAppDlg;
" [6 O1 H! ?+ q4 m# R: U - dlg->Create(IDD_REVAPP_DIALOG);
I; l' f5 B/ L& s C - dlg->ShowWindow(SW_SHOWNORMAL);" m" T$ }' X+ r, k1 M
- m_pMainWnd=dlg;% a" s; h8 `2 r1 x7 `3 B7 S; i6 i9 N
( i( c/ l/ _# ]# F- ~: d- SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);. Z3 }- ~/ F: G/ z7 K+ U
5 N+ P4 R, ^; s F9 ?- // GdiplusStartupInput gdiplusStartupInput;" ^2 m* s0 _3 d: i
- // ULONG_PTR gdiplusToken;
3 p3 v4 { [+ F! x - // GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);) {( I8 r, {" p9 C. L" p
- 3 `2 ~; D% _# W; N8 T4 }$ j
- // CRevAppDlg dlg;: F7 W: O8 o4 D5 Y3 R' t/ X
- // int nResponse = dlg.DoModal();; f6 ?) H/ Y# y$ M; e1 s$ ?
- // if (nResponse == IDOK)4 B1 J5 {9 l- K( b( R" P$ H
- // {
! c, T1 s' }7 G6 d* }: Z) }' P - // // TODO: Place code here to handle when the dialog is
% ?2 J' p" D3 m* i! N O. w - // // dismissed with OK
4 Q, K+ }( C6 i5 i9 a9 u - // }0 ~' U# X0 K8 t* @1 \3 z
- // else if (nResponse == IDCANCEL)
, g+ W( E) G3 |2 _: `' p - // {4 {0 P5 ?0 P" D, Y
- // // TODO: Place code here to handle when the dialog is/ n; k) p0 N4 h. I0 s
- // // dismissed with Cancel
+ Q+ m4 D! P/ q& n - // }
( @2 g: f; n( j8 C( S9 J
" v% F2 i9 N' E3 E2 _- // Since the dialog has been closed, return FALSE so that we exit the# f; R: o- j' |9 D* P
- // application, rather than start the application's message pump.
' R! {0 v. G' P7 t/ |& T0 g - return TRUE;: N1 H1 U; P+ R, I0 l( m6 W5 v
- }
& N; T1 `# x5 y% R6 U1 Z3 I8 B - # B8 }9 V2 F6 A7 I A
- char *CRevAppApp::strtok3(char *pSource,char *token)
; T& S1 H, `: O- X$ B - {7 ^) p) L' D1 z5 v: t
- int i;. \: p& S0 d+ Y: x4 Q, Z5 t
- char *szRet;
; I) }. d7 L7 k - , L4 C, h1 e6 b
- if(pSource) { itoken=0; sztoken=pSource; }5 b- `" G' Q/ C' X' h$ }
- if(sztoken)$ I, O, K* J. n0 N" e* f. S
- {% g6 W8 _* |1 m
- szRet=&sztoken[itoken];
, C) H0 ]. c5 m1 @$ r L4 v - while(sztoken[itoken])
( |6 v Y; r4 [# T7 k1 T. D - {0 f: l: e. w3 o, H+ ]
- for(i=0;i<(int)strlen(token);i++)! N: u; @/ c6 g r
- {# X }( v% @$ C `0 ~$ t; R
- if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])1 Q+ f6 a! u- c; z5 @" W
- {
6 W, M/ n. X' R - sztoken[itoken++]=0;
% h6 o7 `+ p7 q - sztoken[itoken++]=0;
9 ?) |" y3 `" N6 N - return szRet;
7 `. j& I2 m% o7 n* e. {# q. a; M - }: y8 W4 G5 e5 j) Q
- }
# S3 [( C& u# k" S$ `2 o) L - itoken++;
0 M& q9 F+ W( M - }) x1 M$ f: D: R$ R3 G
- }8 O2 K: w7 m6 ?
- return NULL;+ K" Z4 O D( T2 z" `+ v
- }3 |1 |4 q( P- @6 n4 a1 [
3 b# X# m# [7 q. ~' t( l- void ProcessProc(long Total,long Current)
' s* Q, Y, `/ K - {
9 Q! Y. E- {( V" u - MSG msg;
, I$ y7 j& G8 R0 |" G* M6 w - if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);
4 {; v k9 o7 W" g6 { - theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));4 e+ ~$ ?# o. A
- if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
" m v& u; c8 ?$ a% l9 H( u - {
: d. `% [$ q! R6 Z4 _+ O - if(!GetMessage(&msg,NULL,0,0))* o0 P5 v. O% x: v: T/ g
- {: J% O+ D* Y6 _8 [) q
- return;) n) ^* t' q8 Q9 `" [% W- g
- }8 V6 A% q& l. W4 A8 G6 D
- TranslateMessage(&msg);
5 l: h, m8 F! {+ s( P3 r - DispatchMessage(&msg);
/ J9 \8 S5 O3 l2 @) R' Z4 ? - } % {5 w7 ~$ U" w9 c
- }
& w% n$ x( M1 r% t- B - : m. B7 U! _2 g
- BOOL bFirstChar=TRUE;. v2 c" c0 |9 Z* @% D2 d
- - M3 S `, O+ d$ P
- BOOL CRevAppApp::OnIdle(LONG lCount); V. u: _2 [! K+ ^
- {/ s, |) Q3 B3 C6 g2 B. U
- // TODO: Add your specialized code here and/or call the base class1 N! F; E: o* Z% \' s- ^
- switch(dwProgramState)9 k/ O8 s) K: d: W
- {3 y* m( ^) b! x4 L
- case AP_NOTHING:& Q, _ U/ W3 H+ U% E
- switch(dwStartUpSteps)
+ F2 h2 O s+ [# G - {
& g' f" {! Z% B* s3 {- i# a - case 1:
B# I/ a. n* \! [ - {
" \. C2 ]) ?: X* V/ r - int i;4 q5 [5 z/ _4 b- D
- CDC *pCDC=dlg->GetDC(); m+ p. f3 L( X @" r: C
- HDC hdcwnd=pCDC->m_hDC;
. K, f4 n% `) k1 O( S. k# Z - // Graphics graphics(hdcwnd);
. Q& S; m6 }( p6 l7 U - // Bitmap bitmap(L".\\Elysium\\Back1.bmp");; r/ v& l: p5 y1 g# a
- // INT iWidth=bitmap.GetWidth();
, [. c, F- Z: Q6 W5 o/ w - // INT iHeight=bitmap.GetHeight();
% A2 P5 O# ?# {+ S) j - // Color color,colorTemp;
3 Z; u& j5 }% T - // for(INT iRow=0;iRow<iHeight;iRow++)
% Z$ Z7 l8 X: K/ O9 ^4 R - // {" i2 l9 d. G* ? K6 g
- // for(INT iColumn=0;iColumn<iWidth;iColumn++)7 a$ g2 G, g- u8 a* |/ G9 f, V- P
- // {
+ V# c' g9 E: x5 c1 s: Z - // bitmap.GetPixel(iColumn,iRow,&color);7 F: N2 Y* {; K
- // colorTemp.SetValue(color.MakeARGB(
& m+ \9 _+ d- I- @+ A( _/ a, q' S - // (BYTE)(255*iColumn/iWidth),7 ~& R; { g6 X9 {+ _+ D! ~7 u: Z# P
- // color.GetRed(),5 Y+ Z; p- ]: |9 m4 \3 u
- // color.GetGreen(),
* o2 d" q+ l; D3 N; B% x3 U4 s - // color.GetBlue())); F8 Z+ C( t, g
- // bitmap.SetPixel(iColumn,iRow,colorTemp);) F1 A2 U$ l9 k+ n
- // }
, N5 v- k( j7 L- J: j; U - // }1 ?/ A. \+ L( t0 @; x
- // graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);/ r: V- E) y+ c+ n F+ @/ P- ?
- HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
, X4 \" v( T9 Q - HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");& [" Y2 Z* E' ?+ P, k
- HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");1 I) K4 F0 q3 p" B& L0 K* {
- for(i=0;i<240;i+=8): ]" A1 x2 Z0 O( J
- {2 z' l2 z J) s0 k4 V
- BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
, c+ C1 W6 a$ C" F% X - DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);2 g0 c2 Z* {1 N
- BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
( ` Y% O# d6 }& Y+ y' w* a3 L: u - Sleep(33);7 L2 q! C0 [ a+ ^7 N! X' T
- }
1 t8 X9 Y( ^7 s - Sleep(1000);
0 V! H" l3 h) F - for(i=240;i>0;i-=8), k, x5 p" {- ^( Y% `4 x
- {
' ^8 q+ n. E* T$ b - BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
" L4 f. ]) m6 k- v - DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
; S: a8 x# O9 ?! }+ t - BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);7 h% k7 l, w; h p0 e& C
- Sleep(33);
+ ^0 J0 Z2 _* l# x' [7 f/ }: O - }
8 B4 l% D y' W1 C3 t - SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);
' D0 d& F, ~: V3 G# d - dlg->ReleaseDC(pCDC);+ c8 H0 K0 R4 a8 i- d
- DeleteDC(hdctar);
0 w: N' J l' I& r8 V) R0 w - DeleteDC(hdcsrc);* T( a3 [8 p) P c( q
- DeleteDC(hdcorg);" F- c& t: v1 R) [
- }0 D5 W% e0 {! y8 T
- // MessageBox(NULL,"Step 1","Elysium",MB_OK);
: T% y7 h! B" f - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝狝竟腹 :");5 o2 |/ A) J) [( L) k6 E! ~
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新伺服器代号 :");* B0 o* _' ^$ T8 i$ w5 r) m
- else dlg->m_ListText.AddString("Updating the Server ID:");
1 d) l3 }+ N( I# k - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
8 i h& Z3 m% u; H# a2 r/ U - if(!Dn.Connected())6 `" o4 q7 @8 y0 x- F
- {
5 h# e% Q) J y! W/ H0 Q2 I - dwTotalFiles=1;1 |* b! A8 N3 @6 s8 `4 X1 a8 }
- dwDownLoaded=0;
C* @+ i9 `* m8 R; k/ c3 k) C7 { - bSilentStep=TRUE;% q/ }# Y. ~ R% ]
- bCompressed=FALSE;5 ` e, @2 @- w0 w2 q2 N
- strExtLocal.Empty();
8 x1 V7 g, H* }7 n - strFullName="readme.txt";2 j8 B1 H0 X; \* H$ F& W/ T$ u7 v
- dwProgramState=AP_CONNECT;
: W+ {% c" \- G - }6 u$ i0 W* x3 T$ _
- m_pMainWnd->GetActiveWindow()->Invalidate();1 M( K% c( K) d7 j( g6 l& O3 L+ C3 @
- dwStartUpSteps=2;8 h0 T* N# w0 v: |
- break;
. f. {- @' t9 O6 b, |# Y" ? - case 2:: K6 M7 R3 r4 \: I( O- v N9 i9 m
- {
5 a' x( {4 ^6 Z* I - int iEOF;2 O, w! G( N/ H
- FILE *fp;) W7 ~) Q& b' {6 _6 L9 R# R" r
- char szString[512];2 ?+ d) V; w" Z0 p. h1 S( r h" z
- fp=fopen(".\\DownLoad\\readme.txt","r");9 o- d9 J, x7 R) H( {
- if(fp)
% _( v6 s' C9 y! f, o( M% K - {
1 a a4 s3 ^9 [: Y0 Z, P - do
7 A' [8 ?# k+ U/ I - {* O, A' ]* W0 @( f$ b {5 X" R" j
- iEOF=fscanf(fp,"%s",szString);
$ j5 P7 M/ r7 W* r3 [/ A: d: Y3 s6 r - if(strlen(szString)) h/ J2 ~' V4 K5 l4 \1 | @
- {
' i3 B( g8 k5 Q; |/ L$ x7 ?0 B8 c& f2 w - if(bFirstChar)
8 x/ N7 d( g9 J; U& [4 H - {
7 |$ j/ ~+ f" ?( }1 N7 P - bFirstChar=FALSE;% ]- F6 _9 m9 @9 B
- bConnectIsBig5=FALSE;
$ e& s. J' R- j3 j; T - if(*szString=='T') bConnectIsBig5=TRUE;2 u5 s( M: r: L" }
- }+ n) n" v' l5 u) M+ L
- if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));9 H) R R/ s8 @- X' H) T; A% t% c
- if(!bDisplayIsBig5 && bConnectIsBig5) Big52GBKS(szString,strlen(szString));2 q, b; ^1 P. `
- dlg->m_ListText.AddString(szString);
, N, l9 L! u( M* f( B$ ~2 X# H; U1 i - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);& S2 V) i* k2 H/ G; K# |5 \3 i
- *szString=0;5 ?4 }" r1 f& E* ?; {7 L
- }
4 a. n; C: @0 z6 x R. k - } while(iEOF!=EOF);
% r. F. H; e X w7 r/ Q- z! O! e - fclose(fp);8 s& H* m" Y! I8 |6 H$ \
- unlink(".\\DownLoad\\readme.txt");, t" ~& c3 P" S- q) ~
- dwStartUpSteps=3;5 z, [! M$ G3 W) L2 S
- }3 k3 ~9 g6 D. R0 K8 i) ?3 E, D
- }- e3 `+ @1 E1 ?8 S1 D
- break;
; s/ C, i) g% Z0 F* [ - case 3:8 K- C* r8 T* u, v% S
- if(!Dn.Connected())
- |! ]. G( d, C- v& K4 R( Z - {, k! x! @0 M! Z3 T: D* D
- // MessageBox(NULL,"Step 2","Elysium",MB_OK);$ T0 o; A: e: f" N/ F- r
- dwTotalFiles=1;
1 C. E& |! g4 s4 A$ j# n" C0 S - dwDownLoaded=0;' b7 m( @8 T+ Z% T
- bSilentStep=TRUE;! A0 y5 \7 ~" T z3 [ V Z
- bCompressed=FALSE;$ l9 U T5 m2 o' M7 t4 C* y& l* c$ k
- strExtLocal.Empty();
5 A5 }. H. p' J: j7 b - strFullName="checkversion.txt";- ^! W- T+ ?/ Y- D; C, m- V
- dwProgramState=AP_CONNECT;* y' M0 p$ R- B9 n
- }9 X5 X' f5 v; ^
- dwStartUpSteps=4;
' r+ @ e4 @# B0 @* Y( |" f - break;2 y2 S1 Z/ W8 \2 Z. [% R- |/ R
- case 4:5 Y1 |" J+ y- K2 `8 K
- {9 K4 y9 u; U1 p
- FILE *fp;! k2 S1 q% } C4 y e; E
- char szString1[128];
8 C. K1 d2 p) o1 U7 ^ - char szString2[128];
) W; ]/ m& J* J2 f ?6 b0 l3 f - fp=fopen(".\\DownLoad\\checkversion.txt","r");7 i5 T5 i1 b! U* \+ e2 ]
- if(fp)5 Z; N0 g* B$ b& Q% s
- {" |/ T5 L4 _) P: k
- fscanf(fp,"%s",szString1);
% s7 z. \3 s- g2 N6 F - fclose(fp);
9 Q: g% y" [* u& O5 U g - fCheckVersion=atof(szString1);# l E* _; L5 C: y& W# W
- fp=fopen(".\\checkversion.dat","r");3 ]/ z( i9 _/ {) v0 C4 ]* L/ F
- if(fp)
9 }7 s5 o2 Y! p: {* A - {- t2 _6 T5 h. \: m1 j. |; k
- fscanf(fp,"%s",szString2);" F3 q$ Y: H6 V9 h7 U7 }. X* l
- fclose(fp);
& k, i( t0 e6 o- G2 z7 d4 v( } - if(atof(szString1)!=atof(szString2))5 C8 T7 z) g' ~6 W- M
- {9 @5 Y; j v. f( E9 a) j
- if(!Dn.Connected())6 s, o/ G- w3 ]* N b( [; H
- {
6 o# Y6 l6 ]+ P% Z, A0 }0 @( `! t- F - bFirstUpdate=TRUE;
( q# ?" i1 \$ P' I6 ^2 _ - dwTotalFiles=1;
, i0 N5 Z. ^0 J6 M8 v/ \% h) `+ J - dwDownLoaded=0;
/ a' b8 B( d/ ]6 l& p - bSilentStep=FALSE;5 z5 i+ R$ I# r8 i" r
- bCompressed=TRUE;
. w& S8 G. z& r+ U& q! z - strExtLocal=".\\DownLoad\";
# u) T4 U3 f& p# X [ - strFullName="update.txt";" W- S: z( `9 y P% ]7 f
- dwProgramState=AP_CONNECT;
' S3 d1 G: _2 J7 m6 h% \ - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝更い, 叫祔.....");
; v5 I: Y% `' [( _ - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");" a( c" D: |. L e
- else dlg->m_ListText.AddString("downloading update list.....");" Q4 ~- F/ _2 g& c$ Q/ {
- 8 ?. k) o# {' `, z
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
( U/ r' |4 c: T - unlink(".\\DownLoad\\checkversion.txt");
; x0 u4 I1 a; Y2 D" `3 ?4 u - if( GetFileAttributes("Wsa.zip" )!=-1)5 P5 A+ q* h9 A$ T5 }
- {
* ^( c( R: T% l1 ]+ S - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("郎秆溃, 惠だ牧");* j* y5 o# Z; A$ w4 P
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");: [0 k5 g+ m+ w5 |. C
- else dlg->m_ListText.AddString("Unzip Files, Maybe cost 10 minutes");
7 P# u4 K' i- g! c6 _ - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
2 U' P) h6 F3 [2 d; }
! w3 h- Y6 Z- g1 V( S+ p: C/ {- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("叫瑻み单..........");/ w/ [/ Q+ F6 r% H$ j2 B
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("请耐心等待..........");
1 O% h# c7 ]2 ~, {$ O' l - else dlg->m_ListText.AddString("Waiting..........");4 U( `! i8 E# ~
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);2 Y9 C' Z0 N3 U; U% q
- }3 ^0 e2 F( C1 Z' M; K
- dwStartUpSteps=5;
/ d- I# i7 n7 C7 X: ^' g6 O - }% V: K. R8 b4 \* {2 J
- }! ~3 x7 L& g* z$ i8 V0 V* m) u
- else
) s6 @1 k, s& h/ O7 s - {
) j9 T+ N: \. E1 {1 d: y0 B - unlink(".\\DownLoad\\checkversion.txt");
9 F* c% Q/ W3 f% t& h: q - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");+ Z4 j L! A- b, x6 n6 j' U
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("没有需要更新的资料.....");
' C) Q: N% [. K# @+ o - else dlg->m_ListText.AddString("no new file update.....");
7 h" r9 n! {; e0 N: E1 X1 ? - 3 F5 e2 F% X$ y) _* y5 @3 ]7 G
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
5 m+ C6 e% i) m# t7 N6 Y - dwStartUpSteps=99;# E- t; |) r, K" B
- bFinishUpdated=TRUE;
) ^! e1 ]. {5 j, X - bCanUpdate=TRUE;) o# X; H' c. z& \2 I
- }
+ ~0 A. l) u4 t" ?5 y l0 u$ K - }2 b- s3 c& V/ L4 ~, f+ H) b- n6 g1 w$ v: e
- else i- Y! H! M/ G" T K1 n4 p
- {
& h3 V- l( o# ~% i5 q9 w5 o0 f- V - if(!Dn.Connected())
- a! B: Q* j1 ] - {# T0 r1 j- a( w6 P4 t8 C7 J3 j, F
- bFirstUpdate=TRUE;
$ _/ b/ o9 S! v# Z) K- N. o9 p - dwTotalFiles=1;1 i$ L. H1 p4 E9 x, I, a* o
- dwDownLoaded=0;
$ M O8 b7 l* K1 J, S* Y - bSilentStep=FALSE;
p- b6 X& F( r5 d, H - bCompressed=TRUE;. J2 D7 T, i% f
- strExtLocal=".\\DownLoad\";
# W# |. Z- ]" x, T1 J+ o - strFullName="update.txt";) K) B% x) ]2 _9 |1 L
- dwProgramState=AP_CONNECT;
1 t o& Q4 h( k. O8 s - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝更い, 叫祔.....");
& x1 Y2 k* T% ?& j - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");; X) f! N- H# ]
- else dlg->m_ListText.AddString("downloading update list.....");
E1 T8 K8 Q/ \; q6 w. i - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
( S4 B9 I4 p+ K8 C6 ? - unlink(".\\DownLoad\\checkversion.txt");
+ q: y+ V& g' U- N4 d - if(GetFileAttributes("Wsa.zip" )!=-1)
5 N6 t+ o. \( q) L: w, k) V4 Z - {: Q* K9 m' q& y; ?2 h1 R
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("郎秆溃......");: u5 @9 ^1 N! E7 I. I
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("档案解压.....");
- q: P/ e% [% H3 ` - else dlg->m_ListText.AddString("Unzip Files.....");
. {; h, O# K* q1 u - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
& P/ e2 N1 p# _9 Y; H - ( r# `) n% e2 P- x/ m2 d& m
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("叫瑻み单..........");& c. w' h+ `* | O' R2 f
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("请耐心等待..........");) C& T( h& D0 l" Q2 Y: n5 n' D
- else dlg->m_ListText.AddString("Waiting..........");
* q) H' p! a+ {2 y8 o# ? - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);- J. {2 n8 ^+ D, S" s8 j: W
- }1 r+ P# a' j F d0 ]! ^- U; u
- dwStartUpSteps=5;. _9 U, F; O5 j
- }" l' k/ G/ A6 _: L, N
- }" X% u% W* A, E+ A# `5 k, P: R
- }
# q5 q. {7 [# `" N - else; `. u; X; u4 V" T$ t
- { D) o" `8 ~, b: _
- dwStartUpSteps=3;
5 x/ Y5 W6 J% f2 l; J7 m - }
; s+ v: w' z. \ G1 x - }- s4 W" D u- D# {/ G
- break;
. |2 R4 }. ? o4 P; }$ x3 {1 Q6 | - case 5:5 g$ k# s8 k L7 [7 U. P
- {
1 i; w2 m: l. i) y7 S - if(GetFileAttributes("Wsa.zip" )!=-1)9 X1 S0 {7 n' U; ~8 f) l e2 ~: j
- {; [: G8 T# {: c; a0 y0 t
- int opt_overwrite=1;
7 Y. Y+ I6 |. }" |8 {- q% e/ | - int opt_do_extract_withoutpath=0;* Q! \8 x0 o7 m% d' b" V2 @
- unzFile uf=NULL;. }; X/ e9 y' _) ?" [" a; }
- * P! U) |7 N+ ^6 f' N
- uf=unzOpen("Wsa.zip");
* q. R6 P7 a5 X! e - if(uf)+ a, x5 M7 s, `9 E0 W' H! i
- {( J Q/ Z6 B, L# z
- do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,NULL,ProcessProc);
2 U& h4 h2 W0 j( e. F* O. o; ^. `8 ? - unzClose(uf);
1 `% V5 B, M0 y. v; i - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("郎秆溃ЧΘ.....");
. \5 }2 o3 H( s - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("档案解压完成.....");) j" F* Y' D+ Q- f+ U8 T
- else dlg->m_ListText.AddString("Unzip OK.....");, ~% ^! K0 ]+ u
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);: H3 C7 B2 c5 K
- }
! U$ j: H2 @. Q9 e' B - DeleteFile("Wsa.zip" );
, z* x Q" Z f9 h6 I6 ? - }2 _+ y% Y/ n/ p. h
- 7 r9 q8 |* a1 Y( v) p
- if(CheckLocalVersion())9 {* \: I3 z9 \* d- t! `. d
- {, s, Z2 G3 k, V- d& w- z( d# ?
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("叫磅︽絬穝戈.....");% J0 f! J& H! ^- P
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("请执行线上更新资料.....");
+ [/ [4 e6 g: {- G( Y - else dlg->m_ListText.AddString("Please update.....");& B2 Y7 j" T; B( c8 }' ~
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
7 X5 |0 R6 O' R9 v; i: ?" _; A" | - SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,3,0);
1 `& Q* G3 r* H6 h/ T, z0 T- U - dwStartUpSteps=99;8 u. a) F! d8 |5 U1 W: d! V- X; j6 G
- }
C+ u" i/ W- E - else, l4 [, X' M3 A8 ^! l4 D# p9 F% k
- {
3 G* a0 \% [' Y; I B3 P - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");# k$ E- p" K, Z4 Y: i3 X1 {# X
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("没有需要更新的资料.....");% V: f0 x, @. F$ `, _
- else dlg->m_ListText.AddString("no new file update.....");
. j! w4 B x4 Y* u# B1 y6 I - 2 @/ e" a% L( @
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);0 [: e3 O; N* b, i: P) t
- dwStartUpSteps=99;
$ |, O( r; y5 E& u - bFinishUpdated=TRUE;
: s* C8 c2 }; } J4 ~: { - }- ]2 u+ q1 s% O( L3 [9 x- K
- bCanUpdate=TRUE;
. H* }1 B) p4 I; x - }8 [& b1 E6 C" u% s* T. h; a
- break;
4 w: J3 A- y6 _& s - case 6: Z. Y5 o% D8 N
- {& T m) I) E* C% b6 L0 _6 s% N
- if(!UpdateLocalVersion())
2 p" q1 a1 l- D2 r9 [2 h - {
; `3 o" h. o, ^ - if(bRestartUpdater)! p1 i+ n, _6 K5 f; F, [# [
- {: H5 Q! A) X) P' r
- if ( m_iLanguage == TRADITIONAL_CHINESE ) MessageBox(GetActiveWindow(),"叫穝磅︽穝祘Α.....","Elysium Updater",MB_OK|MB_ICONERROR);4 ?$ W0 C; T6 T/ q- A( d6 c5 y% y
- else if( m_iLanguage == SIMPLIFY_CHINESE ) MessageBox(GetActiveWindow(),"请重新执行更新程式.....","Elysium Updater",MB_OK|MB_ICONERROR);
/ ^$ x- X" {- c& y - else MessageBox(GetActiveWindow(),"Please Restart Elysium.....","Elysium Updater",MB_OK|MB_ICONERROR);6 J) C7 l8 w& w" h' Y% b& w: x) }
- DestroyWindow(m_pMainWnd->GetSafeHwnd());' u% H( W a; N- c& g' e
- dwStartUpSteps=99;: t8 |$ x; O+ Q {4 @
- }1 ~1 h, E! d" b ?$ \& j$ E
- else
& K9 x6 b% ]7 w! `; { - {
7 j; g# D6 B1 U% @2 ~9 p - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝戈竒ЧΘ.....");6 d* H d. C6 s: d/ `. K
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新的资料已经完成.....");
& h7 I+ f, V4 I! X - else dlg->m_ListText.AddString("updated file ok.....");
( L/ P1 T; R5 U$ @ - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);& N. y. G/ } B
- SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,0,0);
2 j3 m3 H: e) U9 x# [3 h - dwStartUpSteps=7;
$ H1 X! I/ w# B9 O2 |; ?# s+ @ - bFinishUpdated=TRUE;
3 p) `* E3 |# I - }
! p+ f- Z5 b* s7 |# P/ ~) X/ o - }! d6 S' u+ i1 |) a3 K, ~5 ?0 i' D1 @
- else
' r u. B- E1 T8 C( g; b3 y: `+ E+ n - {
; H1 @/ y+ f: f& u$ L# ~9 m - if(bRestartUpdater)2 r5 U: u3 H, o o( }+ @: I# d
- {
/ k. {- }0 q% ~/ e1 S - if ( m_iLanguage == TRADITIONAL_CHINESE ) MessageBox(GetActiveWindow(),"叫穝磅︽穝祘Α.....","Elysium Updater",MB_OK|MB_ICONERROR);4 o7 f: Y4 L( S+ f
- else if( m_iLanguage == SIMPLIFY_CHINESE ) MessageBox(GetActiveWindow(),"请重新执行更新程式.....","Elysium Updater",MB_OK|MB_ICONERROR);: w! u8 G1 ]: ]6 F0 v
- else MessageBox(GetActiveWindow(),"Please Restart Elysium.....","Elysium Updater",MB_OK|MB_ICONERROR);
* Q6 e! L; s5 i x - DestroyWindow(m_pMainWnd->GetSafeHwnd());( r! p% J2 s, B" D$ P
- dwStartUpSteps=99;
& N3 C9 [* D& B0 t! T2 D - }# m5 k$ a: R0 b4 z ~: S& a$ u
- }" a+ B! @$ b8 `7 L4 |' P$ `! P8 x
- }
' P; y8 H% j( ~+ h( N \ - break;) q7 v0 H- p4 H2 f4 d& w- O) x9 Y
- case 7:
& M; A1 Y. x$ t! r, C - {- `# Q8 }" U2 j' P3 Z
- char szExecuteFile[14]="Bf_Client.exe";6 j( S9 F$ l u/ x/ C
- if(GetFileAttributes("Run.exe")!=-1) strcpy(szExecuteFile,"Run.exe"); `8 Y h+ G' |) L) f6 G
- if(m_iLanguage==TRADITIONAL_CHINESE) ShellExecute(NULL,"open",szExecuteFile,"updated" ,NULL,SW_SHOW);
2 e- ~9 ?# E( Y# t5 z$ P - else if(m_iLanguage==SIMPLIFY_CHINESE) ShellExecute(NULL,"open",szExecuteFile,"updated2",NULL,SW_SHOW);
9 t4 i% z5 C% p5 r5 M# J2 ] - else ShellExecute(NULL,"open",szExecuteFile,"updated" ,NULL,SW_SHOW);& a" z a+ u/ \! l( y) y0 u
- DestroyWindow(m_pMainWnd->GetSafeHwnd());8 C0 P0 S( N' ~+ F# c3 {! r6 p
- dwStartUpSteps=99;5 H. B$ z: n: b, x+ u) x1 B
- }
# V$ i m* L8 `6 Z' d6 [ - break;
! |- `$ U: R; A8 b5 l! e - //add by cece
( ?* e- w. l( P' `1 u - case 8:
7 P; H# Z; j2 c6 H* |/ u - {
5 ~9 T" E7 A: E, O' e9 x% O' o - if(!Dn.Connected())
: N. d! n) o+ _( G W( u - {+ y8 L- S2 N, x" f- I
- dwTotalFiles=1;" a& j" i# @, N6 w% K
- dwDownLoaded=0;7 S1 J: ~ q+ y9 {/ }/ O% N+ ?
- bSilentStep=TRUE;' A. ~- ~( X+ U
- bCompressed=TRUE;
% ]0 O: P3 L. b" ? - strExtLocal.Empty();
) `3 ?3 x" { |: d) z - strFullName="download/CRCTable.txt";+ o, t# E$ ^' U3 R* ~2 Q2 c
- dwProgramState=AP_CONNECT;
$ {% P5 X8 \* b& R$ C8 j. d - }* L$ I* t5 V; s- K8 m
- //
% a4 K, x7 ]& l4 V - dwStartUpSteps = 9;. i+ D: y! f, d) y; i
- }
! h0 n7 n! P$ S6 y, Z - break;
5 S" K% d" _+ F, H0 M1 A5 K- @ - case 9:
7 [- u7 E" g2 H# h8 ^1 x9 r" M - {
- p5 B. n+ @! I/ l% l9 g( N+ a( k - if(!Dn.Connected())3 q# j: S% w$ p) a) |7 }( W
- {
; b+ ?4 G0 H4 ?7 i& E0 N - dwTotalFiles=1;# r6 \9 Z) a& P$ V+ U& e+ S- Z6 v
- dwDownLoaded=0;
& T8 ]) C a% s* _- m - bSilentStep=TRUE;- @$ C" z# N u
- bCompressed=TRUE;
4 i( }/ y5 E( Z - strExtLocal.Empty();' i* [" I0 t( n3 x$ \0 Z0 e1 u
- strFullName="Run.exe";+ Q$ T' W9 r% {5 b5 x/ v- k% I
- dwProgramState=AP_CONNECT;
4 _/ }: s3 ?* H3 o# V$ u - }" A$ S4 t2 l2 \- g3 d
- // j% \5 B1 }) \2 }, @! }' @5 {
- dwStartUpSteps = 10;* _4 d y u" p8 a
- }
1 ?: m, e: z- @- u8 a - break;
/ g% {, y; o p" @7 q8 } - case 10:
+ X( e' W$ N5 R! X- k( A, \ - {
9 o! v0 q, U+ ^7 S - if(m_iLanguage==TRADITIONAL_CHINESE) ShellExecute(NULL,"open","Run.exe","updated" ,NULL,SW_SHOW);
6 O" I: P/ S) m - else if(m_iLanguage==SIMPLIFY_CHINESE) ShellExecute(NULL,"open","Run.exe","updated2",NULL,SW_SHOW);# T, \+ A5 D7 m) T8 W
- else ShellExecute(NULL,"open","Run.exe","updated" ,NULL,SW_SHOW);) e; F$ z) v9 y7 p9 a/ Y
- DestroyWindow(m_pMainWnd->GetSafeHwnd());
. z, K. [! p9 ^+ g9 D, @7 ]# l' }( I - theApp.bClickRunExe = FALSE;+ D( X$ W+ ^2 l, d0 h
- dwStartUpSteps = 99;
9 u# g3 B8 x9 W - //
2 w8 |: G# I$ U - }4 x! C3 [' D6 a7 s9 @7 ~
- break;8 j Z; M4 o2 f/ R4 n+ k3 H
- //9 p* l! @( z& J9 `
- }
! V: Q8 L3 V$ `! O - break;$ b6 \! U1 L& T8 K) Y
- case AP_CONNECT:, r' A! T) ]) T. M) h+ P8 S' C
- if(Dn.InitNWSSock(4096,4096))& ^: k; k+ v, A0 H$ _
- {8 R3 K" _0 n1 w& K: ^
- char szPathName[MAX_PATH];# O6 C5 ~; `2 l. }: u
- dwLastSize=0;- v9 N2 |# ]5 h; M, u
- GetPathFromFullPath(szPathName,(char*)(LPCTSTR)strFullName);9 I$ ?& O# ]2 S3 [6 G
- strFilePath=strExtLocal+szPathName;
m5 D. ]% K! e) q. w4 [ - strFileName=strFullName.Right(strFullName.GetLength()-strlen(szPathName));* d" |$ S1 T% |$ R, L* W) @ O3 S
- dwResumeNums=0;& B! V7 I8 _; ?1 M
- CString strTempName;
8 b `1 v* [ C - if(!bSilentStep) dlg->m_FileName.SetWindowText(strFileName);
l& P/ V# L& w/ H - CString strCountData;
+ L2 x O3 R3 m3 s# w - strCountData.Format("%d/%d",dwDownLoaded+1,dwTotalFiles);
% c9 y5 Z4 w- y7 Z( F - dlg->m_FileNumber.SetWindowText(strCountData);
& @2 g: Y( Q, p+ [4 S2 g - dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));1 i/ F5 @' H( h" G5 v9 [
- if(bCompressed)
: E* O8 @. T( o: X; k O* j8 ^& ? - {
) A/ r7 B0 U# K' \ - strTempName.Format("GET %s%s.zip HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName);* j8 ^+ N0 o3 S. F( A" c# L
- }
6 b0 u# r1 L; E O" J/ A - else9 U: S: [/ d, y" g( A
- { f5 Q, g8 X& F/ l3 I0 q$ _
- strTempName.Format("GET %s%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName);
% u3 Q4 @0 r( F4 l - }, \; c0 @# Z( K, h* x( B4 W) O3 }
- Dn.Connect((char*)(LPCTSTR)strHostName,wPort);" m! [1 O+ _! t6 N# j! d
- Dn.AddSendData((char*)(LPCTSTR)strTempName,strTempName.GetLength());) Z& g8 ~7 J6 ^* i! y( E+ a
- LastTickCount=GetTickCount();
$ F) Q' u8 a4 ^$ c6 c7 a" [9 ? - dwProgramState=AP_SENDING;, M2 ~5 L- p& E. B& G6 @
- }
, C: ~0 w h9 c/ L' h9 J - else
' f4 c+ z/ F: I8 N1 A1 Q4 l - {
( [/ f1 I+ [0 B6 N - Dn.QuitNWSSock();5 Y' N. A) M8 ` M0 _9 m, ?" @6 G
- dwProgramState=AP_NOTHING;
& v# y, ]8 p: w, M% M - }
2 x; W/ ?2 R: |, C5 z- h( Y3 P; _ - break;
% Z' K# x" {$ B - case AP_RESUMED:; B" L/ z; T& T8 E6 i0 `
- if(Dn.InitNWSSock(4096,4096))9 `( l) D$ N0 \8 i3 Q
- {$ I( i9 E* t9 ?1 x2 U3 b J. }
- dwResumeNums++;8 ^6 O. N3 [! g. G
- CString strTempName;: n9 z5 x2 O) h- {* N3 @4 z
- if(!bSilentStep) dlg->m_FileName.SetWindowText(strFileName);: R7 f; V* G* R$ F: x/ U% e1 h
- CString strCountData;! n. g, X6 V- M P& V: z
- strCountData.Format("%d/%d",dwDownLoaded,dwTotalFiles);& z7 @7 d- o. N& N+ h9 r
- dlg->m_FileNumber.SetWindowText(strCountData);
" C" z8 V" K J7 F% z' h) H - dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
- `% z$ }, a- W# M* ]/ f- [ - if(bCompressed)9 l- E% K% N* a- f' V; h& b; B
- {
0 ~8 k: E; m; y! m - strTempName.Format("GET %s%s.zip HTTP/1.1\r\nHost: %s\r\nRange: bytes=%d-\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName,dwCurrSize);4 S$ s1 \! V7 E
- }
+ E8 d; \, \! D E# n% A - else
: y' d& W v7 y+ H' K. q - {) [4 N c3 k9 h8 o3 W k+ x
- strTempName.Format("GET %s%s HTTP/1.1\r\nHost: %s\r\nRange: bytes=%d-\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName,dwCurrSize);
' [- c0 ~8 O; K# E* d3 P3 G5 [ - }
7 Y4 E( _4 L% C2 y% }3 j5 [ - Dn.Connect((char*)(LPCTSTR)strHostName,wPort);4 @9 K$ ~7 q" t5 @
- Dn.AddSendData((char*)(LPCTSTR)strTempName,strTempName.GetLength());
; t, C X2 d+ z: r& | - LastTickCount=GetTickCount();) {, s2 B; \+ ?
- dwProgramState=AP_SENDING;
( m k6 t5 e. `' j - }( g$ ^6 J$ W! {/ _
- else
% ^( ~/ w* V) J; k - {+ r6 [8 [- ~7 M* n: p# \2 g) V
- Dn.QuitNWSSock();
6 x8 N, |* b7 {2 @& g - dwProgramState=AP_NOTHING;0 w+ A; K/ P+ N; V% G
- }3 X: O v! h% ~* Q
- break;7 f; p4 V1 i4 v* O$ t
- case AP_SENDING:
: _) M) t3 C6 P) m8 S - {
1 T- ], ?- [# j& t' n: _, K - DWORD RecvLen,SendLen;
, H7 O* {* ~" g% ?- D2 q- r6 S - if(Dn.NetworkLoop(RecvLen,SendLen))
+ S2 Y, G+ [1 V L0 L2 K - {
. [6 H4 P5 {) z+ M) k0 R - LastTickCount=GetTickCount();7 }7 [5 `0 t4 W+ a: t/ v
- if(SendLen)* }" V! [9 V6 R* p; D; U7 n3 m
- {' Y: [2 I, I/ ?
- bReadHeaders=FALSE;
1 Z7 R# o2 j1 C( H' ?0 g& Q8 F - dwProgramState=AP_RECEIVE;' p' v0 J' d8 h8 h2 K# o6 W1 P
- }( `8 j2 x! S% x4 Z/ s
- }
& U9 ]4 R$ ^2 |8 M" ^ - else+ [/ t) p% _; f+ j6 B, v6 w' O( J
- {: p8 k0 n" z. w
- if(GetTickCount()-LastTickCount>3000)- j' k6 y$ q9 r! }. ^1 V# _
- {
/ x" R( q$ t" j/ ` - Dn.QuitNWSSock();; _$ h) A( @: A: y8 s
- dwProgramState=AP_CONNECT;
2 E; s: x5 R+ J+ Z! ^ - //
& L' h* w7 N: s - static DWORD s_dwCount = 0;
6 w% |0 y9 C# E2 M5 o! v - s_dwCount++;
0 ]3 n( z( v/ j2 U4 I/ B - if( s_dwCount > 10 )
9 K" `. T, Q' I& |( k8 L - {4 g( a9 x0 ]& x' |( T/ V; u5 K
- if(m_iLanguage==TRADITIONAL_CHINESE) MessageBox(GetActiveWindow(),"硈钡穝狝竟ア毖叫浪琩眤呼蹈砞竚 ","Error",MB_OK|MB_ICONERROR);
- s5 v! J( j1 I - else if(m_iLanguage==SIMPLIFY_CHINESE) MessageBox(GetActiveWindow(),"连接更新伺服器失败,请检查您的网络设置 ","Error",MB_OK|MB_ICONERROR);. ~5 O' c, x: A# g
- else MessageBox(GetActiveWindow(),"Connected Error, Please Check Your Network Status ","Error",MB_OK|MB_ICONERROR);7 x9 }* ~% P9 h0 A
- DestroyWindow(m_pMainWnd->GetSafeHwnd());
# c( m; R4 k1 w5 x# G; y4 U - }
: x4 R6 F* Y0 {- y$ g - }4 g5 n! B* F0 m3 }
- }
s# }- X- J( E- a( Z# c - }
( i) z" i" C7 F$ F V" h1 I7 Q - break;
; @6 ]& @% z c" c7 z! D' W. B - case AP_RECEIVE:
+ i' K; f' V L# X - {" s L8 W5 T; ?8 q' A" o5 U
- int Count;6 V) h! m1 d; V0 K
- DWORD RecvLen,SendLen;
; s, i. J! a0 S0 {# z8 ]9 Q - if(Dn.NetworkLoop(RecvLen,SendLen))
/ q" E& V8 P, P0 j - {
8 f4 E, ^$ { ? - LastTickCount=GetTickCount();8 P, M! v. e* s* R" O/ @
- if(RecvLen)
. j l: \8 }8 C. T. O$ ~& m - {
" c2 _0 E/ f2 Q" e - if(!bReadHeaders)7 z" J4 \$ _1 t
- {8 g8 F# N, F1 l8 @
- char *token=strtok3(Dn.szRecvBuff,"\r\n");
% V& [' m- z ?: K* B - if(token)
4 {; a4 T. q& w* ?; t% E1 Y9 ^ - {
/ l! z' Y F% I) P - dwFileSize=0;
* _1 y) r$ T/ X! ~: U% J5 q9 p. I - for(int i=0;i<(int)strlen(token)-3;i++)
6 _7 X0 C! X3 ^ - { L8 H7 J+ l0 Q/ {. A$ |
- if(!strnicmp(&token[i],"206",3))
, k0 ~- F8 H2 x4 W& `( X - {: }" f' m1 S( [
- if(!bSilentStep)
6 V) Y, C) A% ^1 O - {5 z3 h6 V4 f0 t
- CString strTempName;: C m3 R5 c( e0 l% G _
- strTempName.Format("%s.....resuming(%d)",strFileName,dwResumeNums);/ n# B( _ c6 v8 ?
- if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);" C0 N* e3 t% q# {8 K* M) W8 Z
- dlg->m_ListText.AddString(strTempName);
1 x6 z- s9 ?/ n0 {& W - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
6 k6 t9 S) N ?) g! |3 } - }
# f; k4 K- D Y3 l9 W- b) V) R" A( w - bReadHeaders=TRUE;
9 q* J. X( t, Q* i; O - while(token=strtok3(NULL,"\r\n"))
6 {2 h8 J/ H- W3 l9 r# b - {+ _' v* h6 ^! H: T% Z
- if(!strlen(token)&&dwFileSize)/ ?2 ]2 W. u1 u- J. ~+ p, P
- {
4 b, x# j; h; y. N# j+ i - Dn.dwRecvLeft-=token+2-Dn.szRecvBuff;
% z x5 M2 S/ j; ?; F - if((int)Dn.dwRecvLeft>0): v6 e: j6 ?9 C- l1 y
- {
8 s- T/ d; Y( g5 C% I* x) O - if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)
- o) d |) v* E4 x' k - {: o4 G- I1 i) A- u$ u+ B5 ]: L
- dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;2 ?8 m* P: X: [8 `: e. m' c
- Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);$ n2 _. i/ c) j! \; N" p8 V
- }
; ?6 ?% ]' ?9 g" C. Q' Q6 B) s - memcpy(Dn.szCompBuff+dwCurrSize,token+2,Dn.dwRecvLeft);
. ^ F( ?! F2 @) V% c - dwCurrSize+=Dn.dwRecvLeft;1 K6 g( o* q4 C f# E5 I
- Dn.dwRecvLeft-=Dn.dwRecvLeft;
# R0 q& p! ^3 U/ v; O - if(dwCurrSize>=dwFileSize) goto SaveFileJump;, \% Y) I$ C3 M, I
- }3 a' G4 N, a8 Y
- break;& b* U4 h% n) O
- }
' c4 _+ p' I, F1 u! e - else" ^: R( u: X" I( q+ ]
- {4 C# \6 I8 o0 B9 c: y
- if(!strnicmp(token,"Content-Length",14))
5 g7 j n- T% Z/ V - {6 O2 b n7 W3 i5 O7 N
- if(!Dn.szCompBuff) u- E: ~! H8 Z( k# g2 i* T
- {
2 Q2 H* j' A# L+ U# g& P# F% `: i( k - dwLastSize=dwFileSize=atoi(&token[16])+dwCurrSize;4 a0 b' {. X8 W8 {/ b# l2 a8 e- R
- Dn.szCompBuff=(LPSTR)malloc(dwFileSize);) U$ _' \ V9 G$ t
- }
0 I$ v6 K) O: Q e6 j6 Z1 ? - else if(dwFileSize!=dwLastSize)* {$ Q% Z% y) F: ?0 M$ H
- {& v& R& W _5 W
- dwLastSize=dwFileSize=atoi(&token[16])+dwCurrSize;2 M* E, E( C$ K/ a: x3 L) ~
- Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);( B# P3 C1 e( R* n
- } d' c- E+ w7 _/ q: D: C, m
- }5 u2 ~6 X" H2 \* {
- }
) v- p2 x+ f: ^ ]7 x - }& }5 k0 V4 U6 E, b* |! f. b& I+ \
- break;
5 r* D4 b4 n; | E8 @4 O - }+ n6 Y: |2 ?* Y) V5 h. f
- if(!strnicmp(&token[i],"200",3)). r3 g/ ]! P# i6 M* {9 A+ p5 z! a
- {
# @6 I4 |/ H% d- t - if(!bSilentStep)
5 } y$ L# r# W3 W2 i- t - {
. a# y* h* s: ]! I4 f: [ - dlg->m_ListText.AddString(strFileName+".....downloading");
8 e9 D3 [) e8 D - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
' |; s, M, @/ m! f - }+ B- s6 X* h: \6 J7 |
- dwCurrSize=0;
3 g2 V" V* ~3 V6 S - bReadHeaders=TRUE;5 G7 k. x9 w# C) V( u1 G# t
- while(token=strtok3(NULL,"\r\n")), U4 N% U( j; ?2 M0 \. t% A v, J- W
- {8 C( k$ l0 J; Y7 g3 Y4 k7 D
- if(!strlen(token)&&dwFileSize)
' k$ n: a3 x0 [& i1 v - {
1 s! s+ L( L1 K# E$ u# m - Dn.dwRecvLeft-=token+2-Dn.szRecvBuff;3 R5 Q: T7 ?& ~
- if((int)Dn.dwRecvLeft>0)
2 ?# P9 N8 X3 M# v - {
) i# P. s# U/ J/ \* {- p - if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)3 n* x& \3 U5 q$ `
- {
5 C, ?) x* Z( Y3 p - dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;
' C6 V) B" K+ a& {5 f% ` - Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);, Q8 A$ r8 \& j! k+ l
- }
7 s& A A8 q0 h, L - memcpy(Dn.szCompBuff+dwCurrSize,token+2,Dn.dwRecvLeft);
" A5 V* p! d& M- i& l - dwCurrSize+=Dn.dwRecvLeft;' j8 w9 g* d5 u0 r" o2 C
- Dn.dwRecvLeft-=Dn.dwRecvLeft;
- A6 G5 B- t% W0 X4 K/ B6 E - if(dwCurrSize>=dwFileSize) goto SaveFileJump;% K* }" Z2 i* x& x
- }
; e, K0 P9 i- p8 a" i - break;: O8 c2 E9 S! d' y% [ y
- }
2 M& n. h ~/ J+ c4 A- e! C s2 X - else
3 V" F1 ^4 n; g - {
' z* q( x9 [( {- f! P - if(!strnicmp(token,"Content-Length",14))
' r( w2 X+ `7 W7 }$ ^7 n - {
) f9 N6 p/ [+ D3 l/ R - if(Dn.szCompBuff) { free(Dn.szCompBuff); Dn.szCompBuff=NULL; }
$ w! ]3 C5 f1 d6 Z - dwLastSize=dwFileSize=atoi(&token[16]);
8 ]- }6 E1 ^1 a v# g+ O, r& N- y - Dn.szCompBuff=(LPSTR)malloc(dwFileSize);
' ~$ j. U( H. J1 Y* V1 u( O4 I6 h! t - }, S F+ j7 I! n: K
- }
" P! Q: q* c$ ^1 Q9 ? - }- Z$ Q7 {: |! k4 F( b
- break;( j& Z ~- ^ e) l
- }
$ T X% c! C) s# ^$ [+ E - }
; Z/ Z. z# ^% [, Q. H - if(!bReadHeaders||!dwFileSize)5 U2 c! v; ^' h- A2 f( N1 G$ |! a
- {
& x# n+ ~9 g5 Y* ]2 R, [- V - // Wrong Header or Reading File Size Error
. b& A y, E5 P3 R - Dn.QuitNWSSock();2 ]; a: n+ o3 G; N7 N$ Y0 l
- dwProgramState=AP_NOTHING;
- l: J4 [+ t2 ~9 F! z3 B - CString strTempName;( V9 T, N& @7 b, A$ Z) C6 y* F6 \$ {; y
- strTempName.Format("Navigate %s File Error !",strFullName);
" e6 d# ^7 f9 [1 {4 @2 P: y - MessageBox(GetActiveWindow(),strTempName,"Error",MB_OK|MB_ICONERROR);9 Q O+ ^7 M z% i9 @9 V W7 N
- bRestartUpdater=TRUE;# F- m+ h! ~, s% E
- }3 T) p j$ f' u
- }
% ?. S6 R4 q" |1 R - else
3 @& i9 A) B8 X3 K - {
) c* F2 f6 f6 Q" e0 Y6 @+ [ - // Have No Header
8 M. ^6 N' H9 D5 b$ O- Z8 H - Dn.QuitNWSSock();! a6 G" n5 }2 Z$ D5 e7 M
- dwProgramState=AP_CONNECT;
7 S. V# ^( c4 Q. B6 l - }
& O9 l4 V4 j+ W, K - }0 b" O9 g0 F% L2 h8 }
- else( a# l- L2 e& ^7 p; }5 \* \
- {
' }5 }' K6 L% d - // Reading File From Web% `' |7 q: M2 e& T$ ^. @
- if((int)Dn.dwRecvLeft>0)0 N+ J, C$ B. j& p. r
- {
# o. B: P- }; l( V - if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)
& L2 [( G# a( }2 }7 x - {1 {" B; ]5 Y" e5 l
- dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;
. \0 I2 g; |3 e) K - Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);
; n2 r" V1 r/ z4 r: M9 H# E* T - }
4 r, A1 B! j9 j5 } - memcpy(Dn.szCompBuff+dwCurrSize,Dn.szRecvBuff,Dn.dwRecvLeft);6 j/ g. u( h h* D; N9 m& R6 S+ @
- dwCurrSize+=RecvLen;
u( m4 C/ S: L8 X% \ - Dn.dwRecvLeft-=RecvLen;
2 A. R( P& r1 g/ w) e$ B - }
/ Z& M9 k7 N# J4 W& j: v( b - dlg->m_Process2.SetPos(100*dwCurrSize/(dwFileSize<=0?1:dwFileSize));
z [8 M ? \1 P. E( p. q8 p2 d - // int iRate = 100*dwCurrSize/(dwFileSize<=0?1:dwFileSize);$ _4 |. E# V, }( m
- // dlg->m_Process2.SetPos(iRate);& @2 J- I6 N: C8 ^: f
- // if(iRate < 0) iRate = 0;, ~' S' S$ Q5 G3 g
- // if(iRate > 100) iRate = 100;
" R8 }% m! Y3 I8 m9 q - // char szShow[5];; Q; M/ }! S( B W. Q
- // sprintf(szShow,"%d%%",iRate);. D) s" @, P/ [% P9 ^/ q
- // dlg->m_SingleRate.SetWindowText(szShow);
u& _. o8 H0 B+ d - if(dwCurrSize>=dwFileSize) goto SaveFileJump;
$ P9 L7 ], _' x( H1 ~+ b/ V - }7 w9 v: a% t" A' ^3 p% Q* g9 t6 W
- }
) c9 M$ i3 H$ [8 w+ s" h* U - else if(dwCurrSize<dwFileSize)- P5 w) B8 F' h% m) M
- {4 Z: P1 u8 V" d$ c5 \- y( j. L
- // Disconnection But Size Error( l& g5 d2 ~) c1 z# x6 q. k; p( w
- Dn.QuitNWSSock();2 S' {: C* c. e
- if(dwCurrSize) dwProgramState=AP_RESUMED;5 `8 w8 y9 L+ a$ l1 _- @8 l! g. _# Y
- else dwProgramState=AP_CONNECT;) W: `) h' a" r' G
- }5 E% v1 w8 i4 Z% r
- else+ _* X* S; v( `/ X* u6 L
- {9 X$ d9 e: m$ \, q( ]) Z" R
- SaveFileJump:* [7 y+ [! K" ~# T- l
- // End of File and Disconnect- {: N! x7 T: c' N, s! G! K8 X, {
- FILE *Fp;
$ a. O/ @/ B: K! E6 V6 s+ ^ - char szTempName[MAX_PATH];
: m9 z' M( n. W2 D, X$ W - strcpy(szTempName,".\\DownLoad\");
% o9 s4 a5 o8 k4 N$ |6 J: |9 }6 w - strcat(szTempName,(char*)(LPCTSTR)strFileName);
' q( m( r% _$ B9 Y! K8 L - if(bCompressed) strcat(szTempName,".zip");' y2 Q4 P( v- J; N
- if(dwCurrSize)- Z8 W. z. ~+ t: t4 ?& k
- {; v; G; R" r3 y' T" `1 Q
- Fp=fopen(szTempName,"wb");
9 w: G" l4 N8 o - if(!Fp), s- q$ m- t; z f. I1 t
- {
& W# h* E. ~! Z' I) m - _mkdir("DownLoad");; x+ w, c; s' ^6 v6 `0 ?: p
- Fp=fopen(szTempName,"wb");! [' e ?! {3 g* v; z% ?2 B
- }' b3 ~$ L# U) }" M
- if(Fp)
# r( G3 D1 L- f5 W5 L7 ?; N' g - {0 Z- i6 t. |. R; u' k: w# J$ a0 X
- fwrite(Dn.szCompBuff,1,dwCurrSize,Fp);
. A2 t5 [% i9 j7 F8 H, v$ b3 w* n q9 A - fclose(Fp);" }7 O( A6 ^0 E
- } l L7 m+ Z/ E3 G6 j
- }
' v, Z$ q( _& n. X! g2 Y! t( p* L - if(!bSilentStep)
) c" W$ e! u& p5 x( M1 O& { - {5 ?$ d4 G1 Q6 ~2 {2 J) S
- if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
. O) ]* ?+ m$ [7 U: C" Q - dlg->m_ListText.AddString(strFileName+".....saving");* i7 n9 F! ~: u1 k! |2 d' H$ q% f
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
! i# N5 `* W$ q# }0 ^! @# q& w - }0 X' q# ]" E6 s, j
- if(bCompressed)6 \6 w1 A) D: L
- {# u% S' n* E2 R1 w1 }1 d
- int opt_overwrite=1;
* c$ C* P6 ^ B1 @ - int opt_do_extract_withoutpath=0;3 ?! c. {: Y. \7 ?% }0 T8 ~% b
- unzFile uf=NULL;" t: S4 t; ~6 K& Q- C
- uf=unzOpen(szTempName);- P0 E" F! O7 @4 k# ?% r# M
- if(uf)8 |( `% H4 ]3 ^ m
- {
3 C4 B5 }( H. P9 c8 V, U ` - if(!bSilentStep)
; @9 H) h1 a$ ?; S* [3 O - {
; x5 n4 ?" }1 E - if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
5 w5 R$ G& Q B9 A0 U - dlg->m_ListText.AddString(strFileName+".....extracting");
; q& H. v# }+ b v' q - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);/ r+ g- t) m- `% n: M
- }
; u% u0 Q, M1 G+ V - if(do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,(char*)(LPCTSTR)strFilePath,NULL)==UNZ_OK)4 q" x( {" s7 T: x7 l+ I Q
- {
; @. v& v7 C5 [7 \ f5 A0 ? - if(!bSilentStep)) J. Q- Y8 T5 O8 B2 d' G5 [5 \
- {
" \3 z @: e! E$ U. G/ ~ - if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
; w4 W8 {& o7 X) o - dlg->m_ListText.AddString(strFileName+".....done");' _8 L2 u. {/ w4 F
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
: Y9 r1 H i5 }7 @ - }
8 K/ y: Q9 E& M5 W+ [ - dwDownLoaded++;" o7 x/ E2 U4 e
- dwProgramState=AP_NOTHING;
: | J, F+ m: {' M" p9 D - }- K: A4 s! Z6 W
- else4 A% C4 v4 b$ X( r. h( o
- {5 z' p m3 t' } n! h
- dwProgramState=AP_CONNECT;
+ F! @0 }0 X$ Z- {; |$ B5 b - }) h3 u+ u. s) V! l4 l ?" Q0 M
- unzClose(uf);) u" O T% n. M# u6 B0 N8 L+ ^+ x
- }3 K6 k) I# n$ R( u: g
- else* {9 K7 G% v! M, w) y& t
- {
& ^8 k3 v6 q6 d - dwProgramState=AP_CONNECT;
% c/ k8 g0 C8 G/ w - }
0 a# _8 o) F. h% ~ - unlink(szTempName);$ e! H. d$ B' r( P. i
- }
) M3 a% l8 \1 d/ u* _+ G - else, U X! A# M$ E
- {4 R1 i: u& s, j# _
- if(!bSilentStep)
0 ?6 L0 i8 c" X! E2 U/ ` - {6 G! n r+ C) L6 g
- if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);9 {8 N2 n s" n/ U& f& O" W
- dlg->m_ListText.AddString(strFileName+".....done");
; U8 b& l/ c7 p! c8 r& p# f - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);+ _9 D* M! w% w8 F U
- }6 c4 `5 h$ f+ h$ N+ E
- dwDownLoaded++;
1 F3 W: j# y6 M2 r - dwProgramState=AP_NOTHING;
2 W% o9 ]' N7 J0 z* Y0 y; w; e - }! e" V+ i( d9 B
- Dn.QuitNWSSock();5 Y4 O$ P( W$ _+ A3 n, f# W
- }
7 \5 x v% f9 p0 }7 B7 c- |$ q d - }
% q& m7 ~4 T; c! l' p( m- c" b* O - else# M: I. E1 v, R+ R& e4 N ^) `9 E4 G
- {
3 S; c+ e0 Y% m7 n2 d# q - // Connect Timeout8 u6 ~2 G- v" P
- if(GetTickCount()-LastTickCount>30000)6 k2 P3 p! D3 Q7 f& E+ ^, p4 `, l
- {# u- y' h& m: g' I7 x
- Dn.QuitNWSSock();. i( o+ I/ c5 v: i4 H% j6 b4 D
- if(dwCurrSize) dwProgramState=AP_RESUMED;
7 |! {% E' L) f2 b; J4 ` m - else dwProgramState=AP_CONNECT;1 e. y0 [, P. v I
- }
& _/ C$ o- x: ~: N) A3 t$ o - }
1 [, x- a4 {( A" H/ Y1 {0 H - }
; c7 b# _- [0 b6 {% a/ H: t - break;! E& N, _! a9 G2 v* c
- }. Y+ C; r) |: B Q3 L0 ` P. ]
- return CWinApp::OnIdle(lCount);" O, C8 J( C4 z
- }
$ A5 I/ e5 i- o3 x1 S) ]' a
複製代碼 其实登陆器也就是这么一回事儿……- C7 M1 d0 x4 q6 i" y
附件有编译教程和源码
' D" a }* B9 I# }0 Z$ [% h5 m1 [' h& \0 n
; Y- I# U8 e* `/ E. y( L |