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.

214 lines
4.7 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Windows NT Secure Server Roles Security Configuration Wizard
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 2002
  7. //
  8. // File: SelectInputCfgPage.cxx
  9. //
  10. // Contents: Select Input Configuration Page.
  11. //
  12. // History: 2-Oct-01 EricB created
  13. //
  14. //-----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #include "resource.h"
  17. #include "misc.h"
  18. #include "state.h"
  19. #include "SelectInputCfgPage.h"
  20. SelectInputCfgPage::SelectInputCfgPage()
  21. :
  22. SecCfgWizardPage(
  23. IDD_SELECTCFG_NAME,
  24. IDS_SELECTCFG_NAME_PAGE_TITLE,
  25. IDS_SELECTCFG_NAME_PAGE_SUBTITLE)
  26. {
  27. LOG_CTOR(SelectInputCfgPage);
  28. }
  29. SelectInputCfgPage::~SelectInputCfgPage()
  30. {
  31. LOG_DTOR(SelectInputCfgPage);
  32. }
  33. void
  34. SelectInputCfgPage::OnInit()
  35. {
  36. LOG_FUNCTION(SelectInputCfgPage::OnInit);
  37. Win::Edit_LimitText(Win::GetDlgItem(hwnd, IDC_EXISTING_CFG_EDIT), MAX_PATH);
  38. Win::CheckDlgButton(hwnd, IDC_NEW_CFG_RADIO, BST_CHECKED);
  39. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_EXISTING_CFG_EDIT), false);
  40. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_BROWSE_FOR_CFG_BTN), false);
  41. }
  42. static
  43. void
  44. enable(HWND dialog)
  45. {
  46. ASSERT(Win::IsWindow(dialog));
  47. int next = PSWIZB_NEXT;
  48. if (Win::IsDlgButtonChecked(dialog, IDC_EDIT_CFG_RADIO))
  49. {
  50. next = !Win::GetTrimmedDlgItemText(dialog, IDC_EXISTING_CFG_EDIT).empty()
  51. ? PSWIZB_NEXT : 0;
  52. }
  53. Win::PropSheet_SetWizButtons(
  54. Win::GetParent(dialog),
  55. PSWIZB_BACK | next);
  56. }
  57. bool
  58. SelectInputCfgPage::OnCommand(
  59. HWND /* windowFrom */ ,
  60. unsigned controlIDFrom,
  61. unsigned code)
  62. {
  63. // LOG_FUNCTION(SelectInputCfgPage::OnCommand);
  64. State& state = State::GetInstance();
  65. switch (controlIDFrom)
  66. {
  67. case IDC_EDIT_CFG_RADIO:
  68. {
  69. if (code == BN_CLICKED)
  70. {
  71. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_EXISTING_CFG_EDIT), true);
  72. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_BROWSE_FOR_CFG_BTN), true);
  73. enable(hwnd);
  74. state.SetInputType(State::OpenExisting);
  75. }
  76. break;
  77. }
  78. case IDC_NEW_CFG_RADIO:
  79. case IDC_ROLLBACK_CFG_RADIO:
  80. {
  81. if (code == BN_CLICKED)
  82. {
  83. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_EXISTING_CFG_EDIT), false);
  84. Win::EnableWindow(Win::GetDlgItem(hwnd, IDC_BROWSE_FOR_CFG_BTN), false);
  85. enable(hwnd);
  86. state.SetInputType(controlIDFrom == IDC_NEW_CFG_RADIO ?
  87. State::CreateNew : State::Rollback);
  88. }
  89. break;
  90. }
  91. case IDC_EXISTING_CFG_EDIT:
  92. {
  93. if (code == EN_CHANGE)
  94. {
  95. enable(hwnd);
  96. }
  97. break;
  98. }
  99. case IDC_BROWSE_FOR_CFG_BTN:
  100. {
  101. if (code == BN_CLICKED)
  102. {
  103. String str(L"placeholder for file open dialog");
  104. popup.Info(hwnd, str);
  105. }
  106. break;
  107. }
  108. default:
  109. {
  110. // do nothing
  111. break;
  112. }
  113. }
  114. return false;
  115. }
  116. bool
  117. SelectInputCfgPage::OnSetActive()
  118. {
  119. LOG_FUNCTION(SelectInputCfgPage::OnSetActive);
  120. enable(hwnd);
  121. return true;
  122. }
  123. int
  124. SelectInputCfgPage::Validate()
  125. {
  126. LOG_FUNCTION(SelectInputCfgPage::Validate);
  127. int nextPage = IDD_SECURITY_LEVEL;//IDD_SERVER_ROLE_SEL; //IDD_FINISH;
  128. State& state = State::GetInstance();
  129. HRESULT hr = S_OK;
  130. switch (state.GetInputType())
  131. {
  132. case State::OpenExisting:
  133. state.SetInputFileName(
  134. Win::GetTrimmedDlgItemText(hwnd, IDC_EXISTING_CFG_EDIT));
  135. hr = state.ParseInputFile();
  136. if (FAILED(hr))
  137. {
  138. popup.Error(hwnd,
  139. hr, IDS_INVALID_EXISTING_INPUT_FILE);
  140. nextPage = -1;
  141. }
  142. break;
  143. case State::CreateNew:
  144. hr = state.ParseInputFile();
  145. if (FAILED(hr))
  146. {
  147. if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
  148. {
  149. popup.Gripe(hwnd,
  150. String::load(IDS_INPUT_FILE_NOT_FOUND, hResourceModuleHandle));
  151. }
  152. else
  153. {
  154. popup.Error(hwnd, hr, IDS_INVALID_INPUT_FILE);
  155. }
  156. // nextPage = ?; now what?
  157. }
  158. break;
  159. case State::Rollback:
  160. hr = state.DoRollback();
  161. if (FAILED(hr))
  162. {
  163. popup.Error(hwnd, hr, IDS_ROLLBACK_FAILED);
  164. // nextPage = ?; now what?
  165. }
  166. break;
  167. default:
  168. ASSERT(false);
  169. }
  170. return nextPage;
  171. }