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