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