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