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.

196 lines
3.1 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // new site page
  4. //
  5. // 1-6-98 sburns
  6. #include "headers.hxx"
  7. #include "page.hpp"
  8. #include "NewSitePage.hpp"
  9. #include "resource.h"
  10. #include "state.hpp"
  11. #include "common.hpp"
  12. #include "dns.hpp"
  13. NewSitePage::NewSitePage()
  14. :
  15. DCPromoWizardPage(
  16. IDD_NEW_SITE,
  17. IDS_NEW_SITE_PAGE_TITLE,
  18. IDS_NEW_SITE_PAGE_SUBTITLE)
  19. {
  20. LOG_CTOR(NewSitePage);
  21. }
  22. NewSitePage::~NewSitePage()
  23. {
  24. LOG_DTOR(NewSitePage);
  25. }
  26. void
  27. NewSitePage::OnInit()
  28. {
  29. LOG_FUNCTION(NewSitePage::OnInit);
  30. Win::Edit_LimitText(
  31. Win::GetDlgItem(hwnd, IDC_SITE),
  32. Dns::MAX_LABEL_LENGTH);
  33. State& state = State::GetInstance();
  34. if (state.UsingAnswerFile())
  35. {
  36. Win::SetDlgItemText(
  37. hwnd,
  38. IDC_SITE,
  39. state.GetAnswerFileOption(State::OPTION_SITE_NAME));
  40. }
  41. if (Win::GetTrimmedDlgItemText(hwnd, IDC_SITE).empty())
  42. {
  43. // assign a default site name
  44. Win::SetDlgItemText(
  45. hwnd,
  46. IDC_SITE,
  47. String::load(IDS_FIRST_SITE));
  48. }
  49. }
  50. void
  51. NewSitePage::Enable()
  52. {
  53. int next =
  54. !Win::GetTrimmedDlgItemText(hwnd, IDC_SITE).empty()
  55. ? PSWIZB_NEXT : 0;
  56. Win::PropSheet_SetWizButtons(
  57. Win::GetParent(hwnd),
  58. PSWIZB_BACK | next);
  59. }
  60. bool
  61. NewSitePage::OnCommand(
  62. HWND /* windowFrom */ ,
  63. unsigned controlIDFrom,
  64. unsigned code)
  65. {
  66. // LOG_FUNCTION(NewSitePage::OnCommand);
  67. switch (controlIDFrom)
  68. {
  69. case IDC_SITE:
  70. {
  71. if (code == EN_CHANGE)
  72. {
  73. SetChanged(controlIDFrom);
  74. Enable();
  75. return true;
  76. }
  77. break;
  78. }
  79. default:
  80. {
  81. // do nothing
  82. break;
  83. }
  84. }
  85. return false;
  86. }
  87. bool
  88. NewSitePage::OnSetActive()
  89. {
  90. LOG_FUNCTION(NewSitePage::OnSetActive);
  91. Win::PropSheet_SetWizButtons(
  92. Win::GetParent(hwnd),
  93. PSWIZB_BACK);
  94. Wizard& wizard = GetWizard();
  95. if (wizard.IsBacktracking())
  96. {
  97. // backup once again
  98. wizard.Backtrack(hwnd);
  99. }
  100. else
  101. {
  102. int nextPage = Validate();
  103. if (nextPage != -1)
  104. {
  105. wizard.SetNextPageID(hwnd, nextPage);
  106. return true;
  107. }
  108. else
  109. {
  110. State::GetInstance().ClearHiddenWhileUnattended();
  111. }
  112. }
  113. Enable();
  114. return true;
  115. }
  116. int
  117. NewSitePage::Validate()
  118. {
  119. LOG_FUNCTION(NewSitePage::Validate);
  120. State& state = State::GetInstance();
  121. // this page is only used in new forest scenarios
  122. ASSERT(state.GetOperation() == State::FOREST);
  123. int nextPage = -1;
  124. String site = Win::GetTrimmedDlgItemText(hwnd, IDC_SITE);
  125. if (!site.empty())
  126. {
  127. if (ValidateSiteName(hwnd, IDC_SITE))
  128. {
  129. state.SetSiteName(Win::GetTrimmedDlgItemText(hwnd, IDC_SITE));
  130. nextPage = IDD_RAS_FIXUP;
  131. }
  132. }
  133. else
  134. {
  135. popup.Gripe(hwnd, IDC_SITE, IDS_MUST_SPECIFY_SITE);
  136. }
  137. if (nextPage != -1)
  138. {
  139. if (!state.IsDNSOnNetwork())
  140. {
  141. nextPage = IDD_RAS_FIXUP;
  142. }
  143. else
  144. {
  145. nextPage = IDD_DYNAMIC_DNS;
  146. }
  147. }
  148. return nextPage;
  149. }