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