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