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