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.

654 lines
25 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: MTNode.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 9/13/1996 RaviR Created
  15. //
  16. //____________________________________________________________________________
  17. #ifndef _MTNODE_H_
  18. #define _MTNODE_H_
  19. #pragma once
  20. #include "refcount.h" // CRefCountedPtr
  21. #include "xmlimage.h" // CXMLImageList
  22. #define MMC_SYSTEMROOT_VARIABLE _T("systemroot")
  23. #define MMC_SYSTEMROOT_VARIABLE_PERC _T("%systemroot%")
  24. #define MMC_WINDIR_VARIABLE_PERC _T("%windir%")
  25. ///////////////////////////////////////////////////////////////////////////////
  26. // Classes referd to here declared in other local files.
  27. class CSnapIn; // from SnapIn.h
  28. class CSnapInsCache; // from SnapIn.h
  29. class CComponent; // from Node.h
  30. class CNode; // from Node.h
  31. class CSnapInNode; // from Node.h
  32. class CDoc;
  33. class CSPImageCache; // from ScopImag.h
  34. class CExtensionsCache;
  35. class CPersistor;
  36. class CBookmark; // from bookmark.h
  37. class CSnapinProperties; // from siprop.h
  38. ///////////////////////////////////////////////////////////////////////////////
  39. // Classes declared in this file
  40. class CComponentData;
  41. class CMTNode;
  42. class CMTSnapInNode;
  43. ///////////////////////////////////////////////////////////////////////////////
  44. // typedefs
  45. typedef CMTNode * PMTNODE;
  46. typedef CTypedPtrList<MMC::CPtrList, CNode*> CNodeList;
  47. typedef CList<HMTNODE, HMTNODE> CHMTNODEList;
  48. typedef CComponentData* PCCOMPONENTDATA;
  49. typedef std::vector<PCCOMPONENTDATA> CComponentDataArray;
  50. typedef CArray<GUID, GUID&> CGuidArray;
  51. HRESULT CreateSnapIn (const CLSID& clsid, IComponentData** ppICD,
  52. bool fCreateDummyOnFailure = true);
  53. HRESULT LoadRequiredExtensions(CSnapIn* pSnapIn, IComponentData* pICD, CSnapInsCache* pCache = NULL);
  54. HRESULT AddRequiredExtension(CSnapIn* pSnapIn, CLSID& rcslid);
  55. void DisplayPolicyErrorMessage(const CLSID& clsid, bool bExtension);
  56. #include "snapinpersistence.h"
  57. //____________________________________________________________________________
  58. //
  59. // Class: CComponentData
  60. //____________________________________________________________________________
  61. //
  62. class CComponentData
  63. {
  64. DECLARE_NOT_COPIABLE (CComponentData)
  65. DECLARE_NOT_ASSIGNABLE (CComponentData)
  66. public:
  67. // Constructor & Destructor
  68. CComponentData(CSnapIn * pSnapIn);
  69. ~CComponentData();
  70. // Attributes
  71. void SetComponentID(COMPONENTID nID)
  72. {
  73. ASSERT(nID >= 0);
  74. ASSERT(nID < 1000);
  75. m_ComponentID = nID;
  76. }
  77. void SetIComponentData(IComponentData* pICD) { m_spIComponentData = pICD; }
  78. BOOL IsInitialized()
  79. {
  80. return (m_spIFramePrivate != NULL);
  81. }
  82. CSnapIn* GetSnapIn(void) const { return m_spSnapIn; }
  83. const CLSID& GetCLSID() const { return m_spSnapIn->GetSnapInCLSID(); }
  84. IComponentData* GetIComponentData(void) const { return m_spIComponentData; }
  85. IFramePrivate* GetIFramePrivate(void) const { return m_spIFramePrivate; }
  86. IImageListPrivate* GetIImageListPrivate(void);
  87. COMPONENTID GetComponentID(void) const { return m_ComponentID; }
  88. LPUNKNOWN GetUnknownToLoad(void) const { return m_spIComponentData; }
  89. // IComponentData interface methods
  90. HRESULT Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  91. HRESULT QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  92. HRESULT GetNodeType(MMC_COOKIE cookie, GUID* pGuid);
  93. HRESULT GetDisplayInfo(SCOPEDATAITEM* pScopeDataItem);
  94. // IComponentData2 helpers
  95. SC ScQueryDispatch(MMC_COOKIE, DATA_OBJECT_TYPES type, PPDISPATCH ppScopeNodeObject);
  96. // Operations
  97. // Initialization
  98. HRESULT Init(HMTNODE hMTNode);
  99. void ResetComponentID(COMPONENTID id)
  100. {
  101. m_spIFramePrivate->SetComponentID(m_ComponentID = id);
  102. }
  103. // loaded from stream/storage; initailized with the new one; or does not need initialization
  104. bool IsIComponentDataInitialized()
  105. {
  106. return m_bIComponentDataInitialized;
  107. }
  108. // loaded from stream/storage; initailized with the new one; or does not need initialization
  109. void SetIComponentDataInitialized()
  110. {
  111. m_bIComponentDataInitialized = true;
  112. }
  113. private:
  114. // Implementation
  115. CSnapInPtr m_spSnapIn;
  116. IComponentDataPtr m_spIComponentData;
  117. IFramePrivatePtr m_spIFramePrivate;
  118. COMPONENTID m_ComponentID;
  119. bool m_bIComponentDataInitialized;
  120. }; // class CComponentData
  121. /*+-------------------------------------------------------------------------*
  122. * class CMTNode
  123. *
  124. *
  125. * PURPOSE:
  126. *
  127. *+-------------------------------------------------------------------------*/
  128. class CMTNode : public XMLListCollectionBase
  129. {
  130. DECLARE_NOT_COPIABLE (CMTNode)
  131. DECLARE_NOT_ASSIGNABLE (CMTNode)
  132. protected:
  133. // codes corresponding to legacy node types.
  134. enum eNodeCodes
  135. {
  136. NODE_CODE_SNAPIN = 1,
  137. NODE_CODE_FOLDER = 2, // codes 2,3,4 are no longer correspond to
  138. NODE_CODE_HTML = 3, // MTNode derived classes, but are retained
  139. NODE_CODE_OCX = 4, // for converting old .msc files
  140. NODE_CODE_ENUMERATED = 10
  141. };
  142. public:
  143. static CMTNode* FromScopeItem (HSCOPEITEM item);
  144. static HSCOPEITEM ToScopeItem (const CMTNode* pMTNode) { return (reinterpret_cast<HSCOPEITEM>(pMTNode)); }
  145. static CMTNode* FromHandle (HMTNODE hMTNode) { return (reinterpret_cast<CMTNode*>(hMTNode)); }
  146. static HMTNODE ToHandle (const CMTNode* pMTNode) { return (reinterpret_cast<HMTNODE>(const_cast<CMTNode*>(pMTNode))); }
  147. // Constructor
  148. CMTNode();
  149. virtual HRESULT Init(void);
  150. // Attributes
  151. virtual BOOL IsStaticNode() const {return FALSE;}
  152. BOOL IsDynamicNode() const {return !IsStaticNode();}
  153. virtual HRESULT IsExpandable();
  154. HRESULT QueryDataObject(DATA_OBJECT_TYPES type, LPDATAOBJECT* ppdtobj);
  155. // Images
  156. UINT GetImage(void) { return m_nImage; }
  157. UINT GetOpenImage(void) { return m_nOpenImage; }
  158. UINT GetState(void);
  159. void SetImage(UINT nImage) { m_nImage = nImage; }
  160. void SetOpenImage(UINT nImage) { m_nOpenImage = nImage; }
  161. void SetState(UINT nState) { m_nState = nState; }
  162. void SetOwnerID(long id) { m_idOwner = id; }
  163. long GetOwnerID(void) const { return m_idOwner; }
  164. void SetPrimaryComponentData(CComponentData* pDI) { m_pPrimaryComponentData = pDI; }
  165. CComponentData* GetPrimaryComponentData() const { return m_pPrimaryComponentData; }
  166. virtual tstring GetDisplayName();
  167. virtual void SetDisplayName(LPCTSTR pszName);
  168. protected:
  169. tstring GetCachedDisplayName() const {return m_strName.str();}
  170. void SetCachedDisplayName(LPCTSTR pszName);
  171. public:
  172. BOOL IsInitialized() { return m_bInit; }
  173. int GetDynExtCLSID ( LPCLSID *ppCLSID );
  174. void SetNoPrimaryChildren(BOOL bState = TRUE);
  175. HRESULT OnRename(long fRename, LPOLESTR pszNewName);
  176. SC ScQueryDispatch(DATA_OBJECT_TYPES type, PPDISPATCH ppScopeNodeObject);
  177. HRESULT AddExtension(LPCLSID lpclsid);
  178. CSnapIn* GetPrimarySnapIn(void) const { return m_pPrimaryComponentData->GetSnapIn(); }
  179. COMPONENTID GetPrimaryComponentID();
  180. CMTSnapInNode* GetStaticParent(void);
  181. const CLSID& GetPrimarySnapInCLSID(void);
  182. LPARAM GetUserParam(void) const { return m_lUserParam; }
  183. void SetUserParam(LPARAM lParam) { m_lUserParam = lParam; }
  184. HRESULT GetNodeType(GUID* pGuid);
  185. SC ScGetPropertyFromINodeProperties(LPDATAOBJECT pDataObject, BSTR bstrPropertyName, PBSTR pbstrPropertyValue);
  186. // Operations
  187. virtual CNode * GetNode(CViewData* pViewData,
  188. BOOL fRootNode = FALSE); // Method to create a node for this Master Node.
  189. HRESULT Expand(void);
  190. HRESULT Expand (CComponentData*, IDataObject*, BOOL);
  191. virtual bool AllowNewWindowFromHere() const { return (true); }
  192. // Reference counting methods.
  193. USHORT AddRef();
  194. USHORT Release();
  195. // Tree traversal methods.
  196. PMTNODE Next() const {return m_pNext;}
  197. PMTNODE Prev() const {return m_pPrev;}
  198. PMTNODE Child() const {return m_pChild;}
  199. PMTNODE LastChild() const {return m_pLastChild;}
  200. PMTNODE Parent() const {return m_pParent;}
  201. CMTNode * NextStaticNode();
  202. //+------------------------------------------------------------------
  203. // Tree Manipulation methods
  204. //
  205. // ScInsertChild: Inserts pmtn as a child after pmtnInsertAfter
  206. // (first child if pmtnInsertAfter is NULL)
  207. //
  208. // ScDeleteChild: Deletes child pmtn
  209. //
  210. // ScDeleteTrailingChildren: Deletes pmtnFirst and following children
  211. //---------------------------------------------------------------------
  212. SC ScInsertChild(CMTNode* pmtn, CMTNode* pmtnInsertAfter);
  213. SC ScDeleteChild(CMTNode* pmtn);
  214. SC ScDeleteTrailingChildren(CMTNode* pmtnFirst);
  215. // Iterators that expand
  216. PMTNODE GetNext() const {return Next();}
  217. PMTNODE GetChild();
  218. void CreatePathList(CHMTNODEList& path);
  219. // Returns true if the stucture of tree needs to be saved,
  220. // or if any of the nodes need to be saved.
  221. // Derived classes which want to do more complex IsDirty() testing
  222. // may over-ride this function.
  223. virtual HRESULT IsDirty();
  224. HRESULT InitNew(PersistData*); // Saves the stream information for later use and sets the dirty flag.
  225. static SC ScLoad(PersistData*, CMTNode** ppRootNode); // Creates a new tree structure from the provided storage and returns it in ppRootNode.
  226. void ResetExpandedAtLeastOnce() {_SetFlag(FLAG_EXPANDED_AT_LEAST_ONCE, FALSE);}
  227. void SetExpandedAtLeastOnce() {_SetFlag(FLAG_EXPANDED_AT_LEAST_ONCE, TRUE);}
  228. BOOL WasExpandedAtLeastOnce() {return _IsFlagSet(FLAG_EXPANDED_AT_LEAST_ONCE);}
  229. void SetPropertyPageIsDisplayed(BOOL bSet) {_SetFlag(FLAG_PROPERTY_PAGE_IS_DISPLAYED, bSet);}
  230. BOOL IsPropertyPageDisplayed() {return _IsFlagSet(FLAG_PROPERTY_PAGE_IS_DISPLAYED);}
  231. // Flag to monitor if MMCN_REMOVE_CHILDREN was sent to the snapin owning the node
  232. void SetRemovingChildren(bool b) {_SetFlag(FLAG_REMOVING_CHILDREN, b);}
  233. bool AreChildrenBeingRemoved();
  234. // Unique ID helper functions. (Each node will be assigned an unique id
  235. // within the .msc file.)
  236. static MTNODEID GetNextID() throw() {return m_NextID++;}
  237. static void ResetID() throw() {m_NextID = ROOTNODEID;}
  238. CMTNode* Find(MTNODEID id);
  239. MTNODEID GetID() const throw() {return m_ID;}
  240. void SetID(MTNODEID key) {m_ID = key;}
  241. HRESULT DestroyElements(); // recursive function
  242. HRESULT DoDestroyElements(); // non-recursvie part
  243. // Deletes any persistence data stored in the current file
  244. void SetDirty(bool bIsDirty = true) {m_bIsDirty = bIsDirty;}
  245. void ClearDirty() {m_bIsDirty = false;}
  246. virtual void NotifyAddedToTree() {}
  247. virtual HRESULT CloseView(int viewID);
  248. virtual HRESULT DeleteView(int viewID);
  249. virtual bool DoDelete(HWND hwnd) { return true; }
  250. virtual void OnChildrenChanged() {}
  251. CMTNode* GetLastChild();
  252. virtual CSnapInNode* FindNode(int nViewID) { return NULL; }
  253. // Unique ID for the node instance.
  254. CBookmark* GetBookmark();
  255. virtual void Reset();
  256. protected:
  257. virtual ~CMTNode();
  258. virtual HRESULT InitNew() {return S_OK;} // Provides the derived nodes the opportunity to initialize the persistent resources.
  259. virtual SC ScLoad();
  260. public:
  261. virtual void Persist(CPersistor& persistor); // persists the node
  262. virtual void OnNewElement(CPersistor& persistor);
  263. static void PersistNewNode(CPersistor &persistor, CMTNode** ppNode);
  264. DEFINE_XML_TYPE(XML_TAG_MT_NODE);
  265. static wchar_t* GetViewStorageName(wchar_t* name, int idView);
  266. static SC ScGetComponentStreamName(wchar_t* szName, int cchName, const CLSID& clsid);
  267. static SC ScGetComponentStorageName(wchar_t* szName, int cchName, const CLSID& clsid);
  268. static int GetViewIdFromStorageName(const wchar_t* name);
  269. protected:
  270. // Allows the tree to re-attach to a persistence source.
  271. IStream* GetTreeStream() {return m_spTreeStream;}
  272. BOOL GetDirty() {return m_bIsDirty;}
  273. wchar_t* GetStorageName(wchar_t* name) {return _ltow(GetID(), name, 36);}
  274. IStorage* GetNodeStorage() {return m_spNodeStorage;}
  275. IStorage* GetViewStorage() {return m_spViewStorage;}
  276. IStorage* GetStorageForCD() {return m_spCDStorage;}
  277. PersistData* GetPersistData() {return m_spPersistData;}
  278. bool Loaded() {return m_bLoaded;}
  279. bool AreExtensionsExpanded(void) const { return m_bExtensionsExpanded; }
  280. private: // Helper methods
  281. // Tree manipulation helpers
  282. void AttachNext(PMTNODE pmn) {m_pNext = pmn;}
  283. void AttachPrev(PMTNODE pmn) {m_pPrev = pmn;}
  284. void AttachChild(PMTNODE pmn) {m_pChild = pmn;}
  285. void AttachLastChild(PMTNODE pmn) {m_pLastChild = pmn;}
  286. void AttachParent(PMTNODE pmn) {m_pParent = pmn;}
  287. // Helper for ScLoad(PersistData*, CMTNode**)
  288. static SC ScLoad(PersistData*, CMTNode** ppRootNode,
  289. CMTNode* pParent, CMTNode* pPrev);
  290. // Implementation
  291. private:
  292. PMTNODE m_pNext;
  293. PMTNODE m_pPrev;
  294. PMTNODE m_pChild; // First Child
  295. PMTNODE m_pLastChild;
  296. PMTNODE m_pParent;
  297. std::auto_ptr<CBookmarkEx> m_bookmark; // For node instance persistance
  298. PersistDataPtr m_spPersistData;
  299. IStoragePtr m_spNodeStorage;
  300. IStoragePtr m_spViewStorage;
  301. IStoragePtr m_spCDStorage;
  302. IStreamPtr m_spTreeStream;
  303. bool m_bIsDirty;
  304. USHORT m_cRef;
  305. USHORT m_usFlags; // m_bExpandedAtLeastOnce;
  306. enum ENUM_FLAGS
  307. {
  308. FLAG_EXPANDED_AT_LEAST_ONCE = 0x0001,
  309. FLAG_PROPERTY_PAGE_IS_DISPLAYED = 0x0002,
  310. FLAG_REMOVING_CHILDREN = 0x0004,
  311. };
  312. void _SetFlag(ENUM_FLAGS flag, BOOL bSet);
  313. BOOL _IsFlagSet(ENUM_FLAGS flag){return ((m_usFlags & flag) == flag);}
  314. MTNODEID m_ID; // Unique id for this node within the .msc file.
  315. bool m_bLoaded; // when true, load should be called instead of init new
  316. static MTNODEID m_NextID; // The last unique identifier given out.
  317. HRESULT OpenStorageForNode(); // Opens the storage for this specific instance of a node.
  318. HRESULT OpenStorageForView(); // Opens the view storage for this specific instance of a node.
  319. HRESULT OpenStorageForCD(); // Opens the view storage for this specific instance of a node.
  320. private:
  321. HRESULT OpenTreeStream(); // Opens the stream to be used to contain this nodes data.
  322. void SetParent(CMTNode* pParent);// Sets the parent for this and all next nodes.
  323. protected:
  324. UINT m_nImage;
  325. UINT m_nOpenImage;
  326. UINT m_nState;
  327. CStringTableString m_strName; // Display name
  328. protected:
  329. enum StreamVersionIndicator
  330. {
  331. Stream_V0100 = 1, // MMC 1.0
  332. Stream_V0110 = 2, // MMC 1.1
  333. Stream_CurrentVersion = Stream_V0110,
  334. VersionedStreamMarker = 0xFFFFFFFF,
  335. };
  336. private:
  337. long m_idOwner; // One of the SnapIns.
  338. LPARAM m_lUserParam;
  339. CComponentData* m_pPrimaryComponentData;
  340. BOOL m_bInit;
  341. bool m_bExtensionsExpanded;
  342. CGuidArray m_arrayDynExtCLSID;
  343. unsigned short m_usExpandFlags;
  344. enum ENUM_EXPAND_FLAGS
  345. {
  346. FLAG_NO_CHILDREN_FROM_PRIMARY = 0x0001,
  347. FLAG_NO_NAMESPACE_EXTNS = 0x0002,
  348. FLAG_NAMESPACE_EXTNS_CHECKED = 0x0004
  349. };
  350. }; // class CMTNode
  351. /*+-------------------------------------------------------------------------*
  352. * class ViewRootStorage
  353. *
  354. *
  355. * PURPOSE:
  356. *
  357. *+-------------------------------------------------------------------------*/
  358. class ViewRootStorage
  359. {
  360. public:
  361. ViewRootStorage() {}
  362. ~ViewRootStorage()
  363. {
  364. Clear();
  365. }
  366. void Initialize(IStorage* pRootStorage)
  367. {
  368. ASSERT(m_spRootStorage == NULL);
  369. ASSERT(pRootStorage != NULL);
  370. m_spRootStorage = pRootStorage;
  371. }
  372. IStorage* GetRootStorage()
  373. {
  374. return m_spRootStorage;
  375. }
  376. bool Insert(IStorage* pViewStorage, int idView)
  377. {
  378. ASSERT(pViewStorage != NULL);
  379. if ( NULL == m_Views.Find(idView))
  380. {
  381. return m_Views.Insert(IStoragePtr(pViewStorage), idView);
  382. }
  383. return true;
  384. }
  385. bool Remove(int idView)
  386. {
  387. const bool bRemoved = m_Views.Remove(idView);
  388. return bRemoved;
  389. }
  390. IStorage* FindViewStorage(int idView) const
  391. {
  392. CAdapt<IStoragePtr> *pspStorage = m_Views.Find(idView);
  393. return (pspStorage ? pspStorage->m_T : NULL);
  394. }
  395. void Clear()
  396. {
  397. m_Views.Clear();
  398. m_spRootStorage = NULL;
  399. }
  400. private:
  401. // CAdapt is used to hide operator&() - which will be invoked by map
  402. // implementation to get address of the element.
  403. // Smart pointer's operator&() releases reference plus returns wrong type for a map.
  404. Map<CAdapt<IStoragePtr>, int> m_Views;
  405. IStoragePtr m_spRootStorage;
  406. }; // class ViewRootStorage
  407. /*+-------------------------------------------------------------------------*
  408. * class CMTSnapInNode
  409. *
  410. *
  411. * PURPOSE: The root node of a primary snap-in. Added to the console and
  412. * the scope tree by MMC. Only a snap-in that is added from the
  413. * Add/Remove snapin page of the Snapin manager has a static node;
  414. * extensions of any type do not.
  415. *
  416. *+-------------------------------------------------------------------------*/
  417. class CMTSnapInNode : public CMTNode, public CTiedObject
  418. {
  419. DECLARE_NOT_COPIABLE (CMTSnapInNode)
  420. DECLARE_NOT_ASSIGNABLE (CMTSnapInNode)
  421. public:
  422. // Constructor & Destructor
  423. CMTSnapInNode(Properties* pProps);
  424. ~CMTSnapInNode();
  425. // SnapIn object model methods
  426. public:
  427. SC ScGetSnapIn(PPSNAPIN ppSnapIn);
  428. SC Scget_Name( PBSTR pbstrName);
  429. SC Scget_Extensions( PPEXTENSIONS ppExtensions);
  430. SC Scget_SnapinCLSID(PBSTR pbstrSnapinCLSID);
  431. SC Scget_Properties( PPPROPERTIES ppProperties);
  432. SC ScEnableAllExtensions (BOOL bEnable);
  433. // helper for CMMCSnapIn
  434. SC ScGetSnapinClsid(CLSID& clsid);
  435. static SC ScGetCMTSnapinNode(PSNAPIN pSnapIn, CMTSnapInNode **ppMTSnapInNode);
  436. public:
  437. // Attributes
  438. virtual BOOL IsStaticNode() const { return TRUE; }
  439. UINT GetResultImage(CNode* pNode, IImageListPrivate* pImageList);
  440. void SetResultImage(UINT index) { m_resultImage = index; }
  441. void SetPrimarySnapIn(CSnapIn * pSI);
  442. CNodeList& GetNodeList(void) { return m_NodeList; }
  443. virtual HRESULT IsExpandable();
  444. // Operations
  445. // Initialize
  446. virtual HRESULT Init(void);
  447. // Create a node for this master node.
  448. virtual CNode * GetNode(CViewData* pViewData, BOOL fRootNode = FALSE);
  449. virtual tstring GetDisplayName();
  450. virtual void SetDisplayName(LPCTSTR pszName);
  451. void AddNode(CNode * pNode);
  452. void RemoveNode(CNode * pNode);
  453. virtual CSnapInNode* FindNode(int nViewID);
  454. int GetNumberOfComponentDatas() { return m_ComponentDataArray.size(); }
  455. COMPONENTID AddComponentDataToArray(CComponentData* pCCD);
  456. CComponentData* GetComponentData(const CLSID& clsid);
  457. CComponentData* GetComponentData(COMPONENTID nID);
  458. CComponent* GetComponent(UINT nViewID, COMPONENTID nID, CSnapIn* pSnapIn);
  459. virtual HRESULT CloseView(int viewID);
  460. virtual HRESULT DeleteView(int viewID);
  461. // Loads from existing stream/storage or initializes with the new one
  462. SC ScInitIComponentData( CComponentData* pCD );
  463. SC ScInitIComponent(CComponent* pComponent, int viewID);
  464. virtual void Reset();
  465. void CompressComponentDataArray();
  466. BOOL IsPreloadRequired () const;
  467. void SetPreloadRequired (bool bPreload) { m_ePreloadState = (bPreload) ? ePreload_True : ePreload_False;}
  468. SC ScConvertLegacyNode(const CLSID &clsid);
  469. // Implementation
  470. protected:
  471. // virtual HRESULT InitNew();
  472. virtual HRESULT IsDirty();
  473. virtual SC ScLoad();
  474. virtual void Persist(CPersistor& persistor);
  475. private:
  476. SC ScInitProperties();
  477. SC ScCreateSnapinProperties(CSnapinProperties** ppSIProps);
  478. SC ScAddImagesToImageList();
  479. SC ScReadStreamsAndStoragesFromConsole();
  480. // Loads from existing sream/storage of initializes with the new one.
  481. SC ScInitComponentOrComponentData( IUnknown *pSnapin, CMTSnapinNodeStreamsAndStorages *pStreamsAndStorages,
  482. int idView , const CLSID& clsid );
  483. private:
  484. enum PersistType
  485. {
  486. PT_None,
  487. PT_IStream,
  488. PT_IStreamInit,
  489. PT_IStorage
  490. };
  491. enum PreloadState
  492. {
  493. ePreload_Unknown = -1, // don't know if MMCN_PRELOAD is required yet
  494. ePreload_False = 0, // MMCN_PRELOAD not required
  495. ePreload_True = 1, // MMCN_PRELOAD required
  496. };
  497. SC ScQueryPreloadRequired (PreloadState& ePreload) const;
  498. SC ScHandleCustomImages (const CLSID& clsidSnapin);
  499. SC ScHandleCustomImages (HBITMAP hbmSmall, HBITMAP hbmSmallOpen, HBITMAP hbmLarge, COLORREF crMask);
  500. HRESULT AreIComponentDatasDirty();
  501. HRESULT AreIComponentsDirty();
  502. HRESULT IsIUnknownDirty(IUnknown* pUnk);
  503. SC ScSaveIComponentDatas();
  504. SC ScSaveIComponentData( CComponentData* pCD );
  505. SC ScSaveIComponents();
  506. SC ScSaveIComponent( CComponent* pCComponent, int viewID );
  507. SC ScAskSnapinToSaveData( IUnknown *pSnapin, CMTSnapinNodeStreamsAndStorages *pStreamsAndStorages,
  508. int idView , const CLSID& clsid, CSnapIn *pCSnapin );
  509. private:
  510. PropertiesPtr m_spProps;
  511. SnapInPtr m_spSnapIn;
  512. CComponentDataArray m_ComponentDataArray;
  513. CNodeList m_NodeList;
  514. ViewRootStorage m_ComponentStorage;
  515. CXMLImageList m_imlSmall; // small, open images
  516. CXMLImageList m_imlLarge; // large image
  517. UINT m_resultImage;
  518. CDPersistor m_CDPersistor;
  519. CComponentPersistor m_ComponentPersistor;
  520. mutable PreloadState m_ePreloadState;
  521. BOOL m_bHasBitmaps;
  522. bool m_fCallbackForDisplayName; // snap-in gave us MMC_TEXTCALLBACK for node name?
  523. }; // class CMTSnapInNode
  524. #include "mtnode.inl"
  525. #endif // _MTNODE_H_