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