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