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

WizardNetworksPage.cpp

Go to the documentation of this file.
00001 //
00002 // WizardNetworksPage.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 "HostCache.h"
00026 #include "DiscoveryServices.h"
00027 #include "WizardNetworksPage.h"
00028 #include "DlgDonkeyImport.h"
00029 #include "Skin.h"
00030 #include "DlgHelp.h"
00031 #include <shlobj.h>
00032 
00033 #ifdef _DEBUG
00034 #define new DEBUG_NEW
00035 #undef THIS_FILE
00036 static char THIS_FILE[] = __FILE__;
00037 #endif
00038 
00039 IMPLEMENT_DYNCREATE(CWizardNetworksPage, CWizardPage)
00040 
00041 BEGIN_MESSAGE_MAP(CWizardNetworksPage, CWizardPage)
00042         //{{AFX_MSG_MAP(CWizardNetworksPage)
00043         //}}AFX_MSG_MAP
00044 END_MESSAGE_MAP()
00045 
00046 
00048 // CWizardNetworksPage property page
00049 
00050 CWizardNetworksPage::CWizardNetworksPage() : CWizardPage(CWizardNetworksPage::IDD)
00051 {
00052         //{{AFX_DATA_INIT(CWizardNetworksPage)
00053         m_bG2Enable = FALSE;
00054         m_bG1Enable = FALSE;
00055         m_bEDEnable = FALSE;
00056         //}}AFX_DATA_INIT
00057 }
00058 
00059 CWizardNetworksPage::~CWizardNetworksPage()
00060 {
00061 }
00062 
00063 void CWizardNetworksPage::DoDataExchange(CDataExchange* pDX)
00064 {
00065         CWizardPage::DoDataExchange(pDX);
00066         //{{AFX_DATA_MAP(CWizardNetworksPage)
00067         DDX_Control(pDX, IDC_G2_ENABLE, m_wndG2Enable);
00068         DDX_Check(pDX, IDC_G2_ENABLE, m_bG2Enable);
00069         DDX_Check(pDX, IDC_G1_ENABLE, m_bG1Enable);
00070         DDX_Check(pDX, IDC_ED2K_ENABLE, m_bEDEnable);
00071         //}}AFX_DATA_MAP
00072 }
00073 
00075 // CWizardNetworksPage message handlers
00076 
00077 BOOL CWizardNetworksPage::OnInitDialog() 
00078 {
00079         CWizardPage::OnInitDialog();
00080 
00081         Skin.Apply( _T("CWizardNetworksPage"), this );
00082         
00083         m_bG2Enable = Settings.Gnutella2.EnableToday;
00084         m_bG1Enable = Settings.Gnutella1.EnableToday;
00085         m_bEDEnable = Settings.eDonkey.EnableToday;
00086         
00087         m_wndG2Enable.EnableWindow( ! m_bG2Enable );
00088         UpdateData( FALSE );
00089         
00090         return TRUE;
00091 }
00092 
00093 BOOL CWizardNetworksPage::OnSetActive() 
00094 {
00095         SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
00096         return CWizardPage::OnSetActive();
00097 }
00098 
00099 LRESULT CWizardNetworksPage::OnWizardNext() 
00100 {
00101         UpdateData();
00102         
00103         Settings.Gnutella2.EnableToday  = m_bG2Enable;
00104         Settings.Gnutella1.EnableToday  = m_bG1Enable;
00105         Settings.eDonkey.EnableToday    = m_bEDEnable;
00106         
00107         DoDonkeyImport();
00108 
00109         /*
00110         if ( m_bEDEnable ) 
00111         {
00112                 CHelpDlg::Show( _T("GeneralHelp.UploadWarning") );
00113                 Settings.Live.UploadLimitWarning = TRUE;
00114         }
00115         */
00116         
00117         return 0;
00118 }
00119 
00120 void CWizardNetworksPage::DoDonkeyImport()
00121 {
00122         CString strPrograms, strFolder;
00123         CDonkeyImportDlg dlg( this );
00124         
00125         if ( HINSTANCE hShell = LoadLibrary( _T("shfolder.dll") ) )
00126         {
00127                 HRESULT (WINAPI *pfnSHGetFolderPath)(HWND, int, HANDLE, DWORD, LPWSTR);
00128                 (FARPROC&)pfnSHGetFolderPath = GetProcAddress( hShell, "SHGetFolderPathW" );
00129                 
00130                 if ( pfnSHGetFolderPath != NULL )
00131                 {
00132                         strPrograms.ReleaseBuffer(
00133                                 (*pfnSHGetFolderPath)( GetSafeHwnd(), 0x26, NULL, 0,
00134                                 strPrograms.GetBuffer( MAX_PATH + 1 ) ) == S_OK ? -1 : 0 );
00135                 }
00136                 
00137                 FreeLibrary( hShell );
00138         }
00139         
00140         if ( strPrograms.IsEmpty() ) strPrograms = _T("C:\\Program Files");
00141         
00142         // Get the server list from eMule if possible
00143         strFolder = strPrograms + _T("\\eMule\\server.met");
00144         HostCache.eDonkey.Import( strFolder );
00145         
00146         // Get a server list from the web (if you need one)
00147         if ( ( Settings.eDonkey.EnableToday ) && ( HostCache.eDonkey.CountHosts() < 20 ) ) 
00148                 DiscoveryServices.QueryForHosts( PROTOCOL_ED2K );
00149         
00150         LPCTSTR pszFolders[] =
00151         {
00152                 _T("<%PROGRAMFILES%>\\eMule\\temp"),
00153                 _T("<%PROGRAMFILES%>\\eDonkey2000\\temp"),
00154                 NULL
00155         };
00156         
00157     int nCount = 0;
00158         for ( int nFolder = 0 ; pszFolders[ nFolder ] ; nFolder++ )
00159         {
00160                 strFolder = pszFolders[ nFolder ];
00161                 Replace( strFolder, _T("<%PROGRAMFILES%>"), strPrograms );
00162                 
00163                 if ( GetFileAttributes( strFolder ) != 0xFFFFFFFF )
00164                 {
00165                         dlg.m_pImporter.AddFolder( strFolder );
00166                         nCount++;
00167                 }
00168         }
00169         
00170         if ( nCount > 0 ) dlg.DoModal();
00171 }

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