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