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