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