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