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