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.

248 lines
5.9 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1999 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. dnsprop.cpp
  7. The dynamic DNS property page
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "DnsProp.h"
  12. #include "server.h"
  13. #include "scope.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CDnsPropRegistration property page
  21. IMPLEMENT_DYNCREATE(CDnsPropRegistration, CPropertyPageBase)
  22. CDnsPropRegistration::CDnsPropRegistration() : CPropertyPageBase(CDnsPropRegistration::IDD)
  23. {
  24. //{{AFX_DATA_INIT(CDnsPropRegistration)
  25. m_fEnableDynDns = FALSE;
  26. m_fGarbageCollect = FALSE;
  27. m_fUpdateDownlevel = FALSE;
  28. m_nRegistrationType = -1;
  29. //}}AFX_DATA_INIT
  30. }
  31. CDnsPropRegistration::~CDnsPropRegistration()
  32. {
  33. }
  34. void CDnsPropRegistration::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CPropertyPageBase::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CDnsPropRegistration)
  38. DDX_Check(pDX, IDC_CHECK_ENABLE_DYN_DNS, m_fEnableDynDns);
  39. DDX_Check(pDX, IDC_CHECK_GARBAGE_COLLECT, m_fGarbageCollect);
  40. DDX_Check(pDX, IDC_CHECK_UPDATE_DOWNLEVEL, m_fUpdateDownlevel);
  41. DDX_Radio(pDX, IDC_RADIO_CLIENT, m_nRegistrationType);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CDnsPropRegistration, CPropertyPageBase)
  45. //{{AFX_MSG_MAP(CDnsPropRegistration)
  46. ON_BN_CLICKED(IDC_RADIO_ALWAYS, OnRadioAlways)
  47. ON_BN_CLICKED(IDC_RADIO_CLIENT, OnRadioClient)
  48. ON_BN_CLICKED(IDC_CHECK_ENABLE_DYN_DNS, OnCheckEnableDynDns)
  49. ON_BN_CLICKED(IDC_CHECK_GARBAGE_COLLECT, OnCheckGarbageCollect)
  50. ON_BN_CLICKED(IDC_CHECK_UPDATE_DOWNLEVEL, OnCheckUpdateDownlevel)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CDnsPropRegistration message handlers
  55. void CDnsPropRegistration::OnRadioAlways()
  56. {
  57. DWORD dwFlags = m_dwFlags;
  58. UpdateControls();
  59. if (dwFlags != m_dwFlags)
  60. SetDirty(TRUE);
  61. }
  62. void CDnsPropRegistration::OnRadioClient()
  63. {
  64. DWORD dwFlags = m_dwFlags;
  65. UpdateControls();
  66. if (dwFlags != m_dwFlags)
  67. SetDirty(TRUE);
  68. }
  69. BOOL CDnsPropRegistration::OnInitDialog()
  70. {
  71. m_fEnableDynDns = (m_dwFlags & DNS_FLAG_ENABLED) ? TRUE : FALSE;
  72. m_fUpdateDownlevel = (m_dwFlags & DNS_FLAG_UPDATE_DOWNLEVEL) ? TRUE : FALSE;
  73. m_fGarbageCollect = (m_dwFlags & DNS_FLAG_CLEANUP_EXPIRED) ? TRUE : FALSE;
  74. m_nRegistrationType = (m_dwFlags & DNS_FLAG_UPDATE_BOTH_ALWAYS) ? 1 : 0;
  75. CPropertyPageBase::OnInitDialog();
  76. UpdateControls();
  77. return TRUE; // return TRUE unless you set the focus to a control
  78. // EXCEPTION: OCX Property Pages should return FALSE
  79. }
  80. BOOL CDnsPropRegistration::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  81. {
  82. SPITFSNode spNode;
  83. DWORD dwFlags = m_dwFlags;
  84. DWORD dwError;
  85. BEGIN_WAIT_CURSOR;
  86. spNode = GetHolder()->GetNode();
  87. switch (m_dhcpOptionType)
  88. {
  89. case DhcpGlobalOptions:
  90. {
  91. CDhcpServer * pServer = GETHANDLER(CDhcpServer, spNode);
  92. dwError = pServer->SetDnsRegistration(dwFlags);
  93. if (dwError != ERROR_SUCCESS)
  94. {
  95. GetHolder()->SetError(dwError);
  96. }
  97. break;
  98. }
  99. case DhcpSubnetOptions:
  100. {
  101. CDhcpScope * pScope = GETHANDLER(CDhcpScope, spNode);
  102. dwError = pScope->SetDnsRegistration(dwFlags);
  103. if (dwError != ERROR_SUCCESS)
  104. {
  105. GetHolder()->SetError(dwError);
  106. }
  107. break;
  108. }
  109. case DhcpReservedOptions:
  110. {
  111. CDhcpReservationClient * pClient = GETHANDLER(CDhcpReservationClient, spNode);
  112. dwError = pClient->SetDnsRegistration(spNode, dwFlags);
  113. if (dwError != ERROR_SUCCESS)
  114. {
  115. GetHolder()->SetError(dwError);
  116. }
  117. break;
  118. }
  119. default:
  120. Assert(FALSE);
  121. break;
  122. }
  123. END_WAIT_CURSOR;
  124. return FALSE;
  125. }
  126. BOOL CDnsPropRegistration::OnApply()
  127. {
  128. UpdateData();
  129. BOOL bRet = CPropertyPageBase::OnApply();
  130. if (bRet == FALSE)
  131. {
  132. // Something bad happened... grab the error code
  133. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  134. ::DhcpMessageBox(GetHolder()->GetError());
  135. }
  136. return bRet;
  137. }
  138. void CDnsPropRegistration::OnCheckEnableDynDns()
  139. {
  140. DWORD dwFlags = m_dwFlags;
  141. UpdateControls();
  142. if (dwFlags != m_dwFlags)
  143. SetDirty(TRUE);
  144. }
  145. void CDnsPropRegistration::OnCheckGarbageCollect()
  146. {
  147. DWORD dwFlags = m_dwFlags;
  148. UpdateControls();
  149. if (dwFlags != m_dwFlags)
  150. SetDirty(TRUE);
  151. }
  152. void CDnsPropRegistration::OnCheckUpdateDownlevel()
  153. {
  154. DWORD dwFlags = m_dwFlags;
  155. UpdateControls();
  156. if (dwFlags != m_dwFlags)
  157. SetDirty(TRUE);
  158. }
  159. void CDnsPropRegistration::UpdateControls()
  160. {
  161. UpdateData();
  162. if (m_fEnableDynDns)
  163. {
  164. GetDlgItem(IDC_RADIO_CLIENT)->EnableWindow(TRUE);
  165. GetDlgItem(IDC_RADIO_ALWAYS)->EnableWindow(TRUE);
  166. GetDlgItem(IDC_CHECK_GARBAGE_COLLECT)->EnableWindow(TRUE);
  167. GetDlgItem(IDC_CHECK_UPDATE_DOWNLEVEL)->EnableWindow(TRUE);
  168. m_dwFlags = DNS_FLAG_ENABLED;
  169. if (m_nRegistrationType == 1)
  170. {
  171. // user has selected to always update client information
  172. m_dwFlags |= DNS_FLAG_UPDATE_BOTH_ALWAYS;
  173. }
  174. if (m_fGarbageCollect)
  175. {
  176. m_dwFlags |= DNS_FLAG_CLEANUP_EXPIRED;
  177. }
  178. if (m_fUpdateDownlevel)
  179. {
  180. m_dwFlags |= DNS_FLAG_UPDATE_DOWNLEVEL;
  181. }
  182. }
  183. else
  184. {
  185. // turn off everything. If DynDns is turned off then
  186. // all other flags are ignored.
  187. GetDlgItem(IDC_RADIO_CLIENT)->EnableWindow(FALSE);
  188. GetDlgItem(IDC_RADIO_ALWAYS)->EnableWindow(FALSE);
  189. GetDlgItem(IDC_CHECK_GARBAGE_COLLECT)->EnableWindow(FALSE);
  190. GetDlgItem(IDC_CHECK_UPDATE_DOWNLEVEL)->EnableWindow(FALSE);
  191. m_dwFlags = 0;
  192. }
  193. }