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