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