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