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