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