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.

241 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. deffs.cpp
  5. Abstract:
  6. Default Ftp Site Dialog
  7. Author:
  8. Sergei Antonov (sergeia)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "resource.h"
  18. #include "common.h"
  19. #include "inetmgrapp.h"
  20. #include "inetprop.h"
  21. #include "shts.h"
  22. #include "ftpsht.h"
  23. #include "deffs.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /* static */
  30. void
  31. CDefFtpSitePage::ParseMaxNetworkUse(
  32. DWORD& dwMaxBandwidth,
  33. DWORD& dwMaxBandwidthDisplay,
  34. BOOL& fLimitBandwidth
  35. )
  36. {
  37. //
  38. // Special case: If dwMaxBandwidth is 0(an invalid value), the
  39. // value likely could not be inherited from the root (the user
  40. // is an operator and can't see the properties there). Adjust
  41. // the value to a possibly misleading value.
  42. //
  43. if (dwMaxBandwidth == 0L)
  44. {
  45. TRACEEOLID("Adjusting invalid bandwidth throttling value -- "
  46. "are you an operator?");
  47. dwMaxBandwidth = INFINITE_BANDWIDTH;
  48. }
  49. fLimitBandwidth = (dwMaxBandwidth != INFINITE_BANDWIDTH);
  50. dwMaxBandwidthDisplay = fLimitBandwidth ?
  51. (dwMaxBandwidth / KILOBYTE) : (DEF_BANDWIDTH / KILOBYTE);
  52. }
  53. IMPLEMENT_DYNCREATE(CDefFtpSitePage, CInetPropertyPage)
  54. CDefFtpSitePage::CDefFtpSitePage(
  55. IN CInetPropertySheet * pSheet
  56. )
  57. : CInetPropertyPage(CDefFtpSitePage::IDD, pSheet)
  58. {
  59. }
  60. CDefFtpSitePage::~CDefFtpSitePage()
  61. {
  62. }
  63. void
  64. CDefFtpSitePage::DoDataExchange(
  65. IN CDataExchange * pDX
  66. )
  67. {
  68. CInetPropertyPage::DoDataExchange(pDX);
  69. //{{AFX_DATA_MAP(CDefWebSitePage)
  70. DDX_Check(pDX, IDC_CHECK_LIMIT_NETWORK_USE, m_fLimitBandwidth);
  71. DDX_Control(pDX, IDC_CHECK_LIMIT_NETWORK_USE, m_LimitBandwidth);
  72. DDX_Control(pDX, IDC_MAX_BANDWIDTH, m_MaxBandwidth);
  73. DDX_TextBalloon(pDX, IDC_MAX_BANDWIDTH, m_dwMaxBandwidthDisplay);
  74. DDX_Control(pDX, IDC_MAX_BANDWIDTH_SPIN, m_MaxBandwidthSpin);
  75. //}}AFX_DATA_MAP
  76. if (!pDX->m_bSaveAndValidate || m_fLimitBandwidth)
  77. {
  78. // This Needs to come before DDX_Text which will try to put text big number into small number
  79. DDV_MinMaxBalloon(pDX, IDC_MAX_BANDWIDTH, BANDWIDTH_MIN, BANDWIDTH_MAX);
  80. DDX_TextBalloon(pDX, IDC_MAX_BANDWIDTH, m_dwMaxBandwidthDisplay);
  81. }
  82. }
  83. /* virtual */
  84. HRESULT
  85. CDefFtpSitePage::FetchLoadedValues()
  86. /*++
  87. Routine Description:
  88. Move configuration data from sheet to dialog controls
  89. Arguments:
  90. None
  91. Return Value:
  92. HRESULT
  93. --*/
  94. {
  95. CError err;
  96. BEGIN_META_INST_READ(CFtpSheet)
  97. FETCH_INST_DATA_FROM_SHEET(m_dwMaxBandwidth);
  98. ParseMaxNetworkUse(
  99. m_dwMaxBandwidth,
  100. m_dwMaxBandwidthDisplay,
  101. m_fLimitBandwidth
  102. );
  103. END_META_INST_READ(err)
  104. return err;
  105. }
  106. /* virtual */
  107. HRESULT
  108. CDefFtpSitePage::SaveInfo()
  109. /*++
  110. Routine Description:
  111. Save the information on this property page
  112. Arguments:
  113. None
  114. Return Value:
  115. Error return code
  116. --*/
  117. {
  118. ASSERT(IsDirty());
  119. TRACEEOLID("Saving Ftp default site page now...");
  120. CError err;
  121. BuildMaxNetworkUse(
  122. m_dwMaxBandwidth,
  123. m_dwMaxBandwidthDisplay,
  124. m_fLimitBandwidth
  125. );
  126. BeginWaitCursor();
  127. BEGIN_META_INST_WRITE(CFtpSheet)
  128. STORE_INST_DATA_ON_SHEET(m_dwMaxBandwidth);
  129. END_META_INST_WRITE(err)
  130. EndWaitCursor();
  131. return err;
  132. }
  133. BOOL
  134. CDefFtpSitePage::SetControlStates()
  135. {
  136. if (::IsWindow(m_LimitBandwidth.m_hWnd))
  137. {
  138. BOOL fLimitOn = m_LimitBandwidth.GetCheck() > 0
  139. // && HasBwThrottling()
  140. // && HasAdminAccess()
  141. ;
  142. m_MaxBandwidth.EnableWindow(fLimitOn);
  143. m_MaxBandwidthSpin.EnableWindow(fLimitOn);
  144. return fLimitOn;
  145. }
  146. return FALSE;
  147. }
  148. //
  149. // Message Map
  150. //
  151. BEGIN_MESSAGE_MAP(CDefFtpSitePage, CInetPropertyPage)
  152. //{{AFX_MSG_MAP(CW3PerfPage)
  153. ON_BN_CLICKED(IDC_CHECK_LIMIT_NETWORK_USE, OnCheckLimitNetworkUse)
  154. //}}AFX_MSG_MAP
  155. ON_EN_CHANGE(IDC_MAX_BANDWIDTH, OnItemChanged)
  156. END_MESSAGE_MAP()
  157. BOOL
  158. CDefFtpSitePage::OnInitDialog()
  159. {
  160. UDACCEL toAcc[3] = {{1, 1}, {3, 5}, {6, 10}};
  161. CInetPropertyPage::OnInitDialog();
  162. //
  163. // Disable some settings based on what's possible
  164. //
  165. #if 0
  166. m_LimitBandwidth.EnableWindow(
  167. !IsMasterInstance()
  168. && HasBwThrottling()
  169. && HasAdminAccess()
  170. );
  171. #endif
  172. SETUP_EDIT_SPIN(m_fLimitBandwidth, m_MaxBandwidth, m_MaxBandwidthSpin,
  173. BANDWIDTH_MIN, BANDWIDTH_MAX, m_dwMaxBandwidthDisplay);
  174. SetControlStates();
  175. return TRUE;
  176. }
  177. void
  178. CDefFtpSitePage::OnItemChanged()
  179. {
  180. SetControlStates();
  181. SetModified(TRUE);
  182. }
  183. void
  184. CDefFtpSitePage::OnCheckLimitNetworkUse()
  185. {
  186. if (SetControlStates())
  187. {
  188. m_MaxBandwidth.SetSel(0, -1);
  189. m_MaxBandwidth.SetFocus();
  190. }
  191. OnItemChanged();
  192. }