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