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

PageSettingsDonkey.cpp

Go to the documentation of this file.
00001 //
00002 // PageSettingsDonkey.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 "Settings.h"
00025 #include "WndSettingsSheet.h"
00026 #include "PageSettingsNetworks.h"
00027 #include "PageSettingsDonkey.h"
00028 #include "DlgDonkeyImport.h"
00029 #include "DlgDonkeyServers.h"
00030 
00031 #ifdef _DEBUG
00032 #define new DEBUG_NEW
00033 #undef THIS_FILE
00034 static char THIS_FILE[] = __FILE__;
00035 #endif
00036 
00037 IMPLEMENT_DYNCREATE(CDonkeySettingsPage, CSettingsPage)
00038 
00039 BEGIN_MESSAGE_MAP(CDonkeySettingsPage, CSettingsPage)
00040         //{{AFX_MSG_MAP(CDonkeySettingsPage)
00041         ON_BN_CLICKED(IDC_DISCOVERY_GO, OnDiscoveryGo)
00042         ON_BN_CLICKED(IDC_SERVER_WALK, OnServerWalk)
00043         ON_BN_CLICKED(IDC_IMPORT_DOWNLOADS, OnImportDownloads)
00044         ON_BN_CLICKED(IDC_ENABLE_TODAY, OnEnableToday)
00045         //}}AFX_MSG_MAP
00046 END_MESSAGE_MAP()
00047 
00048 
00050 // CDonkeySettingsPage property page
00051 
00052 CDonkeySettingsPage::CDonkeySettingsPage() : CSettingsPage( CDonkeySettingsPage::IDD )
00053 {
00054         //{{AFX_DATA_INIT(CDonkeySettingsPage)
00055         m_nResults = 0;
00056         m_bServerWalk = FALSE;
00057         m_nLinks = 0;
00058         m_bEnableToday = FALSE;
00059         m_bEnableAlways = FALSE;
00060         //}}AFX_DATA_INIT
00061 }
00062 
00063 CDonkeySettingsPage::~CDonkeySettingsPage()
00064 {
00065 }
00066 
00067 void CDonkeySettingsPage::DoDataExchange(CDataExchange* pDX)
00068 {
00069         CSettingsPage::DoDataExchange(pDX);
00070         //{{AFX_DATA_MAP(CDonkeySettingsPage)
00071         DDX_Control(pDX, IDC_LINKS_SPIN, m_wndLinksSpin);
00072         DDX_Control(pDX, IDC_RESULTS, m_wndResults);
00073         DDX_Control(pDX, IDC_RESULTS_SPIN, m_wndResultsSpin);
00074         DDX_Control(pDX, IDC_DISCOVERY_GO, m_wndDiscoveryGo);
00075         DDX_Text(pDX, IDC_RESULTS, m_nResults);
00076         DDX_Check(pDX, IDC_SERVER_WALK, m_bServerWalk);
00077         DDX_Text(pDX, IDC_LINKS, m_nLinks);
00078         DDX_Check(pDX, IDC_ENABLE_TODAY, m_bEnableToday);
00079         DDX_Check(pDX, IDC_ENABLE_ALWAYS, m_bEnableAlways);
00080         //}}AFX_DATA_MAP
00081 }
00082 
00084 // CDonkeySettingsPage message handlers
00085 
00086 BOOL CDonkeySettingsPage::OnInitDialog()
00087 {
00088         CSettingsPage::OnInitDialog();
00089 
00090         m_bEnableToday  = Settings.eDonkey.EnableToday;
00091         m_bEnableAlways = Settings.eDonkey.EnableAlways;
00092         m_nLinks                = Settings.eDonkey.MaxLinks;
00093         m_bServerWalk   = Settings.eDonkey.ServerWalk;
00094         m_nResults              = Settings.eDonkey.MaxResults;
00095 
00096         UpdateData( FALSE );
00097 
00098         m_wndResults.EnableWindow( m_bServerWalk );
00099         m_wndResultsSpin.SetRange( 0, 201 );
00100         m_wndLinksSpin.SetRange( 0, 2048 );
00101 
00102         return TRUE;
00103 }
00104 
00105 BOOL CDonkeySettingsPage::OnSetActive()
00106 {
00107         CNetworksSettingsPage* ppNetworks =
00108                 (CNetworksSettingsPage*)GetPage( RUNTIME_CLASS(CNetworksSettingsPage) );
00109 
00110         if ( ppNetworks->GetSafeHwnd() != NULL )
00111         {
00112                 ppNetworks->UpdateData( TRUE );
00113                 m_bEnableToday = ppNetworks->m_bEDEnable;
00114                 UpdateData( FALSE );
00115         }
00116 
00117         return CSettingsPage::OnSetActive();
00118 }
00119 
00120 void CDonkeySettingsPage::OnEnableToday()
00121 {
00122         UpdateData( TRUE );
00123 
00124         if ( m_bEnableToday && ( Settings.GetOutgoingBandwidth() < 2 ) )
00125         {
00126                 CString strMessage;
00127                 LoadString( strMessage, IDS_NETWORK_BANDWIDTH_LOW );
00128                 AfxMessageBox( strMessage, MB_OK );
00129                 m_bEnableToday = FALSE;
00130                 UpdateData( FALSE );
00131         }
00132 
00133         CNetworksSettingsPage* ppNetworks =
00134                 (CNetworksSettingsPage*)GetPage( RUNTIME_CLASS(CNetworksSettingsPage) );
00135 
00136         if ( ppNetworks->GetSafeHwnd() != NULL )
00137         {
00138                 ppNetworks->UpdateData( TRUE );
00139                 ppNetworks->m_bEDEnable = m_bEnableToday;
00140                 ppNetworks->UpdateData( FALSE );
00141         }
00142 }
00143 
00144 void CDonkeySettingsPage::OnServerWalk()
00145 {
00146         UpdateData();
00147         m_wndResultsSpin.EnableWindow( m_bServerWalk );
00148         m_wndResults.EnableWindow( m_bServerWalk );
00149 }
00150 
00151 void CDonkeySettingsPage::OnImportDownloads()
00152 {
00153         TCHAR szPath[MAX_PATH];
00154         LPITEMIDLIST pPath;
00155         LPMALLOC pMalloc;
00156         BROWSEINFO pBI;
00157 
00158         ZeroMemory( &pBI, sizeof(pBI) );
00159         pBI.hwndOwner           = AfxGetMainWnd()->GetSafeHwnd();
00160         pBI.pszDisplayName      = szPath;
00161         pBI.lpszTitle           = _T("Select your temp (download) folder:");
00162         pBI.ulFlags                     = BIF_RETURNONLYFSDIRS;
00163 
00164         pPath = SHBrowseForFolder( &pBI );
00165 
00166         if ( pPath == NULL ) return;
00167 
00168         SHGetPathFromIDList( pPath, szPath );
00169         SHGetMalloc( &pMalloc );
00170         pMalloc->Free( pPath );
00171         pMalloc->Release();
00172 
00173         CDonkeyImportDlg dlg;
00174         dlg.m_pImporter.AddFolder( szPath );
00175         dlg.DoModal();
00176 }
00177 
00178 void CDonkeySettingsPage::OnDiscoveryGo()
00179 {
00180         CDonkeyServersDlg dlg;
00181         dlg.DoModal();
00182 }
00183 
00184 void CDonkeySettingsPage::OnOK()
00185 {
00186         UpdateData();
00187 
00188         Settings.eDonkey.EnableAlways   = m_bEnableAlways && ( Settings.GetOutgoingBandwidth() >= 2 );
00189         Settings.eDonkey.EnableToday    = ( m_bEnableToday || Settings.eDonkey.EnableAlways ) && ( Settings.GetOutgoingBandwidth() >= 2 );
00190         Settings.eDonkey.MaxLinks               = m_nLinks;
00191         Settings.eDonkey.ServerWalk             = m_bServerWalk;
00192         Settings.eDonkey.MaxResults             = m_nResults;
00193 
00194         CSettingsPage::OnOK();
00195 }

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