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