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