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