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