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