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