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