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