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