Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

DlgUpgrade.cpp

Go to the documentation of this file.
00001 //
00002 // DlgUpgrade.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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         //{{AFX_MSG_MAP(CUpgradeDlg)
00042         //}}AFX_MSG_MAP
00043 END_MESSAGE_MAP()
00044 
00045 
00047 // CUpgradeDlg dialog
00048 
00049 CUpgradeDlg::CUpgradeDlg(CWnd* pParent) : CSkinDialog(CUpgradeDlg::IDD, pParent)
00050 {
00051         //{{AFX_DATA_INIT(CUpgradeDlg)
00052         m_bCheck = FALSE;
00053         m_sMessage = _T("");
00054         //}}AFX_DATA_INIT
00055 }
00056 
00057 void CUpgradeDlg::DoDataExchange(CDataExchange* pDX)
00058 {
00059         CSkinDialog::DoDataExchange(pDX);
00060         //{{AFX_DATA_MAP(CUpgradeDlg)
00061         DDX_Check(pDX, IDC_DONT_CHECK, m_bCheck);
00062         DDX_Text(pDX, IDC_MESSAGE, m_sMessage);
00063         //}}AFX_DATA_MAP
00064 }
00065 
00067 // CUpgradeDlg message handlers
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 }

Generated on Thu Dec 15 10:39:40 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2