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