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 "WndSettingsSheet.h"
00026 #include "PageSettingsNetworks.h"
00027 #include "PageSettingsGnutella.h"
00028 #include ".\pagesettingsgnutella.h"
00029
00030 #ifdef _DEBUG
00031 #define new DEBUG_NEW
00032 #undef THIS_FILE
00033 static char THIS_FILE[] = __FILE__;
00034 #endif
00035
00036 IMPLEMENT_DYNCREATE(CGnutellaSettingsPage, CSettingsPage)
00037
00038 BEGIN_MESSAGE_MAP(CGnutellaSettingsPage, CSettingsPage)
00039
00040 ON_BN_CLICKED(IDC_G2_TODAY, OnG2Today)
00041 ON_BN_CLICKED(IDC_G1_TODAY, OnG1Today)
00042 ON_BN_CLICKED(IDC_G2_ALWAYS, OnG2Always)
00043
00044 END_MESSAGE_MAP()
00045
00046
00048
00049
00050 CGnutellaSettingsPage::CGnutellaSettingsPage() : CSettingsPage( CGnutellaSettingsPage::IDD )
00051 {
00052
00053 m_bG2Today = FALSE;
00054 m_bG1Today = FALSE;
00055 m_bG1Always = FALSE;
00056 m_nG1Hubs = 0;
00057 m_nG1Leafs = 0;
00058 m_nG1Peers = 0;
00059 m_nG2Hubs = 0;
00060 m_nG2Leafs = 0;
00061 m_nG2Peers = 0;
00062 m_bDeflateHub2Hub = FALSE;
00063 m_bDeflateLeaf2Hub = FALSE;
00064 m_bDeflateHub2Leaf = FALSE;
00065
00066 }
00067
00068 CGnutellaSettingsPage::~CGnutellaSettingsPage()
00069 {
00070 }
00071
00072 void CGnutellaSettingsPage::DoDataExchange(CDataExchange* pDX)
00073 {
00074 CSettingsPage::DoDataExchange(pDX);
00075
00076 DDX_Control(pDX, IDC_G2_PEERS_SPIN, m_wndG2Peers);
00077 DDX_Control(pDX, IDC_G2_LEAFS_SPIN, m_wndG2Leafs);
00078 DDX_Control(pDX, IDC_G2_HUBS_SPIN, m_wndG2Hubs);
00079 DDX_Control(pDX, IDC_G1_PEERS_SPIN, m_wndG1Peers);
00080 DDX_Control(pDX, IDC_G1_LEAFS_SPIN, m_wndG1Leafs);
00081 DDX_Control(pDX, IDC_G1_HUBS_SPIN, m_wndG1Hubs);
00082 DDX_Check(pDX, IDC_G2_TODAY, m_bG2Today);
00083 DDX_Control(pDX, IDC_G2_ALWAYS, m_wndG2Always);
00084 DDX_Check(pDX, IDC_G1_TODAY, m_bG1Today);
00085 DDX_Check(pDX, IDC_G1_ALWAYS, m_bG1Always);
00086 DDX_Text(pDX, IDC_G1_HUBS, m_nG1Hubs);
00087 DDX_Text(pDX, IDC_G1_LEAFS, m_nG1Leafs);
00088 DDX_Text(pDX, IDC_G1_PEERS, m_nG1Peers);
00089 DDX_Text(pDX, IDC_G2_HUBS, m_nG2Hubs);
00090 DDX_Text(pDX, IDC_G2_LEAFS, m_nG2Leafs);
00091 DDX_Text(pDX, IDC_G2_PEERS, m_nG2Peers);
00092 DDX_Check(pDX, IDC_DEFLATE_HUB2HUB, m_bDeflateHub2Hub);
00093 DDX_Check(pDX, IDC_DEFLATE_LEAF2HUB, m_bDeflateLeaf2Hub);
00094 DDX_Check(pDX, IDC_DEFLATE_HUB2LEAF, m_bDeflateHub2Leaf);
00095 DDX_Control(pDX, IDC_G1_CLIENTMODE, m_wndG1ClientMode);
00096 DDX_Control(pDX, IDC_G2_CLIENTMODE, m_wndG2ClientMode);
00097
00098 }
00099
00101
00102
00103 BOOL CGnutellaSettingsPage::OnInitDialog()
00104 {
00105 CSettingsPage::OnInitDialog();
00106
00107
00108 m_bG2Today = Settings.Gnutella2.EnableToday;
00109 m_bG1Today = Settings.Gnutella1.EnableToday;
00110 m_bG1Always = Settings.Gnutella1.EnableAlways;
00111 m_bDeflateHub2Hub = Settings.Gnutella.DeflateHub2Hub;
00112 m_bDeflateLeaf2Hub = Settings.Gnutella.DeflateLeaf2Hub;
00113 m_bDeflateHub2Leaf = Settings.Gnutella.DeflateHub2Leaf;
00114 m_nG1Hubs = Settings.Gnutella1.NumHubs;
00115 m_nG1Leafs = Settings.Gnutella1.NumLeafs;
00116 m_nG1Peers = Settings.Gnutella1.NumPeers;
00117 m_nG2Hubs = Settings.Gnutella2.NumHubs;
00118 m_nG2Leafs = Settings.Gnutella2.NumLeafs;
00119 m_nG2Peers = Settings.Gnutella2.NumPeers;
00120
00121 m_wndG1Peers.SetRange( 0, 64 );
00122 m_wndG1Leafs.SetRange( 0, 1024 );
00123 m_wndG1Hubs.SetRange( 0, 2 );
00124
00125 m_wndG2Peers.SetRange( 0, 64 );
00126 m_wndG2Leafs.SetRange( 0, 1024 );
00127 m_wndG2Hubs.SetRange( 0, 3 );
00128
00129 m_wndG1ClientMode.SetItemData( 0, MODE_AUTO );
00130 m_wndG1ClientMode.SetItemData( 1, MODE_LEAF );
00131 m_wndG1ClientMode.SetItemData( 2, MODE_ULTRAPEER );
00132
00133 m_wndG1ClientMode.SetCurSel( Settings.Gnutella1.ClientMode );
00134
00135 m_wndG2ClientMode.SetItemData( 0, MODE_AUTO );
00136 m_wndG2ClientMode.SetItemData( 1, MODE_LEAF );
00137 m_wndG2ClientMode.SetItemData( 2, MODE_HUB );
00138
00139
00140 Settings.Gnutella1.ClientMode = MODE_LEAF;
00141 m_wndG1ClientMode.EnableWindow( FALSE );
00142 m_wndG1ClientMode.SetCurSel( MODE_LEAF );
00143
00144
00145 if ( ! theApp.m_bNT )
00146 {
00147 Settings.Gnutella2.ClientMode = MODE_LEAF;
00148 m_wndG2ClientMode.EnableWindow( FALSE );
00149 }
00150 m_wndG2ClientMode.SetCurSel( Settings.Gnutella2.ClientMode );
00151
00152 m_wndG2Always.SetCheck( BST_INDETERMINATE );
00153
00154 UpdateData( FALSE );
00155
00156 return TRUE;
00157 }
00158
00159 BOOL CGnutellaSettingsPage::OnSetActive()
00160 {
00161 CNetworksSettingsPage* ppNetworks =
00162 (CNetworksSettingsPage*)GetPage( RUNTIME_CLASS(CNetworksSettingsPage) );
00163
00164 if ( ppNetworks->GetSafeHwnd() != NULL )
00165 {
00166 ppNetworks->UpdateData( TRUE );
00167 m_bG2Today = ppNetworks->m_bG2Enable;
00168 m_bG1Today = ppNetworks->m_bG1Enable;
00169 UpdateData( FALSE );
00170 }
00171
00172 return CSettingsPage::OnSetActive();
00173 }
00174
00175 void CGnutellaSettingsPage::OnG2Today()
00176 {
00177 UpdateData();
00178
00179 if ( ! m_bG2Today )
00180 {
00181 CString strMessage;
00182 LoadString( strMessage, IDS_NETWORK_DISABLE_G2 );
00183
00184 if ( AfxMessageBox( strMessage, MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 ) != IDYES )
00185 {
00186 m_bG2Today = TRUE;
00187 UpdateData( FALSE );
00188 }
00189 }
00190
00191 CNetworksSettingsPage* ppNetworks =
00192 (CNetworksSettingsPage*)GetPage( RUNTIME_CLASS(CNetworksSettingsPage) );
00193
00194 if ( ppNetworks->GetSafeHwnd() != NULL )
00195 {
00196 ppNetworks->UpdateData( TRUE );
00197 ppNetworks->m_bG2Enable = m_bG2Today;
00198 ppNetworks->UpdateData( FALSE );
00199 }
00200 }
00201
00202 void CGnutellaSettingsPage::OnG1Today()
00203 {
00204 UpdateData( TRUE );
00205
00206 if ( m_bG1Today && ( Settings.GetOutgoingBandwidth() < 2 ) )
00207 {
00208 CString strMessage;
00209 LoadString( strMessage, IDS_NETWORK_BANDWIDTH_LOW );
00210 AfxMessageBox( strMessage, MB_OK );
00211 m_bG1Today = FALSE;
00212 UpdateData( FALSE );
00213 }
00214
00215 CNetworksSettingsPage* ppNetworks =
00216 (CNetworksSettingsPage*)GetPage( RUNTIME_CLASS(CNetworksSettingsPage) );
00217
00218 if ( ppNetworks->GetSafeHwnd() != NULL )
00219 {
00220 UpdateData( TRUE );
00221 ppNetworks->UpdateData( TRUE );
00222 ppNetworks->m_bG1Enable = m_bG1Today;
00223 ppNetworks->UpdateData( FALSE );
00224 }
00225 }
00226
00227 void CGnutellaSettingsPage::OnOK()
00228 {
00229 UpdateData();
00230
00231
00232 if ( ( m_wndG2ClientMode.GetCurSel() == MODE_HUB ) && ( Settings.Gnutella2.ClientMode != MODE_HUB ) )
00233 {
00234 CString strMessage;
00235 LoadString( strMessage, IDS_NETWORK_FORCE_HUB );
00236
00237 if ( AfxMessageBox( strMessage, MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 ) != IDYES )
00238 {
00239 m_wndG2ClientMode.SetCurSel( MODE_AUTO );
00240 Settings.Gnutella2.ClientMode = MODE_AUTO;
00241 UpdateData( FALSE );
00242 }
00243 }
00244
00245
00246 if ( ( Settings.GetOutgoingBandwidth() < 2 ) )
00247 {
00248 m_bG1Today = m_bG1Always = FALSE;
00249 }
00250
00251
00252 m_nG1Hubs = min( m_nG1Hubs, 2 );
00253 m_nG1Leafs = min( m_nG1Leafs, 1024 );
00254 m_nG1Peers = min( m_nG1Peers, 64 );
00255 m_nG2Hubs = min( m_nG2Hubs, 3 );
00256 m_nG2Leafs = min( m_nG2Leafs, 1024 );
00257 m_nG2Peers = min( m_nG2Peers, 64 );
00258
00259
00260 Settings.Gnutella2.EnableToday = m_bG2Today;
00261 Settings.Gnutella1.EnableToday = m_bG1Today || m_bG1Always;
00262 Settings.Gnutella1.EnableAlways = m_bG1Always;
00263 Settings.Gnutella.DeflateHub2Hub = m_bDeflateHub2Hub;
00264 Settings.Gnutella.DeflateLeaf2Hub = m_bDeflateLeaf2Hub;
00265 Settings.Gnutella.DeflateHub2Leaf = m_bDeflateHub2Leaf;
00266 Settings.Gnutella1.NumHubs = m_nG1Hubs;
00267 Settings.Gnutella1.NumLeafs = m_nG1Leafs;
00268 Settings.Gnutella1.NumPeers = m_nG1Peers;
00269 Settings.Gnutella2.NumHubs = m_nG2Hubs;
00270 Settings.Gnutella2.NumLeafs = m_nG2Leafs;
00271 Settings.Gnutella2.NumPeers = m_nG2Peers;
00272
00273 Settings.Gnutella1.ClientMode = m_wndG1ClientMode.GetCurSel();
00274 if ( Settings.Gnutella1.ClientMode > MODE_ULTRAPEER ) Settings.Gnutella1.ClientMode = MODE_AUTO;
00275
00276 if ( Settings.Gnutella1.ClientMode == MODE_ULTRAPEER )
00277 {
00278 Settings.Gnutella1.NumLeafs = max( Settings.Gnutella1.NumLeafs, 5 );
00279 Settings.Gnutella1.NumPeers = max( Settings.Gnutella1.NumPeers, 4 );
00280 }
00281
00282 Settings.Gnutella2.ClientMode = m_wndG2ClientMode.GetCurSel();
00283 if ( Settings.Gnutella2.ClientMode > MODE_HUB ) Settings.Gnutella2.ClientMode = MODE_AUTO;
00284
00285 if ( Settings.Gnutella2.ClientMode == MODE_HUB )
00286 {
00287 Settings.Gnutella2.NumLeafs = max( Settings.Gnutella2.NumLeafs, 50 );
00288 Settings.Gnutella2.NumPeers = max( Settings.Gnutella2.NumPeers, 4 );
00289 }
00290
00291
00292 UpdateData( FALSE );
00293
00294 CSettingsPage::OnOK();
00295 }
00296
00297 void CGnutellaSettingsPage::OnG2Always()
00298 {
00299 m_wndG2Always.SetCheck( BST_INDETERMINATE );
00300 }