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.

179 lines
2.8 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // pick site page
  4. //
  5. // 12-22-97 sburns
  6. #include "headers.hxx"
  7. #include "page.hpp"
  8. #include "PickSitePage.hpp"
  9. #include "resource.h"
  10. #include "state.hpp"
  11. #include "common.hpp"
  12. #include "dns.hpp"
  13. PickSitePage::PickSitePage()
  14. :
  15. DCPromoWizardPage(
  16. IDD_PICK_SITE,
  17. IDS_PICK_SITE_PAGE_TITLE,
  18. IDS_PICK_SITE_PAGE_SUBTITLE)
  19. {
  20. LOG_CTOR(PickSitePage);
  21. }
  22. PickSitePage::~PickSitePage()
  23. {
  24. LOG_DTOR(PickSitePage);
  25. }
  26. void
  27. PickSitePage::OnInit()
  28. {
  29. LOG_FUNCTION(PickSitePage::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. }
  42. void
  43. PickSitePage::Enable()
  44. {
  45. int next =
  46. !Win::GetTrimmedDlgItemText(hwnd, IDC_SITE).empty()
  47. ? PSWIZB_NEXT : 0;
  48. Win::PropSheet_SetWizButtons(
  49. Win::GetParent(hwnd),
  50. PSWIZB_BACK | next);
  51. }
  52. bool
  53. PickSitePage::OnCommand(
  54. HWND /* windowFrom */ ,
  55. unsigned controlIDFrom,
  56. unsigned code)
  57. {
  58. // LOG_FUNCTION(PickSitePage::OnCommand);
  59. switch (controlIDFrom)
  60. {
  61. case IDC_SITE:
  62. {
  63. if (code == EN_CHANGE)
  64. {
  65. SetChanged(controlIDFrom);
  66. Enable();
  67. return true;
  68. }
  69. break;
  70. }
  71. default:
  72. {
  73. // do nothing
  74. break;
  75. }
  76. }
  77. return false;
  78. }
  79. bool
  80. PickSitePage::OnSetActive()
  81. {
  82. LOG_FUNCTION(PickSitePage::OnSetActive);
  83. Win::PropSheet_SetWizButtons(
  84. Win::GetParent(hwnd),
  85. PSWIZB_BACK);
  86. Wizard& wizard = GetWizard();
  87. if (wizard.IsBacktracking())
  88. {
  89. // backup once again
  90. wizard.Backtrack(hwnd);
  91. }
  92. else
  93. {
  94. int nextPage = Validate();
  95. if (nextPage != -1)
  96. {
  97. wizard.SetNextPageID(hwnd, nextPage);
  98. return true;
  99. }
  100. else
  101. {
  102. State::GetInstance().ClearHiddenWhileUnattended();
  103. }
  104. }
  105. Enable();
  106. return true;
  107. }
  108. int
  109. PickSitePage::Validate()
  110. {
  111. LOG_FUNCTION(PickSitePage::Validate);
  112. State& state = State::GetInstance();
  113. ASSERT(state.IsDNSOnNetwork());
  114. int nextPage = IDD_RAS_FIXUP;
  115. String site = Win::GetTrimmedDlgItemText(hwnd, IDC_SITE);
  116. if (site.empty())
  117. {
  118. LOG(L"Site not specified.");
  119. }
  120. else
  121. {
  122. if (!ValidateSiteName(hwnd, IDC_SITE))
  123. {
  124. nextPage = -1;
  125. }
  126. }
  127. state.SetSiteName(Win::GetTrimmedDlgItemText(hwnd, IDC_SITE));
  128. if (nextPage != -1)
  129. {
  130. if (state.GetOperation() != State::REPLICA)
  131. {
  132. nextPage = IDD_DYNAMIC_DNS;
  133. }
  134. }
  135. return nextPage;
  136. }