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.

166 lines
3.0 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // New domain page
  4. //
  5. // 9 Feb 2000 sburns
  6. #include "headers.hxx"
  7. #include "page.hpp"
  8. #include "NewDomainPage.hpp"
  9. #include "resource.h"
  10. #include "state.hpp"
  11. NewDomainPage::NewDomainPage()
  12. :
  13. DCPromoWizardPage(
  14. IDD_NEW_DOMAIN,
  15. IDS_NEW_DOMAIN_PAGE_TITLE,
  16. IDS_NEW_DOMAIN_PAGE_SUBTITLE)
  17. {
  18. LOG_CTOR(NewDomainPage);
  19. }
  20. NewDomainPage::~NewDomainPage()
  21. {
  22. LOG_DTOR(NewDomainPage);
  23. }
  24. int
  25. CheckForWin2kOptions(const State& state)
  26. {
  27. LOG_FUNCTION(CheckForWin2kOptions);
  28. int result = IDC_FOREST;
  29. // look for old (win2k) options
  30. String treeOrChild = state.GetAnswerFileOption(L"TreeOrChild").to_upper();
  31. String createOrJoin = state.GetAnswerFileOption(L"CreateOrJoin").to_upper();
  32. static const String TREE(L"TREE");
  33. static const String CREATE(L"CREATE");
  34. do
  35. {
  36. // we set defaults such that they are the same as in win2k
  37. if (treeOrChild != TREE)
  38. {
  39. result = IDC_CHILD;
  40. break;
  41. }
  42. if (createOrJoin != CREATE)
  43. {
  44. result = IDC_TREE;
  45. }
  46. }
  47. while (0);
  48. return result;
  49. }
  50. void
  51. NewDomainPage::OnInit()
  52. {
  53. LOG_FUNCTION(NewDomainPage::OnInit);
  54. State& state = State::GetInstance();
  55. int button = IDC_FOREST;
  56. if (state.UsingAnswerFile())
  57. {
  58. String option =
  59. state.GetAnswerFileOption(AnswerFile::OPTION_NEW_DOMAIN);
  60. // NewDomain trumps the old TreeOrChild/CreateOrJoin options.
  61. if (option.empty())
  62. {
  63. button = CheckForWin2kOptions(state);
  64. }
  65. else if (option.icompare(AnswerFile::VALUE_TREE) == 0)
  66. {
  67. button = IDC_TREE;
  68. }
  69. else if (option.icompare(AnswerFile::VALUE_CHILD) == 0)
  70. {
  71. button = IDC_CHILD;
  72. }
  73. }
  74. Win::CheckDlgButton(hwnd, button, BST_CHECKED);
  75. }
  76. bool
  77. NewDomainPage::OnSetActive()
  78. {
  79. LOG_FUNCTION(NewDomainPage::OnSetActive);
  80. State& state = State::GetInstance();
  81. if (state.RunHiddenUnattended())
  82. {
  83. int nextPage = NewDomainPage::Validate();
  84. if (nextPage != -1)
  85. {
  86. GetWizard().SetNextPageID(hwnd, nextPage);
  87. }
  88. else
  89. {
  90. state.ClearHiddenWhileUnattended();
  91. }
  92. }
  93. Win::PropSheet_SetWizButtons(
  94. Win::GetParent(hwnd),
  95. PSWIZB_BACK | PSWIZB_NEXT);
  96. return true;
  97. }
  98. int
  99. NewDomainPage::Validate()
  100. {
  101. LOG_FUNCTION(NewDomainPage::Validate);
  102. State& state = State::GetInstance();
  103. int nextPage = -1;
  104. if (Win::IsDlgButtonChecked(hwnd, IDC_CHILD))
  105. {
  106. state.SetOperation(State::CHILD);
  107. nextPage = IDD_CONFIG_DNS_CLIENT;
  108. }
  109. else if (Win::IsDlgButtonChecked(hwnd, IDC_TREE))
  110. {
  111. state.SetOperation(State::TREE);
  112. nextPage = IDD_CONFIG_DNS_CLIENT;
  113. }
  114. else if (Win::IsDlgButtonChecked(hwnd, IDC_FOREST))
  115. {
  116. state.SetOperation(State::FOREST);
  117. nextPage = IDD_DNS_ON_NET;
  118. }
  119. return nextPage;
  120. }