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 "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
00043
00044 END_MESSAGE_MAP()
00045
00046
00048
00049
00050 CWizardNetworksPage::CWizardNetworksPage() : CWizardPage(CWizardNetworksPage::IDD)
00051 {
00052
00053 m_bG2Enable = FALSE;
00054 m_bG1Enable = FALSE;
00055 m_bEDEnable = FALSE;
00056
00057 }
00058
00059 CWizardNetworksPage::~CWizardNetworksPage()
00060 {
00061 }
00062
00063 void CWizardNetworksPage::DoDataExchange(CDataExchange* pDX)
00064 {
00065 CWizardPage::DoDataExchange(pDX);
00066
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
00072 }
00073
00075
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
00111
00112
00113
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
00143 strFolder = strPrograms + _T("\\eMule\\server.met");
00144 HostCache.eDonkey.Import( strFolder );
00145
00146
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 }