Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
6.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: domobj.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _DOMOBJ_H
  11. #define _DOMOBJ_H
  12. ///////////////////////////////////////////////////////////////////////
  13. // global helper functions
  14. void ReportError(HWND hWnd, UINT nMsgID, HRESULT hr);
  15. ///////////////////////////////////////////////////////////////////////
  16. // Forward declarations
  17. class CComponentDataImpl;
  18. class CFolderObject;
  19. class CCookieSheetTable;
  20. class CDomainObject;
  21. ///////////////////////////////////////////////////////////////////////
  22. // CDomainTreeBrowser
  23. class CDomainTreeBrowser
  24. {
  25. public:
  26. CDomainTreeBrowser()
  27. {
  28. m_pDomains = NULL;
  29. }
  30. ~CDomainTreeBrowser()
  31. {
  32. _Reset();
  33. }
  34. BOOL HasData() { return m_pDomains != NULL; }
  35. HRESULT Bind(MyBasePathsInfo* pInfo);
  36. HRESULT GetData();
  37. PDOMAIN_TREE GetDomainTree()
  38. {
  39. ASSERT(m_pDomains != NULL);
  40. return m_pDomains;
  41. }
  42. private:
  43. CComPtr<IDsBrowseDomainTree> m_spIDsBrowseDomainTree; // interface pointer for browsing
  44. CComPtr<IDirectorySearch> m_spIDirectorySearch; //
  45. PDOMAIN_TREE m_pDomains; // pointer to the domain info to from backend
  46. void _Reset()
  47. {
  48. _FreeDomains();
  49. m_spIDsBrowseDomainTree = NULL;
  50. m_spIDirectorySearch = NULL;
  51. }
  52. void _FreeDomains()
  53. {
  54. if (m_pDomains == NULL)
  55. return;
  56. if (m_spIDsBrowseDomainTree != NULL)
  57. m_spIDsBrowseDomainTree->FreeDomains(&m_pDomains);
  58. else
  59. ::LocalFree(m_pDomains);
  60. m_pDomains = NULL;
  61. }
  62. };
  63. ////////////////////////////////////////////////////////////////////
  64. // CCookieTableBase
  65. class CCookieTableBase
  66. {
  67. public:
  68. CCookieTableBase();
  69. ~CCookieTableBase();
  70. void Add(CFolderObject* pCookie);
  71. BOOL Remove(CFolderObject* pCookie);
  72. BOOL IsPresent(CFolderObject* pCookie);
  73. void Reset();
  74. UINT GetCount();
  75. protected:
  76. UINT m_nEntries;
  77. CFolderObject** m_pCookieArr;
  78. };
  79. ////////////////////////////////////////////////////////////////////
  80. // CCookieSheetTable
  81. class CCookieSheetTable : public CCookieTableBase
  82. {
  83. public:
  84. void BringToForeground(CFolderObject* pCookie, CComponentDataImpl* pCD);
  85. };
  86. ///////////////////////////////////////////////////////////////////////
  87. // CFolderObject
  88. typedef CList<CFolderObject*, CFolderObject*> CFolderObjectList;
  89. class CFolderObject
  90. {
  91. public:
  92. CFolderObject()
  93. {
  94. m_nImage = 0;
  95. m_ID = 0;
  96. m_pParentFolder = NULL;
  97. m_nSheetLockCount = 0;
  98. }
  99. virtual ~CFolderObject();
  100. void SetScopeID(HSCOPEITEM ID) { m_ID = ID; }
  101. HSCOPEITEM GetScopeID() { return m_ID; }
  102. void SetImageIndex(int nImage) { m_nImage = nImage;}
  103. int GetImageIndex() { return m_nImage;}
  104. virtual LPCTSTR GetDisplayString(int nIndex) { return L"";}
  105. virtual HRESULT OnCommand(CComponentDataImpl* pCD, long nCommandID) { return S_OK;}
  106. virtual HRESULT OnAddMenuItems(LPCONTEXTMENUCALLBACK pContextMenuCallback,
  107. long *pInsertionAllowed) { return S_OK;}
  108. BOOL AddChild(CFolderObject* pChildFolderObject);
  109. void RemoveAllChildren();
  110. void SetParentFolder(CFolderObject* pParentFolder) { m_pParentFolder = pParentFolder; }
  111. CFolderObject* GetParentFolder() { return m_pParentFolder; }
  112. void IncrementSheetLockCount();
  113. void DecrementSheetLockCount();
  114. BOOL IsSheetLocked() { return (m_nSheetLockCount > 0); }
  115. BOOL _WarningOnSheetsUp(CComponentDataImpl* pCD);
  116. private:
  117. HSCOPEITEM m_ID; // scope item ID for this folder
  118. int m_nImage; // index if the image for folder
  119. CFolderObjectList m_childList; // list of children
  120. CFolderObject* m_pParentFolder;
  121. LONG m_nSheetLockCount; // keeps track if a node has been locked by a property sheet
  122. };
  123. ///////////////////////////////////////////////////////////////////////
  124. // CRootFolderObject
  125. class CRootFolderObject : public CFolderObject
  126. {
  127. public:
  128. CRootFolderObject(CComponentDataImpl* pCD);
  129. virtual ~CRootFolderObject() { }
  130. BOOL HasData() { return m_domainTreeBrowser.HasData(); }
  131. HRESULT Bind();
  132. HRESULT GetData();
  133. HRESULT EnumerateRootFolder(CComponentDataImpl* pComponentData);
  134. HRESULT EnumerateFolder(CFolderObject* pFolderObject,
  135. HSCOPEITEM pParent,
  136. CComponentDataImpl* pComponentData);
  137. virtual HRESULT OnCommand(CComponentDataImpl* pCD, long nCommandID);
  138. virtual HRESULT OnAddMenuItems(LPCONTEXTMENUCALLBACK pContextMenuCallback,
  139. long *pInsertionAllowed);
  140. HRESULT OnAddPages(LPPROPERTYSHEETCALLBACK lpProvider,
  141. LONG_PTR handle);
  142. CDomainObject* GetEnterpriseRootNode(void) {return m_pEnterpriseRoot;};
  143. private:
  144. //void OnDomainTrustWizard();
  145. void OnRetarget();
  146. void OnEditFSMO();
  147. CComponentDataImpl* m_pCD; // back pointer to snapin
  148. CDomainTreeBrowser m_domainTreeBrowser;
  149. CDomainObject* m_pEnterpriseRoot;
  150. };
  151. ///////////////////////////////////////////////////////////////////////
  152. // CDomainObject
  153. class CDomainObject : public CFolderObject
  154. {
  155. friend class CRootFolderObject;
  156. public:
  157. CDomainObject() : m_pDomainDescription(NULL), _fPdcAvailable(false)
  158. {
  159. TRACE(L"CDomainObject CTOR (0x%08x)\n", this);
  160. m_bSecondary = FALSE;
  161. };
  162. virtual ~CDomainObject();
  163. virtual LPCTSTR GetDisplayString(int nIndex);
  164. virtual HRESULT OnCommand(CComponentDataImpl* pCD, long nCommandID);
  165. virtual HRESULT OnAddMenuItems(LPCONTEXTMENUCALLBACK pContextMenuCallback,
  166. long *pInsertionAllowed);
  167. // Interface
  168. public:
  169. // string access functions
  170. LPCWSTR GetDomainName() { return GetDescriptionPtr()->pszName; };
  171. LPCWSTR GetNCName() { return GetDescriptionPtr()->pszNCName; };
  172. LPCWSTR GetClass () { return GetDescriptionPtr()->pszObjectClass; };
  173. DOMAIN_DESC* GetDescriptionPtr()
  174. { ASSERT(m_pDomainDescription != NULL); return m_pDomainDescription; };
  175. void InitializeForSecondaryPage(LPCWSTR pszNCName,
  176. LPCWSTR pszObjectClass,
  177. int nImage);
  178. void SetPDC(PCWSTR pwzPDC) {_strPDC = pwzPDC;};
  179. PCWSTR GetPDC(void) {return _strPDC;};
  180. void SetPdcAvailable(bool fAvail);
  181. bool PdcAvailable(void) {return _fPdcAvailable;};
  182. // Implementation
  183. private:
  184. void Initialize(DOMAIN_DESC* pDomainDescription,
  185. int nImage,
  186. BOOL bHasChildren = FALSE);
  187. void OnManage(CComponentDataImpl* pCD);
  188. void OnDomainTrustWizard(CComponentDataImpl* pCD);
  189. // Attributes
  190. private:
  191. DOMAIN_DESC * m_pDomainDescription; // pointer to the data in the blob
  192. BOOL m_bSecondary; // from a secondary page
  193. CString _strPDC;
  194. bool _fPdcAvailable;
  195. };
  196. #endif // _DOMOBJ_H