Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

455 lines
9.5 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. perform.cpp
  5. Abstract:
  6. WWW Performance Property Page
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager
  12. Revision History:
  13. 11/29/2000 sergeia Changed for IIS6. Removed excessive commenting
  14. --*/
  15. //
  16. // Include Files
  17. //
  18. #include "stdafx.h"
  19. #include "resource.h"
  20. #include "common.h"
  21. #include "inetmgrapp.h"
  22. #include "inetprop.h"
  23. #include "shts.h"
  24. #include "w3sht.h"
  25. #include "supdlgs.h"
  26. #include "perform.h"
  27. #ifdef _DEBUG
  28. #undef THIS_FILE
  29. static char BASED_CODE THIS_FILE[] = __FILE__;
  30. #endif
  31. #define CONNECTIONS_MIN 0
  32. #define CONNECTIONS_MAX 2000000
  33. #define LIMITED_CONNECTIONS_MIN (10)
  34. #define LIMITED_CONNECTIONS_MAX (40)
  35. //#define MAX_MAX_CONNECTIONS (1999999999L)
  36. #define INITIAL_MAX_CONNECTIONS ( 1000L)
  37. //#define UNLIMITED_CONNECTIONS (2000000000L)
  38. IMPLEMENT_DYNCREATE(CW3PerfPage, CInetPropertyPage)
  39. /* static */
  40. void
  41. CW3PerfPage::ParseMaxNetworkUse(
  42. DWORD& dwMaxBandwidth,
  43. DWORD& dwMaxBandwidthDisplay,
  44. BOOL& fLimitBandwidth
  45. )
  46. {
  47. //
  48. // Special case: If dwMaxBandwidth is 0(an invalid value), the
  49. // value likely could not be inherited from the root (the user
  50. // is an operator and can't see the properties there). Adjust
  51. // the value to a possibly misleading value.
  52. //
  53. if (dwMaxBandwidth == 0L)
  54. {
  55. TRACEEOLID("Adjusting invalid bandwidth throttling value -- "
  56. "are you an operator?");
  57. dwMaxBandwidth = INFINITE_BANDWIDTH;
  58. }
  59. fLimitBandwidth = (dwMaxBandwidth != INFINITE_BANDWIDTH);
  60. dwMaxBandwidthDisplay = fLimitBandwidth ?
  61. (dwMaxBandwidth / KILOBYTE) : (DEF_BANDWIDTH / KILOBYTE);
  62. }
  63. CW3PerfPage::CW3PerfPage(
  64. IN CInetPropertySheet * pSheet
  65. )
  66. : CInetPropertyPage(CW3PerfPage::IDD, pSheet)
  67. {
  68. #ifdef _DEBUG
  69. afxMemDF |= checkAlwaysMemDF;
  70. #endif // _DEBUG
  71. m_nUnlimited = RADIO_LIMITED;
  72. m_nMaxConnections = 50;
  73. m_nVisibleMaxConnections = 50;
  74. }
  75. CW3PerfPage::~CW3PerfPage()
  76. {
  77. }
  78. void
  79. CW3PerfPage::DoDataExchange(
  80. IN CDataExchange * pDX
  81. )
  82. /*++
  83. Routine Description:
  84. Initialise/Store control data
  85. Arguments:
  86. CDataExchange * pDX - DDX/DDV control structure
  87. Return Value:
  88. None
  89. --*/
  90. {
  91. CInetPropertyPage::DoDataExchange(pDX);
  92. //{{AFX_DATA_MAP(CW3PerfPage)
  93. DDX_Check(pDX, IDC_CHECK_LIMIT_NETWORK_USE, m_fLimitBandwidth);
  94. DDX_Control(pDX, IDC_CHECK_LIMIT_NETWORK_USE, m_LimitBandwidth);
  95. DDX_Control(pDX, IDC_MAX_BANDWIDTH, m_MaxBandwidth);
  96. DDX_Text(pDX, IDC_MAX_BANDWIDTH, m_dwMaxBandwidthDisplay);
  97. DDX_Control(pDX, IDC_MAX_BANDWIDTH_SPIN, m_MaxBandwidthSpin);
  98. DDX_Control(pDX, IDC_STATIC_MAX_NETWORK_USE, m_MaxBandwidthTxt);
  99. DDX_Check(pDX, IDC_UNINSTALL_PSHED, m_fUninstallPSHED);
  100. DDX_Control(pDX, IDC_UNINSTALL_PSHED, m_UninstallPSHED);
  101. DDX_Control(pDX, IDC_STATIC_PSHED_REQUIRED, m_static_PSHED_Required);
  102. DDX_Control(pDX, IDC_STATIC_CONN, m_WebServiceConnGrp);
  103. DDX_Control(pDX, IDC_STATIC_CONN_TXT, m_WebServiceConnTxt);
  104. DDX_Control(pDX, IDC_RADIO_UNLIMITED, m_radio_Unlimited);
  105. DDX_Control(pDX, IDC_RADIO_LIMITED, m_radio_Limited);
  106. DDX_Radio(pDX, IDC_RADIO_UNLIMITED, m_nUnlimited);
  107. DDX_Control(pDX, IDC_EDIT_MAX_CONNECTIONS, m_edit_MaxConnections);
  108. DDX_Text(pDX, IDC_EDIT_MAX_CONNECTIONS, m_nMaxConnections);
  109. DDX_Control(pDX, IDC_SPIN_MAX_CONNECTIONS, m_MaxConnectionsSpin);
  110. DDX_Control(pDX, IDC_STATIC_CONNECTIONS, m_ConnectionsTxt);
  111. //}}AFX_DATA_MAP
  112. if (!pDX->m_bSaveAndValidate || m_fLimitBandwidth)
  113. {
  114. DDX_Text(pDX, IDC_MAX_BANDWIDTH, m_dwMaxBandwidthDisplay);
  115. DDV_MinMaxLong(pDX, m_dwMaxBandwidthDisplay,
  116. BANDWIDTH_MIN, BANDWIDTH_MAX);
  117. }
  118. if (IsMasterInstance())
  119. {
  120. if (!pDX->m_bSaveAndValidate || !m_fUnlimitedConnections )
  121. {
  122. DDX_Text(pDX, IDC_EDIT_MAX_CONNECTIONS, m_nVisibleMaxConnections);
  123. }
  124. DDV_MinMaxDWord(pDX, m_nVisibleMaxConnections, 0, UNLIMITED_CONNECTIONS);
  125. }
  126. }
  127. //
  128. // Message Map
  129. //
  130. BEGIN_MESSAGE_MAP(CW3PerfPage, CInetPropertyPage)
  131. //{{AFX_MSG_MAP(CW3PerfPage)
  132. ON_BN_CLICKED(IDC_CHECK_LIMIT_NETWORK_USE, OnCheckLimitNetworkUse)
  133. ON_BN_CLICKED(IDC_RADIO_LIMITED, OnRadioLimited)
  134. ON_BN_CLICKED(IDC_RADIO_UNLIMITED, OnRadioUnlimited)
  135. //}}AFX_MSG_MAP
  136. ON_EN_CHANGE(IDC_EDIT_MAX_CONNECTIONS, OnItemChanged)
  137. ON_EN_CHANGE(IDC_MAX_BANDWIDTH, OnItemChanged)
  138. END_MESSAGE_MAP()
  139. BOOL
  140. CW3PerfPage::SetControlStates()
  141. /*++
  142. Routine Description:
  143. Set control states depending on contents of the dialog
  144. Arguments:
  145. None
  146. Return Value:
  147. TRUE if the 'limit network use' is on.
  148. --*/
  149. {
  150. BOOL fLimitOn = FALSE;
  151. if (::IsWindow(m_LimitBandwidth.m_hWnd))
  152. {
  153. fLimitOn = m_LimitBandwidth.GetCheck() > 0
  154. && HasBwThrottling()
  155. && HasAdminAccess();
  156. m_static_PSHED_Required.ShowWindow(fLimitOn &&
  157. fLimitOn != m_fLimitBandwidthInitial ? SW_SHOW : SW_HIDE);
  158. m_UninstallPSHED.ShowWindow(!fLimitOn &&
  159. fLimitOn != m_fLimitBandwidthInitial ? SW_SHOW : SW_HIDE);
  160. m_MaxBandwidthTxt.EnableWindow(fLimitOn);
  161. m_MaxBandwidth.EnableWindow(fLimitOn);
  162. m_MaxBandwidthSpin.EnableWindow(fLimitOn);
  163. }
  164. if (::IsWindow(m_edit_MaxConnections.m_hWnd))
  165. {
  166. m_edit_MaxConnections.EnableWindow(!m_fUnlimitedConnections);
  167. m_MaxConnectionsSpin.EnableWindow(!m_fUnlimitedConnections);
  168. m_ConnectionsTxt.EnableWindow(!m_fUnlimitedConnections);
  169. }
  170. return fLimitOn;
  171. }
  172. /* virtual */
  173. HRESULT
  174. CW3PerfPage::FetchLoadedValues()
  175. /*++
  176. Routine Description:
  177. Move configuration data from sheet to dialog controls
  178. Arguments:
  179. None
  180. Return Value:
  181. HRESULT
  182. --*/
  183. {
  184. CError err;
  185. BEGIN_META_INST_READ(CW3Sheet)
  186. FETCH_INST_DATA_FROM_SHEET(m_nMaxConnections);
  187. FETCH_INST_DATA_FROM_SHEET(m_dwMaxBandwidth);
  188. ParseMaxNetworkUse(
  189. m_dwMaxBandwidth,
  190. m_dwMaxBandwidthDisplay,
  191. m_fLimitBandwidth
  192. );
  193. m_fUnlimitedConnections =
  194. ((ULONG)(LONG)m_nMaxConnections >= UNLIMITED_CONNECTIONS);
  195. //
  196. // Set the visible max connections edit field, which
  197. // may start out with a default value
  198. //
  199. m_nVisibleMaxConnections = m_fUnlimitedConnections
  200. ? INITIAL_MAX_CONNECTIONS : m_nMaxConnections;
  201. //
  202. // Set radio value
  203. //
  204. m_nUnlimited = m_fUnlimitedConnections ? RADIO_UNLIMITED : RADIO_LIMITED;
  205. END_META_INST_READ(err)
  206. m_fLimitBandwidthInitial = m_fLimitBandwidth;
  207. return err;
  208. }
  209. /* virtual */
  210. HRESULT
  211. CW3PerfPage::SaveInfo()
  212. /*++
  213. Routine Description:
  214. Save the information on this property page
  215. Arguments:
  216. None
  217. Return Value:
  218. Error return code
  219. --*/
  220. {
  221. ASSERT(IsDirty());
  222. TRACEEOLID("Saving W3 performance page now...");
  223. CError err;
  224. BuildMaxNetworkUse(
  225. m_dwMaxBandwidth,
  226. m_dwMaxBandwidthDisplay,
  227. m_fLimitBandwidth
  228. );
  229. m_nMaxConnections = m_fUnlimitedConnections
  230. ? UNLIMITED_CONNECTIONS
  231. : m_nVisibleMaxConnections;
  232. BeginWaitCursor();
  233. BEGIN_META_INST_WRITE(CW3Sheet)
  234. STORE_INST_DATA_ON_SHEET(m_dwMaxBandwidth);
  235. STORE_INST_DATA_ON_SHEET(m_nMaxConnections);
  236. END_META_INST_WRITE(err)
  237. EndWaitCursor();
  238. m_fLimitBandwidthInitial = m_fLimitBandwidth;
  239. return err;
  240. }
  241. //
  242. // Message Handlers
  243. //
  244. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  245. BOOL
  246. CW3PerfPage::OnSetActive()
  247. {
  248. return CInetPropertyPage::OnSetActive();
  249. }
  250. void
  251. CW3PerfPage::OnItemChanged()
  252. {
  253. SetControlStates();
  254. SetModified(TRUE);
  255. }
  256. void
  257. CW3PerfPage::OnRadioLimited()
  258. /*++
  259. Routine Description:
  260. 'limited' radio button handler
  261. Arguments:
  262. None
  263. Return Value:
  264. None
  265. --*/
  266. {
  267. m_fUnlimitedConnections = FALSE;
  268. SetControlStates();
  269. m_edit_MaxConnections.SetSel(0,-1);
  270. m_edit_MaxConnections.SetFocus();
  271. OnItemChanged();
  272. }
  273. void
  274. CW3PerfPage::OnRadioUnlimited()
  275. /*++
  276. Routine Description:
  277. 'unlimited' radio button handler
  278. Arguments:
  279. None
  280. Return Value:
  281. None
  282. --*/
  283. {
  284. m_fUnlimitedConnections = TRUE;
  285. OnItemChanged();
  286. }
  287. void
  288. CW3PerfPage::OnCheckLimitNetworkUse()
  289. /*++
  290. Routine Description:
  291. The "limit network use" checkbox has been clicked
  292. Enable/disable the "max bandwidth" controls.
  293. Arguments:
  294. None
  295. Return Value:
  296. None
  297. --*/
  298. {
  299. if (SetControlStates())
  300. {
  301. m_MaxBandwidth.SetSel(0, -1);
  302. m_MaxBandwidth.SetFocus();
  303. }
  304. OnItemChanged();
  305. }
  306. BOOL
  307. CW3PerfPage::OnInitDialog()
  308. {
  309. UDACCEL toAcc[3] = {{1, 1}, {3, 5}, {6, 10}};
  310. CInetPropertyPage::OnInitDialog();
  311. m_LimitBandwidth.EnableWindow(
  312. HasBwThrottling() && HasAdminAccess());
  313. m_UninstallPSHED.ShowWindow(SW_HIDE);
  314. m_static_PSHED_Required.ShowWindow(SW_HIDE);
  315. if (!IsMasterInstance())
  316. {
  317. m_WebServiceConnGrp.ShowWindow(SW_HIDE);
  318. m_WebServiceConnTxt.ShowWindow(SW_HIDE);
  319. m_radio_Unlimited.ShowWindow(SW_HIDE);
  320. m_radio_Limited.ShowWindow(SW_HIDE);
  321. m_edit_MaxConnections.ShowWindow(SW_HIDE);
  322. m_MaxConnectionsSpin.ShowWindow(SW_HIDE);
  323. m_ConnectionsTxt.ShowWindow(SW_HIDE);
  324. }
  325. else
  326. {
  327. SETUP_SPIN(m_MaxConnectionsSpin,
  328. CONNECTIONS_MIN, CONNECTIONS_MAX, m_nMaxConnections);
  329. }
  330. SETUP_EDIT_SPIN(m_fLimitBandwidth, m_MaxBandwidth, m_MaxBandwidthSpin,
  331. BANDWIDTH_MIN, BANDWIDTH_MAX, m_dwMaxBandwidthDisplay);
  332. SetControlStates();
  333. return TRUE;
  334. }