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.

204 lines
5.8 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: NetworkServerPage.cpp
  4. //
  5. // Synopsis: Defines Network Server Page for the CYS
  6. // Wizard
  7. //
  8. // History: 02/06/2001 JeffJon Created
  9. #include "pch.h"
  10. #include "resource.h"
  11. #include "InstallationUnitProvider.h"
  12. #include "NetworkServerPage.h"
  13. #include "state.h"
  14. static PCWSTR NETWORKSERVER_PAGE_HELP = L"cys.chm::/sag_ADserverRoles.htm";
  15. NetworkServerPage::NetworkServerPage()
  16. :
  17. CYSWizardPage(
  18. IDD_NETWORK_SERVER_PAGE,
  19. IDS_NETWORK_SERVER_TITLE,
  20. IDS_NETWORK_SERVER_SUBTITLE,
  21. NETWORKSERVER_PAGE_HELP)
  22. {
  23. LOG_CTOR(NetworkServerPage);
  24. }
  25. NetworkServerPage::~NetworkServerPage()
  26. {
  27. LOG_DTOR(NetworkServerPage);
  28. }
  29. void
  30. NetworkServerPage::OnInit()
  31. {
  32. LOG_FUNCTION(NetworkServerPage::OnInit);
  33. // Check and disable the checkboxes for services that are already installed
  34. // and configured
  35. bool isDHCPInstalled =
  36. InstallationUnitProvider::GetInstance().GetDHCPInstallationUnit().IsServiceInstalled();
  37. bool isDHCPConfigured =
  38. InstallationUnitProvider::GetInstance().GetDHCPInstallationUnit().IsConfigured();
  39. Win::Button_SetCheck(
  40. Win::GetDlgItem(hwnd, IDC_DHCP_CHECK),
  41. (isDHCPInstalled && isDHCPConfigured) ? BST_CHECKED : BST_UNCHECKED);
  42. Win::EnableWindow(
  43. Win::GetDlgItem(hwnd, IDC_DHCP_CHECK),
  44. !isDHCPInstalled && !isDHCPConfigured);
  45. bool isDNSInstalled =
  46. InstallationUnitProvider::GetInstance().GetDNSInstallationUnit().IsServiceInstalled();
  47. Win::Button_SetCheck(
  48. Win::GetDlgItem(hwnd, IDC_DNS_CHECK),
  49. isDNSInstalled ? BST_CHECKED : BST_UNCHECKED);
  50. Win::EnableWindow(
  51. Win::GetDlgItem(hwnd, IDC_DNS_CHECK),
  52. !isDNSInstalled);
  53. bool isWINSInstalled =
  54. InstallationUnitProvider::GetInstance().GetWINSInstallationUnit().IsServiceInstalled();
  55. Win::Button_SetCheck(
  56. Win::GetDlgItem(hwnd, IDC_WINS_CHECK),
  57. isWINSInstalled ? BST_CHECKED : BST_UNCHECKED);
  58. Win::EnableWindow(
  59. Win::GetDlgItem(hwnd, IDC_WINS_CHECK),
  60. !isWINSInstalled);
  61. bool isRRASInstalled =
  62. InstallationUnitProvider::GetInstance().GetRRASInstallationUnit().IsServiceInstalled();
  63. bool isRRASConfigured =
  64. InstallationUnitProvider::GetInstance().GetRRASInstallationUnit().IsConfigured();
  65. Win::Button_SetCheck(
  66. Win::GetDlgItem(hwnd, IDC_RRAS_CHECK),
  67. (isRRASInstalled && isRRASConfigured) ? BST_CHECKED : BST_UNCHECKED);
  68. Win::EnableWindow(
  69. Win::GetDlgItem(hwnd, IDC_RRAS_CHECK),
  70. !isRRASInstalled || !isRRASConfigured);
  71. }
  72. bool
  73. NetworkServerPage::OnSetActive()
  74. {
  75. LOG_FUNCTION(NetworkServerPage::OnSetActive);
  76. // Set the wizard buttons according to the state of the UI
  77. SetWizardButtons();
  78. return true;
  79. }
  80. bool
  81. NetworkServerPage::OnCommand(
  82. HWND /*windowFrom*/,
  83. unsigned controlIDFrom,
  84. unsigned code)
  85. {
  86. // LOG_FUNCTION(NetworkServerPage::OnCommand);
  87. bool result = false;
  88. if (IDC_DHCP_CHECK == controlIDFrom ||
  89. IDC_DNS_CHECK == controlIDFrom ||
  90. IDC_WINS_CHECK == controlIDFrom ||
  91. IDC_RRAS_CHECK == controlIDFrom)
  92. {
  93. // If at least one checkbox is checked then allow the next button to be enabled
  94. // NOTE: this does not take into account whether the service is already installed or not
  95. if (BN_CLICKED == code &&
  96. IDC_DHCP_CHECK == controlIDFrom)
  97. {
  98. bool ischecked = Win::Button_GetCheck(Win::GetDlgItem(hwnd, IDC_DHCP_CHECK));
  99. if (!InstallationUnitProvider::GetInstance().GetDHCPInstallationUnit().IsServiceInstalled())
  100. {
  101. InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().SetDHCPInstall(ischecked);
  102. }
  103. }
  104. if (BN_CLICKED == code &&
  105. IDC_DNS_CHECK == controlIDFrom)
  106. {
  107. bool ischecked = Win::Button_GetCheck(Win::GetDlgItem(hwnd, IDC_DNS_CHECK));
  108. if (!InstallationUnitProvider::GetInstance().GetDNSInstallationUnit().IsServiceInstalled())
  109. {
  110. InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().SetDNSInstall(ischecked);
  111. }
  112. }
  113. if (BN_CLICKED == code &&
  114. IDC_WINS_CHECK == controlIDFrom)
  115. {
  116. bool ischecked = Win::Button_GetCheck(Win::GetDlgItem(hwnd, IDC_WINS_CHECK));
  117. if (!InstallationUnitProvider::GetInstance().GetWINSInstallationUnit().IsServiceInstalled())
  118. {
  119. InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().SetWINSInstall(ischecked);
  120. }
  121. }
  122. if (BN_CLICKED == code &&
  123. IDC_RRAS_CHECK == controlIDFrom)
  124. {
  125. bool ischecked = Win::Button_GetCheck(Win::GetDlgItem(hwnd, IDC_RRAS_CHECK));
  126. if (!InstallationUnitProvider::GetInstance().GetRRASInstallationUnit().IsServiceInstalled())
  127. {
  128. InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().SetRRASInstall(ischecked);
  129. }
  130. }
  131. SetWizardButtons();
  132. }
  133. return result;
  134. }
  135. void
  136. NetworkServerPage::SetWizardButtons()
  137. {
  138. // LOG_FUNCTION(NetworkServerPage::SetWizardButtons);
  139. // Enable the Next button only if one of the checkboxes have been checked
  140. bool enableNext = InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().GetDHCPInstall()
  141. || InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().GetDNSInstall()
  142. || InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().GetWINSInstall()
  143. || InstallationUnitProvider::GetInstance().GetNetworkServerInstallationUnit().GetRRASInstall();
  144. Win::PropSheet_SetWizButtons(
  145. Win::GetParent(hwnd),
  146. enableNext ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK);
  147. }
  148. int
  149. NetworkServerPage::Validate()
  150. {
  151. LOG_FUNCTION(NetworkServerPage::Validate);
  152. return IDD_FINISH_PAGE;
  153. }