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