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