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.

338 lines
10 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: ScopTree.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History:
  15. //____________________________________________________________________________
  16. //
  17. #ifndef _SCOPTREE_H_
  18. #define _SCOPTREE_H_
  19. class CDocument;
  20. class CNode;
  21. class CMTNode;
  22. class CSPImageCache;
  23. class CMTSnapInNode;
  24. class CExtensionsCache;
  25. class CSnapIn;
  26. class CMultiSelection;
  27. class CConsoleTaskpad;
  28. class CConsoleTaskpadList;
  29. class CDefaultTaskpadList;
  30. class CConsoleFrame;
  31. class CNewTreeNode;
  32. typedef CNewTreeNode* PNEWTREENODE;
  33. typedef CList <PNEWTREENODE, PNEWTREENODE> NewNodeList;
  34. typedef CList<HMTNODE, HMTNODE> CHMTNODEList;
  35. typedef CTypedPtrList<MMC::CPtrList, CMTNode*> CMTNodeList;
  36. typedef CList<CMTNode*, CMTNode*> MTNodesList;
  37. typedef std::map<CMTNode*, PNODE> CMapMTNodeToMMCNode;
  38. typedef CMTSnapInNode * PMTSNAPINNODE;
  39. // forward declarations for external classes
  40. class CBookmark;
  41. /*+-------------------------------------------------------------------------*
  42. * class CMMCScopeNode
  43. *
  44. *
  45. * PURPOSE: Implements the Node automation interface, for a scope node
  46. *
  47. *+-------------------------------------------------------------------------*/
  48. class CMMCScopeNode :
  49. public CMMCIDispatchImpl<Node>
  50. {
  51. friend class CScopeTree;
  52. public:
  53. BEGIN_MMC_COM_MAP(CMMCScopeNode)
  54. END_MMC_COM_MAP()
  55. // Node methods
  56. public:
  57. STDMETHODIMP get_Name( PBSTR pbstrName);
  58. STDMETHODIMP get_Property( BSTR PropertyName, PBSTR PropertyValue);
  59. STDMETHODIMP get_Bookmark( PBSTR pbstrBookmark);
  60. STDMETHODIMP IsScopeNode(PBOOL pbIsScopeNode);
  61. STDMETHODIMP get_Nodetype(PBSTR Nodetype);
  62. // determines whether the object is valid or not.
  63. ::SC ScIsValid();
  64. ~CMMCScopeNode();
  65. public: // accessors
  66. CMTNode *GetMTNode() {return m_pMTNode;}
  67. void ResetMTNode() {m_pMTNode = NULL;}
  68. private:
  69. ::SC ScGetDataObject(IDataObject **ppDataObject); // returns the data object for the underlying scope node.
  70. private: // implementation
  71. CMTNode *m_pMTNode;
  72. };
  73. //____________________________________________________________________________
  74. //
  75. // class: CScopeTree
  76. //____________________________________________________________________________
  77. //
  78. class CScopeTree :
  79. public IScopeTree,
  80. public IPersistStorage,
  81. public CComObjectRoot,
  82. public CComCoClass<CScopeTree, &CLSID_ScopeTree>,
  83. public CTiedObject
  84. {
  85. // Constructor/Destructor
  86. public:
  87. CScopeTree();
  88. ~CScopeTree();
  89. public:
  90. #ifdef DBG
  91. ULONG InternalAddRef()
  92. {
  93. return CComObjectRoot::InternalAddRef();
  94. }
  95. ULONG InternalRelease()
  96. {
  97. return CComObjectRoot::InternalRelease();
  98. }
  99. int dbg_InstID;
  100. #endif // DBG
  101. // ATL Map
  102. public:
  103. BEGIN_COM_MAP(CScopeTree)
  104. COM_INTERFACE_ENTRY(IScopeTree)
  105. COM_INTERFACE_ENTRY(IPersistStorage)
  106. END_COM_MAP()
  107. DECLARE_NOT_AGGREGATABLE(CScopeTree)
  108. DECLARE_MMC_OBJECT_REGISTRATION (
  109. g_szMmcndmgrDll, // implementing DLL
  110. CLSID_ScopeTree, // CLSID
  111. _T("ScopeTree 1.0 Object"), // class name
  112. _T("NODEMGR.ScopeTreeObject.1"), // ProgID
  113. _T("NODEMGR.ScopeTreeObject")) // version-independent ProgID
  114. private: // Object model related tied COM objects
  115. SnapInsPtr m_spSnapIns;
  116. ScopeNamespacePtr m_spScopeNamespace;
  117. public: // Object model methods
  118. // SnapIns interface
  119. typedef PMTSNAPINNODE CSnapIns_Positon;
  120. CMTSnapInNode *GetNextStaticNode(CMTNode *pMTNode);
  121. SC ScAdd (BSTR bstrSnapinNameOrCLSID, VARIANT varParentSnapin,
  122. VARIANT varProperties, SnapIn** ppSnapIn); // add a snap-in.
  123. SC ScItem(long Index, PPSNAPIN ppSnapIn);
  124. SC ScRemove(PSNAPIN pSnapIn);
  125. SC Scget_Count(PLONG pCount);
  126. // SnapIns enumerator
  127. SC ScGetNextSnapInPos(CSnapIns_Positon &pos); // helper function
  128. SC ScEnumNext(CSnapIns_Positon &pos, PDISPATCH & pDispatch);
  129. SC ScEnumSkip(unsigned long celt, unsigned long& celtSkipped, CSnapIns_Positon &pos);
  130. SC ScEnumReset( CSnapIns_Positon &pos);
  131. // ScopeNamespace interface
  132. SC ScGetParent(PNODE pNode, PPNODE ppChild);
  133. SC ScGetChild(PNODE pNode, PPNODE ppChild);
  134. SC ScGetNext(PNODE pNode, PPNODE ppNext);
  135. SC ScGetRoot(PPNODE ppRoot);
  136. SC ScExpand(PNODE pNode);
  137. // helpers
  138. private:
  139. SC ScGetNode(CMTNode *pMTNode, PPNODE ppOut); // creates a Node interface object for the given MTNode.
  140. SC ScGetRootNode(PPNODE ppRootNode); // Calls above method to get to Root node.
  141. public:
  142. SC ScGetNode(PNODE pNode, CMTNode **ppMTNodeOut);
  143. // Operations
  144. public:
  145. // IScopeTree methods
  146. STDMETHOD(Initialize)(HWND hwndFrame, IStringTablePrivate* pStringTable);
  147. STDMETHOD(QueryIterator)(IScopeTreeIter** ppIter);
  148. STDMETHOD(QueryNodeCallback)(INodeCallback** ppNodeCallback);
  149. STDMETHOD(CreateNode)(HMTNODE hMTNode, LONG_PTR lViewData, BOOL fRootNode,
  150. HNODE* phNode);
  151. STDMETHOD(CloseView)(int nView);
  152. STDMETHOD(DeleteView)(int nView);
  153. STDMETHOD(DestroyNode)(HNODE hNode);
  154. STDMETHOD(Find)(MTNODEID mID, HMTNODE* hMTNode);
  155. STDMETHOD(Find)(MTNODEID mID, CMTNode** ppMTNode);
  156. STDMETHOD(GetImageList)(PLONG_PTR pImageList);
  157. STDMETHOD(RunSnapIn)(HWND hwndParent);
  158. STDMETHOD(GetFileVersion)(IStorage* pstgRoot, int* pnVersion);
  159. STDMETHOD(GetNodeIDFromBookmark)(HBOOKMARK hbm, MTNODEID* pID, bool& bExactMatchFound);
  160. STDMETHOD(GetNodeIDFromStream)(IStream *pStm, MTNODEID* pID);
  161. STDMETHOD(GetNodeFromBookmark)(HBOOKMARK hbm, CConsoleView *pConsoleView, PPNODE ppNode, bool& bExactMatchFound); // get the node from bookmark
  162. STDMETHOD(GetIDPath)(MTNODEID id, MTNODEID** ppIDs, long* pLength);
  163. STDMETHOD(IsSynchronousExpansionRequired)();
  164. STDMETHOD(RequireSynchronousExpansion)(BOOL fRequireSyncExpand);
  165. STDMETHOD(SetConsoleData)(LPARAM lConsoleData);
  166. STDMETHOD(GetPathString)(HMTNODE hmtnRoot, HMTNODE hmtnLeaf, LPOLESTR* pPath);
  167. STDMETHOD(QuerySnapIns)(SnapIns **ppSnapIns);
  168. STDMETHOD(QueryScopeNamespace)(ScopeNamespace **ppScopeNamespace);
  169. STDMETHOD(CreateProperties)(Properties** ppProperties);
  170. STDMETHOD(GetNodeID)(PNODE pNode, MTNODEID *pID);
  171. STDMETHOD(GetHMTNode)(PNODE pNode, HMTNODE *phMTNode);
  172. STDMETHOD(GetMMCNode)(HMTNODE hMTNode, PPNODE ppNode);
  173. STDMETHOD(QueryRootNode)(PPNODE ppNode);
  174. STDMETHOD(IsSnapinInUse)(REFCLSID refClsidSnapIn, PBOOL pbInUse);
  175. STDMETHOD(Persist)(HPERSISTOR pPersistor);
  176. // IPersistStorage methods
  177. STDMETHOD(HandsOffStorage)(void);
  178. STDMETHOD(InitNew)(IStorage *pStg);
  179. STDMETHOD(IsDirty)(void);
  180. STDMETHOD(Load)(IStorage *pStg);
  181. STDMETHOD(Save)(IStorage *pStg, BOOL fSameAsLoad);
  182. STDMETHOD(SaveCompleted)(IStorage *pStg);
  183. // IPersist method
  184. STDMETHOD(GetClassID)(CLSID *pClassID);
  185. // snap-in addition and removal
  186. SC ScAddOrRemoveSnapIns(MTNodesList * pmtnDeletedList, NewNodeList * pnnList);
  187. public:
  188. SC ScAddSnapin(LPCWSTR szSnapinNameOrCLSID, SnapIn* pParentSnapinNode, Properties* varProperties, SnapIn*& rpSnapIn);
  189. private: // taskpad persistence
  190. HRESULT LoadTaskpadList(IStorage *pStg);
  191. // Attributes
  192. public:
  193. CMTNode* GetRoot(void);
  194. CSPImageCache* GetImageCache(void) { return m_pImageCache; }
  195. /*
  196. * convenient, type-safe alternative to IScopeTree::GetImageList
  197. */
  198. HIMAGELIST GetImageList () const;
  199. // Operations
  200. SC ScInsert(LPSCOPEDATAITEM pSDI, COMPONENTID nID,
  201. CMTNode** ppMTNodeNew);
  202. SC ScDelete(CMTNode* pmtn, BOOL fDeleteThis, COMPONENTID nID);
  203. void DeleteNode(CMTNode* pmtn);
  204. void UpdateAllViews(LONG lHint, LPARAM lParam);
  205. void Cleanup(void);
  206. HWND GetMainWindow()
  207. {
  208. return (m_pConsoleData->m_hwndMainFrame);
  209. }
  210. static IStringTablePrivate* GetStringTable()
  211. {
  212. return (m_spStringTable);
  213. }
  214. static bool _IsSynchronousExpansionRequired()
  215. {
  216. return (m_fRequireSyncExpand);
  217. }
  218. static void _RequireSynchronousExpansion(bool fRequireSyncExpand)
  219. {
  220. m_fRequireSyncExpand = fRequireSyncExpand;
  221. }
  222. static CScopeTree* GetScopeTree()
  223. {
  224. return (m_pScopeTree);
  225. }
  226. PersistData* GetPersistData() const
  227. {
  228. return m_spPersistData;
  229. }
  230. SConsoleData* GetConsoleData() const
  231. {
  232. return m_pConsoleData;
  233. }
  234. CConsoleFrame* GetConsoleFrame() const
  235. {
  236. return ((m_pConsoleData != NULL) ? m_pConsoleData->GetConsoleFrame() : NULL);
  237. }
  238. CConsoleTaskpadList* GetConsoleTaskpadList() const
  239. {
  240. return (m_pConsoleTaskpads);
  241. }
  242. CDefaultTaskpadList* GetDefaultTaskpadList() const
  243. {
  244. return (m_pDefaultTaskpads);
  245. }
  246. SC ScSetHelpCollectionInvalid();
  247. HRESULT InsertConsoleTaskpad (CConsoleTaskpad *pConsoleTaskpad,
  248. CNode *pNodeTarget, bool bStartTaskWizard);
  249. SC ScUnadviseMTNode(CMTNode* pMTNode); // called from ~CMTNode()
  250. SC ScUnadviseMMCScopeNode(PNODE pNode); // called from ~MMCScopeNode();
  251. // Implementation
  252. private:
  253. // the one and only CScopeTree for this console
  254. static CScopeTree* m_pScopeTree;
  255. CMTNode* m_pMTNodeRoot;
  256. CSPImageCache* m_pImageCache;
  257. PersistDataPtr m_spPersistData;
  258. CMTNodeList m_MTNodesToBeReset;
  259. SConsoleData* m_pConsoleData;
  260. CConsoleTaskpadList* m_pConsoleTaskpads;
  261. CDefaultTaskpadList* m_pDefaultTaskpads;
  262. CMapMTNodeToMMCNode m_mapMTNodeToMMCNode;
  263. static bool m_fRequireSyncExpand;
  264. static IStringTablePrivatePtr m_spStringTable;
  265. void _DeleteNode(CMTNode* pmtn);
  266. void _GetPathString(CMTNode* pmtnRoot, CMTNode* pmtnCur, CStr& strPath);
  267. void DeleteDynamicNodes(CMTNode* pMTNode);
  268. BOOL ExtensionsHaveChanged(CMTSnapInNode* pMTSINode);
  269. void HandleExtensionChanges(CMTNode* pMTNode);
  270. // Not implemented
  271. CScopeTree(const CScopeTree& rhs);
  272. CScopeTree& operator= (const CScopeTree& rhs);
  273. }; // CScopeTree
  274. #endif // _SCOPTREE_H_