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.

318 lines
7.2 KiB

  1. // Copyright (c) 2001 Microsoft Corporation
  2. //
  3. // File: FileServerPage.cpp
  4. //
  5. // Synopsis: Defines the File server page of the CYS wizard
  6. //
  7. // History: 02/08/2001 JeffJon Created
  8. #include "pch.h"
  9. #include "resource.h"
  10. #include "InstallationUnitProvider.h"
  11. #include "FileServerPage.h"
  12. #include "xbytes.h"
  13. static PCWSTR FILESERVER_PAGE_HELP = L"cys.chm::/file_server_role.htm#filesrvdiskquotas";
  14. FileServerPage::FileServerPage()
  15. :
  16. CYSWizardPage(
  17. IDD_FILE_SERVER_PAGE,
  18. IDS_FILE_SERVER_TITLE,
  19. IDS_FILE_SERVER_SUBTITLE,
  20. FILESERVER_PAGE_HELP)
  21. {
  22. LOG_CTOR(FileServerPage);
  23. }
  24. FileServerPage::~FileServerPage()
  25. {
  26. LOG_DTOR(FileServerPage);
  27. }
  28. void
  29. FileServerPage::OnInit()
  30. {
  31. LOG_FUNCTION(FileServerPage::OnInit);
  32. CYSWizardPage::OnInit();
  33. // Hook up the editbox/combobox controls to their appropriate
  34. // XBytes class
  35. quotaUIControls.Initialize(
  36. hwnd,
  37. IDC_SPACE_EDIT,
  38. IDC_SPACE_COMBO,
  39. 0);
  40. warningUIControls.Initialize(
  41. hwnd,
  42. IDC_LEVEL_EDIT,
  43. IDC_LEVEL_COMBO,
  44. 0);
  45. // unselect the "Set up default disk quotas" as the default
  46. Win::Button_SetCheck(
  47. Win::GetDlgItem(hwnd, IDC_DEFAULT_QUOTAS_CHECK),
  48. BST_UNCHECKED);
  49. SetControlState();
  50. }
  51. bool
  52. FileServerPage::OnSetActive()
  53. {
  54. LOG_FUNCTION(FileServerPage::OnSetActive);
  55. // Disable the controls based on the UI state
  56. SetControlState();
  57. return true;
  58. }
  59. bool
  60. FileServerPage::OnCommand(
  61. HWND /*windowFrom*/,
  62. unsigned controlIDFrom,
  63. unsigned code)
  64. {
  65. // LOG_FUNCTION(FileServerPage::OnCommand);
  66. bool result = false;
  67. switch (controlIDFrom)
  68. {
  69. case IDC_DEFAULT_QUOTAS_CHECK:
  70. if (code == BN_CLICKED)
  71. {
  72. SetControlState();
  73. }
  74. break;
  75. case IDC_SPACE_COMBO:
  76. if (code == CBN_SELCHANGE)
  77. {
  78. quotaUIControls.OnComboNotifySelChange();
  79. }
  80. break;
  81. case IDC_LEVEL_COMBO:
  82. if (code == CBN_SELCHANGE)
  83. {
  84. warningUIControls.OnComboNotifySelChange();
  85. }
  86. break;
  87. case IDC_SPACE_EDIT:
  88. if (code == EN_UPDATE)
  89. {
  90. quotaUIControls.OnEditNotifyUpdate();
  91. }
  92. else if (code == EN_KILLFOCUS)
  93. {
  94. quotaUIControls.OnEditKillFocus();
  95. }
  96. break;
  97. case IDC_LEVEL_EDIT:
  98. if (code == EN_UPDATE)
  99. {
  100. warningUIControls.OnEditNotifyUpdate();
  101. }
  102. else if (code == EN_KILLFOCUS)
  103. {
  104. warningUIControls.OnEditKillFocus();
  105. }
  106. break;
  107. default:
  108. // do nothing
  109. break;
  110. }
  111. return result;
  112. }
  113. void
  114. FileServerPage::SetControlState()
  115. {
  116. LOG_FUNCTION(FileServerPage::SetControlState);
  117. bool settingQuotas =
  118. Win::Button_GetCheck(
  119. Win::GetDlgItem(hwnd, IDC_DEFAULT_QUOTAS_CHECK));
  120. // enable or disable all the controls based on the Set up default quotas checkbox
  121. quotaUIControls.Enable(settingQuotas);
  122. warningUIControls.Enable(settingQuotas);
  123. Win::EnableWindow(
  124. Win::GetDlgItem(hwnd, IDC_SPACE_STATIC),
  125. settingQuotas);
  126. Win::EnableWindow(
  127. Win::GetDlgItem(hwnd, IDC_LEVEL_STATIC),
  128. settingQuotas);
  129. Win::EnableWindow(
  130. Win::GetDlgItem(hwnd, IDC_DENY_DISK_CHECK),
  131. settingQuotas);
  132. Win::EnableWindow(
  133. Win::GetDlgItem(hwnd, IDC_EVENT_STATIC),
  134. settingQuotas);
  135. Win::EnableWindow(
  136. Win::GetDlgItem(hwnd, IDC_DISK_SPACE_CHECK),
  137. settingQuotas);
  138. Win::EnableWindow(
  139. Win::GetDlgItem(hwnd, IDC_WARNING_LEVEL_CHECK),
  140. settingQuotas);
  141. if (!settingQuotas)
  142. {
  143. Win::Button_SetCheck(
  144. Win::GetDlgItem(hwnd, IDC_DENY_DISK_CHECK),
  145. BST_UNCHECKED);
  146. Win::Button_SetCheck(
  147. Win::GetDlgItem(hwnd, IDC_DISK_SPACE_CHECK),
  148. BST_UNCHECKED);
  149. Win::Button_SetCheck(
  150. Win::GetDlgItem(hwnd, IDC_WARNING_LEVEL_CHECK),
  151. BST_UNCHECKED);
  152. }
  153. // enable the next button if the user chose to set quotas
  154. // and there is something in the quota edit box
  155. bool spaceSet = quotaUIControls.GetBytes() > 0;
  156. bool enableNext = (settingQuotas &&
  157. spaceSet) ||
  158. !settingQuotas;
  159. Win::PropSheet_SetWizButtons(
  160. Win::GetParent(hwnd),
  161. enableNext ? PSWIZB_NEXT | PSWIZB_BACK : PSWIZB_BACK);
  162. }
  163. int
  164. FileServerPage::Validate()
  165. {
  166. LOG_FUNCTION(FileServerPage::Validate);
  167. int nextPage = -1;
  168. // Gather the UI data and set it in the installation unit
  169. FileInstallationUnit& fileInstallationUnit =
  170. InstallationUnitProvider::GetInstance().GetFileInstallationUnit();
  171. if (Win::Button_GetCheck(
  172. Win::GetDlgItem(hwnd, IDC_DEFAULT_QUOTAS_CHECK)))
  173. {
  174. // We are setting the defaults
  175. fileInstallationUnit.SetDefaultQuotas(true);
  176. fileInstallationUnit.SetDenyUsersOverQuota(
  177. Win::Button_GetCheck(
  178. Win::GetDlgItem(hwnd, IDC_DENY_DISK_CHECK)));
  179. fileInstallationUnit.SetEventDiskSpaceLimit(
  180. Win::Button_GetCheck(
  181. Win::GetDlgItem(hwnd, IDC_DISK_SPACE_CHECK)));
  182. fileInstallationUnit.SetEventWarningLevel(
  183. Win::Button_GetCheck(
  184. Win::GetDlgItem(hwnd, IDC_WARNING_LEVEL_CHECK)));
  185. INT64 quotaValue = quotaUIControls.GetBytes();
  186. INT64 warningValue = warningUIControls.GetBytes();
  187. if (warningValue > quotaValue)
  188. {
  189. // Get the quota text and append the size
  190. String quotaString =
  191. Win::GetDlgItemText(
  192. hwnd,
  193. IDC_SPACE_EDIT);
  194. quotaString += L" " +
  195. Win::ComboBox_GetCurText(
  196. Win::GetDlgItem(
  197. hwnd,
  198. IDC_SPACE_COMBO));
  199. // Get the warning text and append the size
  200. String warningString =
  201. Win::GetDlgItemText(
  202. hwnd,
  203. IDC_LEVEL_EDIT);
  204. warningString += L" " +
  205. Win::ComboBox_GetCurText(
  206. Win::GetDlgItem(
  207. hwnd,
  208. IDC_LEVEL_COMBO));
  209. String warning =
  210. String::format(
  211. IDS_FILE_WARNING_LARGER_THAN_QUOTA,
  212. warningString.c_str(),
  213. quotaString.c_str(),
  214. quotaString.c_str());
  215. if (IDYES == popup.MessageBox(
  216. hwnd,
  217. warning,
  218. MB_ICONINFORMATION | MB_YESNO))
  219. {
  220. warningValue = quotaValue;
  221. warningUIControls.SetBytes(warningValue);
  222. }
  223. }
  224. fileInstallationUnit.SetSpaceQuotaValue(quotaValue);
  225. fileInstallationUnit.SetLevelQuotaValue(warningValue);
  226. }
  227. else
  228. {
  229. // The defaults will not be set
  230. fileInstallationUnit.SetDefaultQuotas(false);
  231. }
  232. nextPage = IDD_INDEXING_PAGE;
  233. LOG(String::format(
  234. L"nextPage = %1!d!",
  235. nextPage));
  236. return nextPage;
  237. }