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.

3205 lines
86 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: zoneui.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "preDNSsn.h"
  11. #include <SnapBase.h>
  12. #include "resource.h"
  13. #include "dnsutil.h"
  14. #include "DNSSnap.h"
  15. #include "snapdata.h"
  16. #include "server.h"
  17. #include "domain.h"
  18. #include "record.h"
  19. #include "zone.h"
  20. #include "ZoneUI.h"
  21. #include "browser.h"
  22. #ifdef DEBUG_ALLOCATOR
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. #endif
  29. #ifdef USE_NDNC
  30. ///////////////////////////////////////////////////////////////////////////////
  31. // CDNSZoneChangeReplicationScopeDialog
  32. class CDNSZoneChangeReplicationScopeDialog : public CHelpDialog
  33. {
  34. public:
  35. CDNSZoneChangeReplicationScopeDialog(CPropertyPageHolderBase* pHolder,
  36. ReplicationType replType,
  37. PCWSTR pszCustomScope,
  38. DWORD dwServerVersion);
  39. ReplicationType m_newReplType; // IN/OUT
  40. CString m_szCustomScope; // IN/OUT
  41. protected:
  42. virtual BOOL OnInitDialog();
  43. virtual void OnOK();
  44. virtual void OnCancel();
  45. afx_msg void OnRadioChange();
  46. afx_msg void OnCustomComboSelChange();
  47. DECLARE_MESSAGE_MAP()
  48. private:
  49. void SyncRadioButtons();
  50. ReplicationType m_replType;
  51. BOOL m_dwServerVersion;
  52. CPropertyPageHolderBase* m_pHolder;
  53. };
  54. CDNSZoneChangeReplicationScopeDialog::CDNSZoneChangeReplicationScopeDialog(CPropertyPageHolderBase* pHolder,
  55. ReplicationType replType,
  56. PCWSTR pszCustomScope,
  57. DWORD dwServerVersion)
  58. : m_pHolder(pHolder),
  59. m_replType(replType),
  60. m_newReplType(replType),
  61. m_szCustomScope(pszCustomScope),
  62. m_dwServerVersion(dwServerVersion),
  63. CHelpDialog(IDD_ZONE_GENERAL_CHANGE_REPLICATION, pHolder->GetComponentData())
  64. {
  65. ASSERT(pHolder != NULL);
  66. }
  67. BEGIN_MESSAGE_MAP(CDNSZoneChangeReplicationScopeDialog, CHelpDialog)
  68. ON_BN_CLICKED(IDC_FOREST_RADIO, OnRadioChange)
  69. ON_BN_CLICKED(IDC_DOMAIN_RADIO, OnRadioChange)
  70. ON_BN_CLICKED(IDC_DOMAIN_DC_RADIO, OnRadioChange)
  71. ON_BN_CLICKED(IDC_CUSTOM_RADIO, OnRadioChange)
  72. ON_CBN_EDITCHANGE(IDC_CUSTOM_COMBO, OnRadioChange)
  73. ON_CBN_SELCHANGE(IDC_CUSTOM_COMBO, OnCustomComboSelChange)
  74. END_MESSAGE_MAP()
  75. void CDNSZoneChangeReplicationScopeDialog::OnRadioChange()
  76. {
  77. if (SendDlgItemMessage(IDC_FOREST_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  78. {
  79. m_newReplType = forest;
  80. }
  81. else if (SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  82. {
  83. m_newReplType = domain;
  84. }
  85. else if (SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  86. {
  87. m_newReplType = w2k;
  88. }
  89. else if (SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  90. {
  91. m_newReplType = custom;
  92. LRESULT iSel = SendDlgItemMessage(IDC_CUSTOM_COMBO, CB_GETCURSEL, 0, 0);
  93. if (CB_ERR != iSel)
  94. {
  95. CString szTemp;
  96. CComboBox* pComboBox = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_CUSTOM_COMBO));
  97. ASSERT(pComboBox);
  98. pComboBox->GetLBText(static_cast<int>(iSel), m_szCustomScope);
  99. }
  100. }
  101. else
  102. {
  103. // one of the radio buttons must be selected
  104. ASSERT(FALSE);
  105. }
  106. SyncRadioButtons();
  107. }
  108. void CDNSZoneChangeReplicationScopeDialog::SyncRadioButtons()
  109. {
  110. switch (m_newReplType)
  111. {
  112. case forest:
  113. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  114. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  115. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  116. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  117. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  118. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  119. break;
  120. case domain:
  121. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  122. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  123. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  124. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  125. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  126. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  127. break;
  128. case w2k:
  129. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  130. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  131. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  132. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  133. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  134. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  135. break;
  136. case custom:
  137. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  138. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  139. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  140. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  141. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(TRUE);
  142. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(TRUE);
  143. break;
  144. default:
  145. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  146. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  147. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  148. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  149. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  150. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  151. break;
  152. }
  153. if (BST_CHECKED == SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_GETCHECK, 0, 0))
  154. {
  155. CString szTemp;
  156. GetDlgItemText(IDC_CUSTOM_COMBO, szTemp);
  157. GetDlgItem(IDOK)->EnableWindow(!szTemp.IsEmpty());
  158. }
  159. else
  160. {
  161. GetDlgItem(IDOK)->EnableWindow(TRUE);
  162. }
  163. }
  164. void CDNSZoneChangeReplicationScopeDialog::OnCustomComboSelChange()
  165. {
  166. LRESULT iSel = SendDlgItemMessage(IDC_CUSTOM_COMBO, CB_GETCURSEL, 0, 0);
  167. if (CB_ERR != iSel)
  168. {
  169. CComboBox* pComboBox = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_CUSTOM_COMBO));
  170. ASSERT(pComboBox);
  171. pComboBox->GetLBText(static_cast<int>(iSel), m_szCustomScope);
  172. GetDlgItem(IDOK)->EnableWindow(!m_szCustomScope.IsEmpty());
  173. }
  174. else
  175. {
  176. GetDlgItem(IDOK)->EnableWindow(FALSE);
  177. }
  178. }
  179. BOOL CDNSZoneChangeReplicationScopeDialog::OnInitDialog()
  180. {
  181. CHelpDialog::OnInitDialog();
  182. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  183. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)m_pHolder;
  184. CDNSServerNode* pServerNode = pHolder->GetZoneNode()->GetServerNode();
  185. //
  186. // We should only reach this dialog if we are on a Whistler or greater server
  187. //
  188. ASSERT(DNS_SRV_BUILD_NUMBER(m_dwServerVersion) >= DNS_SRV_BUILD_NUMBER_WHISTLER &&
  189. (DNS_SRV_MAJOR_VERSION(m_dwServerVersion) > DNS_SRV_MAJOR_VERSION_NT_5 ||
  190. DNS_SRV_MINOR_VERSION(m_dwServerVersion) >= DNS_SRV_MINOR_VERSION_WHISTLER));
  191. USES_CONVERSION;
  192. //
  193. // Get the forest and domain names and format them into the UI
  194. //
  195. PCWSTR pszDomainName = UTF8_TO_W(pServerNode->GetDomainName());
  196. PCWSTR pszForestName = UTF8_TO_W(pServerNode->GetForestName());
  197. ASSERT(pszDomainName);
  198. ASSERT(pszForestName);
  199. CString szWin2KReplText;
  200. szWin2KReplText.Format(IDS_ZWIZ_AD_REPL_FORMAT, pszDomainName);
  201. SetDlgItemText(IDC_DOMAIN_DC_RADIO, szWin2KReplText);
  202. CString szDNSDomainText;
  203. szDNSDomainText.Format(IDS_ZWIZ_AD_DOMAIN_FORMAT, pszDomainName);
  204. SetDlgItemText(IDC_DOMAIN_RADIO, szDNSDomainText);
  205. CString szDNSForestText;
  206. szDNSForestText.Format(IDS_ZWIZ_AD_FOREST_FORMAT, pszForestName);
  207. SetDlgItemText(IDC_FOREST_RADIO, szDNSForestText);
  208. //
  209. // Enumerate the available directory partitions
  210. //
  211. PDNS_RPC_DP_LIST pDirectoryPartitions = NULL;
  212. DWORD dwErr = ::DnssrvEnumDirectoryPartitions(pServerNode->GetRPCName(),
  213. DNS_DP_ENLISTED,
  214. &pDirectoryPartitions);
  215. //
  216. // Don't show an error if we are not able to get the available directory partitions
  217. // We can still continue on and the user can type in the directory partition they need
  218. //
  219. if (dwErr == 0 && pDirectoryPartitions)
  220. {
  221. for (DWORD dwIdx = 0; dwIdx < pDirectoryPartitions->dwDpCount; dwIdx++)
  222. {
  223. PDNS_RPC_DP_INFO pDirectoryPartition = 0;
  224. dwErr = ::DnssrvDirectoryPartitionInfo(pServerNode->GetRPCName(),
  225. pDirectoryPartitions->DpArray[dwIdx]->pszDpFqdn,
  226. &pDirectoryPartition);
  227. if (dwErr == 0 &&
  228. pDirectoryPartition)
  229. {
  230. //
  231. // Only add the partition if it is not one of the autocreated ones
  232. // and the DNS server is enlisted in the partition
  233. //
  234. if (!(pDirectoryPartition->dwFlags & DNS_DP_AUTOCREATED) &&
  235. (pDirectoryPartition->dwFlags & DNS_DP_ENLISTED))
  236. {
  237. SendDlgItemMessage(IDC_CUSTOM_COMBO,
  238. CB_ADDSTRING,
  239. 0,
  240. (LPARAM)UTF8_TO_W(pDirectoryPartition->pszDpFqdn));
  241. }
  242. ::DnssrvFreeDirectoryPartitionInfo(pDirectoryPartition);
  243. }
  244. }
  245. ::DnssrvFreeDirectoryPartitionList(pDirectoryPartitions);
  246. }
  247. //
  248. // Select the correct partition if we are using a custom partition
  249. //
  250. if (m_replType == custom)
  251. {
  252. LRESULT lIdx = SendDlgItemMessage(IDC_CUSTOM_COMBO,
  253. CB_FINDSTRINGEXACT,
  254. (WPARAM)-1,
  255. (LPARAM)(PCWSTR)m_szCustomScope);
  256. if (lIdx != CB_ERR)
  257. {
  258. SendDlgItemMessage(IDC_CUSTOM_COMBO,
  259. CB_SETCURSEL,
  260. (WPARAM)lIdx,
  261. 0);
  262. }
  263. else
  264. {
  265. //
  266. // Add the partition
  267. //
  268. SendDlgItemMessage(IDC_CUSTOM_COMBO,
  269. CB_ADDSTRING,
  270. 0,
  271. (LPARAM)(PCWSTR)m_szCustomScope);
  272. }
  273. }
  274. SyncRadioButtons();
  275. return TRUE;
  276. }
  277. void CDNSZoneChangeReplicationScopeDialog::OnCancel()
  278. {
  279. if (m_pHolder != NULL)
  280. {
  281. m_pHolder->PopDialogHWnd();
  282. }
  283. CHelpDialog::OnCancel();
  284. }
  285. void CDNSZoneChangeReplicationScopeDialog::OnOK()
  286. {
  287. if (m_pHolder != NULL)
  288. {
  289. m_pHolder->PopDialogHWnd();
  290. }
  291. CHelpDialog::OnOK();
  292. }
  293. #endif // USE_NDNC
  294. ///////////////////////////////////////////////////////////////////////////////
  295. // CDNSZoneChangeTypeDialog
  296. class CDNSZoneChangeTypeDialog : public CHelpDialog
  297. {
  298. public:
  299. CDNSZoneChangeTypeDialog(CPropertyPageHolderBase* pHolder,
  300. BOOL bServerADSEnabled,
  301. DWORD dwServerVersion);
  302. BOOL m_bIsPrimary; // IN/OUT
  303. BOOL m_bDSIntegrated; // IN/OUT
  304. BOOL m_bIsStub; // IN/OUT
  305. protected:
  306. virtual BOOL OnInitDialog();
  307. virtual void OnOK();
  308. virtual void OnCancel();
  309. afx_msg void OnRadioChange();
  310. DECLARE_MESSAGE_MAP()
  311. private:
  312. BOOL m_bServerADSEnabled;
  313. BOOL m_dwServerVersion;
  314. CPropertyPageHolderBase* m_pHolder;
  315. };
  316. CDNSZoneChangeTypeDialog::CDNSZoneChangeTypeDialog(CPropertyPageHolderBase* pHolder,
  317. BOOL bServerADSEnabled,
  318. DWORD dwServerVersion)
  319. : CHelpDialog(IDD_ZONE_GENERAL_CHANGE_TYPE, pHolder->GetComponentData())
  320. {
  321. ASSERT(pHolder != NULL);
  322. m_pHolder = pHolder;
  323. m_bServerADSEnabled = bServerADSEnabled;
  324. m_dwServerVersion = dwServerVersion;
  325. }
  326. BEGIN_MESSAGE_MAP(CDNSZoneChangeTypeDialog, CHelpDialog)
  327. ON_BN_CLICKED(IDC_RADIO_ZONE_PRIMARY, OnRadioChange)
  328. ON_BN_CLICKED(IDC_RADIO_ZONE_SECONDARY, OnRadioChange)
  329. ON_BN_CLICKED(IDC_RADIO_ZONE_STUB, OnRadioChange)
  330. END_MESSAGE_MAP()
  331. void CDNSZoneChangeTypeDialog::OnRadioChange()
  332. {
  333. if (SendDlgItemMessage(IDC_RADIO_ZONE_SECONDARY, BM_GETCHECK, 0, 0) == BST_CHECKED)
  334. {
  335. SendDlgItemMessage(IDC_ADINT_CHECK, BM_SETCHECK, BST_UNCHECKED, 0);
  336. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  337. }
  338. else
  339. {
  340. if (m_bServerADSEnabled)
  341. {
  342. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(TRUE);
  343. }
  344. else
  345. {
  346. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  347. }
  348. }
  349. }
  350. BOOL CDNSZoneChangeTypeDialog::OnInitDialog()
  351. {
  352. CHelpDialog::OnInitDialog();
  353. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  354. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(m_bServerADSEnabled);
  355. int nIDCheckButton;
  356. if (m_bIsPrimary)
  357. {
  358. nIDCheckButton = IDC_RADIO_ZONE_PRIMARY;
  359. }
  360. else
  361. {
  362. if (m_bIsStub)
  363. {
  364. nIDCheckButton = IDC_RADIO_ZONE_STUB;
  365. }
  366. else
  367. {
  368. nIDCheckButton = IDC_RADIO_ZONE_SECONDARY;
  369. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  370. }
  371. }
  372. CheckRadioButton(IDC_RADIO_ZONE_PRIMARY, IDC_RADIO_ZONE_STUB, nIDCheckButton);
  373. SendDlgItemMessage(IDC_ADINT_CHECK, BM_SETCHECK, m_bDSIntegrated, 0);
  374. if (DNS_SRV_BUILD_NUMBER(m_dwServerVersion) < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  375. (DNS_SRV_MAJOR_VERSION(m_dwServerVersion) <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  376. DNS_SRV_MINOR_VERSION(m_dwServerVersion) < DNS_SRV_MINOR_VERSION_WHISTLER))
  377. {
  378. //
  379. // Stub zones not available on pre-Whistler servers
  380. //
  381. GetDlgItem(IDC_RADIO_ZONE_STUB)->EnableWindow(FALSE);
  382. GetDlgItem(IDC_STUB_STATIC)->EnableWindow(FALSE);
  383. }
  384. return TRUE;
  385. }
  386. void CDNSZoneChangeTypeDialog::OnCancel()
  387. {
  388. if (m_pHolder != NULL)
  389. {
  390. m_pHolder->PopDialogHWnd();
  391. }
  392. CHelpDialog::OnCancel();
  393. }
  394. void CDNSZoneChangeTypeDialog::OnOK()
  395. {
  396. BOOL bIsPrimary = TRUE;
  397. BOOL bDSIntegrated = TRUE;
  398. BOOL bIsStub = FALSE;
  399. int nIDCheckButton = GetCheckedRadioButton(IDC_RADIO_ZONE_PRIMARY, IDC_RADIO_ZONE_STUB);
  400. switch (nIDCheckButton)
  401. {
  402. case IDC_RADIO_ZONE_PRIMARY:
  403. bIsPrimary = TRUE;
  404. bIsStub = FALSE;
  405. break;
  406. case IDC_RADIO_ZONE_SECONDARY:
  407. bIsPrimary = FALSE;
  408. bIsStub = FALSE;
  409. break;
  410. case IDC_RADIO_ZONE_STUB:
  411. bIsPrimary = FALSE;
  412. bIsStub = TRUE;
  413. break;
  414. default:
  415. ASSERT(FALSE);
  416. break;
  417. }
  418. bDSIntegrated = static_cast<BOOL>(SendDlgItemMessage(IDC_ADINT_CHECK, BM_GETCHECK, 0, 0));
  419. //
  420. // warnings on special transitions
  421. //
  422. if (m_bDSIntegrated && !bDSIntegrated)
  423. {
  424. //
  425. // warning changing from DS integrated to something else
  426. //
  427. if (IDCANCEL == DNSMessageBox(IDS_MSG_ZONE_WARNING_CHANGE_TYPE_FROM_DS,MB_OKCANCEL))
  428. {
  429. return;
  430. }
  431. }
  432. else if (!m_bDSIntegrated && bDSIntegrated)
  433. {
  434. //
  435. // warning changing from primary to DS integrated primary
  436. //
  437. if (IDCANCEL == DNSMessageBox(IDS_MSG_ZONE_WARNING_CHANGE_TYPE_TO_DS,MB_OKCANCEL))
  438. {
  439. return;
  440. }
  441. }
  442. m_bIsPrimary = bIsPrimary;
  443. m_bDSIntegrated = bDSIntegrated;
  444. m_bIsStub = bIsStub;
  445. if (m_pHolder != NULL)
  446. {
  447. m_pHolder->PopDialogHWnd();
  448. }
  449. CHelpDialog::OnOK();
  450. }
  451. ///////////////////////////////////////////////////////////////////////////////
  452. // CDNSZoneChangeTypeDataConflict
  453. class CDNSZoneChangeTypeDataConflict : public CHelpDialog
  454. {
  455. public:
  456. CDNSZoneChangeTypeDataConflict(CPropertyPageHolderBase* pHolder);
  457. BOOL m_bUseDsData; // IN/OUT
  458. protected:
  459. virtual BOOL OnInitDialog();
  460. virtual void OnOK();
  461. virtual void OnCancel();
  462. private:
  463. CPropertyPageHolderBase* m_pHolder;
  464. };
  465. CDNSZoneChangeTypeDataConflict::CDNSZoneChangeTypeDataConflict(
  466. CPropertyPageHolderBase* pHolder)
  467. : CHelpDialog(IDD_ZONE_GENERAL_CHANGE_TYPE_DATA_CONFLICT, pHolder->GetComponentData())
  468. {
  469. m_pHolder = pHolder;
  470. m_bUseDsData = FALSE;
  471. }
  472. BOOL CDNSZoneChangeTypeDataConflict::OnInitDialog()
  473. {
  474. CHelpDialog::OnInitDialog();
  475. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  476. CheckRadioButton(IDC_RADIO_USE_DS_DATA, IDC_RADIO_USE_MEM_DATA,
  477. m_bUseDsData ? IDC_RADIO_USE_DS_DATA : IDC_RADIO_USE_MEM_DATA);
  478. return TRUE;
  479. }
  480. void CDNSZoneChangeTypeDataConflict::OnCancel()
  481. {
  482. if (m_pHolder != NULL)
  483. m_pHolder->PopDialogHWnd();
  484. CHelpDialog::OnCancel();
  485. }
  486. void CDNSZoneChangeTypeDataConflict::OnOK()
  487. {
  488. int nIDCheckButton = GetCheckedRadioButton(
  489. IDC_RADIO_USE_DS_DATA, IDC_RADIO_USE_MEM_DATA);
  490. m_bUseDsData = (nIDCheckButton == IDC_RADIO_USE_DS_DATA);
  491. if (m_pHolder != NULL)
  492. m_pHolder->PopDialogHWnd();
  493. CHelpDialog::OnOK();
  494. }
  495. ///////////////////////////////////////////////////////////////////////////////
  496. // CDNSZoneNotifyDialog
  497. class CDNSZoneNotifyDialog : public CHelpDialog
  498. {
  499. public:
  500. CDNSZoneNotifyDialog(CDNSZone_ZoneTransferPropertyPage* pPage, BOOL bSecondaryZone,
  501. CComponentDataObject* pComponentData);
  502. protected:
  503. virtual BOOL OnInitDialog();
  504. virtual void OnOK();
  505. virtual void OnCancel();
  506. afx_msg void OnRadioNotifyOff() { SyncUIRadioHelper(IDC_CHECK_AUTO_NOTIFY);}
  507. afx_msg void OnRadioNotifyAll() { SyncUIRadioHelper(IDC_RADIO_NOTIFY_ALL);}
  508. afx_msg void OnRadioNotifyList() { SyncUIRadioHelper(IDC_RADIO_NOTIFY_LIST);}
  509. DECLARE_MESSAGE_MAP()
  510. private:
  511. void SyncUIRadioHelper(UINT nRadio);
  512. int SetRadioState(DWORD fNotifyFlag);
  513. DWORD GetRadioState();
  514. CDNSZone_ZoneTransferPropertyPage* m_pPage;
  515. BOOL m_bSecondaryZone;
  516. class CDNSNotifyIPEditor : public CIPEditor
  517. {
  518. public:
  519. CDNSNotifyIPEditor() : CIPEditor(TRUE) {} // no up/down buttons
  520. virtual void OnChangeData();
  521. };
  522. CDNSNotifyIPEditor m_notifyListEditor;
  523. friend class CDNSNotifyIPEditor;
  524. CComponentDataObject* m_pComponentData;
  525. };
  526. BEGIN_MESSAGE_MAP(CDNSZoneNotifyDialog, CHelpDialog)
  527. ON_BN_CLICKED(IDC_CHECK_AUTO_NOTIFY, OnRadioNotifyOff)
  528. ON_BN_CLICKED(IDC_RADIO_NOTIFY_ALL, OnRadioNotifyAll)
  529. ON_BN_CLICKED(IDC_RADIO_NOTIFY_LIST, OnRadioNotifyList)
  530. END_MESSAGE_MAP()
  531. void CDNSZoneNotifyDialog::CDNSNotifyIPEditor::OnChangeData()
  532. {
  533. CWnd* pWnd = GetParentWnd();
  534. pWnd->GetDlgItem(IDOK)->EnableWindow(TRUE); // it is dirty now
  535. }
  536. CDNSZoneNotifyDialog::CDNSZoneNotifyDialog(CDNSZone_ZoneTransferPropertyPage* pPage,
  537. BOOL bSecondaryZone,
  538. CComponentDataObject* pComponentData)
  539. : CHelpDialog(IDD_ZONE_NOTIFY_SUBDIALOG, pComponentData)
  540. {
  541. m_pPage = pPage;
  542. m_bSecondaryZone = bSecondaryZone;
  543. m_pComponentData = pComponentData;
  544. }
  545. BOOL CDNSZoneNotifyDialog::OnInitDialog()
  546. {
  547. CHelpDialog::OnInitDialog();
  548. m_pPage->GetHolder()->PushDialogHWnd(GetSafeHwnd());
  549. VERIFY(m_notifyListEditor.Initialize(this,
  550. this,
  551. IDC_BUTTON_UP,
  552. IDC_BUTTON_DOWN,
  553. IDC_BUTTON_ADD,
  554. IDC_BUTTON_REMOVE,
  555. IDC_IPEDIT,
  556. IDC_LIST));
  557. if (m_bSecondaryZone)
  558. {
  559. ASSERT(m_pPage->m_fNotifyLevel != ZONE_NOTIFY_ALL);
  560. GetDlgItem(IDC_RADIO_NOTIFY_ALL)->EnableWindow(FALSE);
  561. }
  562. // read the state and set the UI
  563. if ( (ZONE_NOTIFY_LIST == m_pPage->m_fNotifyLevel) && (m_pPage->m_cNotify > 0) )
  564. {
  565. m_notifyListEditor.AddAddresses(m_pPage->m_aipNotify, m_pPage->m_cNotify);
  566. }
  567. SyncUIRadioHelper(SetRadioState(m_pPage->m_fNotifyLevel));
  568. GetDlgItem(IDOK)->EnableWindow(FALSE); // not dirty
  569. BOOL bListState = ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->GetCheck();
  570. BOOL bAllState = ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_ALL))->GetCheck();
  571. if (!bAllState && !bListState)
  572. {
  573. ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->SetCheck(TRUE);
  574. }
  575. return TRUE;
  576. }
  577. void CDNSZoneNotifyDialog::OnCancel()
  578. {
  579. if (m_pPage->GetHolder() != NULL)
  580. m_pPage->GetHolder()->PopDialogHWnd();
  581. CHelpDialog::OnCancel();
  582. }
  583. void CDNSZoneNotifyDialog::OnOK()
  584. {
  585. // read the data back to the main page storage
  586. m_pPage->m_fNotifyLevel = GetRadioState();
  587. m_pPage->m_cNotify = 0;
  588. if (m_pPage->m_aipNotify != NULL)
  589. {
  590. free(m_pPage->m_aipNotify);
  591. m_pPage->m_aipNotify = NULL;
  592. }
  593. if (m_pPage->m_fNotifyLevel == ZONE_NOTIFY_LIST)
  594. {
  595. m_pPage->m_cNotify = m_notifyListEditor.GetCount();
  596. if (m_pPage->m_cNotify > 0)
  597. {
  598. m_pPage->m_aipNotify = (DWORD*) malloc(sizeof(DWORD)*m_pPage->m_cNotify);
  599. int nFilled = 0;
  600. if (m_pPage->m_aipNotify != NULL)
  601. {
  602. m_notifyListEditor.GetAddresses(m_pPage->m_aipNotify, m_pPage->m_cNotify, &nFilled);
  603. }
  604. ASSERT(nFilled == (int)m_pPage->m_cNotify);
  605. }
  606. }
  607. // dismiss dialog, all cool
  608. if (m_pPage->GetHolder())
  609. m_pPage->GetHolder()->PopDialogHWnd();
  610. CHelpDialog::OnOK();
  611. }
  612. void CDNSZoneNotifyDialog::SyncUIRadioHelper(UINT nRadio)
  613. {
  614. m_notifyListEditor.EnableUI(IDC_RADIO_NOTIFY_LIST == nRadio, TRUE);
  615. // if (IDC_RADIO_NOTIFY_LIST != nRadio)
  616. // m_notifyListEditor.Clear();
  617. GetDlgItem(IDOK)->EnableWindow(TRUE); // dirty
  618. if (IDC_CHECK_AUTO_NOTIFY == nRadio)
  619. {
  620. BOOL bState = ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->GetCheck();
  621. ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->EnableWindow(bState);
  622. ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_ALL))->EnableWindow(bState);
  623. BOOL bRadioState = ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->GetCheck();
  624. m_notifyListEditor.EnableUI(bRadioState && bState, TRUE);
  625. }
  626. }
  627. int CDNSZoneNotifyDialog::SetRadioState(DWORD fNotifyLevel)
  628. {
  629. int nRadio = 0;
  630. switch (fNotifyLevel)
  631. {
  632. case ZONE_NOTIFY_OFF:
  633. nRadio = IDC_CHECK_AUTO_NOTIFY;
  634. ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->SetCheck(FALSE);
  635. break;
  636. case ZONE_NOTIFY_LIST:
  637. nRadio = IDC_RADIO_NOTIFY_LIST;
  638. ((CButton*)GetDlgItem(nRadio))->SetCheck(TRUE);
  639. ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->SetCheck(TRUE);
  640. break;
  641. case ZONE_NOTIFY_ALL:
  642. nRadio = IDC_RADIO_NOTIFY_ALL;
  643. ((CButton*)GetDlgItem(nRadio))->SetCheck(TRUE);
  644. ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->SetCheck(TRUE);
  645. break;
  646. }
  647. ASSERT(nRadio != 0);
  648. return nRadio;
  649. }
  650. DWORD CDNSZoneNotifyDialog::GetRadioState()
  651. {
  652. static int nRadioArr[] =
  653. {
  654. IDC_RADIO_NOTIFY_OFF,
  655. IDC_RADIO_NOTIFY_LIST,
  656. IDC_RADIO_NOTIFY_ALL
  657. };
  658. int nRadio = 0;
  659. if (!((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->GetCheck())
  660. {
  661. nRadio = IDC_CHECK_AUTO_NOTIFY;
  662. }
  663. else
  664. {
  665. if (((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->GetCheck())
  666. {
  667. nRadio = IDC_RADIO_NOTIFY_LIST;
  668. }
  669. else if (((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_ALL))->GetCheck())
  670. {
  671. nRadio = IDC_RADIO_NOTIFY_ALL;
  672. }
  673. }
  674. // int nRadio = ::GetCheckedRadioButtonHelper(m_hWnd, 3, nRadioArr, IDC_RADIO_NOTIFY_OFF);
  675. ASSERT(nRadio != 0);
  676. DWORD fNotifyLevel = (DWORD)-1;
  677. switch (nRadio)
  678. {
  679. case IDC_CHECK_AUTO_NOTIFY:
  680. fNotifyLevel = ZONE_NOTIFY_OFF;
  681. break;
  682. case IDC_RADIO_NOTIFY_LIST:
  683. fNotifyLevel = ZONE_NOTIFY_LIST;
  684. break;
  685. case IDC_RADIO_NOTIFY_ALL:
  686. fNotifyLevel = ZONE_NOTIFY_ALL;
  687. break;
  688. }
  689. ASSERT(fNotifyLevel != (DWORD)-1);
  690. return fNotifyLevel;
  691. }
  692. ///////////////////////////////////////////////////////////////////////////////
  693. // CDNSZone_GeneralPropertyPage
  694. //
  695. // defines for the status text string positions (matching the RC file)
  696. //
  697. #define N_ZONE_STATES 3
  698. #define N_ZONE_STATUS_RUNNING 0
  699. #define N_ZONE_STATUS_PAUSED 1
  700. #define N_ZONE_STATUS_EXPIRED 2
  701. #define N_ZONE_TYPES 4
  702. #define N_ZONE_TYPES_PRIMARY 0
  703. #define N_ZONE_TYPES_DS_PRIMARY 1
  704. #define N_ZONE_TYPES_SECONDARY 2
  705. #define N_ZONE_TYPES_STUB 3
  706. void CDNSZone_GeneralIPEditor::OnChangeData()
  707. {
  708. if (m_bNoUpdateNow)
  709. {
  710. return;
  711. }
  712. ((CDNSZone_GeneralPropertyPage*)GetParentWnd())->OnChangeIPEditorData();
  713. }
  714. void CDNSZone_GeneralIPEditor::FindMastersNames()
  715. {
  716. m_bNoUpdateNow = TRUE;
  717. FindNames();
  718. m_bNoUpdateNow = FALSE;
  719. }
  720. BEGIN_MESSAGE_MAP(CDNSZone_GeneralPropertyPage, CPropertyPageBase)
  721. ON_BN_CLICKED(IDC_CHANGE_TYPE_BUTTON, OnChangeTypeButton)
  722. #ifdef USE_NDNC
  723. ON_BN_CLICKED(IDC_CHANGE_REPL_BUTTON, OnChangeReplButton)
  724. #endif // USE_NDNC
  725. ON_BN_CLICKED(IDC_PAUSE_START_BUTTON, OnPauseStartButton)
  726. ON_EN_CHANGE(IDC_FILE_NAME_EDIT, OnChangePrimaryFileNameEdit)
  727. ON_CBN_SELCHANGE(IDC_PRIMARY_DYN_UPD_COMBO, OnChangePrimaryDynamicUpdateCombo)
  728. ON_BN_CLICKED(IDC_BROWSE_MASTERS_BUTTON, OnBrowseMasters)
  729. ON_BN_CLICKED(IDC_FIND_MASTERS_NAMES_BUTTON, OnFindMastersNames)
  730. ON_BN_CLICKED(IDC_AGING_BUTTON, OnAging)
  731. ON_BN_CLICKED(IDC_LOCAL_LIST_CHECK, OnLocalCheck)
  732. END_MESSAGE_MAP()
  733. CDNSZone_GeneralPropertyPage::CDNSZone_GeneralPropertyPage()
  734. : CPropertyPageBase(CDNSZone_GeneralPropertyPage::IDD),
  735. m_statusHelper(N_ZONE_STATES), m_typeStaticHelper(N_ZONE_TYPES)
  736. {
  737. // actual values will be set when loading UI data
  738. m_bIsPrimary = TRUE;
  739. m_bIsPaused = FALSE;
  740. m_bIsExpired = FALSE;
  741. m_bDSIntegrated = FALSE;
  742. m_bIsStub = FALSE;
  743. m_bServerADSEnabled = FALSE;
  744. m_bScavengingEnabled = FALSE;
  745. m_dwRefreshInterval = 0;
  746. m_dwNoRefreshInterval = 0;
  747. m_nAllowsDynamicUpdate = ZONE_UPDATE_OFF;
  748. m_bDiscardUIState = FALSE;
  749. m_bDiscardUIStateShowMessage = FALSE;
  750. #ifdef USE_NDNC
  751. m_replType = none;
  752. #endif // USE_NDNC
  753. }
  754. void CDNSZone_GeneralPropertyPage::OnChangeIPEditorData()
  755. {
  756. ASSERT(!m_bIsPrimary);
  757. SetDirty(TRUE);
  758. GetFindMastersNamesButton()->EnableWindow(m_mastersEditor.GetCount()>0);
  759. }
  760. BOOL CDNSZone_GeneralPropertyPage::OnPropertyChange(BOOL, long*)
  761. {
  762. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  763. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  764. // need to apply the pause/start zone command ?
  765. BOOL bWasPaused = pZoneNode->IsPaused();
  766. if (bWasPaused != m_bIsPaused)
  767. {
  768. DNS_STATUS err = pZoneNode->TogglePauseHelper(pHolder->GetComponentData());
  769. if (err != 0)
  770. pHolder->SetError(err);
  771. }
  772. return TRUE;
  773. }
  774. void CDNSZone_GeneralPropertyPage::SetUIData()
  775. {
  776. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  777. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  778. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  779. //
  780. // get zone type
  781. //
  782. DWORD dwZoneType = pZoneNode->GetZoneType();
  783. ASSERT((dwZoneType == DNS_ZONE_TYPE_PRIMARY) ||
  784. (dwZoneType == DNS_ZONE_TYPE_SECONDARY)||
  785. (dwZoneType == DNS_ZONE_TYPE_STUB));
  786. m_bIsPrimary = (dwZoneType == DNS_ZONE_TYPE_PRIMARY);
  787. m_bIsStub = (dwZoneType == DNS_ZONE_TYPE_STUB);
  788. m_bDSIntegrated = pZoneNode->IsDSIntegrated();
  789. m_bIsPaused = pZoneNode->IsPaused();
  790. m_bIsExpired = pZoneNode->IsExpired();
  791. m_bScavengingEnabled = pZoneNode->IsScavengingEnabled();
  792. m_dwRefreshInterval = pZoneNode->GetAgingRefreshInterval();
  793. m_dwNoRefreshInterval = pZoneNode->GetAgingNoRefreshInterval();
  794. m_dwScavengingStart = pZoneNode->GetScavengingStart();
  795. #ifdef USE_NDNC
  796. m_replType = pZoneNode->GetDirectoryPartitionFlagsAsReplType();
  797. m_szCustomScope = pZoneNode->GetCustomPartitionName();
  798. //
  799. // Enable the replication scope button only for AD integrated zones
  800. //
  801. if (m_bDSIntegrated &&
  802. (DNS_SRV_BUILD_NUMBER(pServerNode->GetVersion()) >= DNS_SRV_BUILD_NUMBER_WHISTLER &&
  803. (DNS_SRV_MAJOR_VERSION(pServerNode->GetVersion()) > DNS_SRV_MAJOR_VERSION_NT_5 ||
  804. DNS_SRV_MINOR_VERSION(pServerNode->GetVersion()) >= DNS_SRV_MINOR_VERSION_WHISTLER)))
  805. {
  806. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(TRUE);
  807. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(TRUE);
  808. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(TRUE);
  809. }
  810. else
  811. {
  812. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(FALSE);
  813. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(FALSE);
  814. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(FALSE);
  815. }
  816. #endif // USE_NDNC
  817. //
  818. // change the controls to the zone type
  819. //
  820. ChangeUIControls();
  821. USES_CONVERSION;
  822. //
  823. // set the file name control
  824. //
  825. CString szZoneStorage;
  826. szZoneStorage = UTF8_TO_W(pZoneNode->GetDataFile());
  827. if (m_bIsPrimary)
  828. {
  829. m_nAllowsDynamicUpdate = pZoneNode->GetDynamicUpdate();
  830. }
  831. else // secondary
  832. {
  833. DWORD cAddrCount;
  834. PIP_ADDRESS pipMasters;
  835. if (m_bIsStub)
  836. {
  837. pZoneNode->GetLocalListOfMasters(&cAddrCount, &pipMasters);
  838. if (cAddrCount > 0 && pipMasters != NULL)
  839. {
  840. m_mastersEditor.AddAddresses(pipMasters, cAddrCount);
  841. SendDlgItemMessage(IDC_LOCAL_LIST_CHECK, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  842. }
  843. else
  844. {
  845. pZoneNode->GetMastersInfo(&cAddrCount, &pipMasters);
  846. if (cAddrCount > 0)
  847. {
  848. m_mastersEditor.AddAddresses(pipMasters, cAddrCount);
  849. }
  850. SendDlgItemMessage(IDC_LOCAL_LIST_CHECK, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  851. }
  852. }
  853. else
  854. {
  855. pZoneNode->GetMastersInfo(&cAddrCount, &pipMasters);
  856. if (cAddrCount > 0)
  857. {
  858. m_mastersEditor.AddAddresses(pipMasters, cAddrCount);
  859. }
  860. }
  861. }
  862. if (m_bDSIntegrated && !m_bIsStub)
  863. {
  864. GetDlgItem(IDC_AGING_STATIC)->EnableWindow(TRUE);
  865. GetDlgItem(IDC_AGING_STATIC)->ShowWindow(TRUE);
  866. GetDlgItem(IDC_AGING_BUTTON)->EnableWindow(TRUE);
  867. GetDlgItem(IDC_AGING_BUTTON)->ShowWindow(TRUE);
  868. }
  869. //
  870. // we set also the database name of the "other" zone type, just
  871. // in case the user promotes or demotes
  872. //
  873. GetFileNameEdit()->SetWindowText(szZoneStorage);
  874. SetPrimaryDynamicUpdateComboVal(m_nAllowsDynamicUpdate);
  875. if (m_bIsExpired)
  876. {
  877. //
  878. // hide the start/stop button
  879. //
  880. CButton* pBtn = GetPauseStartButton();
  881. pBtn->ShowWindow(FALSE);
  882. pBtn->EnableWindow(FALSE);
  883. //
  884. // change the text to "expired"
  885. //
  886. m_statusHelper.SetStateX(N_ZONE_STATUS_EXPIRED);
  887. }
  888. else
  889. {
  890. m_statusHelper.SetStateX(m_bIsPaused ? N_ZONE_STATUS_PAUSED : N_ZONE_STATUS_RUNNING);
  891. m_pauseStartHelper.SetToggleState(!m_bIsPaused);
  892. }
  893. }
  894. #define PRIMARY_DYN_UPD_COMBO_ITEM_COUNT 3
  895. void _MoveChildWindowY(CWnd* pChild, CWnd* pParent, int nY)
  896. {
  897. CRect r;
  898. pChild->GetWindowRect(r);
  899. pParent->ScreenToClient(r);
  900. int nDy = r.bottom - r.top;
  901. r.top = nY;
  902. r.bottom = nY + nDy;
  903. pChild->MoveWindow(r, TRUE);
  904. }
  905. BOOL CDNSZone_GeneralPropertyPage::OnInitDialog()
  906. {
  907. CPropertyPageBase::OnInitDialog();
  908. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  909. m_bServerADSEnabled = pHolder->GetZoneNode()->GetServerNode()->CanUseADS();
  910. VERIFY(m_mastersEditor.Initialize(this,
  911. GetParent(),
  912. IDC_MASTERS_BUTTON_UP,
  913. IDC_MASTERS_BUTTON_DOWN,
  914. IDC_MASTERS_BUTTON_ADD,
  915. IDC_MASTERS_BUTTON_REMOVE,
  916. IDC_MASTERS_IPEDIT,
  917. IDC_MASTERS_IP_LIST));
  918. UINT pnButtonStringIDs[2] = { IDS_BUTTON_TEXT_PAUSE_BUTTON, IDS_BUTTON_TEXT_START_BUTTON };
  919. VERIFY(m_pauseStartHelper.Init(this, IDC_PAUSE_START_BUTTON, pnButtonStringIDs));
  920. VERIFY(m_typeStaticHelper.Init(this, IDC_TYPE_STATIC));
  921. VERIFY(m_statusHelper.Init(this, IDC_STATUS_STATIC));
  922. VERIFY(m_zoneStorageStaticHelper.Init(this, IDC_STORAGE_STATIC));
  923. SendDlgItemMessage(IDC_FILE_NAME_EDIT, EM_SETLIMITTEXT, (WPARAM)_MAX_FNAME, 0);
  924. // initial positioning (in the resource these controls are at the bottom of the screen)
  925. // move relative the file name exit box
  926. CRect fileNameEditRect;
  927. GetDlgItem(IDC_FILE_NAME_EDIT)->GetWindowRect(fileNameEditRect);
  928. ScreenToClient(fileNameEditRect);
  929. // move below the edit box, with with separation equal of 6 (DBU)
  930. // height of the edit box.
  931. int nYPos = fileNameEditRect.bottom + 6;
  932. CComboBox* pDynamicUpdateCombo = GetPrimaryDynamicUpdateCombo();
  933. // The static control needs to be 2 lower
  934. _MoveChildWindowY(GetPrimaryDynamicUpdateStatic(), this, nYPos + 2);
  935. _MoveChildWindowY(pDynamicUpdateCombo, this, nYPos);
  936. // initialize the state of the page
  937. SetUIData();
  938. #ifdef USE_NDNC
  939. SetTextForReplicationScope();
  940. #endif
  941. SetDirty(FALSE);
  942. return TRUE; // return TRUE unless you set the focus to a control
  943. // EXCEPTION: OCX Property Pages should return FALSE
  944. }
  945. BOOL CDNSZone_GeneralPropertyPage::OnApply()
  946. {
  947. if (m_bDiscardUIState)
  948. {
  949. // if we get called from other pages, we have to make them fail
  950. if (m_bDiscardUIStateShowMessage)
  951. {
  952. DNSMessageBox(IDS_ZONE_LOADED_FROM_DS_WARNING);
  953. m_bDiscardUIStateShowMessage = FALSE;
  954. }
  955. return FALSE;
  956. }
  957. if (!IsDirty())
  958. return TRUE;
  959. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  960. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  961. //
  962. // changed from primary to secondary or vice versa?
  963. //
  964. DWORD dwZoneType = pZoneNode->GetZoneType();
  965. ASSERT((dwZoneType == DNS_ZONE_TYPE_PRIMARY) ||
  966. (dwZoneType == DNS_ZONE_TYPE_SECONDARY)||
  967. (dwZoneType == DNS_ZONE_TYPE_STUB));
  968. BOOL bWasPrimary = (dwZoneType == DNS_ZONE_TYPE_PRIMARY);
  969. DNS_STATUS dwErr = 0;
  970. USES_CONVERSION;
  971. CString szDataStorageName;
  972. GetStorageName(szDataStorageName);
  973. DWORD dwLoadOptions;
  974. if (m_bIsPrimary)
  975. {
  976. dwLoadOptions = 0x0;
  977. PWSTR pszZoneFile = UTF8_TO_W(pZoneNode->GetDataFile());
  978. //
  979. // Check to see if this was primary before if so only submit changes if the storage changed
  980. //
  981. if (!bWasPrimary ||
  982. (bWasPrimary &&
  983. ((pZoneNode->IsDSIntegrated() && !m_bDSIntegrated) ||
  984. (!pZoneNode->IsDSIntegrated() && m_bDSIntegrated))) ||
  985. (pszZoneFile && szDataStorageName.CompareNoCase(pszZoneFile)))
  986. {
  987. dwErr = pZoneNode->SetPrimary(dwLoadOptions, m_bDSIntegrated, szDataStorageName);
  988. if (m_bDSIntegrated && (dwErr == DNS_ERROR_DS_ZONE_ALREADY_EXISTS))
  989. {
  990. FIX_THREAD_STATE_MFC_BUG();
  991. CDNSZoneChangeTypeDataConflict dlg(pHolder);
  992. //
  993. // if the zone was a primary, use in memory data
  994. // otherwise, use DS data
  995. //
  996. dlg.m_bUseDsData = bWasPrimary ? FALSE : TRUE;
  997. if (IDOK == dlg.DoModal())
  998. {
  999. //
  1000. // try again, getting options from dialog
  1001. //
  1002. dwLoadOptions = dlg.m_bUseDsData ? DNS_ZONE_LOAD_OVERWRITE_MEMORY : DNS_ZONE_LOAD_OVERWRITE_DS;
  1003. dwErr = pZoneNode->SetPrimary(dwLoadOptions, m_bDSIntegrated, szDataStorageName);
  1004. if ((dwErr == 0) && dlg.m_bUseDsData)
  1005. {
  1006. //
  1007. // we loaded from the DS, we will have to discard all the other
  1008. // changes the user has made.
  1009. //
  1010. m_bDiscardUIState = TRUE;
  1011. //
  1012. // tell the user to bail out
  1013. //
  1014. m_bDiscardUIStateShowMessage = FALSE;
  1015. DNSMessageBox(IDS_ZONE_LOADED_FROM_DS_WARNING);
  1016. SetDirty(FALSE);
  1017. return TRUE;
  1018. }
  1019. }
  1020. else
  1021. {
  1022. //
  1023. // user canceled the operation, just stop here
  1024. //
  1025. return FALSE;
  1026. }
  1027. }
  1028. }
  1029. if (dwErr == 0)
  1030. {
  1031. // update dynamic update flag, if changed
  1032. m_nAllowsDynamicUpdate = GetPrimaryDynamicUpdateComboVal();
  1033. UINT nWasDynamicUpdate = pZoneNode->GetDynamicUpdate();
  1034. if ( (dwErr == 0) && (m_nAllowsDynamicUpdate != nWasDynamicUpdate) )
  1035. {
  1036. dwErr = pZoneNode->SetDynamicUpdate(m_nAllowsDynamicUpdate);
  1037. if (dwErr != 0)
  1038. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_DYN_UPD);
  1039. }
  1040. }
  1041. else
  1042. {
  1043. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_PRIMARY);
  1044. }
  1045. if (dwErr == 0 && m_bIsPrimary)
  1046. {
  1047. dwErr = pZoneNode->SetAgingNoRefreshInterval(m_dwNoRefreshInterval);
  1048. if (dwErr != 0)
  1049. {
  1050. DNSErrorDialog(dwErr, IDS_MSG_ERROR_NO_REFRESH_INTERVAL);
  1051. return FALSE;
  1052. }
  1053. dwErr = pZoneNode->SetAgingRefreshInterval(m_dwRefreshInterval);
  1054. if (dwErr != 0)
  1055. {
  1056. DNSErrorDialog(dwErr, IDS_MSG_ERROR_REFRESH_INTERVAL);
  1057. return FALSE;
  1058. }
  1059. dwErr = pZoneNode->SetScavengingEnabled(m_bScavengingEnabled);
  1060. if (dwErr != 0)
  1061. {
  1062. DNSErrorDialog(dwErr, IDS_MSG_ERROR_SCAVENGING_ENABLED);
  1063. return FALSE;
  1064. }
  1065. }
  1066. }
  1067. else // it is a secondary or stub
  1068. {
  1069. //
  1070. // get data from the IP editor
  1071. //
  1072. DWORD cAddrCount = m_mastersEditor.GetCount();
  1073. DWORD* pArr = (cAddrCount > 0) ? (DWORD*) malloc(sizeof(DWORD)*cAddrCount) : NULL;
  1074. if (cAddrCount > 0)
  1075. {
  1076. int nFilled = 0;
  1077. m_mastersEditor.GetAddresses(pArr, cAddrCount, &nFilled);
  1078. ASSERT(nFilled == (int)cAddrCount);
  1079. }
  1080. dwLoadOptions = 0x0;
  1081. if (m_bIsStub)
  1082. {
  1083. LRESULT lLocalListOfMasters = SendDlgItemMessage(IDC_LOCAL_LIST_CHECK, BM_GETCHECK, 0, 0);
  1084. BOOL bLocalListOfMasters = (lLocalListOfMasters == BST_CHECKED);
  1085. dwErr = pZoneNode->SetStub(cAddrCount,
  1086. pArr,
  1087. dwLoadOptions,
  1088. m_bDSIntegrated,
  1089. szDataStorageName,
  1090. bLocalListOfMasters);
  1091. if (dwErr != 0)
  1092. {
  1093. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_STUB);
  1094. }
  1095. }
  1096. else
  1097. {
  1098. dwErr = pZoneNode->SetSecondary(cAddrCount, pArr, dwLoadOptions, szDataStorageName);
  1099. if (dwErr != 0)
  1100. {
  1101. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_SECONDARY);
  1102. }
  1103. }
  1104. if (pArr)
  1105. {
  1106. free(pArr);
  1107. pArr = 0;
  1108. }
  1109. }
  1110. #ifdef USE_NDNC
  1111. if ((m_replType != pZoneNode->GetDirectoryPartitionFlagsAsReplType() ||
  1112. _wcsicmp(m_szCustomScope, pZoneNode->GetCustomPartitionName()) != 0) &&
  1113. m_bDSIntegrated)
  1114. {
  1115. dwErr = pZoneNode->ChangeDirectoryPartitionType(m_replType, m_szCustomScope);
  1116. if (dwErr != 0)
  1117. {
  1118. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_REPLTYPE);
  1119. }
  1120. }
  1121. #endif
  1122. // if promoted or demoted, have to change icon
  1123. // if paused/started, have to apply the command
  1124. BOOL bWasPaused = pZoneNode->IsPaused();
  1125. DNS_STATUS dwPauseStopErr = 0;
  1126. if ((bWasPrimary != m_bIsPrimary) || (bWasPaused != m_bIsPaused))
  1127. {
  1128. dwPauseStopErr = pHolder->NotifyConsole(this);
  1129. if (dwPauseStopErr != 0)
  1130. {
  1131. if (m_bIsPaused)
  1132. DNSErrorDialog(dwPauseStopErr, IDS_ERROR_ZONE_PAUSE);
  1133. else
  1134. DNSErrorDialog(dwPauseStopErr, IDS_ERROR_ZONE_START);
  1135. }
  1136. }
  1137. if ( (dwErr != 0) || (dwPauseStopErr != 0) )
  1138. return FALSE; // something went wrong, already got error messages
  1139. SetDirty(FALSE);
  1140. return TRUE;
  1141. }
  1142. void CDNSZone_GeneralPropertyPage::OnAging()
  1143. {
  1144. CDNSZonePropertyPageHolder* pHolder =
  1145. (CDNSZonePropertyPageHolder*)GetHolder();
  1146. CDNSZone_AgingDialog dlg(pHolder, IDD_ZONE_AGING_DIALOG, pHolder->GetComponentData());
  1147. dlg.m_dwRefreshInterval = m_dwRefreshInterval;
  1148. dlg.m_dwNoRefreshInterval = m_dwNoRefreshInterval;
  1149. dlg.m_dwScavengingStart = m_dwScavengingStart;
  1150. dlg.m_fScavengingEnabled = m_bScavengingEnabled;
  1151. dlg.m_bAdvancedView = pHolder->IsAdvancedView();
  1152. if (IDCANCEL == dlg.DoModal())
  1153. {
  1154. return;
  1155. }
  1156. m_dwRefreshInterval = dlg.m_dwRefreshInterval;
  1157. m_dwNoRefreshInterval = dlg.m_dwNoRefreshInterval;
  1158. m_bScavengingEnabled = dlg.m_fScavengingEnabled;
  1159. SetDirty(TRUE);
  1160. }
  1161. void CDNSZone_GeneralPropertyPage::OnLocalCheck()
  1162. {
  1163. SetDirty(TRUE);
  1164. }
  1165. #ifdef USE_NDNC
  1166. void CDNSZone_GeneralPropertyPage::OnChangeReplButton()
  1167. {
  1168. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1169. FIX_THREAD_STATE_MFC_BUG();
  1170. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1171. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1172. CDNSZoneChangeReplicationScopeDialog dlg(GetHolder(),
  1173. m_replType,
  1174. m_szCustomScope,
  1175. pZoneNode->GetServerNode()->GetVersion());
  1176. if (IDCANCEL == dlg.DoModal())
  1177. {
  1178. return;
  1179. }
  1180. BOOL bDirty = (m_replType != dlg.m_newReplType) ||
  1181. (m_szCustomScope != dlg.m_szCustomScope);
  1182. if (!bDirty)
  1183. {
  1184. return;
  1185. }
  1186. m_replType = dlg.m_newReplType;
  1187. m_szCustomScope = dlg.m_szCustomScope;
  1188. SetTextForReplicationScope();
  1189. SetDirty(TRUE);
  1190. }
  1191. void CDNSZone_GeneralPropertyPage::SetTextForReplicationScope()
  1192. {
  1193. UINT nStringID = 0;
  1194. CString szReplText;
  1195. if (m_bDSIntegrated)
  1196. {
  1197. switch(m_replType)
  1198. {
  1199. case domain :
  1200. nStringID = IDS_ZONE_REPLICATION_DOMAIN_TEXT;
  1201. break;
  1202. case forest :
  1203. nStringID = IDS_ZONE_REPLICATION_FOREST_TEXT;
  1204. break;
  1205. case custom :
  1206. nStringID = IDS_ZONE_REPLICATION_CUSTOM_TEXT;
  1207. break;
  1208. default :
  1209. nStringID = IDS_ZONE_REPLICATION_W2K_TEXT;
  1210. break;
  1211. }
  1212. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(TRUE);
  1213. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(TRUE);
  1214. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(TRUE);
  1215. }
  1216. else
  1217. {
  1218. nStringID = IDS_ZONE_REPLICATION_NONDS_TEXT;
  1219. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(FALSE);
  1220. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(FALSE);
  1221. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(FALSE);
  1222. }
  1223. szReplText.LoadString(nStringID);
  1224. SetDlgItemText(IDC_REPLICATION_STATIC, szReplText);
  1225. }
  1226. #endif // USE_NDNC
  1227. void CDNSZone_GeneralPropertyPage::OnChangeTypeButton()
  1228. {
  1229. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1230. FIX_THREAD_STATE_MFC_BUG();
  1231. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1232. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1233. CDNSZoneChangeTypeDialog dlg(GetHolder(),
  1234. m_bServerADSEnabled,
  1235. pZoneNode->GetServerNode()->GetVersion());
  1236. dlg.m_bIsPrimary = m_bIsPrimary;
  1237. dlg.m_bIsStub = m_bIsStub;
  1238. dlg.m_bDSIntegrated = m_bDSIntegrated;
  1239. if (IDCANCEL == dlg.DoModal())
  1240. {
  1241. return;
  1242. }
  1243. BOOL bDirty = (m_bIsPrimary != dlg.m_bIsPrimary) ||
  1244. (m_bDSIntegrated != dlg.m_bDSIntegrated) ||
  1245. (m_bIsStub != dlg.m_bIsStub);
  1246. if (!bDirty)
  1247. {
  1248. return;
  1249. }
  1250. CString szZoneStorage;
  1251. GetFileNameEdit()->GetWindowText(szZoneStorage);
  1252. if (dlg.m_bDSIntegrated == FALSE &&
  1253. m_bDSIntegrated == TRUE &&
  1254. szZoneStorage.IsEmpty())
  1255. {
  1256. //
  1257. // we have no file name, synthesize one
  1258. //
  1259. CString szZoneName = pZoneNode->GetDisplayName();
  1260. int nLen = szZoneName.GetLength();
  1261. if (nLen == 0)
  1262. {
  1263. szZoneStorage.Empty();
  1264. }
  1265. else if (nLen == 1 && szZoneName[0] == TEXT('.'))
  1266. {
  1267. szZoneStorage = _T("root.dns");
  1268. }
  1269. else
  1270. {
  1271. LPCTSTR lpszFmt = ( TEXT('.') == szZoneName.GetAt(nLen-1))
  1272. ? _T("%sdns") : _T("%s.dns");
  1273. szZoneStorage.Format(lpszFmt, (LPCTSTR)szZoneName);
  1274. }
  1275. GetFileNameEdit()->SetWindowText(szZoneStorage);
  1276. }
  1277. m_bIsPrimary = dlg.m_bIsPrimary;
  1278. m_bDSIntegrated = dlg.m_bDSIntegrated;
  1279. m_bIsStub = dlg.m_bIsStub;
  1280. SetDirty(TRUE);
  1281. ChangeUIControls();
  1282. #ifdef USE_NDNC
  1283. SetTextForReplicationScope();
  1284. #endif
  1285. }
  1286. void CDNSZone_GeneralPropertyPage::OnPauseStartButton()
  1287. {
  1288. ASSERT(!m_bIsExpired); // the button should not be enabled
  1289. SetDirty(TRUE);
  1290. m_bIsPaused = !m_bIsPaused;
  1291. m_pauseStartHelper.SetToggleState(!m_bIsPaused);
  1292. m_statusHelper.SetStateX(m_bIsPaused ? N_ZONE_STATUS_PAUSED : N_ZONE_STATUS_RUNNING);
  1293. }
  1294. void CDNSZone_GeneralPropertyPage::OnBrowseMasters()
  1295. {
  1296. ASSERT(!m_bIsPrimary);
  1297. CDNSZonePropertyPageHolder* pZoneHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1298. if (!m_mastersEditor.BrowseFromDNSNamespace(pZoneHolder->GetComponentData(),
  1299. pZoneHolder,
  1300. TRUE,
  1301. pZoneHolder->GetZoneNode()->GetServerNode()->GetDisplayName()))
  1302. {
  1303. DNSMessageBox(IDS_MSG_ZONE_MASTERS_BROWSE_FAIL);
  1304. }
  1305. }
  1306. void CDNSZone_GeneralPropertyPage::OnFindMastersNames()
  1307. {
  1308. m_mastersEditor.FindMastersNames();
  1309. }
  1310. void CDNSZone_GeneralPropertyPage::SetPrimaryDynamicUpdateComboVal(UINT nAllowsDynamicUpdate)
  1311. {
  1312. int nIndex = 0;
  1313. switch (nAllowsDynamicUpdate)
  1314. {
  1315. case ZONE_UPDATE_OFF:
  1316. nIndex = 0;
  1317. break;
  1318. case ZONE_UPDATE_UNSECURE:
  1319. nIndex = 1;
  1320. break;
  1321. case ZONE_UPDATE_SECURE:
  1322. nIndex = 2;
  1323. break;
  1324. default:
  1325. ASSERT(FALSE);
  1326. }
  1327. VERIFY(CB_ERR != GetPrimaryDynamicUpdateCombo()->SetCurSel(nIndex));
  1328. }
  1329. UINT CDNSZone_GeneralPropertyPage::GetPrimaryDynamicUpdateComboVal()
  1330. {
  1331. int nIndex = GetPrimaryDynamicUpdateCombo()->GetCurSel();
  1332. ASSERT(nIndex != CB_ERR);
  1333. UINT nVal = 0;
  1334. switch (nIndex)
  1335. {
  1336. case 0:
  1337. nVal = ZONE_UPDATE_OFF;
  1338. break;
  1339. case 1:
  1340. nVal = ZONE_UPDATE_UNSECURE;
  1341. break;
  1342. case 2:
  1343. nVal = ZONE_UPDATE_SECURE;
  1344. break;
  1345. default:
  1346. ASSERT(FALSE);
  1347. }
  1348. return nVal;
  1349. }
  1350. void CDNSZone_GeneralPropertyPage::ChangeUIControlHelper(CWnd* pChild, BOOL bEnable)
  1351. {
  1352. pChild->EnableWindow(bEnable);
  1353. pChild->ShowWindow(bEnable);
  1354. }
  1355. void CDNSZone_GeneralPropertyPage::ChangeUIControls()
  1356. {
  1357. // change button label
  1358. int nType;
  1359. if (m_bIsPrimary)
  1360. {
  1361. nType = m_bDSIntegrated ? N_ZONE_TYPES_DS_PRIMARY : N_ZONE_TYPES_PRIMARY;
  1362. }
  1363. else
  1364. {
  1365. if (m_bIsStub)
  1366. {
  1367. nType = N_ZONE_TYPES_STUB;
  1368. }
  1369. else
  1370. {
  1371. nType = N_ZONE_TYPES_SECONDARY;
  1372. }
  1373. }
  1374. m_typeStaticHelper.SetStateX(nType);
  1375. //
  1376. // file name controls (show for secondary and for non DS integrated primary and stub)
  1377. //
  1378. BOOL bNotDSIntegrated = (!m_bIsPrimary && !m_bIsStub) ||
  1379. (m_bIsPrimary && !m_bDSIntegrated) ||
  1380. (m_bIsStub && !m_bDSIntegrated);
  1381. m_zoneStorageStaticHelper.SetToggleState(bNotDSIntegrated); // bNotDSIntegrated == bShowEdit
  1382. ChangeUIControlHelper(GetFileNameEdit(), bNotDSIntegrated); // bNotDSIntegrated == bShowEdit
  1383. //
  1384. // change primary zone controls
  1385. CComboBox* pPrimaryDynamicUpdateCombo = GetPrimaryDynamicUpdateCombo();
  1386. //
  1387. // see if the combo box had a selection in it and save it
  1388. //
  1389. UINT nAllowsDynamicUpdateSaved = ZONE_UPDATE_OFF;
  1390. if (pPrimaryDynamicUpdateCombo->GetCurSel() != CB_ERR)
  1391. {
  1392. nAllowsDynamicUpdateSaved = GetPrimaryDynamicUpdateComboVal();
  1393. }
  1394. //
  1395. // set strings in the combo box
  1396. //
  1397. UINT nMaxAddCount = PRIMARY_DYN_UPD_COMBO_ITEM_COUNT;
  1398. //
  1399. // the last item in the combo box would be the "secure dynamic udate"
  1400. // which is valid only for DS integrated primaries
  1401. //
  1402. if (bNotDSIntegrated)
  1403. {
  1404. nMaxAddCount--; // remove the last one
  1405. }
  1406. VERIFY(LoadStringsToComboBox(_Module.GetModuleInstance(),
  1407. pPrimaryDynamicUpdateCombo,
  1408. IDS_ZONE_PRIMARY_DYN_UPD_OPTIONS,
  1409. 256, nMaxAddCount));
  1410. //
  1411. // reset selection
  1412. //
  1413. if (bNotDSIntegrated && (nAllowsDynamicUpdateSaved == ZONE_UPDATE_SECURE))
  1414. {
  1415. //
  1416. // the selected secure update otion is gone, so turn off secure update
  1417. //
  1418. nAllowsDynamicUpdateSaved = ZONE_UPDATE_OFF;
  1419. }
  1420. SetPrimaryDynamicUpdateComboVal(nAllowsDynamicUpdateSaved);
  1421. ChangeUIControlHelper(GetPrimaryDynamicUpdateStatic(), m_bIsPrimary);
  1422. ChangeUIControlHelper(GetPrimaryDynamicUpdateCombo(), m_bIsPrimary);
  1423. //
  1424. // change secondary zone controls
  1425. //
  1426. GetIPLabel()->ShowWindow(!m_bIsPrimary);
  1427. GetIPLabel()->EnableWindow(!m_bIsPrimary);
  1428. m_mastersEditor.ShowUI(!m_bIsPrimary);
  1429. CButton* pBrowseButton = GetMastersBrowseButton();
  1430. pBrowseButton->ShowWindow(!m_bIsPrimary);
  1431. pBrowseButton->EnableWindow(!m_bIsPrimary);
  1432. CButton* pFindMastersNamesButton = GetFindMastersNamesButton();
  1433. pFindMastersNamesButton->ShowWindow(!m_bIsPrimary);
  1434. pFindMastersNamesButton->EnableWindow(!m_bIsPrimary && m_mastersEditor.GetCount()>0);
  1435. GetDlgItem(IDC_LOCAL_LIST_CHECK)->EnableWindow(m_bIsStub && !bNotDSIntegrated);
  1436. GetDlgItem(IDC_LOCAL_LIST_CHECK)->ShowWindow(m_bIsStub && !bNotDSIntegrated);
  1437. GetDlgItem(IDC_AGING_STATIC)->EnableWindow(m_bIsPrimary);
  1438. GetDlgItem(IDC_AGING_STATIC)->ShowWindow(m_bIsPrimary);
  1439. GetDlgItem(IDC_AGING_BUTTON)->EnableWindow(m_bIsPrimary);
  1440. GetDlgItem(IDC_AGING_BUTTON)->ShowWindow(m_bIsPrimary);
  1441. }
  1442. void CDNSZone_GeneralPropertyPage::GetStorageName(CString& szDataStorageName)
  1443. {
  1444. //
  1445. // only for secondary ad for non DS integrated primary)
  1446. //
  1447. GetFileNameEdit()->GetWindowText(szDataStorageName);
  1448. szDataStorageName.TrimLeft();
  1449. szDataStorageName.TrimRight();
  1450. }
  1451. ///////////////////////////////////////////////////////////////////////////////
  1452. // CDNSZone_ZoneTransferPropertyPage
  1453. void CDNSZone_ZoneTransferPropertyPage::CDNSSecondariesIPEditor::OnChangeData()
  1454. {
  1455. CDNSZone_ZoneTransferPropertyPage* pPage = (CDNSZone_ZoneTransferPropertyPage*)GetParentWnd();
  1456. pPage->SetDirty(TRUE);
  1457. }
  1458. BEGIN_MESSAGE_MAP(CDNSZone_ZoneTransferPropertyPage, CPropertyPageBase)
  1459. ON_BN_CLICKED(IDC_CHECK_ALLOW_TRANSFERS, OnRadioSecSecureNone)
  1460. ON_BN_CLICKED(IDC_RADIO_SECSECURE_OFF, OnRadioSecSecureOff)
  1461. ON_BN_CLICKED(IDC_RADIO_SECSECURE_NS, OnRadioSecSecureNS)
  1462. ON_BN_CLICKED(IDC_RADIO_SECSECURE_LIST, OnRadioSecSecureList)
  1463. ON_BN_CLICKED(IDC_BUTTON_NOTIFY, OnButtonNotify)
  1464. END_MESSAGE_MAP()
  1465. CDNSZone_ZoneTransferPropertyPage::CDNSZone_ZoneTransferPropertyPage()
  1466. : CPropertyPageBase(IDD_ZONE_ZONE_TRANSFER_PAGE)
  1467. {
  1468. m_fNotifyLevel = (DWORD)-1;
  1469. m_cNotify = 0;
  1470. m_aipNotify = NULL;
  1471. m_bStub = FALSE;
  1472. }
  1473. CDNSZone_ZoneTransferPropertyPage::~CDNSZone_ZoneTransferPropertyPage()
  1474. {
  1475. if (m_aipNotify != NULL)
  1476. free(m_aipNotify);
  1477. }
  1478. BOOL CDNSZone_ZoneTransferPropertyPage::OnSetActive()
  1479. {
  1480. CDNSZonePropertyPageHolder* pHolder =
  1481. (CDNSZonePropertyPageHolder*)GetHolder();
  1482. m_bStub = pHolder->IsStubZoneUI();
  1483. GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS)->EnableWindow(!m_bStub);
  1484. return CPropertyPageBase::OnSetActive();
  1485. }
  1486. void CDNSZone_ZoneTransferPropertyPage::OnButtonNotify()
  1487. {
  1488. CDNSZonePropertyPageHolder* pHolder =
  1489. (CDNSZonePropertyPageHolder*)GetHolder();
  1490. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1491. FIX_THREAD_STATE_MFC_BUG();
  1492. CDNSZoneNotifyDialog dlg(this, pZoneNode->GetZoneType() == DNS_ZONE_TYPE_SECONDARY,
  1493. pHolder->GetComponentData());
  1494. if (IDOK == dlg.DoModal())
  1495. {
  1496. //
  1497. // the dialog already updated the notify data
  1498. //
  1499. SetDirty(TRUE);
  1500. }
  1501. }
  1502. void CDNSZone_ZoneTransferPropertyPage::SyncUIRadioHelper(UINT nRadio)
  1503. {
  1504. BOOL bState = ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->GetCheck();
  1505. GetNotifyButton()->EnableWindow(bState);
  1506. m_secondariesListEditor.EnableUI(IDC_RADIO_SECSECURE_LIST == nRadio, TRUE);
  1507. if (IDC_RADIO_SECSECURE_LIST != nRadio)
  1508. m_secondariesListEditor.Clear();
  1509. SetDirty(TRUE);
  1510. if (IDC_CHECK_ALLOW_TRANSFERS == nRadio)
  1511. {
  1512. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->EnableWindow(bState);
  1513. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->EnableWindow(bState);
  1514. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->EnableWindow(bState);
  1515. BOOL bRadioState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->GetCheck();
  1516. m_secondariesListEditor.EnableUI(bRadioState && bState, TRUE);
  1517. }
  1518. }
  1519. int CDNSZone_ZoneTransferPropertyPage::SetRadioState(DWORD fSecureSecondaries)
  1520. {
  1521. int nRadio = 0;
  1522. switch (fSecureSecondaries)
  1523. {
  1524. case ZONE_SECSECURE_NONE:
  1525. nRadio = IDC_CHECK_ALLOW_TRANSFERS;
  1526. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(FALSE);
  1527. break;
  1528. case ZONE_SECSECURE_LIST:
  1529. nRadio = IDC_RADIO_SECSECURE_LIST;
  1530. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->SetCheck(TRUE);
  1531. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(TRUE);
  1532. break;
  1533. case ZONE_SECSECURE_OFF:
  1534. nRadio = IDC_RADIO_SECSECURE_OFF;
  1535. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->SetCheck(TRUE);
  1536. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(TRUE);
  1537. break;
  1538. case ZONE_SECSECURE_NS:
  1539. nRadio = IDC_RADIO_SECSECURE_NS;
  1540. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->SetCheck(TRUE);
  1541. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(TRUE);
  1542. break;
  1543. }
  1544. ASSERT(nRadio != 0);
  1545. return nRadio;
  1546. }
  1547. DWORD CDNSZone_ZoneTransferPropertyPage::GetRadioState()
  1548. {
  1549. int nRadio = 0;
  1550. if (!((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->GetCheck())
  1551. {
  1552. nRadio = IDC_CHECK_ALLOW_TRANSFERS;
  1553. }
  1554. else
  1555. {
  1556. if (((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->GetCheck())
  1557. {
  1558. nRadio = IDC_RADIO_SECSECURE_OFF;
  1559. }
  1560. else if (((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->GetCheck())
  1561. {
  1562. nRadio = IDC_RADIO_SECSECURE_LIST;
  1563. }
  1564. else if (((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->GetCheck())
  1565. {
  1566. nRadio = IDC_RADIO_SECSECURE_NS;
  1567. }
  1568. }
  1569. ASSERT(nRadio != 0);
  1570. DWORD fSecureSecondaries = (DWORD)-1;
  1571. switch (nRadio)
  1572. {
  1573. case IDC_CHECK_ALLOW_TRANSFERS:
  1574. fSecureSecondaries = ZONE_SECSECURE_NONE;
  1575. break;
  1576. case IDC_RADIO_SECSECURE_LIST:
  1577. fSecureSecondaries = ZONE_SECSECURE_LIST;
  1578. break;
  1579. case IDC_RADIO_SECSECURE_OFF:
  1580. fSecureSecondaries = ZONE_SECSECURE_OFF;
  1581. break;
  1582. case IDC_RADIO_SECSECURE_NS:
  1583. fSecureSecondaries = ZONE_SECSECURE_NS;
  1584. break;
  1585. }
  1586. ASSERT(fSecureSecondaries != (DWORD)-1);
  1587. return fSecureSecondaries;
  1588. }
  1589. BOOL CDNSZone_ZoneTransferPropertyPage::OnInitDialog()
  1590. {
  1591. //
  1592. // NOTE: this control has to be initialized before the
  1593. // base class OnInitDialog is called because the
  1594. // base class OnInitDialog calls SetUIData() in
  1595. // this derived class which uses this control
  1596. //
  1597. VERIFY(m_secondariesListEditor.Initialize(this,
  1598. GetParent(),
  1599. IDC_BUTTON_UP,
  1600. IDC_BUTTON_DOWN,
  1601. IDC_BUTTON_ADD,
  1602. IDC_BUTTON_REMOVE,
  1603. IDC_IPEDIT,
  1604. IDC_LIST));
  1605. CPropertyPageBase::OnInitDialog();
  1606. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1607. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1608. DWORD fSecureSecondaries;
  1609. DWORD cSecondaries;
  1610. PIP_ADDRESS aipSecondaries;
  1611. ASSERT(m_fNotifyLevel == (DWORD)-1);
  1612. ASSERT(m_cNotify == 0);
  1613. ASSERT(m_aipNotify == NULL);
  1614. pZoneNode->GetSecondariesInfo(&fSecureSecondaries, &cSecondaries, &aipSecondaries,
  1615. &m_fNotifyLevel, &m_cNotify, &m_aipNotify);
  1616. BOOL bSecondaryZone = pZoneNode->GetZoneType() == DNS_ZONE_TYPE_SECONDARY ||
  1617. pZoneNode->GetZoneType() == DNS_ZONE_TYPE_STUB;
  1618. if (bSecondaryZone)
  1619. {
  1620. //
  1621. // just to make sure here...
  1622. //
  1623. ASSERT(m_fNotifyLevel != ZONE_NOTIFY_ALL);
  1624. if (m_fNotifyLevel == ZONE_NOTIFY_ALL)
  1625. {
  1626. m_fNotifyLevel = ZONE_NOTIFY_OFF;
  1627. }
  1628. }
  1629. if ( (m_cNotify > 0) && (m_aipNotify != NULL) )
  1630. {
  1631. //
  1632. // make a deep copy
  1633. //
  1634. PIP_ADDRESS aipNotifyTemp = (DWORD*) malloc(sizeof(DWORD)*m_cNotify);
  1635. if (aipNotifyTemp != NULL)
  1636. {
  1637. memcpy(aipNotifyTemp, m_aipNotify, sizeof(DWORD)*m_cNotify);
  1638. m_aipNotify = aipNotifyTemp;
  1639. }
  1640. }
  1641. if ( (ZONE_SECSECURE_LIST == fSecureSecondaries) && (cSecondaries > 0) )
  1642. {
  1643. m_secondariesListEditor.AddAddresses(aipSecondaries, cSecondaries);
  1644. }
  1645. SyncUIRadioHelper(SetRadioState(fSecureSecondaries));
  1646. BOOL bListState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->GetCheck();
  1647. BOOL bAllState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->GetCheck();
  1648. BOOL bNSState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->GetCheck();
  1649. if (!bAllState && !bListState && !bNSState)
  1650. {
  1651. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->SetCheck(TRUE);
  1652. }
  1653. SetDirty(FALSE);
  1654. return TRUE; // return TRUE unless you set the focus to a control
  1655. // EXCEPTION: OCX Property Pages should return FALSE
  1656. }
  1657. BOOL CDNSZone_ZoneTransferPropertyPage::OnApply()
  1658. {
  1659. CDNSZonePropertyPageHolder* pHolder =
  1660. (CDNSZonePropertyPageHolder*)GetHolder();
  1661. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1662. // first commit possible zone type transition changes
  1663. if (!pHolder->ApplyGeneralPageChanges())
  1664. return FALSE;
  1665. if (!IsDirty())
  1666. return TRUE;
  1667. DWORD fSecureSecondaries = GetRadioState();
  1668. DWORD cSecondaries = 0;
  1669. DWORD* aipSecondaries = NULL;
  1670. if (fSecureSecondaries == ZONE_SECSECURE_LIST)
  1671. {
  1672. cSecondaries = m_secondariesListEditor.GetCount();
  1673. aipSecondaries = (cSecondaries > 0) ? (DWORD*) malloc(sizeof(DWORD)*cSecondaries) : NULL;
  1674. if (aipSecondaries != NULL && cSecondaries > 0)
  1675. {
  1676. int nFilled = 0;
  1677. m_secondariesListEditor.GetAddresses(aipSecondaries, cSecondaries, &nFilled);
  1678. ASSERT(nFilled == (int)cSecondaries);
  1679. }
  1680. }
  1681. BOOL bRet = TRUE;
  1682. // write to server
  1683. DNS_STATUS err = pZoneNode->ResetSecondaries(fSecureSecondaries, cSecondaries, aipSecondaries,
  1684. m_fNotifyLevel, m_cNotify, m_aipNotify);
  1685. if (err != 0)
  1686. {
  1687. DNSErrorDialog(err, IDS_MSG_ZONE_FAIL_UPDATE_ZONE_TRANSFERS);
  1688. bRet = FALSE;
  1689. }
  1690. if (aipSecondaries)
  1691. {
  1692. free (aipSecondaries);
  1693. aipSecondaries = 0;
  1694. }
  1695. // all went fine
  1696. if (bRet)
  1697. {
  1698. SetDirty(FALSE);
  1699. }
  1700. return bRet;
  1701. }
  1702. ////////////////////////////////////////////////////////////////////////////
  1703. // CDNSZone_SOA_PropertyPage
  1704. void CDNS_SOA_SerialNumberEditGroup::OnEditChange()
  1705. {
  1706. m_pPage->SetDirty(TRUE);
  1707. //
  1708. // SOA serial numbers should be 32 bits in length
  1709. // if = 0xffffffff then we need to set it also because
  1710. // StrToUint() return 0xffffffff if the number is larger
  1711. //
  1712. if (GetVal() >= 0xffffffff)
  1713. {
  1714. SetVal(0xffffffff);
  1715. }
  1716. }
  1717. void CDNS_SOA_TimeIntervalEditGroup::OnEditChange()
  1718. {
  1719. m_pPage->SetDirty(TRUE);
  1720. }
  1721. BEGIN_MESSAGE_MAP(CDNSZone_SOA_PropertyPage, CDNSRecordPropertyPage)
  1722. ON_EN_CHANGE(IDC_PRIMARY_SERV_EDIT, OnPrimaryServerChange)
  1723. ON_EN_CHANGE(IDC_RESP_PARTY_EDIT, OnResponsiblePartyChange)
  1724. ON_EN_CHANGE(IDC_MIN_TTLEDIT, OnMinTTLChange)
  1725. ON_BN_CLICKED(IDC_BROWSE_SERV_BUTTON, OnBrowseServer)
  1726. ON_BN_CLICKED(IDC_BROWSE_PARTY_BUTTON, OnBrowseResponsibleParty)
  1727. END_MESSAGE_MAP()
  1728. CDNSZone_SOA_PropertyPage::CDNSZone_SOA_PropertyPage(BOOL bZoneRoot)
  1729. : CDNSRecordPropertyPage(IDD_RR_SOA)
  1730. {
  1731. m_pTempSOARecord = NULL;
  1732. m_bZoneRoot = bZoneRoot;
  1733. }
  1734. CDNSZone_SOA_PropertyPage::~CDNSZone_SOA_PropertyPage()
  1735. {
  1736. if (m_bZoneRoot && (m_pTempSOARecord != NULL))
  1737. delete m_pTempSOARecord;
  1738. }
  1739. void _DisableDialogControls(HWND hWnd)
  1740. {
  1741. HWND hWndCurr = ::GetWindow(hWnd, GW_CHILD);
  1742. if (hWndCurr != NULL)
  1743. {
  1744. ::ShowWindow(hWndCurr,FALSE);
  1745. ::EnableWindow(hWndCurr,FALSE);
  1746. hWndCurr = ::GetNextWindow(hWndCurr, GW_HWNDNEXT);
  1747. while (hWndCurr)
  1748. {
  1749. ::ShowWindow(hWndCurr,FALSE);
  1750. ::EnableWindow(hWndCurr,FALSE);
  1751. hWndCurr = ::GetNextWindow(hWndCurr, GW_HWNDNEXT);
  1752. }
  1753. }
  1754. }
  1755. void CDNSZone_SOA_PropertyPage::ShowErrorUI()
  1756. {
  1757. _DisableDialogControls(m_hWnd);
  1758. CStatic* pErrorStatic = GetErrorStatic();
  1759. // need to move the error control to the center
  1760. CRect r;
  1761. pErrorStatic->GetWindowRect(&r);
  1762. ScreenToClient(r);
  1763. int dx = r.right - r.left;
  1764. int dy = r.bottom - r.top;
  1765. CRect rThis;
  1766. GetClientRect(rThis);
  1767. int x = ((rThis.right - rThis.left) - dx)/2;
  1768. int y = 4*dy;
  1769. r.top = y;
  1770. r.bottom = y + dy;
  1771. r.left = x;
  1772. r.right = x + dx;
  1773. pErrorStatic->MoveWindow(r, TRUE);
  1774. pErrorStatic->EnableWindow(TRUE);
  1775. pErrorStatic->ShowWindow(TRUE);
  1776. }
  1777. BOOL CDNSZone_SOA_PropertyPage::OnInitDialog()
  1778. {
  1779. CPropertyPageBase::OnInitDialog();
  1780. ASSERT(m_pTempSOARecord == NULL);
  1781. // create temporary record
  1782. if (m_bZoneRoot)
  1783. {
  1784. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1785. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1786. if (pZoneNode->HasSOARecord())
  1787. {
  1788. m_pTempSOARecord = pZoneNode->GetSOARecordCopy();
  1789. }
  1790. else
  1791. {
  1792. // something is wrong, need to disable
  1793. ShowErrorUI();
  1794. }
  1795. }
  1796. else
  1797. {
  1798. // we are in the cache here...
  1799. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  1800. m_pTempSOARecord = (CDNS_SOA_Record*)pHolder->GetTempDNSRecord();
  1801. }
  1802. // initialize controls
  1803. m_serialNumberEditGroup.m_pPage = this;
  1804. VERIFY(m_serialNumberEditGroup.Initialize(this,
  1805. IDC_SERIAL_NUMBER_EDIT,IDC_SERIAL_UP, IDC_SERIAL_DOWN));
  1806. m_serialNumberEditGroup.SetRange(0,(UINT)-1);
  1807. m_refreshIntervalEditGroup.m_pPage = this;
  1808. m_retryIntervalEditGroup.m_pPage = this;
  1809. m_expireIntervalEditGroup.m_pPage = this;
  1810. m_minTTLIntervalEditGroup.m_pPage = this;
  1811. VERIFY(m_refreshIntervalEditGroup.Initialize(this,
  1812. IDC_REFR_INT_EDIT, IDC_REFR_INT_COMBO,IDS_TIME_INTERVAL_UNITS));
  1813. VERIFY(m_retryIntervalEditGroup.Initialize(this,
  1814. IDC_RETRY_INT_EDIT, IDC_RETRY_INT_COMBO,IDS_TIME_INTERVAL_UNITS));
  1815. VERIFY(m_expireIntervalEditGroup.Initialize(this,
  1816. IDC_EXP_INT_EDIT, IDC_EXP_INT_COMBO,IDS_TIME_INTERVAL_UNITS));
  1817. VERIFY(m_minTTLIntervalEditGroup.Initialize(this,
  1818. IDC_MINTTL_INT_EDIT, IDC_MINTTL_INT_COMBO, IDS_TIME_INTERVAL_UNITS));
  1819. HWND dialogHwnd = GetSafeHwnd();
  1820. // Disable IME support on the controls
  1821. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_REFR_INT_EDIT), NULL);
  1822. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_RETRY_INT_EDIT), NULL);
  1823. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_EXP_INT_EDIT), NULL);
  1824. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_MINTTL_INT_EDIT), NULL);
  1825. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_SERIAL_NUMBER_EDIT), NULL);
  1826. // load data
  1827. SetUIData();
  1828. if (!m_bZoneRoot)
  1829. {
  1830. // we are in the cache here...
  1831. EnableDialogControls(m_hWnd, FALSE);
  1832. }
  1833. SetDirty(FALSE);
  1834. return TRUE;
  1835. }
  1836. BOOL CDNSZone_SOA_PropertyPage::OnApply()
  1837. {
  1838. if (!IsDirty())
  1839. {
  1840. return TRUE;
  1841. }
  1842. DNS_STATUS err = 0;
  1843. if (m_bZoneRoot)
  1844. {
  1845. //
  1846. // we are in a real zone
  1847. //
  1848. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1849. ASSERT(!pHolder->IsWizardMode());
  1850. //
  1851. // first commit possible zone type transition changes
  1852. //
  1853. if (!pHolder->ApplyGeneralPageChanges())
  1854. {
  1855. return FALSE;
  1856. }
  1857. if ((m_pTempSOARecord == NULL) || !IsDirty() || !pHolder->IsPrimaryZoneUI())
  1858. {
  1859. return TRUE;
  1860. }
  1861. //
  1862. // No need to verify success here because we don't return anything that isn't valid
  1863. //
  1864. err = GetUIDataEx(FALSE);
  1865. if (err != 0)
  1866. {
  1867. return FALSE;
  1868. }
  1869. err = pHolder->NotifyConsole(this);
  1870. }
  1871. else
  1872. {
  1873. //
  1874. // we are in the cache, that is read only...
  1875. //
  1876. return TRUE;
  1877. }
  1878. if (err != 0)
  1879. {
  1880. DNSErrorDialog(err,IDS_MSG_ZONE_SOA_UPDATE_FAILED);
  1881. return FALSE;
  1882. }
  1883. else
  1884. {
  1885. SetUIData();
  1886. SetDirty(FALSE);
  1887. }
  1888. return TRUE; // all is cool
  1889. }
  1890. BOOL CDNSZone_SOA_PropertyPage::OnPropertyChange(BOOL, long*)
  1891. {
  1892. ASSERT(m_pTempSOARecord != NULL);
  1893. if (m_pTempSOARecord == NULL)
  1894. return FALSE;
  1895. DNS_STATUS err = 0;
  1896. if (m_bZoneRoot)
  1897. {
  1898. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1899. err = pHolder->GetZoneNode()->UpdateSOARecord(m_pTempSOARecord, NULL);
  1900. }
  1901. else
  1902. {
  1903. ASSERT(FALSE);
  1904. }
  1905. if (err != 0)
  1906. GetHolder()->SetError(err);
  1907. return (err == 0);
  1908. }
  1909. void CDNSZone_SOA_PropertyPage::SetUIData()
  1910. {
  1911. CDNS_SOA_Record* pRecord = m_pTempSOARecord;
  1912. if (pRecord == NULL)
  1913. return;
  1914. GetPrimaryServerEdit()->SetWindowText(pRecord->m_szNamePrimaryServer);
  1915. GetResponsiblePartyEdit()->SetWindowText(pRecord->m_szResponsibleParty);
  1916. m_serialNumberEditGroup.SetVal(pRecord->m_dwSerialNo);
  1917. m_refreshIntervalEditGroup.SetVal(pRecord->m_dwRefresh);
  1918. m_retryIntervalEditGroup.SetVal(pRecord->m_dwRetry);
  1919. m_expireIntervalEditGroup.SetVal(pRecord->m_dwExpire);
  1920. m_minTTLIntervalEditGroup.SetVal(pRecord->m_dwMinimumTtl);
  1921. GetTTLCtrl()->SetTTL(pRecord->m_dwTtlSeconds);
  1922. if (m_bZoneRoot)
  1923. {
  1924. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1925. EnableDialogControls(m_hWnd, pHolder->IsPrimaryZoneUI());
  1926. }
  1927. }
  1928. DNS_STATUS CDNSZone_SOA_PropertyPage::GetUIDataEx(BOOL)
  1929. {
  1930. DNS_STATUS err = 0;
  1931. CDNS_SOA_Record* pRecord = m_pTempSOARecord;
  1932. if (pRecord == NULL)
  1933. return err;
  1934. GetPrimaryServerEdit()->GetWindowText(pRecord->m_szNamePrimaryServer);
  1935. GetResponsiblePartyEdit()->GetWindowText(pRecord->m_szResponsibleParty);
  1936. //
  1937. // Check to see if the Responsible Party field contains an '@'
  1938. //
  1939. if (-1 != pRecord->m_szResponsibleParty.Find(L'@'))
  1940. {
  1941. UINT nResult = DNSMessageBox(IDS_MSG_RESPONSIBLE_PARTY_CONTAINS_AT, MB_YESNOCANCEL | MB_ICONWARNING);
  1942. if (IDYES == nResult)
  1943. {
  1944. //
  1945. // Replace '@' with '.'
  1946. //
  1947. pRecord->m_szResponsibleParty.Replace(L'@', L'.');
  1948. }
  1949. else if (IDCANCEL == nResult)
  1950. {
  1951. //
  1952. // Don't make any changes but don't let the apply continue
  1953. //
  1954. err = DNS_ERROR_INVALID_NAME_CHAR;
  1955. }
  1956. else
  1957. {
  1958. //
  1959. // We will allow IDNO to continue to set the responsible party with the '@'
  1960. //
  1961. err = 0;
  1962. }
  1963. }
  1964. pRecord->m_dwSerialNo = m_serialNumberEditGroup.GetVal();
  1965. pRecord->m_dwRefresh = m_refreshIntervalEditGroup.GetVal();
  1966. pRecord->m_dwRetry = m_retryIntervalEditGroup.GetVal();
  1967. pRecord->m_dwExpire = m_expireIntervalEditGroup.GetVal();
  1968. pRecord->m_dwMinimumTtl = m_minTTLIntervalEditGroup.GetVal();
  1969. GetTTLCtrl()->GetTTL(&(pRecord->m_dwTtlSeconds));
  1970. return err;
  1971. }
  1972. void CDNSZone_SOA_PropertyPage::OnPrimaryServerChange()
  1973. {
  1974. SetDirty(TRUE);
  1975. }
  1976. void CDNSZone_SOA_PropertyPage::OnResponsiblePartyChange()
  1977. {
  1978. SetDirty(TRUE);
  1979. }
  1980. void CDNSZone_SOA_PropertyPage::OnMinTTLChange()
  1981. {
  1982. SetDirty(TRUE);
  1983. }
  1984. void CDNSZone_SOA_PropertyPage::OnBrowseServer()
  1985. {
  1986. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1987. FIX_THREAD_STATE_MFC_BUG();
  1988. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(), RECORD_A_AND_CNAME);
  1989. if (IDOK == dlg.DoModal())
  1990. {
  1991. CEdit* pEdit = GetPrimaryServerEdit();
  1992. pEdit->SetWindowText(dlg.GetSelectionString());
  1993. }
  1994. }
  1995. void CDNSZone_SOA_PropertyPage::OnBrowseResponsibleParty()
  1996. {
  1997. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1998. FIX_THREAD_STATE_MFC_BUG();
  1999. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(), RECORD_RP);
  2000. if (IDOK == dlg.DoModal())
  2001. {
  2002. CEdit* pEdit = GetResponsiblePartyEdit();
  2003. pEdit->SetWindowText(dlg.GetSelectionString());
  2004. }
  2005. }
  2006. ////////////////////////////////////////////////////////////////////////////
  2007. // CWinsAdvancedDialog
  2008. class CWinsAdvancedDialog : public CHelpDialog
  2009. {
  2010. public:
  2011. CWinsAdvancedDialog(CPropertyPageHolderBase* pHolder, BOOL bReverse);
  2012. // data
  2013. BOOL m_bNetBios;
  2014. DWORD m_dwLookupTimeout;
  2015. DWORD m_dwCacheTimeout;
  2016. protected:
  2017. virtual BOOL OnInitDialog();
  2018. virtual void OnOK();
  2019. virtual void OnCancel();
  2020. DECLARE_MESSAGE_MAP()
  2021. private:
  2022. CPropertyPageHolderBase* m_pHolder;
  2023. BOOL m_bReverse;
  2024. CButton* GetNetBiosCheck()
  2025. { return (CButton*)GetDlgItem(IDC_NETBIOS_CHECK);}
  2026. CDNSTTLControl* GetCacheTimeoutTTLCtrl()
  2027. { return (CDNSTTLControl*)GetDlgItem(IDC_CACHE_TIMEOUT_TTLEDIT);}
  2028. CDNSTTLControl* GetLookupTimeoutTTLCtrl()
  2029. { return (CDNSTTLControl*)GetDlgItem(IDC_LOOKUP_TIMEOUT_TTLEDIT);}
  2030. };
  2031. BEGIN_MESSAGE_MAP(CWinsAdvancedDialog, CHelpDialog)
  2032. END_MESSAGE_MAP()
  2033. CWinsAdvancedDialog::CWinsAdvancedDialog(CPropertyPageHolderBase* pHolder,
  2034. BOOL bReverse)
  2035. : CHelpDialog(IDD_ZONE_WINS_ADVANCED, pHolder->GetComponentData())
  2036. {
  2037. ASSERT(pHolder != NULL);
  2038. m_pHolder = pHolder;
  2039. m_bReverse = bReverse;
  2040. m_bNetBios = FALSE;
  2041. m_dwLookupTimeout = 0x0;
  2042. m_dwCacheTimeout = 0x0;
  2043. }
  2044. BOOL CWinsAdvancedDialog::OnInitDialog()
  2045. {
  2046. CHelpDialog::OnInitDialog();
  2047. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  2048. if (m_bReverse)
  2049. {
  2050. GetNetBiosCheck()->SetCheck(m_bNetBios);
  2051. }
  2052. else
  2053. {
  2054. GetNetBiosCheck()->EnableWindow(FALSE);
  2055. GetNetBiosCheck()->ShowWindow(FALSE);
  2056. }
  2057. GetCacheTimeoutTTLCtrl()->SetTTL(m_dwCacheTimeout);
  2058. GetLookupTimeoutTTLCtrl()->SetTTL(m_dwLookupTimeout);
  2059. return TRUE; // return TRUE unless you set the focus to a control
  2060. }
  2061. void CWinsAdvancedDialog::OnCancel()
  2062. {
  2063. ASSERT(m_pHolder != NULL);
  2064. m_pHolder->PopDialogHWnd();
  2065. CHelpDialog::OnCancel();
  2066. }
  2067. void CWinsAdvancedDialog::OnOK()
  2068. {
  2069. if (m_bReverse)
  2070. {
  2071. m_bNetBios = GetNetBiosCheck()->GetCheck();
  2072. }
  2073. GetCacheTimeoutTTLCtrl()->GetTTL(&m_dwCacheTimeout);
  2074. GetLookupTimeoutTTLCtrl()->GetTTL(&m_dwLookupTimeout);
  2075. ASSERT(m_pHolder != NULL);
  2076. m_pHolder->PopDialogHWnd();
  2077. CHelpDialog::OnOK();
  2078. }
  2079. ////////////////////////////////////////////////////////////////////////////
  2080. // CDNSZone_WINSBase_PropertyPage
  2081. BEGIN_MESSAGE_MAP(CDNSZone_WINSBase_PropertyPage, CDNSRecordPropertyPage)
  2082. ON_BN_CLICKED(IDC_USE_WINS_RES_CHECK, OnUseWinsResolutionChange)
  2083. ON_BN_CLICKED(IDC_NOT_REPL_CHECK, OnDoNotReplicateChange)
  2084. END_MESSAGE_MAP()
  2085. CDNSZone_WINSBase_PropertyPage::CDNSZone_WINSBase_PropertyPage(UINT nIDTemplate)
  2086. : CDNSRecordPropertyPage(nIDTemplate)
  2087. {
  2088. m_pTempRecord = NULL;
  2089. m_action = none;
  2090. m_iWINSMsg = 0;
  2091. }
  2092. CDNSZone_WINSBase_PropertyPage::~CDNSZone_WINSBase_PropertyPage()
  2093. {
  2094. if (m_pTempRecord != NULL)
  2095. delete m_pTempRecord;
  2096. }
  2097. BOOL CDNSZone_WINSBase_PropertyPage::OnPropertyChange(BOOL, long*)
  2098. {
  2099. ASSERT(m_action != none);
  2100. ASSERT(m_pTempRecord != NULL);
  2101. if (m_pTempRecord == NULL)
  2102. return FALSE;
  2103. CComponentDataObject* pComponentData = GetZoneHolder()->GetComponentData();
  2104. DNS_STATUS err = 0;
  2105. if (IsValidTempRecord())
  2106. {
  2107. switch(m_action)
  2108. {
  2109. case remove:
  2110. err = GetZoneNode()->DeleteWINSRecord(pComponentData);
  2111. break;
  2112. case add:
  2113. err = GetZoneNode()->CreateWINSRecord(m_pTempRecord, pComponentData);
  2114. break;
  2115. case edit:
  2116. err = GetZoneNode()->UpdateWINSRecord(m_pTempRecord, pComponentData);
  2117. break;
  2118. }
  2119. }
  2120. else
  2121. {
  2122. if (m_action == remove)
  2123. {
  2124. err = GetZoneNode()->DeleteWINSRecord(pComponentData);
  2125. }
  2126. else
  2127. {
  2128. err = ERROR_INVALID_DATA;
  2129. }
  2130. }
  2131. if (err != 0)
  2132. GetZoneHolder()->SetError(err);
  2133. return (err == 0);
  2134. }
  2135. CDNSZoneNode* CDNSZone_WINSBase_PropertyPage::GetZoneNode()
  2136. {
  2137. return GetZoneHolder()->GetZoneNode();
  2138. }
  2139. BOOL CDNSZone_WINSBase_PropertyPage::OnInitDialog()
  2140. {
  2141. CPropertyPageBase::OnInitDialog();
  2142. CDNSRootData* pRootData = (CDNSRootData*)GetHolder()->GetComponentData()->GetRootData();
  2143. ASSERT(pRootData != NULL);
  2144. EnableTTLCtrl(pRootData->IsAdvancedView());
  2145. BOOL bUseWins = GetZoneNode()->HasWinsRecord();
  2146. // unabe disable the WINS checkbox
  2147. GetUseWinsCheck()->SetCheck(bUseWins);
  2148. // get new temporary record
  2149. if (bUseWins)
  2150. m_pTempRecord = GetZoneNode()->GetWINSRecordCopy();
  2151. else
  2152. m_pTempRecord = GetZoneNode()->IsReverse() ?
  2153. (CDNSRecord*)(new CDNS_NBSTAT_Record) : (CDNSRecord*)(new CDNS_WINS_Record);
  2154. ASSERT(m_pTempRecord != NULL);
  2155. SetUIData();
  2156. SetDirty(FALSE);
  2157. // EnableUI(bUseWins);
  2158. return TRUE;
  2159. }
  2160. BOOL CDNSZone_WINSBase_PropertyPage::OnSetActive()
  2161. {
  2162. BOOL bRet = CDNSRecordPropertyPage::OnSetActive();
  2163. if (bRet)
  2164. {
  2165. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2166. m_bPrimaryZone = pHolder->IsPrimaryZoneUI();
  2167. m_bStub = pHolder->IsStubZoneUI();
  2168. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2169. m_bLocalRecord = (pRecord->m_dwMappingFlag & DNS_WINS_FLAG_LOCAL);
  2170. BOOL bUseWins = GetZoneNode()->HasWinsRecord();
  2171. if (bUseWins && m_bLocalRecord)
  2172. {
  2173. m_nState = wins_local_state;
  2174. }
  2175. else if (bUseWins && !m_bLocalRecord)
  2176. {
  2177. m_nState = wins_not_local_state;
  2178. }
  2179. else // (!bUseWins && !m_bLocalRecord) || (!bUseWins && m_bLocalRecord)
  2180. {
  2181. m_nState = no_wins_state;
  2182. }
  2183. EnableUI();
  2184. CString szCheckText;
  2185. if (m_bPrimaryZone)
  2186. {
  2187. m_nReplCheckTextID = IDS_CHECK_TEXT_NOT_REPLICATE;
  2188. }
  2189. szCheckText.LoadString(m_nReplCheckTextID);
  2190. GetDoNotReplicateCheck()->SetWindowText((LPWSTR)(LPCWSTR)szCheckText);
  2191. }
  2192. return bRet;
  2193. }
  2194. BOOL CDNSZone_WINSBase_PropertyPage::OnApply()
  2195. {
  2196. CDNSZonePropertyPageHolder* pHolder =
  2197. (CDNSZonePropertyPageHolder*)GetHolder();
  2198. // first commit possible zone type transition changes
  2199. if (!pHolder->ApplyGeneralPageChanges())
  2200. return FALSE;
  2201. BOOL bUseWins = GetZoneNode()->HasWinsRecord(); // current state in the zone
  2202. BOOL bNewUseWins = GetUseWinsCheck()->GetCheck(); // current state in the UI
  2203. if (bUseWins && !bNewUseWins)
  2204. {
  2205. m_action = remove;
  2206. }
  2207. else if (!bUseWins && bNewUseWins)
  2208. {
  2209. m_action = add;
  2210. }
  2211. else if (bUseWins && bNewUseWins && IsDirty())
  2212. {
  2213. m_action = edit;
  2214. }
  2215. if (m_action == none)
  2216. return TRUE;
  2217. // No need to verify the return value here because we don't return anything except success
  2218. DNS_STATUS err = GetUIDataEx(FALSE);
  2219. if (err != 0)
  2220. {
  2221. ASSERT(FALSE);
  2222. return (err == 0);
  2223. }
  2224. err = GetZoneHolder()->NotifyConsole(this);
  2225. if (err != 0)
  2226. {
  2227. DNSErrorDialog(err, m_iWINSMsg);
  2228. }
  2229. else
  2230. {
  2231. // reset dirty flag!!!
  2232. }
  2233. m_action = none;
  2234. return (err == 0);
  2235. }
  2236. void CDNSZone_WINSBase_PropertyPage::OnUseWinsResolutionChange()
  2237. {
  2238. SetDirty(TRUE);
  2239. if (m_bPrimaryZone)
  2240. {
  2241. EnableUI(GetUseWinsCheck()->GetCheck());
  2242. }
  2243. else
  2244. {
  2245. switch (m_nState)
  2246. {
  2247. case wins_local_state :
  2248. #ifdef DBG
  2249. ASSERT(!GetUseWinsCheck()->GetCheck());
  2250. ASSERT(GetUseWinsCheck()->IsWindowEnabled());
  2251. ASSERT(GetDoNotReplicateCheck()->GetCheck());
  2252. ASSERT(!GetDoNotReplicateCheck()->IsWindowEnabled());
  2253. #endif
  2254. m_nState = no_wins_state;
  2255. break;
  2256. case wins_not_local_state : // should never happen
  2257. #ifdef DBG
  2258. ASSERT(FALSE);
  2259. #endif
  2260. break;
  2261. case no_wins_state :
  2262. #ifdef DBG
  2263. ASSERT(GetUseWinsCheck()->GetCheck());
  2264. ASSERT(GetUseWinsCheck()->IsWindowEnabled());
  2265. ASSERT(GetDoNotReplicateCheck()->GetCheck());
  2266. ASSERT(!GetDoNotReplicateCheck()->IsWindowEnabled());
  2267. #endif
  2268. m_nState = wins_local_state;
  2269. break;
  2270. default : // illegal state
  2271. #ifdef DBG
  2272. ASSERT(FALSE);
  2273. #endif
  2274. break;
  2275. }
  2276. EnableUI();
  2277. }
  2278. }
  2279. void CDNSZone_WINSBase_PropertyPage::OnDoNotReplicateChange()
  2280. {
  2281. SetDirty(TRUE);
  2282. if (!m_bPrimaryZone)
  2283. {
  2284. switch (m_nState)
  2285. {
  2286. case wins_local_state : // should never happen
  2287. #ifdef DBG
  2288. ASSERT(FALSE);
  2289. #endif
  2290. break;
  2291. case wins_not_local_state :
  2292. #ifdef DBG
  2293. ASSERT(GetUseWinsCheck()->GetCheck());
  2294. ASSERT(!GetUseWinsCheck()->IsWindowEnabled());
  2295. ASSERT(GetDoNotReplicateCheck()->GetCheck());
  2296. ASSERT(GetDoNotReplicateCheck()->IsWindowEnabled());
  2297. #endif
  2298. m_nState = wins_local_state;
  2299. break;
  2300. case no_wins_state : // should never happen
  2301. #ifdef DBG
  2302. ASSERT(FALSE);
  2303. #endif
  2304. break;
  2305. default : // illegal state
  2306. #ifdef DBG
  2307. ASSERT(FALSE);
  2308. #endif
  2309. break;
  2310. }
  2311. EnableUI();
  2312. }
  2313. }
  2314. void CDNSZone_WINSBase_PropertyPage::EnableUI(BOOL bEnable)
  2315. {
  2316. GetDoNotReplicateCheck()->EnableWindow(bEnable);
  2317. GetAdvancedButton()->EnableWindow(bEnable);
  2318. GetTTLCtrl()->EnableWindow(bEnable);
  2319. }
  2320. void CDNSZone_WINSBase_PropertyPage::EnableUI()
  2321. {
  2322. if (m_bPrimaryZone)
  2323. {
  2324. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2325. if (!IsDirty())
  2326. {
  2327. EnableUI(GetZoneNode()->HasWinsRecord());
  2328. }
  2329. }
  2330. else if (m_bStub)
  2331. {
  2332. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(FALSE);
  2333. EnableUI(FALSE);
  2334. }
  2335. else //secondary
  2336. {
  2337. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2338. switch (m_nState)
  2339. {
  2340. case wins_local_state :
  2341. GetDoNotReplicateCheck()->SetCheck(TRUE);
  2342. GetDoNotReplicateCheck()->EnableWindow(FALSE);
  2343. GetUseWinsCheck()->SetCheck(TRUE);
  2344. GetUseWinsCheck()->EnableWindow(TRUE);
  2345. GetTTLCtrl()->EnableWindow(TRUE);
  2346. GetAdvancedButton()->EnableWindow(TRUE);
  2347. break;
  2348. case wins_not_local_state :
  2349. GetDoNotReplicateCheck()->SetCheck(FALSE);
  2350. GetDoNotReplicateCheck()->EnableWindow(TRUE);
  2351. GetUseWinsCheck()->SetCheck(TRUE);
  2352. GetUseWinsCheck()->EnableWindow(FALSE);
  2353. GetTTLCtrl()->EnableWindow(FALSE);
  2354. GetAdvancedButton()->EnableWindow(FALSE);
  2355. break;
  2356. case no_wins_state :
  2357. GetDoNotReplicateCheck()->SetCheck(TRUE);
  2358. GetDoNotReplicateCheck()->EnableWindow(FALSE);
  2359. GetUseWinsCheck()->SetCheck(FALSE);
  2360. GetUseWinsCheck()->EnableWindow(TRUE);
  2361. GetTTLCtrl()->EnableWindow(FALSE);
  2362. GetAdvancedButton()->EnableWindow(FALSE);
  2363. break;
  2364. default : // Illegal state
  2365. break;
  2366. }
  2367. }
  2368. }
  2369. void CDNSZone_WINSBase_PropertyPage::SetUIData()
  2370. {
  2371. GetTTLCtrl()->SetTTL(m_pTempRecord->m_dwTtlSeconds);
  2372. }
  2373. DNS_STATUS CDNSZone_WINSBase_PropertyPage::GetUIDataEx(BOOL)
  2374. {
  2375. GetTTLCtrl()->GetTTL(&(m_pTempRecord->m_dwTtlSeconds));
  2376. return 0;
  2377. }
  2378. ////////////////////////////////////////////////////////////////////////////
  2379. // CDNSZone_WINS_PropertyPage
  2380. void CDNSZone_WINS_WinsServersIPEditor::OnChangeData()
  2381. {
  2382. CDNSZone_WINS_PropertyPage* pPage =
  2383. (CDNSZone_WINS_PropertyPage*)GetParentWnd();
  2384. pPage->SetDirty(TRUE);
  2385. }
  2386. BEGIN_MESSAGE_MAP(CDNSZone_WINS_PropertyPage, CDNSZone_WINSBase_PropertyPage)
  2387. ON_BN_CLICKED(IDC_ADVANCED_BUTTON, OnAdvancedButton)
  2388. END_MESSAGE_MAP()
  2389. CDNSZone_WINS_PropertyPage::CDNSZone_WINS_PropertyPage()
  2390. : CDNSZone_WINSBase_PropertyPage(IDD_ZONE_WINS_PAGE)
  2391. {
  2392. m_iWINSMsg = IDS_MSG_ZONE_WINS_FAILED;
  2393. m_nReplCheckTextID = IDS_CHECK_TEXT_USE_LOCAL_WINS;
  2394. m_bStub = FALSE;
  2395. }
  2396. BOOL CDNSZone_WINS_PropertyPage::OnInitDialog()
  2397. {
  2398. //
  2399. // NOTE: this control has to be initialized before the
  2400. // base class OnInitDialog is called because the
  2401. // base class OnInitDialog calls SetUIData() in
  2402. // this derived class which uses this control
  2403. //
  2404. VERIFY(m_winsServersEditor.Initialize(this,
  2405. GetParent(),
  2406. IDC_BUTTON_UP,
  2407. IDC_BUTTON_DOWN,
  2408. IDC_BUTTON_ADD,
  2409. IDC_BUTTON_REMOVE,
  2410. IDC_IPEDIT,
  2411. IDC_LIST));
  2412. CDNSZone_WINSBase_PropertyPage::OnInitDialog();
  2413. return TRUE;
  2414. }
  2415. void CDNSZone_WINS_PropertyPage::EnableUI(BOOL bEnable)
  2416. {
  2417. CDNSZone_WINSBase_PropertyPage::EnableUI(bEnable);
  2418. m_winsServersEditor.EnableUI(bEnable);
  2419. }
  2420. void CDNSZone_WINS_PropertyPage::EnableUI()
  2421. {
  2422. CDNSZone_WINSBase_PropertyPage::EnableUI();
  2423. if (m_bPrimaryZone)
  2424. {
  2425. if (!IsDirty())
  2426. {
  2427. m_winsServersEditor.EnableUI(GetZoneNode()->HasWinsRecord());
  2428. }
  2429. }
  2430. else // secondary zone
  2431. {
  2432. switch (m_nState)
  2433. {
  2434. case wins_local_state :
  2435. m_winsServersEditor.EnableUI(TRUE);
  2436. break;
  2437. case wins_not_local_state :
  2438. m_winsServersEditor.EnableUI(FALSE);
  2439. break;
  2440. case no_wins_state :
  2441. m_winsServersEditor.EnableUI(FALSE);
  2442. break;
  2443. default : // Illegal state
  2444. break;
  2445. }
  2446. }
  2447. }
  2448. BOOL CDNSZone_WINS_PropertyPage::IsValidTempRecord()
  2449. {
  2450. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2451. return (pRecord->m_nWinsServerCount > 0);
  2452. }
  2453. void CDNSZone_WINS_PropertyPage::SetUIData()
  2454. {
  2455. CDNSZone_WINSBase_PropertyPage::SetUIData();
  2456. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2457. GetDoNotReplicateCheck()->SetCheck(pRecord->m_dwMappingFlag & DNS_WINS_FLAG_LOCAL);
  2458. m_winsServersEditor.Clear();
  2459. if (pRecord->m_nWinsServerCount > 0)
  2460. {
  2461. DWORD* pTemp = (DWORD*)malloc(sizeof(DWORD)*pRecord->m_nWinsServerCount);
  2462. if (pTemp)
  2463. {
  2464. for (int k=0; k< pRecord->m_nWinsServerCount; k++)
  2465. pTemp[k] = pRecord->m_ipWinsServersArray[k];
  2466. m_winsServersEditor.AddAddresses(pTemp, pRecord->m_nWinsServerCount);
  2467. free(pTemp);
  2468. pTemp = 0;
  2469. }
  2470. }
  2471. }
  2472. DNS_STATUS CDNSZone_WINS_PropertyPage::GetUIDataEx(BOOL bSilent)
  2473. {
  2474. DNS_STATUS err = CDNSZone_WINSBase_PropertyPage::GetUIDataEx(bSilent);
  2475. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2476. pRecord->m_dwMappingFlag = GetDoNotReplicateCheck()->GetCheck() ?
  2477. pRecord->m_dwMappingFlag |= DNS_WINS_FLAG_LOCAL :
  2478. pRecord->m_dwMappingFlag &= ~DNS_WINS_FLAG_LOCAL;
  2479. pRecord->m_nWinsServerCount = m_winsServersEditor.GetCount();
  2480. if (pRecord->m_nWinsServerCount > 0)
  2481. {
  2482. DWORD* pTemp = (DWORD*)malloc(sizeof(DWORD)*pRecord->m_nWinsServerCount);
  2483. if (pTemp)
  2484. {
  2485. int nFilled;
  2486. m_winsServersEditor.GetAddresses(pTemp, pRecord->m_nWinsServerCount, &nFilled);
  2487. ASSERT(nFilled == pRecord->m_nWinsServerCount);
  2488. for (int k=0; k<nFilled; k++)
  2489. pRecord->m_ipWinsServersArray.SetAtGrow(k, pTemp[k]);
  2490. free(pTemp);
  2491. pTemp = 0;
  2492. }
  2493. else
  2494. {
  2495. err = ERROR_OUTOFMEMORY;
  2496. }
  2497. }
  2498. return err;
  2499. }
  2500. void CDNSZone_WINS_PropertyPage::OnAdvancedButton()
  2501. {
  2502. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2503. FIX_THREAD_STATE_MFC_BUG();
  2504. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2505. CWinsAdvancedDialog dlg(GetHolder(), FALSE);
  2506. dlg.m_dwLookupTimeout = pRecord->m_dwLookupTimeout;
  2507. dlg.m_dwCacheTimeout = pRecord->m_dwCacheTimeout;
  2508. if (IDOK == dlg.DoModal() )
  2509. {
  2510. pRecord->m_dwLookupTimeout = dlg.m_dwLookupTimeout;
  2511. pRecord->m_dwCacheTimeout = dlg.m_dwCacheTimeout;
  2512. SetDirty(TRUE);
  2513. }
  2514. }
  2515. ////////////////////////////////////////////////////////////////////////////
  2516. // CDNSZone_NBSTAT_PropertyPage
  2517. BEGIN_MESSAGE_MAP(CDNSZone_NBSTAT_PropertyPage, CDNSZone_WINSBase_PropertyPage)
  2518. ON_EN_CHANGE(IDC_DOMAIN_NAME_EDIT, OnDomainNameEditChange)
  2519. ON_BN_CLICKED(IDC_ADVANCED_BUTTON, OnAdvancedButton)
  2520. END_MESSAGE_MAP()
  2521. CDNSZone_NBSTAT_PropertyPage::CDNSZone_NBSTAT_PropertyPage()
  2522. : CDNSZone_WINSBase_PropertyPage(IDD_ZONE_NBSTAT_PAGE)
  2523. {
  2524. m_iWINSMsg = IDS_MSG_ZONE_NBSTAT_FAILED;
  2525. m_nReplCheckTextID = IDS_CHECK_TEXT_USE_LOCAL_WINSR;
  2526. }
  2527. void CDNSZone_NBSTAT_PropertyPage::OnDomainNameEditChange()
  2528. {
  2529. SetDirty(TRUE);
  2530. }
  2531. void CDNSZone_NBSTAT_PropertyPage::EnableUI(BOOL bEnable)
  2532. {
  2533. CDNSZone_WINSBase_PropertyPage::EnableUI(bEnable);
  2534. GetDomainNameEdit()->EnableWindow(bEnable);
  2535. }
  2536. void CDNSZone_NBSTAT_PropertyPage::EnableUI()
  2537. {
  2538. CDNSZone_WINSBase_PropertyPage::EnableUI();
  2539. if (m_bPrimaryZone)
  2540. {
  2541. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2542. GetDomainNameEdit()->EnableWindow(GetZoneNode()->HasWinsRecord());
  2543. }
  2544. else if (m_bStub)
  2545. {
  2546. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(FALSE);
  2547. EnableUI(FALSE);
  2548. }
  2549. else // secondary zone
  2550. {
  2551. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2552. switch (m_nState)
  2553. {
  2554. case wins_local_state :
  2555. GetDomainNameEdit()->EnableWindow(TRUE);
  2556. break;
  2557. case wins_not_local_state :
  2558. GetDomainNameEdit()->EnableWindow(FALSE);
  2559. break;
  2560. case no_wins_state :
  2561. GetDomainNameEdit()->EnableWindow(FALSE);
  2562. break;
  2563. default : // Illegal state
  2564. break;
  2565. }
  2566. }
  2567. }
  2568. BOOL CDNSZone_NBSTAT_PropertyPage::IsValidTempRecord()
  2569. {
  2570. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2571. CString szTemp = pRecord->m_szNameResultDomain;
  2572. szTemp.TrimLeft();
  2573. szTemp.TrimRight();
  2574. return (!szTemp.IsEmpty());
  2575. }
  2576. void CDNSZone_NBSTAT_PropertyPage::SetUIData()
  2577. {
  2578. CDNSZone_WINSBase_PropertyPage::SetUIData();
  2579. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2580. GetDoNotReplicateCheck()->SetCheck(pRecord->m_dwMappingFlag & DNS_WINS_FLAG_LOCAL);
  2581. // strip out the "in-addr.arpa" suffix
  2582. CString szTemp = pRecord->m_szNameResultDomain;
  2583. //VERIFY(RemoveInAddrArpaSuffix(szTemp.GetBuffer(1)));
  2584. //szTemp.ReleaseBuffer();
  2585. GetDomainNameEdit()->SetWindowText(szTemp);
  2586. }
  2587. DNS_STATUS CDNSZone_NBSTAT_PropertyPage::GetUIDataEx(BOOL bSilent)
  2588. {
  2589. DNS_STATUS err = CDNSZone_WINSBase_PropertyPage::GetUIDataEx(bSilent);
  2590. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2591. pRecord->m_dwMappingFlag = GetDoNotReplicateCheck()->GetCheck() ?
  2592. pRecord->m_dwMappingFlag |= DNS_WINS_FLAG_LOCAL :
  2593. pRecord->m_dwMappingFlag &= ~DNS_WINS_FLAG_LOCAL;
  2594. GetDomainNameEdit()->GetWindowText(pRecord->m_szNameResultDomain);
  2595. return err;
  2596. }
  2597. void CDNSZone_NBSTAT_PropertyPage::OnAdvancedButton()
  2598. {
  2599. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2600. FIX_THREAD_STATE_MFC_BUG();
  2601. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2602. CWinsAdvancedDialog dlg(GetHolder(), TRUE);
  2603. dlg.m_dwLookupTimeout = pRecord->m_dwLookupTimeout;
  2604. dlg.m_dwCacheTimeout = pRecord->m_dwCacheTimeout;
  2605. dlg.m_bNetBios = pRecord->m_dwMappingFlag & DNS_WINS_FLAG_SCOPE;
  2606. if (IDOK == dlg.DoModal())
  2607. {
  2608. pRecord->m_dwLookupTimeout = dlg.m_dwLookupTimeout;
  2609. pRecord->m_dwCacheTimeout = dlg.m_dwCacheTimeout;
  2610. pRecord->m_dwMappingFlag = dlg.m_bNetBios ?
  2611. pRecord->m_dwMappingFlag |= DNS_WINS_FLAG_SCOPE :
  2612. pRecord->m_dwMappingFlag &= ~DNS_WINS_FLAG_SCOPE;
  2613. SetDirty(TRUE);
  2614. }
  2615. }
  2616. ///////////////////////////////////////////////////////////////////////////////
  2617. // CDNSZoneNameServersPropertyPage
  2618. BOOL CDNSZoneNameServersPropertyPage::OnSetActive()
  2619. {
  2620. BOOL bRet = CDNSNameServersPropertyPage::OnSetActive();
  2621. if (bRet)
  2622. {
  2623. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2624. BOOL bReadOnly = !pHolder->IsPrimaryZoneUI();
  2625. if (m_bReadOnly != bReadOnly)
  2626. {
  2627. m_bReadOnly = bReadOnly;
  2628. EnableButtons(!m_bReadOnly);
  2629. }
  2630. }
  2631. return bRet;
  2632. }
  2633. void CDNSZoneNameServersPropertyPage::ReadRecordNodesList()
  2634. {
  2635. ASSERT(m_pCloneInfoList != NULL);
  2636. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2637. CDNSZoneNode* pDomainNode = pHolder->GetZoneNode();
  2638. SetDomainNode(pDomainNode);
  2639. pDomainNode->GetNSRecordNodesInfo(m_pCloneInfoList);
  2640. }
  2641. BOOL CDNSZoneNameServersPropertyPage::WriteNSRecordNodesList()
  2642. {
  2643. ASSERT(m_pCloneInfoList != NULL);
  2644. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2645. CDNSZoneNode* pDomainNode = pHolder->GetZoneNode();
  2646. return pDomainNode->UpdateNSRecordNodesInfo(m_pCloneInfoList, pHolder->GetComponentData());
  2647. }
  2648. ///////////////////////////////////////////////////////////////////////////////
  2649. // CDNSZonePropertyPageHolder
  2650. CDNSZonePropertyPageHolder::CDNSZonePropertyPageHolder(CCathegoryFolderNode* pFolderNode,
  2651. CDNSZoneNode* pZoneNode, CComponentDataObject* pComponentData)
  2652. : CPropertyPageHolderBase(pFolderNode, pZoneNode, pComponentData)
  2653. {
  2654. ASSERT(pComponentData != NULL);
  2655. ASSERT(pFolderNode != NULL);
  2656. ASSERT(pFolderNode == GetContainerNode());
  2657. ASSERT(pZoneNode != NULL);
  2658. ASSERT(pZoneNode == GetZoneNode());
  2659. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  2660. int nCurrPage = 0;
  2661. m_nGenPage = -1;
  2662. m_nSOAPage = -1;
  2663. m_nWINSorWINSRPage = -1;
  2664. m_nNSPage = -1;
  2665. // add pages
  2666. m_nGenPage = nCurrPage;
  2667. AddPageToList((CPropertyPageBase*)&m_generalPage);
  2668. nCurrPage++;
  2669. m_nSOAPage = nCurrPage;
  2670. AddPageToList((CPropertyPageBase*)&m_SOARecordPage);
  2671. nCurrPage++;
  2672. m_nNSPage = nCurrPage;
  2673. AddPageToList((CPropertyPageBase*)&m_nameServersPage);
  2674. nCurrPage++;
  2675. if (pZoneNode->IsReverse())
  2676. {
  2677. m_nWINSorWINSRPage = nCurrPage;
  2678. AddPageToList((CPropertyPageBase*)&m_NBSTATRecordPage);
  2679. nCurrPage++;
  2680. }
  2681. else
  2682. {
  2683. m_nWINSorWINSRPage = nCurrPage;
  2684. AddPageToList((CPropertyPageBase*)&m_WINSRecordPage);
  2685. nCurrPage++;
  2686. }
  2687. AddPageToList((CPropertyPageBase*)&m_zoneTransferPage);
  2688. // security page added only if needed
  2689. m_pAclEditorPage = NULL;
  2690. if (pZoneNode->IsDSIntegrated())
  2691. {
  2692. CString szPath;
  2693. pZoneNode->GetServerNode()->CreateDsZoneLdapPath(pZoneNode, szPath);
  2694. if (!szPath.IsEmpty())
  2695. m_pAclEditorPage = CAclEditorPage::CreateInstance(szPath, this);
  2696. }
  2697. // determine if we need/can have advanced view
  2698. CDNSRootData* pRootData = (CDNSRootData*)pComponentData->GetRootData();
  2699. ASSERT(pRootData != NULL);
  2700. m_bAdvancedView = pRootData->IsAdvancedView();
  2701. }
  2702. CDNSZonePropertyPageHolder::~CDNSZonePropertyPageHolder()
  2703. {
  2704. if (m_pAclEditorPage != NULL)
  2705. delete m_pAclEditorPage;
  2706. }
  2707. int CDNSZonePropertyPageHolder::OnSelectPageMessage(long nPageCode)
  2708. {
  2709. TRACE(_T("CDNSZonePropertyPageHolder::OnSelectPageMessage()\n"));
  2710. switch (nPageCode)
  2711. {
  2712. case ZONE_HOLDER_GEN:
  2713. return m_nGenPage;
  2714. case ZONE_HOLDER_SOA:
  2715. return m_nSOAPage;
  2716. case ZONE_HOLDER_NS:
  2717. return m_nNSPage;
  2718. case ZONE_HOLDER_WINS:
  2719. return m_nWINSorWINSRPage;
  2720. }
  2721. return -1;
  2722. }
  2723. HRESULT CDNSZonePropertyPageHolder::OnAddPage(int nPage, CPropertyPageBase*)
  2724. {
  2725. // add the ACL editor page after the last, if present
  2726. if ( (nPage != -1) || (m_pAclEditorPage == NULL) )
  2727. return S_OK;
  2728. // add the ACLU page
  2729. HPROPSHEETPAGE hPage = m_pAclEditorPage->CreatePage();
  2730. if (hPage == NULL)
  2731. return E_FAIL;
  2732. // add the raw HPROPSHEETPAGE to sheet, not in the list
  2733. return AddPageToSheetRaw(hPage);
  2734. }