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