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