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