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