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.

293 lines
7.0 KiB

  1. // Copyright (c) 2001 Microsoft Corporation
  2. //
  3. // File: BeforeBeginPage.cpp
  4. //
  5. // Synopsis: Defines the Before You Begin Page for the CYS
  6. // Wizard. Tells the user what they should do
  7. // before running CYS.
  8. //
  9. // History: 03/14/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "InstallationUnitProvider.h"
  13. #include "BeforeBeginPage.h"
  14. #include "NetDetectProgressDialog.h"
  15. static PCWSTR BEFORE_BEGIN_PAGE_HELP = L"cys.chm::/prelim_steps.htm";
  16. BeforeBeginPage::BeforeBeginPage()
  17. :
  18. bulletFont(0),
  19. CYSWizardPage(
  20. IDD_BEFORE_BEGIN_PAGE,
  21. IDS_BEFORE_BEGIN_TITLE,
  22. IDS_BEFORE_BEGIN_SUBTITLE,
  23. BEFORE_BEGIN_PAGE_HELP)
  24. {
  25. LOG_CTOR(BeforeBeginPage);
  26. }
  27. BeforeBeginPage::~BeforeBeginPage()
  28. {
  29. LOG_DTOR(BeforeBeginPage);
  30. if (bulletFont)
  31. {
  32. HRESULT hr = Win::DeleteObject(bulletFont);
  33. ASSERT(SUCCEEDED(hr));
  34. }
  35. }
  36. void
  37. BeforeBeginPage::OnInit()
  38. {
  39. LOG_FUNCTION(BeforeBeginPage::OnInit);
  40. CYSWizardPage::OnInit();
  41. // Since this page can be started directly
  42. // we have to be sure to set the wizard title
  43. Win::PropSheet_SetTitle(
  44. Win::GetParent(hwnd),
  45. 0,
  46. String::load(IDS_WIZARD_TITLE));
  47. InitializeBulletedList();
  48. }
  49. void
  50. BeforeBeginPage::InitializeBulletedList()
  51. {
  52. LOG_FUNCTION(BeforeBeginPage::InitializeBulletedList);
  53. bulletFont = CreateFont(
  54. 0,
  55. 0,
  56. 0,
  57. 0,
  58. FW_NORMAL,
  59. 0,
  60. 0,
  61. 0,
  62. SYMBOL_CHARSET,
  63. OUT_CHARACTER_PRECIS,
  64. CLIP_CHARACTER_PRECIS,
  65. PROOF_QUALITY,
  66. VARIABLE_PITCH|FF_DONTCARE,
  67. L"Marlett");
  68. if (bulletFont)
  69. {
  70. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET1), bulletFont, true);
  71. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET2), bulletFont, true);
  72. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET3), bulletFont, true);
  73. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET4), bulletFont, true);
  74. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET5), bulletFont, true);
  75. }
  76. else
  77. {
  78. LOG(String::format(
  79. L"Failed to create font for bullet list: hr = %1!x!",
  80. Win::GetLastErrorAsHresult()));
  81. }
  82. }
  83. bool
  84. BeforeBeginPage::OnSetActive()
  85. {
  86. LOG_FUNCTION(BeforeBeginPage::OnSetActive);
  87. if (State::GetInstance().GetStartPage() == 0)
  88. {
  89. Win::PropSheet_SetWizButtons(
  90. Win::GetParent(hwnd),
  91. PSWIZB_NEXT | PSWIZB_BACK);
  92. }
  93. else
  94. {
  95. Win::PropSheet_SetWizButtons(
  96. Win::GetParent(hwnd),
  97. PSWIZB_NEXT);
  98. }
  99. return true;
  100. }
  101. int
  102. BeforeBeginPage::Validate()
  103. {
  104. LOG_FUNCTION(BeforeBeginPage::Validate);
  105. // Gather the machine network and role information
  106. // Disable the wizard buttons until the operation finishes
  107. Win::PropSheet_SetWizButtons(
  108. Win::GetParent(hwnd),
  109. 0);
  110. Win::WaitCursor wait;
  111. State& state = State::GetInstance();
  112. if (!state.HasStateBeenRetrieved())
  113. {
  114. NetDetectProgressDialog dialog;
  115. dialog.ModalExecute(hwnd);
  116. if (dialog.ShouldCancel())
  117. {
  118. LOG(L"Cancelling wizard by user request");
  119. Win::PropSheet_PressButton(
  120. Win::GetParent(hwnd),
  121. PSBTN_CANCEL);
  122. // Done.
  123. return -1;
  124. }
  125. }
  126. #ifdef TEST_EXPRESS_PATH
  127. LOG(L"Testing express path");
  128. int nextPage = IDD_DECISION_PAGE;
  129. #else
  130. int nextPage = IDD_CUSTOM_SERVER_PAGE;
  131. do
  132. {
  133. // If any of these conditions fail we don't give the user the
  134. // DecisionPage because we don't allow the Express Path
  135. //
  136. // 1. Cannot be Datacenter
  137. // 2. Must have at least one NIC that isn't a modem
  138. // 3. Cannot be running as a remote session
  139. // 4. Cannot be a member of a domain
  140. // 5. Cannot be a Domain Controller
  141. // 6. Cannot be a DNS server
  142. // 7. Cannot be a DHCP server
  143. // 8. RRAS is not configured
  144. // 9. Must have at least one NTFS partition
  145. // 10. If there is only one NIC it cannot have obtained
  146. // an IP lease from a DHCP server. (more than
  147. // one NIC all of which obtain a lease is
  148. // acceptable. We just won't install DHCP)
  149. // 11. Must not be a Certificate Server
  150. // (else dcpromo fails)
  151. if (state.GetProductSKU() == CYS_DATACENTER_SERVER)
  152. {
  153. LOG(L"Express path not available on DataCenter");
  154. break;
  155. }
  156. unsigned int nonModemNICCount = state.GetNonModemNICCount();
  157. if (nonModemNICCount == 0)
  158. {
  159. LOG(String::format(
  160. L"nonModemNICCount = %1!d!",
  161. nonModemNICCount));
  162. break;
  163. }
  164. if (state.IsRemoteSession())
  165. {
  166. LOG(L"Running in a remote session");
  167. break;
  168. }
  169. if (state.IsJoinedToDomain())
  170. {
  171. LOG(L"Computer is joined to a domain");
  172. break;
  173. }
  174. if (state.IsDC())
  175. {
  176. LOG(L"Computer is DC");
  177. break;
  178. }
  179. if (InstallationUnitProvider::GetInstance().
  180. GetDNSInstallationUnit().IsServiceInstalled())
  181. {
  182. LOG(L"Computer is DNS server");
  183. break;
  184. }
  185. if (InstallationUnitProvider::GetInstance().
  186. GetDHCPInstallationUnit().IsServiceInstalled())
  187. {
  188. LOG(L"Computer is DHCP server");
  189. break;
  190. }
  191. if (InstallationUnitProvider::GetInstance().
  192. GetRRASInstallationUnit().IsServiceInstalled())
  193. {
  194. LOG(L"Routing is already setup");
  195. break;
  196. }
  197. if (!state.HasNTFSDrive())
  198. {
  199. LOG(L"Computer does not have an NTFS partition.");
  200. break;
  201. }
  202. if (state.GetNICCount() == 1 &&
  203. state.IsDHCPServerAvailableOnAllNics())
  204. {
  205. LOG(L"Only 1 NIC and we found a DHCP server");
  206. break;
  207. }
  208. // NTRAID#NTBUG9-698719-2002/09/03-artm
  209. // AD installation is not available if Certificate Server is installed
  210. if (NTService(L"CertSvc").IsInstalled())
  211. {
  212. LOG(L"Certificate service is installed");
  213. break;
  214. }
  215. nextPage = IDD_DECISION_PAGE;
  216. } while (false);
  217. // Now that all the operations are complete,
  218. // re-enable the wizard buttons
  219. if (State::GetInstance().GetStartPage() == 0)
  220. {
  221. Win::PropSheet_SetWizButtons(
  222. Win::GetParent(hwnd),
  223. PSWIZB_NEXT | PSWIZB_BACK);
  224. }
  225. else
  226. {
  227. Win::PropSheet_SetWizButtons(
  228. Win::GetParent(hwnd),
  229. PSWIZB_NEXT);
  230. }
  231. #endif // TEST_EXPRESS_PATH
  232. LOG(String::format(
  233. L"nextPage = %1!d!",
  234. nextPage));
  235. return nextPage;
  236. }