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.

184 lines
4.6 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. #include "precomp.h"
  3. #include "..\Common\ServiceThread.h"
  4. #include "moredlg.h"
  5. #ifdef EXT_DEBUG
  6. #undef THIS_FILE
  7. static char THIS_FILE[] = __FILE__;
  8. #endif
  9. #include "resource.h"
  10. #include "..\common\util.h"
  11. #include "IDDlg.h"
  12. #include "MoreDlg.h"
  13. #include "NetUtility.h"
  14. #include "NetHelpIDs.h"
  15. static const DWORD _help_map[] =
  16. {
  17. IDC_DNS, IDH_IDENT_NAMES_DNS_NAME,
  18. IDC_CHANGE, IDH_IDENT_NAMES_CHANGE_DNS_CHECKBOX,
  19. IDC_NETBIOS, IDH_IDENT_NAMES_NETBIOS_NAME,
  20. 0, 0
  21. };
  22. //---------------------------------------------------------------------
  23. MoreChangesDialog::MoreChangesDialog(WbemServiceThread *serviceThread,
  24. State &state)
  25. : WBEMPageHelper(serviceThread),
  26. m_state(state)
  27. {
  28. }
  29. //-------------------------------------------------------------
  30. MoreChangesDialog::~MoreChangesDialog()
  31. {
  32. }
  33. //----------------------------------------------------------
  34. void MoreChangesDialog::enable()
  35. {
  36. bool enabled = false;// = WasChanged(IDC_CHANGE) ||
  37. // WasChanged(IDC_DNS) &&
  38. // !GetTrimmedDlgItemText(m_hWnd, IDC_DNS).IsEmpty();
  39. ::EnableWindow(GetDlgItem(IDOK), enabled);
  40. }
  41. //----------------------------------------------------------
  42. LRESULT MoreChangesDialog::OnInit(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  43. {
  44. m_hDlg = m_hWnd;
  45. // Marshalling shouldn't happen here.
  46. m_WbemServices = g_serviceThread->m_WbemServices;
  47. SetDlgItemText(IDC_DNS, m_state.GetComputerDomainDNSName());
  48. SetDlgItemText(IDC_NETBIOS, m_state.GetNetBIOSComputerName());
  49. CheckDlgButton(IDC_CHANGE, (m_state.GetSyncDNSNames() ? BST_CHECKED : BST_UNCHECKED));
  50. enable();
  51. return S_OK;
  52. }
  53. //----------------------------------------------------------
  54. int MoreChangesDialog::onOKButton()
  55. {
  56. int end_code = 0;
  57. // if(WasChanged(IDC_CHANGE))
  58. {
  59. m_state.SetSyncDNSNames(IsDlgButtonChecked(IDC_CHANGE) == BST_CHECKED);
  60. end_code = 1;
  61. }
  62. // if (WasChanged(IDC_DNS))
  63. {
  64. // compare the new value to the old one. If they're different,
  65. // validate and save the new value
  66. CHString new_domain = GetTrimmedDlgItemText(m_hWnd, IDC_DNS);
  67. CHString old_domain = m_state.GetComputerDomainDNSName();
  68. if(new_domain.CompareNoCase(old_domain) != 0)
  69. {
  70. /* switch (DNS::ValidateDNSNameSyntax(new_domain))
  71. {
  72. case DNS::NON_RFC_NAME:
  73. {
  74. MessageBox(String::format(IDS_NON_RFC_NAME,
  75. new_domain.c_str()),
  76. String::load(IDS_APP_TITLE),
  77. MB_OK | MB_ICONWARNING);
  78. // fall-thru
  79. }
  80. case DNS::VALID_NAME:
  81. {
  82. m_state.SetComputerDomainDNSName(new_domain);
  83. end_code = 1;
  84. break;
  85. }
  86. case DNS::INVALID_NAME:
  87. {
  88. end_code = -1;
  89. gripe(hwnd, IDC_DNS,
  90. String::format(IDS_BAD_DNS_SYNTAX,
  91. new_domain.c_str()),
  92. IDS_APP_TITLE);
  93. break;
  94. }
  95. case DNS::NAME_TOO_LONG:
  96. {
  97. end_code = -1;
  98. gripe(hwnd, IDC_DNS,
  99. String::format(IDS_DNS_NAME_TOO_LONG,
  100. new_domain.c_str(),
  101. DNS::MAX_NAME_LENGTH),
  102. IDS_APP_TITLE);
  103. break;
  104. }
  105. default:
  106. {
  107. assert(false);
  108. break;
  109. }
  110. }
  111. */
  112. }
  113. }
  114. return end_code;
  115. }
  116. //----------------------------------------------------------
  117. LRESULT MoreChangesDialog::OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  118. {
  119. switch (wID)
  120. {
  121. case IDOK:
  122. {
  123. if (wNotifyCode == BN_CLICKED)
  124. {
  125. int end_code = onOKButton();
  126. if (end_code != -1)
  127. {
  128. EndDialog(end_code);
  129. }
  130. }
  131. break;
  132. }
  133. case IDCANCEL:
  134. {
  135. if (wNotifyCode == BN_CLICKED)
  136. {
  137. // 0 => no changes made
  138. EndDialog(NO_CHANGES);
  139. }
  140. break;
  141. }
  142. case IDC_CHANGE:
  143. {
  144. if (wNotifyCode == BN_CLICKED)
  145. {
  146. enable();
  147. }
  148. break;
  149. }
  150. case IDC_DNS:
  151. {
  152. if (wNotifyCode == EN_CHANGE)
  153. {
  154. enable();
  155. }
  156. break;
  157. }
  158. default:
  159. {
  160. bHandled = false;
  161. break;
  162. }
  163. }
  164. return S_OK;
  165. }