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