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