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