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