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