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