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