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.

328 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: domain.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _DOMAIN_H
  11. #define _DOMAIN_H
  12. #include "dnsutil.h"
  13. #include "record.h"
  14. #include "domainUI.h"
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // FORWARD DECLARATIONS
  17. class CDNSServerNode;
  18. class CDNSRecordNodeBase;
  19. class CDNSZoneNode;
  20. class CDNSRootHintsNode;
  21. class CDNS_NS_RecordNodeList;
  22. class CDNSRecordNodeEditInfoList;
  23. BOOL _match(LPCWSTR lpszNSName, CDNS_A_RecordNode* pARecordNode);
  24. /////////////////////////////////////////////////////////////////////////
  25. // CDNSDomainQueryObj
  26. class CDNSDomainQueryObj : public CDNSQueryObj
  27. {
  28. public:
  29. CDNSDomainQueryObj(LPCTSTR lpszServerName,
  30. LPCTSTR lpszZoneName,
  31. DWORD dwServerVersion,
  32. LPCTSTR lpszNodeName,
  33. LPCTSTR lpszFullNodeName,
  34. WORD wRecordType,
  35. DWORD dwSelectFlags,
  36. BOOL bIsZone,
  37. BOOL bReverse,
  38. BOOL bCache,
  39. BOOL bAdvancedView)
  40. : CDNSQueryObj(bAdvancedView, dwServerVersion)
  41. {
  42. m_szServerName = lpszServerName;
  43. m_szZoneName = lpszZoneName;
  44. m_szNodeName = lpszNodeName;
  45. m_szFullNodeName = lpszFullNodeName;
  46. m_wRecordType = wRecordType;
  47. m_dwSelectFlags = dwSelectFlags;
  48. m_bReverse = bReverse;
  49. m_bIsZone = bIsZone;
  50. m_bCache = bCache;
  51. // internal state variables
  52. m_bFirstPass = TRUE;
  53. }
  54. virtual BOOL Enumerate();
  55. // implementation for DNS domain/zone type
  56. BOOL CanAddRecord(WORD wRecordType, LPCWSTR lpszRecordName);
  57. BOOL CanAddDomain(LPCWSTR lpszDomainName)
  58. { return MatchName(lpszDomainName);}
  59. protected:
  60. DNS_STATUS EnumerateFiltered(WORD wRecordType);
  61. protected:
  62. // query parameters (in the sequence expected by CDNSDomainNode::EnumerateNodes)
  63. CString m_szNodeName;
  64. CString m_szZoneName;
  65. CString m_szFullNodeName;
  66. WORD m_wRecordType;
  67. DWORD m_dwSelectFlags;
  68. BOOL m_bIsZone;
  69. BOOL m_bReverse;
  70. BOOL m_bCache;
  71. // query flag to do multiple pass filtered query
  72. BOOL m_bFirstPass;
  73. };
  74. /////////////////////////////////////////////////////////////////////////
  75. // CDNSDomainNode
  76. class CDNSDomainNode : public CDNSMTContainerNode
  77. {
  78. public:
  79. CDNSDomainNode(BOOL bDelegation = FALSE);
  80. virtual ~CDNSDomainNode();
  81. // node info
  82. DECLARE_NODE_GUID()
  83. void SetZone(CDNSZoneNode* pZoneNode){m_pZoneNode = pZoneNode;}
  84. virtual CDNSZoneNode* GetZoneNode()
  85. { ASSERT(m_pZoneNode != NULL); return m_pZoneNode;}
  86. protected:
  87. // helpers for setting names
  88. void SetFullDNSName(BOOL bIsZone, BOOL bReverse,
  89. LPCTSTR lpszNodeName, LPCTSTR lpszParentFullName);
  90. void SetDisplayDNSName(BOOL bIsZone, BOOL bReverse, BOOL bAdvancedView,
  91. LPCTSTR lpszNodeName, LPCTSTR lpszParentFullName);
  92. void ChangePTRRecordsViewOption(BOOL bAdvanced,
  93. CComponentDataObject* pComponentDataObject);
  94. void OnMultiselectDelete(CComponentDataObject* pComponentData, CNodeList* pNodeList);
  95. public:
  96. void SetNames(BOOL bIsZone, BOOL bReverse, BOOL bAdvancedView,
  97. LPCTSTR lpszNodeName, LPCTSTR lpszParentFullName);
  98. virtual HRESULT OnCommand(long nCommandID,
  99. DATA_OBJECT_TYPES type,
  100. CComponentDataObject* pComponentData,
  101. CNodeList* pNodeList);
  102. virtual void OnDelete(CComponentDataObject* pComponentData,
  103. CNodeList* pNodeList);
  104. virtual BOOL OnRefresh(CComponentDataObject* pComponentData,
  105. CNodeList* pNodeList);
  106. virtual LPCWSTR GetString(int nCol)
  107. {
  108. return (nCol == 0) ? GetDisplayName() : g_lpszNullString;
  109. }
  110. virtual int GetImageIndex(BOOL bOpenImage);
  111. virtual LPWSTR GetDescriptionBarText();
  112. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  113. BOOL* pbHideVerb,
  114. CNodeList* pNodeList);
  115. virtual HRESULT CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  116. LONG_PTR handle,
  117. CNodeList* pNodeList);
  118. virtual HRESULT CreatePropertyPagesHelper(LPPROPERTYSHEETCALLBACK lpProvider,
  119. LONG_PTR handle, long nStartPageCode);
  120. virtual int Compare(CTreeNode* pNodeA, CTreeNode* pNodeB, int nCol, long lUserParam);
  121. virtual void Show(BOOL bShow, CComponentDataObject* pComponentData);
  122. virtual RECORD_SEARCH DoesContain(PCWSTR pszFullName,
  123. CComponentDataObject* pComponentData,
  124. CDNSDomainNode** ppDomainNode,
  125. CString& szNonExistentDomain,
  126. BOOL bExpandNodes = FALSE);
  127. protected:
  128. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  129. { return CDNSDomainMenuHolder::GetContextMenuItem(); }
  130. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  131. long *pInsertionAllowed);
  132. virtual BOOL OnSetDeleteVerbState(DATA_OBJECT_TYPES type,
  133. BOOL* pbHide,
  134. CNodeList* pNodeList);
  135. virtual BOOL OnSetRefreshVerbState(DATA_OBJECT_TYPES type,
  136. BOOL* pbHide,
  137. CNodeList* pNodeList);
  138. virtual HRESULT OnSetToolbarVerbState(IToolbar* pToolbar,
  139. CNodeList* pNodeList);
  140. // query creation
  141. virtual CQueryObj* OnCreateQuery();
  142. // main message handlers for thread messages
  143. virtual void OnThreadExitingNotification(CComponentDataObject* pComponentDataObject);
  144. virtual void OnHaveData(CObjBase* pObj, CComponentDataObject* pComponentDataObject);
  145. // command handlers
  146. private:
  147. void OnNewRecordHelper(CComponentDataObject* pComponentData, WORD wType);
  148. protected:
  149. HRESULT OnNewRecord(CComponentDataObject* pComponentData,
  150. CNodeList* pNodeList);
  151. void OnNewDomain(CComponentDataObject* pComponentData);
  152. void OnNewDelegation(CComponentDataObject* pComponentData);
  153. void OnNewHost(CComponentDataObject* pComponentData);
  154. void OnNewAlias(CComponentDataObject* pComponentData);
  155. void OnNewMailExchanger(CComponentDataObject* pComponentData);
  156. void OnNewPointer(CComponentDataObject* pComponentData);
  157. // DNS specific data
  158. protected:
  159. CString m_szFullName; // FQN for the current zone/domain
  160. CDNSZoneNode* m_pZoneNode; // pointer to the zone the domain
  161. BOOL m_bHasDataForPropPages; // TRUE if we have enough data to display PPages
  162. private:
  163. CDNS_NS_RecordNodeList* m_pNSRecordNodeList; // list of cached pointers to NS records
  164. // (used for zones and delegated domains)
  165. BOOL m_bDelegation; // TRUE of the node is a delegated domain
  166. protected:
  167. CDNS_NS_RecordNodeList* GetNSRecordNodeList()
  168. { ASSERT(m_pNSRecordNodeList != NULL); return m_pNSRecordNodeList; }
  169. public:
  170. LPCWSTR GetFullName() { return m_szFullName; }
  171. BOOL IsZone() { return (CDNSDomainNode*)m_pZoneNode == this; }
  172. DWORD GetDefaultTTL();
  173. // subdomain creation
  174. CDNSDomainNode* FindSubdomainNode(LPCTSTR lpszSubdomainNode);
  175. CDNSDomainNode* CreateSubdomainNode(BOOL bDelegation = FALSE); // create C++ object and hook it up
  176. void SetSubdomainName(CDNSDomainNode* pSubdomainNode,
  177. LPCTSTR lpszSubdomainName,
  178. BOOL bAdvancedView); // set the name of the C++ object
  179. DNS_STATUS CreateSubdomain(
  180. CDNSDomainNode* pSubdomainNode,
  181. CComponentDataObject* pComponentData); // assume the 2 above API's got used
  182. DNS_STATUS CreateSubdomain(LPCTSTR lpszDomainName,
  183. CComponentDataObject* pComponentData); // one step API using the ones above
  184. DNS_STATUS Create(); // from a new C++ node, create on the server
  185. // child enumeration
  186. static DNS_STATUS EnumerateNodes(LPCTSTR lpszServerName,
  187. LPCTSTR lpszZoneName,
  188. LPCTSTR lpszNodeName,
  189. LPCTSTR lpszFullNodeName,
  190. WORD wRecordType,
  191. DWORD dwSelectFlag,
  192. BOOL bIsZone, BOOL bReverse, BOOL bAdvancedView,
  193. CDNSDomainQueryObj* pQuery);
  194. public:
  195. BOOL IsDelegation() { return m_bDelegation;}
  196. // NS records management
  197. BOOL HasNSRecords();
  198. void GetNSRecordNodesInfo(CDNSRecordNodeEditInfoList* pNSInfoList);
  199. BOOL UpdateNSRecordNodesInfo(CDNSRecordNodeEditInfoList* pNewInfoList,
  200. CComponentDataObject* pComponentData);
  201. static void FindARecordsFromNSInfo(LPCWSTR lpszServerName, DWORD dwServerVersion,
  202. DWORD cServerAddrCount, PIP_ADDRESS pipServerAddrs,
  203. LPCWSTR lpszZoneName,
  204. LPCWSTR lpszNSName,
  205. CDNSRecordNodeEditInfoList* pNSInfoList,
  206. BOOL bAdvancedView);
  207. virtual void FindARecordsFromNSInfo(LPCTSTR lpszNSName, CDNSRecordNodeEditInfoList* pNSInfoList);
  208. protected:
  209. virtual void UpdateARecordsOfNSInfo(CDNSRecordNodeEditInfo* pNSInfo,
  210. CComponentDataObject* pComponentData);
  211. static void UpdateARecordsOfNSInfoHelper(CDNSDomainNode* pDomainNode,
  212. CDNSRecordNodeEditInfo* pNSInfo,
  213. CComponentDataObject* pComponentData,
  214. BOOL bAskConfirmation);
  215. protected:
  216. // called by OnHaveData() to set cached RR ptrs and generally preprocess RR's
  217. virtual void OnHaveRecord(CDNSRecordNodeBase* pRecordNode,
  218. CComponentDataObject* pComponentDataObject);
  219. private:
  220. DNS_STATUS Delete();
  221. DECLARE_TOOLBAR_MAP()
  222. };
  223. /////////////////////////////////////////////////////////////////////////
  224. // CDNSDummyDomainNode
  225. //
  226. // * not multithreaded and hidden in the UI
  227. class CDNSDummyDomainNode : public CDNSDomainNode
  228. {
  229. public:
  230. CDNSDummyDomainNode()
  231. {
  232. m_dwNodeFlags |= TN_FLAG_HIDDEN;
  233. }
  234. protected:
  235. virtual CQueryObj* OnCreateQuery()
  236. {
  237. // should never be called, only for MT objects
  238. ASSERT(FALSE);
  239. return NULL;
  240. }
  241. };
  242. /////////////////////////////////////////////////////////////////////////
  243. // CDNSRootHintsNode
  244. //
  245. // * exists only if the server is not authoritated for the root
  246. // * not multithreaded and hidden in the UI
  247. class CDNSRootHintsNode : public CDNSDummyDomainNode
  248. {
  249. public:
  250. CDNSRootHintsNode()
  251. {
  252. m_szFullName = _T(".");
  253. m_szDisplayName = _T(".");
  254. }
  255. // this "domain" object is not associated to any zone
  256. virtual CDNSZoneNode* GetZoneNode()
  257. { ASSERT(m_pZoneNode == NULL); return NULL;}
  258. DNS_STATUS QueryForRootHints(LPCTSTR lpszServerName, DWORD dwServerVersion);
  259. DNS_STATUS InitializeFromDnsQueryData(PDNS_RECORD pRootHintsRecordList);
  260. protected:
  261. virtual void FindARecordsFromNSInfo(LPCTSTR lpszNSName, CDNSRecordNodeEditInfoList* pNSInfoList);
  262. virtual void UpdateARecordsOfNSInfo(CDNSRecordNodeEditInfo* pNSInfo,
  263. CComponentDataObject* pComponentData);
  264. private:
  265. DNS_STATUS Clear();
  266. };
  267. #endif // _DOMAIN_H