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