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