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