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