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