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.

193 lines
4.2 KiB

  1. // Copyright (c) 2001 Microsoft Corporation
  2. //
  3. // Confirm removal of Application Partitions page
  4. //
  5. // 26 Jul 2001 sburns
  6. #include "headers.hxx"
  7. #include "ApplicationPartitionConfirmationPage.hpp"
  8. #include "resource.h"
  9. #include "state.hpp"
  10. ApplicationPartitionConfirmationPage::ApplicationPartitionConfirmationPage()
  11. :
  12. DCPromoWizardPage(
  13. IDD_APP_PARTITION_CONFIRM,
  14. IDS_APP_PARTITION_CONFIRM_TITLE,
  15. IDS_APP_PARTITION_CONFIRM_SUBTITLE)
  16. {
  17. LOG_CTOR(ApplicationPartitionConfirmationPage);
  18. }
  19. ApplicationPartitionConfirmationPage::~ApplicationPartitionConfirmationPage()
  20. {
  21. LOG_DTOR(ApplicationPartitionConfirmationPage);
  22. }
  23. void
  24. ApplicationPartitionConfirmationPage::OnInit()
  25. {
  26. LOG_FUNCTION(ApplicationPartitionConfirmationPage::OnInit);
  27. State& state = State::GetInstance();
  28. if (state.UsingAnswerFile())
  29. {
  30. String option =
  31. state.GetAnswerFileOption(AnswerFile::OPTION_REMOVE_APP_PARTITIONS);
  32. if (option.icompare(AnswerFile::VALUE_YES) == 0)
  33. {
  34. Win::CheckDlgButton(hwnd, IDC_CONFIRM, BST_CHECKED);
  35. return;
  36. }
  37. }
  38. Win::CheckDlgButton(hwnd, IDC_CONFIRM, BST_UNCHECKED);
  39. }
  40. void
  41. ApplicationPartitionConfirmationPage::Enable()
  42. {
  43. // LOG_FUNCTION(ApplicationPartitionConfirmationPage::Enable);
  44. int next = Win::IsDlgButtonChecked(hwnd, IDC_CONFIRM) ? PSWIZB_NEXT : 0;
  45. Win::PropSheet_SetWizButtons(
  46. Win::GetParent(hwnd),
  47. PSWIZB_BACK | next);
  48. }
  49. bool
  50. ApplicationPartitionConfirmationPage::OnSetActive()
  51. {
  52. LOG_FUNCTION(ApplicationPartitionConfirmationPage::OnSetActive);
  53. State& state = State::GetInstance();
  54. if (
  55. state.RunHiddenUnattended()
  56. // we don't re-evaluate whether this machine is has the last copy of
  57. // and ndnc (i.e. call state.IsLastAppPartitionReplica) again because
  58. // that evaluation could be kinda expensive if there are many ndncs
  59. // on this box, and we just did it on the previous page, and
  60. // ** we don't want to get a different result that what we showed **
  61. || !state.GetAppPartitionList().size())
  62. {
  63. LOG(L"Planning to skip ApplicationPartitionConfirmationPage");
  64. Wizard& wizard = GetWizard();
  65. if (wizard.IsBacktracking())
  66. {
  67. // backup once again
  68. wizard.Backtrack(hwnd);
  69. return true;
  70. }
  71. int nextPage = ApplicationPartitionConfirmationPage::Validate();
  72. if (nextPage != -1)
  73. {
  74. LOG(L"skipping ApplicationPartitionConfirmationPage");
  75. wizard.SetNextPageID(hwnd, nextPage);
  76. return true;
  77. }
  78. state.ClearHiddenWhileUnattended();
  79. }
  80. Enable();
  81. return true;
  82. }
  83. bool
  84. ApplicationPartitionConfirmationPage::OnCommand(
  85. HWND /* windowFrom */ ,
  86. unsigned controlIDFrom,
  87. unsigned code)
  88. {
  89. // LOG_FUNCTION(CredentialsPage::OnCommand);
  90. switch (controlIDFrom)
  91. {
  92. case IDC_CONFIRM:
  93. {
  94. if (code == BN_CLICKED)
  95. {
  96. SetChanged(controlIDFrom);
  97. Enable();
  98. return true;
  99. }
  100. break;
  101. }
  102. default:
  103. {
  104. // do nothing
  105. break;
  106. }
  107. }
  108. return false;
  109. }
  110. int
  111. ApplicationPartitionConfirmationPage::Validate()
  112. {
  113. LOG_FUNCTION(ApplicationPartitionConfirmationPage::Validate);
  114. State& state = State::GetInstance();
  115. ASSERT(state.GetOperation() == State::DEMOTE);
  116. int nextPage = -1;
  117. if (
  118. !state.GetAppPartitionList().size()
  119. || Win::IsDlgButtonChecked(hwnd, IDC_CONFIRM))
  120. {
  121. // jump to credentials page if the user checked the "last dc in domain"
  122. // checkbox, unless this is last dc in forest root domain. 318736, 391440
  123. const Computer& computer = state.GetComputer();
  124. bool isForestRootDomain =
  125. (computer.GetDomainDnsName().icompare(computer.GetForestDnsName()) == 0);
  126. nextPage =
  127. state.IsLastDCInDomain() && !isForestRootDomain
  128. ? IDD_GET_CREDENTIALS
  129. : IDD_ADMIN_PASSWORD;
  130. }
  131. return nextPage;
  132. }