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