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