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