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.

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