00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "VersionChecker.h"
00025 #include "Network.h"
00026 #include "Downloads.h"
00027 #include "ShareazaURL.h"
00028 #include "SHA.h"
00029 #include "TigerTree.h"
00030 #include "DlgUpgrade.h"
00031 #include "WndMain.h"
00032 #include "WndDownloads.h"
00033
00034 #ifdef _DEBUG
00035 #define new DEBUG_NEW
00036 #undef THIS_FILE
00037 static char THIS_FILE[] = __FILE__;
00038 #endif
00039
00040 BEGIN_MESSAGE_MAP(CUpgradeDlg, CSkinDialog)
00041
00042
00043 END_MESSAGE_MAP()
00044
00045
00047
00048
00049 CUpgradeDlg::CUpgradeDlg(CWnd* pParent) : CSkinDialog(CUpgradeDlg::IDD, pParent)
00050 {
00051
00052 m_bCheck = FALSE;
00053 m_sMessage = _T("");
00054
00055 }
00056
00057 void CUpgradeDlg::DoDataExchange(CDataExchange* pDX)
00058 {
00059 CSkinDialog::DoDataExchange(pDX);
00060
00061 DDX_Check(pDX, IDC_DONT_CHECK, m_bCheck);
00062 DDX_Text(pDX, IDC_MESSAGE, m_sMessage);
00063
00064 }
00065
00067
00068
00069 BOOL CUpgradeDlg::OnInitDialog()
00070 {
00071 CSkinDialog::OnInitDialog();
00072
00073 SkinMe( _T("CUpgradeDlg"), IDR_MAINFRAME );
00074
00075 m_sMessage = VersionChecker.m_sUpgradePrompt;
00076 m_bCheck = FALSE;
00077
00078 UpdateData( FALSE );
00079
00080 return TRUE;
00081 }
00082
00083 void CUpgradeDlg::OnOK()
00084 {
00085 ParseCheckAgain();
00086
00087 CShareazaURL pURL;
00088
00089 pURL.m_nAction = CShareazaURL::uriDownload;
00090 pURL.m_sName = VersionChecker.m_sUpgradeFile;
00091 pURL.m_sURL = VersionChecker.m_sUpgradeSources;
00092
00093 if ( VersionChecker.m_sUpgradeSHA1.GetLength() )
00094 {
00095 pURL.m_bSHA1 = TRUE;
00096 CSHA::HashFromString( VersionChecker.m_sUpgradeSHA1, &pURL.m_pSHA1 );
00097 }
00098
00099 if ( VersionChecker.m_sUpgradeTiger.GetLength() )
00100 {
00101 pURL.m_bTiger = TRUE;
00102 CTigerNode::HashFromString( VersionChecker.m_sUpgradeTiger, &pURL.m_pTiger );
00103 }
00104
00105 if ( VersionChecker.m_sUpgradeSize.GetLength() )
00106 {
00107 QWORD nSize;
00108 if ( ( _stscanf( VersionChecker.m_sUpgradeSize.GetString(), _T("%I64i"), &nSize ) == 1 ) && ( nSize > 0 ) )
00109 {
00110 pURL.m_bSize = TRUE;
00111 pURL.m_nSize = nSize;
00112 }
00113 }
00114
00115 Downloads.Add( &pURL );
00116
00117 if ( ! Network.IsWellConnected() ) Network.Connect( TRUE );
00118
00119 CMainWnd* pMainWnd = (CMainWnd*)AfxGetMainWnd();
00120 pMainWnd->m_pWindows.Open( RUNTIME_CLASS(CDownloadsWnd) );
00121
00122 CSkinDialog::OnOK();
00123 }
00124
00125 void CUpgradeDlg::OnCancel()
00126 {
00127 ParseCheckAgain();
00128
00129 CSkinDialog::OnCancel();
00130 }
00131
00132 void CUpgradeDlg::ParseCheckAgain()
00133 {
00134 UpdateData();
00135
00136 if ( m_bCheck )
00137 {
00138 VersionChecker.SetNextCheck( 31 );
00139 }
00140 }