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