Leaked source code of windows server 2003
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.

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