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