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.

464 lines
14 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: uinode.h
  7. //
  8. //--------------------------------------------------------------------------
  9. #ifndef __UINODE_
  10. #define __UINODE_
  11. #include "dscolumn.h"
  12. // FWD DECL
  13. class CDSComponentData;
  14. class CContextMenuVerbs;
  15. class CInternalFormatCracker;
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CThreadQueryInfo: base class for providing query information to post
  19. // to worker threads, need to derive from it
  20. class CThreadQueryInfo
  21. {
  22. public:
  23. CThreadQueryInfo()
  24. {
  25. m_nMaxItemCount = 0;
  26. m_bTooMuchData = FALSE;
  27. }
  28. virtual ~CThreadQueryInfo(){}
  29. private:
  30. //
  31. // Do nothing copy constructor and operator =
  32. //
  33. CThreadQueryInfo(CThreadQueryInfo&) {}
  34. CThreadQueryInfo& operator=(CThreadQueryInfo&) {}
  35. public:
  36. void SetMaxItemCount(UINT nMaxItemCount)
  37. {
  38. ASSERT(nMaxItemCount > 0);
  39. m_nMaxItemCount = nMaxItemCount;
  40. }
  41. UINT GetMaxItemCount()
  42. {
  43. ASSERT(m_nMaxItemCount > 0);
  44. return m_nMaxItemCount;
  45. }
  46. public:
  47. BOOL m_bTooMuchData;
  48. private:
  49. UINT m_nMaxItemCount;
  50. };
  51. ////////////////////////////////////////////////////////////////////
  52. // CNodeData: base class for node specific information for the
  53. // MMC UI node, need to derive from it
  54. class CNodeData
  55. {
  56. public:
  57. virtual ~CNodeData(){}
  58. protected:
  59. CNodeData(){}; // make it protected to force a derivation
  60. private:
  61. //
  62. // Do nothing copy constructor and operator =
  63. //
  64. CNodeData& operator=(CNodeData&) {}
  65. };
  66. ////////////////////////////////////////////////////////////////////
  67. // CUINodeList: list of node items (child nodes of a folder)
  68. class CUINode; // fwd decl
  69. typedef CList <CUINode *, CUINode*> CUINodeList;
  70. ////////////////////////////////////////////////////////////////////
  71. // CUIFolderInfo: for folder specific data
  72. #define SERIALNUM_NOT_TOUCHED 0x7fffffff
  73. class CUIFolderInfo
  74. {
  75. public:
  76. CUIFolderInfo(CUINode* pUINode);
  77. CUIFolderInfo(const CUIFolderInfo& copyFolder);
  78. ~CUIFolderInfo()
  79. {
  80. DeleteAllContainerNodes();
  81. DeleteAllLeafNodes();
  82. if (m_bOwnColumnMemory &&
  83. m_pColumnSet)
  84. {
  85. delete m_pColumnSet;
  86. m_pColumnSet = 0;
  87. }
  88. }
  89. protected:
  90. CUIFolderInfo() {}
  91. private:
  92. //
  93. // Do nothing copy constructor and operator =
  94. //
  95. CUIFolderInfo& operator=(CUIFolderInfo&) {}
  96. public:
  97. // Node management methods
  98. void DeleteAllContainerNodes();
  99. void DeleteAllLeafNodes();
  100. HRESULT AddNode(CUINode* pUINode);
  101. HRESULT AddListofNodes(CUINodeList* pNodeList);
  102. HRESULT DeleteNode(CUINode* pUINode); // deletes node
  103. HRESULT RemoveNode(CUINode* pUINode); // leaves node intact.
  104. virtual CDSColumnSet* GetColumnSet(PCWSTR pszClass, CDSComponentData* pCD);
  105. void SetColumnSet(CDSColumnSet* pColumnSet, bool bOwnColumnMemory = false)
  106. {
  107. if (m_pColumnSet != NULL)
  108. {
  109. delete m_pColumnSet;
  110. }
  111. m_pColumnSet = pColumnSet;
  112. m_bOwnColumnMemory = bOwnColumnMemory;
  113. }
  114. void SetSortOnNextSelect(BOOL bSort = TRUE) { m_bSortOnNextSelect = bSort; }
  115. BOOL GetSortOnNextSelect() { return m_bSortOnNextSelect; }
  116. void SetScopeItem(HSCOPEITEM hScopeItem) { m_hScopeItem = hScopeItem;}
  117. HSCOPEITEM GetScopeItem() { return m_hScopeItem; }
  118. // methods for expanded once flag
  119. BOOL IsExpanded() { return m_bExpandedOnce; }
  120. void SetExpanded() { m_bExpandedOnce = TRUE; }
  121. void ReSetExpanded() { m_bExpandedOnce = FALSE; }
  122. // methods to manage LRU serial number
  123. void UpdateSerialNumber(CDSComponentData* pCD);
  124. UINT GetSerialNumber(void) { return m_SerialNumber; }
  125. static const UINT nSerialNomberNotTouched;
  126. // methods to manage cached object count
  127. void AddToCount(UINT increment);
  128. void SubtractFromCount(UINT decrement);
  129. void ResetCount() { m_cObjectsContained = 0;}
  130. UINT GetObjectCount() { return m_cObjectsContained; }
  131. void SetTooMuchData(BOOL bSet, UINT nApproximateTotal);
  132. BOOL HasTooMuchData() { return m_bTooMuchData; }
  133. UINT GetApproxTotalContained() { return m_nApproximateTotalContained; }
  134. CUINode* GetParentNode();
  135. CUINodeList* GetLeafList() { return &m_LeafNodes; }
  136. CUINodeList* GetContainerList() { return &m_ContainerNodes; }
  137. void SetNode(CUINode* pUINode) { m_pUINode = pUINode; }
  138. private:
  139. CUINode* m_pUINode; // node the this folder info belong to
  140. CUINodeList m_ContainerNodes; // list of child folder nodes
  141. CUINodeList m_LeafNodes; // list of child leaf nodes
  142. CDSColumnSet* m_pColumnSet; // Column set assigned to this container
  143. HSCOPEITEM m_hScopeItem; // handle from MMC tree control
  144. BOOL m_bExpandedOnce; // expansion flag
  145. UINT m_cObjectsContained; // THIS is how many objects are here.
  146. UINT m_SerialNumber; // LRU value for scavenging folders
  147. BOOL m_bTooMuchData; // Flag to specify when the container has hit the TooMuchData limit
  148. int m_nApproximateTotalContained; // The approximate count of objects in this container retrieved from the msDS-Approx-Immed-Subordinates attribute
  149. BOOL m_bSortOnNextSelect; // Used to determine whether we should sort this container when it is selected next
  150. bool m_bOwnColumnMemory; // This class owns the memory for the column set if this value is true,
  151. // if it is false, the memory is owned elsewhere (probably in the CDSCache)
  152. };
  153. ////////////////////////////////////////////////////////////////////
  154. // CUINode: objects inserted in the MMC UI, the same class is used
  155. // for the scope pane and the result pane. The presence of folder
  156. // info makes it a container
  157. // REVIEW_JEFFJON :
  158. // This should really be a member of the CUINode class. I just didn't
  159. // have time to clean it up.
  160. class CUINode
  161. {
  162. public:
  163. CUINode(NODETYPE newNodeType = GENERIC_UI_NODE, CUINode* pParentNode = NULL);
  164. CUINode(const CUINode& copyNode);
  165. virtual ~CUINode();
  166. private:
  167. //
  168. // Do nothing copy constructor and operator =
  169. //
  170. CUINode& operator=(CUINode&) {}
  171. public:
  172. // Value management functions (to be overritten)
  173. NODETYPE GetNodeType() { return m_nodeType; }
  174. virtual void SetName(LPCWSTR lpszName) = 0;
  175. virtual LPCWSTR GetName() = 0;
  176. virtual void SetDesc(LPCWSTR lpszDesc) = 0;
  177. virtual LPCWSTR GetDesc() = 0;
  178. virtual int GetImage(BOOL bOpen) = 0;
  179. virtual GUID* GetGUID() = 0;
  180. virtual LPCWSTR GetDisplayString(int nCol, CDSColumnSet*)
  181. {
  182. if (nCol == 0)
  183. return GetName();
  184. else if (nCol == 1)
  185. return GetDesc();
  186. return L"";
  187. }
  188. CNodeData* GetNodeData()
  189. {
  190. return m_pNodeData;
  191. }
  192. CUIFolderInfo* GetFolderInfo()
  193. {
  194. ASSERT(m_pFolderInfo != NULL); // must check using IsContainer()
  195. return m_pFolderInfo;
  196. }
  197. BOOL IsContainer() { return m_pFolderInfo != NULL;}
  198. BOOL IsSnapinRoot() { return m_pParentNode == NULL;}
  199. void MakeContainer()
  200. {
  201. ASSERT(!IsContainer());
  202. m_pFolderInfo = new CUIFolderInfo(this);
  203. }
  204. virtual CDSColumnSet* GetColumnSet(CDSComponentData* pComponentData);
  205. void IncrementSheetLockCount();
  206. void DecrementSheetLockCount();
  207. BOOL IsSheetLocked() { return (m_nSheetLockCount > 0);}
  208. void SetExtOp(int opcode) { m_extension_op=opcode;}
  209. DWORD GetExtOp() { return m_extension_op; }
  210. virtual BOOL IsRelative(CUINode* pUINode);
  211. CUINode* GetParent() { return m_pParentNode; }
  212. void ClearParent() { m_pParentNode = NULL; }
  213. void SetParent(CUINode* pParentNode) { m_pParentNode = pParentNode; }
  214. //
  215. // These set the state of the standard context menu items
  216. //
  217. virtual BOOL IsDeleteAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  218. virtual BOOL IsRenameAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  219. virtual BOOL IsRefreshAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  220. virtual BOOL ArePropertiesAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  221. virtual BOOL IsCutAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  222. virtual BOOL IsCopyAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  223. virtual BOOL IsPasteAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  224. virtual BOOL IsPrintAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  225. virtual CContextMenuVerbs* GetContextMenuVerbsObject(CDSComponentData* pComponentData);
  226. virtual HRESULT OnCommand(long, CDSComponentData*) { return S_OK; }
  227. virtual BOOL HasPropertyPages(LPDATAOBJECT) { return FALSE; }
  228. virtual HRESULT Delete(CDSComponentData* pComponentData);
  229. virtual HRESULT DeleteMultiselect(CDSComponentData* pComponentData, CInternalFormatCracker* pObjCracker);
  230. virtual HRESULT Rename(LPCWSTR lpszNewName, CDSComponentData* pComponentData);
  231. virtual void Paste(IDataObject*, CDSComponentData*, LPDATAOBJECT*) {}
  232. virtual HRESULT QueryPaste(IDataObject*, CDSComponentData*) { return S_FALSE; }
  233. virtual HRESULT CreatePropertyPages(LPPROPERTYSHEETCALLBACK,
  234. LONG_PTR,
  235. LPDATAOBJECT,
  236. CDSComponentData*) { return S_FALSE; }
  237. protected:
  238. CNodeData* m_pNodeData; // node specific information
  239. CContextMenuVerbs* m_pMenuVerbs; // Context menus
  240. private:
  241. CUIFolderInfo* m_pFolderInfo; // container specific information
  242. CUINode* m_pParentNode; // back pointer to the parent node
  243. ULONG m_nSheetLockCount; // sheet lock counter
  244. NODETYPE m_nodeType; // the type of UI node as defined by the
  245. // NODETYPE enum
  246. int m_extension_op;
  247. };
  248. ////////////////////////////////////////////////////////////////////
  249. // CUINodeTableBase: base class to support locking of nodes
  250. class CUINodeTableBase
  251. {
  252. public:
  253. CUINodeTableBase();
  254. ~CUINodeTableBase();
  255. private:
  256. //
  257. // Do nothing copy constructor and operator =
  258. //
  259. CUINodeTableBase(CUINodeTableBase&) {}
  260. CUINodeTableBase& operator=(CUINodeTableBase&) {}
  261. public:
  262. void Add(CUINode* pNode);
  263. BOOL Remove(CUINode* pNode);
  264. BOOL IsPresent(CUINode* pNode);
  265. void Reset();
  266. UINT GetCount();
  267. protected:
  268. UINT m_nEntries;
  269. CUINode** m_pCookieArr;
  270. };
  271. ////////////////////////////////////////////////////////////////////
  272. // CUINodeQueryTable
  273. class CUINodeQueryTable : public CUINodeTableBase
  274. {
  275. public:
  276. CUINodeQueryTable() {}
  277. void RemoveDescendants(CUINode* pNode);
  278. BOOL IsLocked(CUINode* pNode);
  279. private:
  280. CUINodeQueryTable(const CUINodeQueryTable&) {}
  281. CUINodeQueryTable& operator=(const CUINodeQueryTable&) {}
  282. };
  283. ////////////////////////////////////////////////////////////////////
  284. // CUINodeSheetTable
  285. class CUINodeSheetTable : public CUINodeTableBase
  286. {
  287. public:
  288. CUINodeSheetTable() {}
  289. void BringToForeground(CUINode* pNode, CDSComponentData* pCD, BOOL bActivate);
  290. private:
  291. CUINodeSheetTable(const CUINodeSheetTable&) {}
  292. CUINodeSheetTable& operator=(const CUINodeSheetTable&) {}
  293. };
  294. /////////////////////////////////////////////////////////////////////////////
  295. // CGenericUINode : generic UI node, not corresponding to a DS object
  296. class CGenericUINode : public CUINode
  297. {
  298. public:
  299. CGenericUINode(
  300. NODETYPE newNodeType = GENERIC_UI_NODE,
  301. CUINode* pParentNode = NULL);
  302. CGenericUINode(const CGenericUINode& copyNode);
  303. private:
  304. //
  305. // Do nothing operator =
  306. //
  307. CGenericUINode& operator=(CGenericUINode&) {}
  308. public:
  309. // override of pure virtual functions
  310. virtual void SetName(LPCWSTR lpszName) { m_strName = lpszName;}
  311. virtual LPCWSTR GetName() { return m_strName; }
  312. virtual void SetDesc(LPCWSTR lpszDesc) { m_strDesc = lpszDesc;}
  313. virtual LPCWSTR GetDesc() { return m_strDesc; }
  314. int GetImage(BOOL) { return m_nImage; }
  315. virtual GUID* GetGUID() { return (GUID*)&GUID_NULL; }
  316. virtual HRESULT XMLSave(IXMLDOMDocument*, IXMLDOMNode**) { return S_OK;}
  317. HRESULT XMLSaveBase(IXMLDOMDocument* pXMLDoc,
  318. IXMLDOMNode* pXMLDOMNode);
  319. static LPCWSTR g_szNameXMLTag;
  320. static LPCWSTR g_szDecriptionXMLTag;
  321. static LPCWSTR g_szDnXMLTag;
  322. virtual void InvalidateSavedQueriesContainingObjects(CDSComponentData* /*pComponentData*/,
  323. const CStringList& /*refDNList*/) {}
  324. private:
  325. CString m_strName;
  326. CString m_strDesc;
  327. int m_nImage;
  328. };
  329. /////////////////////////////////////////////////////////////////////////////
  330. // CRootNode: root of the namespace
  331. class CRootNode : public CGenericUINode
  332. {
  333. public:
  334. CRootNode() : CGenericUINode(ROOT_UI_NODE)
  335. {
  336. MakeContainer();
  337. }
  338. private:
  339. //
  340. // Do nothing copy constructor and operator =
  341. //
  342. CRootNode(CRootNode&) {}
  343. CRootNode& operator=(CRootNode&) {}
  344. public:
  345. LPCWSTR GetPath() { return m_szPath;}
  346. void SetPath(LPCWSTR lpszPath) { m_szPath = lpszPath;}
  347. //
  348. // These set the state of the standard context menu items
  349. //
  350. virtual BOOL IsRefreshAllowed(CDSComponentData* pComponentData, BOOL* pbHide);
  351. virtual CContextMenuVerbs* GetContextMenuVerbsObject(CDSComponentData* pComponentData);
  352. virtual HRESULT OnCommand(long lCommandID, CDSComponentData* pComponentData);
  353. virtual CDSColumnSet* GetColumnSet(CDSComponentData* pComponentData);
  354. private:
  355. CString m_szPath;
  356. };
  357. #endif // __UINODE_