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