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