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