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