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