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.

360 lines
9.7 KiB

  1. // Copyright (c) 1997-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 "state.h"
  13. #define DISK_QUOTAS_LIMIT_TEXT 10
  14. static PCWSTR FILESERVER_PAGE_HELP = L"cys.chm::/cys_configuring_file_server.htm";
  15. FileServerPage::FileServerPage()
  16. :
  17. CYSWizardPage(
  18. IDD_FILE_SERVER_PAGE,
  19. IDS_FILE_SERVER_TITLE,
  20. IDS_FILE_SERVER_SUBTITLE,
  21. FILESERVER_PAGE_HELP)
  22. {
  23. LOG_CTOR(FileServerPage);
  24. }
  25. FileServerPage::~FileServerPage()
  26. {
  27. LOG_DTOR(FileServerPage);
  28. }
  29. void
  30. FileServerPage::OnInit()
  31. {
  32. LOG_FUNCTION(FileServerPage::OnInit);
  33. // Load the size labels into the combo boxes
  34. StringList combolabels;
  35. String kb = String::load(IDS_KB);
  36. push_back_unique(combolabels, kb);
  37. push_back_unique(combolabels, String::load(IDS_MB));
  38. push_back_unique(combolabels, String::load(IDS_GB));
  39. // Add the size labels to the space combo box
  40. HWND spacecombo = Win::GetDlgItem(hwnd, IDC_SPACE_COMBO);
  41. int lastIndex = Win::ComboBox_AddStrings(
  42. spacecombo,
  43. combolabels.begin(),
  44. combolabels.end());
  45. ASSERT(lastIndex != CB_ERR);
  46. // select the first entry in the combo box
  47. Win::ComboBox_SelectString(spacecombo, kb);
  48. // Add the size labels to the warning level combo box
  49. HWND levelcombo = Win::GetDlgItem(hwnd, IDC_LEVEL_COMBO);
  50. lastIndex = Win::ComboBox_AddStrings(
  51. levelcombo,
  52. combolabels.begin(),
  53. combolabels.end());
  54. ASSERT(lastIndex != CB_ERR);
  55. Win::ComboBox_SelectString(levelcombo, kb);
  56. // unselect the "Set up default disk quotas" as the default
  57. Win::Button_SetCheck(
  58. Win::GetDlgItem(hwnd, IDC_DEFAULT_QUOTAS_CHECK),
  59. BST_UNCHECKED);
  60. // Set a limit of 10 characters for both the edit boxes
  61. Win::Edit_LimitText(
  62. Win::GetDlgItem(hwnd, IDC_SPACE_EDIT),
  63. DISK_QUOTAS_LIMIT_TEXT);
  64. Win::Edit_LimitText(
  65. Win::GetDlgItem(hwnd, IDC_LEVEL_EDIT),
  66. DISK_QUOTAS_LIMIT_TEXT);
  67. SetControlState();
  68. }
  69. bool
  70. FileServerPage::OnSetActive()
  71. {
  72. LOG_FUNCTION(FileServerPage::OnSetActive);
  73. // Disable the controls based on the UI state
  74. SetControlState();
  75. return true;
  76. }
  77. bool
  78. FileServerPage::OnCommand(
  79. HWND /*windowFrom*/,
  80. unsigned controlIDFrom,
  81. unsigned code)
  82. {
  83. // LOG_FUNCTION(FileServerPage::OnCommand);
  84. bool result = false;
  85. if (controlIDFrom == IDC_DEFAULT_QUOTAS_CHECK ||
  86. controlIDFrom == IDC_SPACE_EDIT ||
  87. controlIDFrom == IDC_SPACE_COMBO ||
  88. controlIDFrom == IDC_LEVEL_EDIT ||
  89. controlIDFrom == IDC_LEVEL_COMBO)
  90. {
  91. if (code == CBN_SELCHANGE)
  92. {
  93. unsigned editboxID = (IDC_SPACE_COMBO == controlIDFrom)
  94. ? IDC_SPACE_EDIT : IDC_LEVEL_EDIT;
  95. UpdateQuotaControls(controlIDFrom, editboxID);
  96. }
  97. SetControlState();
  98. }
  99. return result;
  100. }
  101. void
  102. FileServerPage::UpdateQuotaControls(
  103. unsigned controlIDFrom,
  104. unsigned editboxID)
  105. {
  106. LOG_FUNCTION(FileServerPage::UpdateQuotaControls);
  107. // On any change in the combobox clear the edit field
  108. Win::SetDlgItemText(hwnd, editboxID, L"");
  109. // Figure out which storage size is selected in the combo box
  110. String currentText = Win::ComboBox_GetCurText(
  111. Win::GetDlgItem(hwnd, controlIDFrom));
  112. String kb = String::load(IDS_KB);
  113. String mb = String::load(IDS_MB);
  114. String gb = String::load(IDS_GB);
  115. if (currentText.icompare(kb) == 0)
  116. {
  117. Win::Edit_LimitText(
  118. Win::GetDlgItem(hwnd, editboxID),
  119. DISK_QUOTAS_LIMIT_TEXT);
  120. }
  121. else if (currentText.icompare(mb) == 0)
  122. {
  123. Win::Edit_LimitText(
  124. Win::GetDlgItem(hwnd, editboxID),
  125. DISK_QUOTAS_LIMIT_TEXT);
  126. }
  127. else if (currentText.icompare(gb) == 0)
  128. {
  129. // Need to reduce the amount of allowed text so that
  130. // we don't get overrun when we convert to bytes
  131. Win::Edit_LimitText(
  132. Win::GetDlgItem(hwnd, editboxID),
  133. DISK_QUOTAS_LIMIT_TEXT - 1);
  134. }
  135. else
  136. {
  137. ASSERT(false && L"Unknown size type found in combobox");
  138. }
  139. }
  140. void
  141. FileServerPage::SetControlState()
  142. {
  143. LOG_FUNCTION(FileServerPage::SetControlState);
  144. bool settingQuotas =
  145. Win::Button_GetCheck(
  146. Win::GetDlgItem(hwnd, IDC_DEFAULT_QUOTAS_CHECK));
  147. // enable or disable all the controls based on the Set up default quotas checkbox
  148. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_SPACE_STATIC), settingQuotas);
  149. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_SPACE_EDIT), settingQuotas);
  150. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_SPACE_COMBO), settingQuotas);
  151. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_LEVEL_STATIC), settingQuotas);
  152. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_LEVEL_EDIT), settingQuotas);
  153. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_LEVEL_COMBO), settingQuotas);
  154. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_DENY_DISK_CHECK), settingQuotas);
  155. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_EVENT_STATIC), settingQuotas);
  156. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_DISK_SPACE_CHECK), settingQuotas);
  157. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_WARNING_LEVEL_CHECK), settingQuotas);
  158. // if both edit boxes contain a value and a size label has been chosen,
  159. // then enable the next button
  160. bool spaceEditFilled = !Win::GetWindowText(
  161. Win::GetDlgItem(hwnd, IDC_SPACE_EDIT)).empty();
  162. bool spaceComboSelected = Win::ComboBox_GetCurSel(
  163. Win::GetDlgItem(hwnd, IDC_SPACE_COMBO)) != CB_ERR;
  164. bool levelEditFilled = !Win::GetWindowText(
  165. Win::GetDlgItem(hwnd, IDC_LEVEL_EDIT)).empty();
  166. bool levelComboSelected = Win::ComboBox_GetCurSel(
  167. Win::GetDlgItem(hwnd, IDC_LEVEL_COMBO)) != CB_ERR;
  168. bool enableNext = (settingQuotas &&
  169. spaceEditFilled &&
  170. spaceComboSelected &&
  171. levelEditFilled &&
  172. levelComboSelected) ||
  173. !settingQuotas;
  174. Win::PropSheet_SetWizButtons(
  175. Win::GetParent(hwnd),
  176. enableNext ? PSWIZB_NEXT | PSWIZB_BACK : PSWIZB_BACK);
  177. }
  178. int
  179. FileServerPage::Validate()
  180. {
  181. LOG_FUNCTION(FileServerPage::Validate);
  182. int nextPage = -1;
  183. // Gather the UI data and set it in the installation unit
  184. FileInstallationUnit& fileInstallationUnit =
  185. InstallationUnitProvider::GetInstance().GetFileInstallationUnit();
  186. if (Win::Button_GetCheck(
  187. Win::GetDlgItem(hwnd, IDC_DEFAULT_QUOTAS_CHECK)))
  188. {
  189. // We are setting the defaults
  190. fileInstallationUnit.SetDefaultQuotas(true);
  191. fileInstallationUnit.SetDenyUsersOverQuota(
  192. Win::Button_GetCheck(
  193. Win::GetDlgItem(hwnd, IDC_DENY_DISK_CHECK)));
  194. fileInstallationUnit.SetEventDiskSpaceLimit(
  195. Win::Button_GetCheck(
  196. Win::GetDlgItem(hwnd, IDC_DISK_SPACE_CHECK)));
  197. fileInstallationUnit.SetEventWarningLevel(
  198. Win::Button_GetCheck(
  199. Win::GetDlgItem(hwnd, IDC_WARNING_LEVEL_CHECK)));
  200. // Get the value from the edit control as text
  201. // and convert to unsigned long
  202. String spaceStringValue = Win::GetDlgItemText(
  203. hwnd,
  204. IDC_SPACE_EDIT);
  205. LARGE_INTEGER spaceValue;
  206. spaceValue.QuadPart = 0;
  207. String::ConvertResult convertResult = spaceStringValue.convert(spaceValue);
  208. ASSERT(convertResult == String::CONVERT_SUCCESSFUL);
  209. fileInstallationUnit.SetSpaceQuotaValue(spaceValue.QuadPart);
  210. String levelStringValue = Win::GetDlgItemText(
  211. hwnd,
  212. IDC_LEVEL_EDIT);
  213. LARGE_INTEGER levelValue;
  214. levelValue.QuadPart = 0;
  215. convertResult = levelStringValue.convert(levelValue);
  216. ASSERT(convertResult == String::CONVERT_SUCCESSFUL);
  217. fileInstallationUnit.SetLevelQuotaValue(levelValue.QuadPart);
  218. String kb = String::load(IDS_KB);
  219. String mb = String::load(IDS_MB);
  220. String gb = String::load(IDS_GB);
  221. String currentText = Win::ComboBox_GetCurText(Win::GetDlgItem(hwnd, IDC_SPACE_COMBO));
  222. if (currentText.icompare(kb) == 0)
  223. {
  224. fileInstallationUnit.SetSpaceQuotaSize(QUOTA_SIZE_KB);
  225. }
  226. else if (currentText.icompare(mb) == 0)
  227. {
  228. fileInstallationUnit.SetSpaceQuotaSize(QUOTA_SIZE_MB);
  229. }
  230. else if (currentText.icompare(gb) == 0)
  231. {
  232. fileInstallationUnit.SetSpaceQuotaSize(QUOTA_SIZE_GB);
  233. }
  234. else
  235. {
  236. ASSERT(false && L"Unknown size type found in combobox");
  237. }
  238. currentText = Win::ComboBox_GetCurText(Win::GetDlgItem(hwnd, IDC_LEVEL_COMBO));
  239. if (currentText.icompare(kb) == 0)
  240. {
  241. fileInstallationUnit.SetLevelQuotaSize(QUOTA_SIZE_KB);
  242. }
  243. else if (currentText.icompare(mb) == 0)
  244. {
  245. fileInstallationUnit.SetLevelQuotaSize(QUOTA_SIZE_MB);
  246. }
  247. else if (currentText.icompare(gb) == 0)
  248. {
  249. fileInstallationUnit.SetLevelQuotaSize(QUOTA_SIZE_GB);
  250. }
  251. else
  252. {
  253. ASSERT(false && L"Unknown size type found in combobox");
  254. }
  255. }
  256. else
  257. {
  258. // The defaults will not be set
  259. fileInstallationUnit.SetDefaultQuotas(false);
  260. }
  261. if (InstallationUnitProvider::GetInstance().GetSharePointInstallationUnit().IsServiceInstalled())
  262. {
  263. nextPage = IDD_FINISH_PAGE;
  264. }
  265. else
  266. {
  267. nextPage = IDD_INDEXING_PAGE;
  268. }
  269. return nextPage;
  270. }