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