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