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.

403 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 2001.
  5. //
  6. // File: Snapin.hxx
  7. //
  8. // Contents: MMC snapin for CI.
  9. //
  10. // History: 26-Nov-1996 KyleP Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #pragma once
  14. #include <catalog.hxx>
  15. #include <rootnode.hxx>
  16. class CMachineAdmin;
  17. class CCISnapin;
  18. class CCISnapinData : public IComponentData,
  19. public IExtendContextMenu,
  20. public IExtendPropertySheet,
  21. public IPersistStream,
  22. public ISnapinAbout,
  23. public ISnapinHelp2
  24. {
  25. public:
  26. //
  27. // IUnknown
  28. //
  29. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid,
  30. void ** ppvObject);
  31. virtual ULONG STDMETHODCALLTYPE AddRef();
  32. virtual ULONG STDMETHODCALLTYPE Release();
  33. //
  34. // IComponentData
  35. //
  36. virtual SCODE STDMETHODCALLTYPE Initialize( IUnknown * pUnknown );
  37. virtual SCODE STDMETHODCALLTYPE CreateComponent( IComponent * * ppComponent );
  38. virtual SCODE STDMETHODCALLTYPE Notify( IDataObject * lpDataObject,
  39. MMC_NOTIFY_TYPE event,
  40. LPARAM arg,
  41. LPARAM param);
  42. virtual SCODE STDMETHODCALLTYPE Destroy();
  43. virtual SCODE STDMETHODCALLTYPE QueryDataObject( MMC_COOKIE cookie,
  44. DATA_OBJECT_TYPES type,
  45. IDataObject * * ppDataObject );
  46. virtual SCODE STDMETHODCALLTYPE GetDisplayInfo( SCOPEDATAITEM * pScopeDataItem );
  47. virtual SCODE STDMETHODCALLTYPE CompareObjects( IDataObject * lpDataObjectA,
  48. IDataObject * lpDataObjectB );
  49. //
  50. // IExtendPropertySheet
  51. //
  52. virtual SCODE STDMETHODCALLTYPE CreatePropertyPages( IPropertySheetCallback * lpProvider,
  53. LONG_PTR handle,
  54. IDataObject * lpIDataObject );
  55. virtual SCODE STDMETHODCALLTYPE QueryPagesFor( IDataObject * lpDataObject );
  56. //
  57. // IExtendContextMenu
  58. //
  59. virtual SCODE STDMETHODCALLTYPE AddMenuItems( IDataObject * piDataObject,
  60. IContextMenuCallback * piCallback,
  61. long * pInsertionAllowed );
  62. virtual SCODE STDMETHODCALLTYPE Command( long lCommandID,
  63. IDataObject * piDataObject );
  64. //
  65. // IPersist
  66. //
  67. virtual SCODE STDMETHODCALLTYPE GetClassID( CLSID * pClassID );
  68. //
  69. // IPersistStream
  70. //
  71. virtual SCODE STDMETHODCALLTYPE IsDirty();
  72. virtual SCODE STDMETHODCALLTYPE Load( IStream * pStm );
  73. virtual SCODE STDMETHODCALLTYPE Save( IStream * pStm, BOOL fClearDirty );
  74. virtual SCODE STDMETHODCALLTYPE GetSizeMax( ULARGE_INTEGER * pcbSize );
  75. //
  76. // ISnapinAbout methods
  77. //
  78. virtual SCODE STDMETHODCALLTYPE GetSnapinDescription(LPOLESTR *lpDescription);
  79. virtual SCODE STDMETHODCALLTYPE GetProvider(LPOLESTR *lpName);
  80. virtual SCODE STDMETHODCALLTYPE GetSnapinVersion(LPOLESTR *lpVersion);
  81. virtual SCODE STDMETHODCALLTYPE GetSnapinImage(HICON *hAppIcon);
  82. virtual SCODE STDMETHODCALLTYPE GetStaticFolderImage(
  83. HBITMAP *hSmallImage,
  84. HBITMAP *hSmallImageOpen,
  85. HBITMAP *hLargeImage,
  86. COLORREF *cMask);
  87. //
  88. // ISnapinHelp2 methods (derived from ISnapinHelp)
  89. //
  90. virtual SCODE STDMETHODCALLTYPE GetHelpTopic( LPOLESTR *lpCompiledHelpFile);
  91. virtual SCODE STDMETHODCALLTYPE GetLinkedTopics( LPOLESTR *lpCompiledHelpFiles);
  92. //
  93. // Local
  94. //
  95. CCISnapinData();
  96. CCatalogs & GetCatalogs() { return _Catalogs; }
  97. SCODE STDMETHODCALLTYPE GetHelpTopic2( LPOLESTR *lpCompiledHelpFile);
  98. void SetRootDisplay();
  99. WCHAR const * GetRootDisplay() { return _xwcsTitle.Get(); }
  100. WCHAR const * GetType() { return _xwcsType.Get(); }
  101. WCHAR const * GetDescription() { return _xwcsDescription.Get(); }
  102. IConsoleNameSpace & GetConsoleNameSpace() { return *_pScopePane; }
  103. void RemoveCatalog( CCIAdminDO * pDO );
  104. LONG_PTR NotifyHandle() { return _notifHandle; }
  105. BOOL IsURLDeselected() { return _fURLDeselected; }
  106. void SetURLDeselected( BOOL f ) { _fURLDeselected = f; }
  107. void SetButtonState( int idCommand,
  108. MMC_BUTTON_STATE nState,
  109. BOOL bState);
  110. private:
  111. friend class CCIAdminCF;
  112. ~CCISnapinData();
  113. void ShowFolder( CCIAdminDO * pDO, BOOL fExpanded, HSCOPEITEM hScopeItem );
  114. BOOL IsRoot( CCIAdminDO * pDO )
  115. {
  116. return ( 0 == pDO );
  117. }
  118. void Refresh();
  119. void MaybeEnableCI( CMachineAdmin & MachineAdmin );
  120. //
  121. // MMC Interfaces
  122. //
  123. IConsole * _pFrame;
  124. HWND _hFrameWindow;
  125. IConsoleNameSpace * _pScopePane;
  126. //
  127. // Result pane(s)
  128. //
  129. CRootNode _rootNode;
  130. CCatalogs _Catalogs;
  131. XGrowable<WCHAR> _xwcsTitle;
  132. XGrowable<WCHAR> _xwcsType;
  133. XGrowable<WCHAR> _xwcsDescription;
  134. BOOL _fIsInitialized;
  135. BOOL _fIsExtension;
  136. LONG_PTR _notifHandle;
  137. //
  138. // Refcounting & child tracking
  139. //
  140. CCISnapin * _pChild;
  141. BOOL _fDirty;
  142. long _uRefs;
  143. //
  144. // Enable-CI
  145. //
  146. BOOL _fTriedEnable;
  147. // Misc -- set to to true when the URL item is deselected
  148. // This flag is used to determine when to ignore a callback
  149. // that has a IDataObject for the query page. See bug # 330306.
  150. // This flag is set when the URL on the scope pane is deselected,
  151. // which happens whenever the user goes to left click on the query
  152. // page. We don't receive a valid IDataObject ptr when MMC calls
  153. // us back in response to this l-click on the query page, hence the
  154. // AV documented in the bug. This is the only instance when we get
  155. // an invalid dataobject ptr when we l-click on the view pane (of
  156. // our snapin)
  157. BOOL _fURLDeselected;
  158. };
  159. //+-------------------------------------------------------------------------
  160. //
  161. // Class: CCISnapin
  162. //
  163. // Purpose: MMC snap-in
  164. //
  165. // History: 26-Nov-1996 KyleP Created
  166. //
  167. //--------------------------------------------------------------------------
  168. class CCISnapin : public IComponent,
  169. public IExtendPropertySheet,
  170. public IExtendContextMenu,
  171. public IExtendControlbar
  172. //public IResultCallback
  173. {
  174. public:
  175. //
  176. // IUnknown
  177. //
  178. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid,
  179. void ** ppvObject);
  180. virtual ULONG STDMETHODCALLTYPE AddRef();
  181. virtual ULONG STDMETHODCALLTYPE Release();
  182. //
  183. // IComponent
  184. //
  185. virtual SCODE STDMETHODCALLTYPE Initialize( IConsole * lpConsole );
  186. virtual SCODE STDMETHODCALLTYPE Notify( IDataObject * pDO,
  187. MMC_NOTIFY_TYPE event,
  188. LPARAM arg,
  189. LPARAM param );
  190. virtual SCODE STDMETHODCALLTYPE Destroy( MMC_COOKIE cookie );
  191. virtual SCODE STDMETHODCALLTYPE QueryDataObject( MMC_COOKIE cookie,
  192. DATA_OBJECT_TYPES type,
  193. IDataObject * * ppDataObject );
  194. virtual SCODE STDMETHODCALLTYPE GetResultViewType( MMC_COOKIE cookie,
  195. BSTR * ppViewType,
  196. long * pViewOptions );
  197. virtual SCODE STDMETHODCALLTYPE GetDisplayInfo( RESULTDATAITEM * pResultDataItem );
  198. virtual SCODE STDMETHODCALLTYPE CompareObjects( IDataObject * lpDataObjectA,
  199. IDataObject * lpDataObjectB );
  200. //
  201. // IExtendPropertySheet
  202. //
  203. virtual SCODE STDMETHODCALLTYPE CreatePropertyPages( IPropertySheetCallback * lpProvider,
  204. LONG_PTR handle,
  205. IDataObject * lpIDataObject );
  206. virtual SCODE STDMETHODCALLTYPE QueryPagesFor( IDataObject * lpDataObject );
  207. //
  208. // IExtendContextMenu
  209. //
  210. virtual SCODE STDMETHODCALLTYPE AddMenuItems( IDataObject * piDataObject,
  211. IContextMenuCallback * piCallback,
  212. long * pInsertionAllowed );
  213. virtual SCODE STDMETHODCALLTYPE Command( long lCommandID,
  214. IDataObject * piDataObject );
  215. //
  216. // IExtendControlbar methods
  217. //
  218. virtual SCODE STDMETHODCALLTYPE SetControlbar( LPCONTROLBAR pControlbar);
  219. virtual SCODE STDMETHODCALLTYPE ControlbarNotify( MMC_NOTIFY_TYPE event,
  220. LPARAM arg,
  221. LPARAM param);
  222. //
  223. // Local methods
  224. //
  225. CCISnapin * Next() { return _pNext; }
  226. void Link( CCISnapin * pNext ) { _pNext = pNext; }
  227. void Refresh();
  228. IResultData* ResultPane() { return _pResultPane; }
  229. private:
  230. friend class CCISnapinData;
  231. CCISnapin( CCISnapinData & SnapinData, CCISnapin * pNext );
  232. ~CCISnapin();
  233. void ShowItem( CCIAdminDO * pDO, BOOL fExpanded, HSCOPEITEM hScopeItem );
  234. void EnableStandardVerbs( IDataObject * piDataObject );
  235. void RemoveScope( CCIAdminDO * pDO );
  236. CCatalog const * GetCurrentCatalog() { return _CurrentCatalog; }
  237. BOOL IsRoot( CCIAdminDO * pDO )
  238. {
  239. return ( 0 == pDO );
  240. }
  241. //
  242. // MMC Interfaces
  243. //
  244. IConsole * _pFrame;
  245. IHeaderCtrl * _pHeader;
  246. IResultData * _pResultPane;
  247. IImageList * _pImageList;
  248. IConsoleVerb * _pConsoleVerb;
  249. IDisplayHelp * _pDisplayHelp;
  250. // IControlbar and toolbar
  251. XInterface<IControlbar> _xControlbar;
  252. XInterface<IToolbar> _xToolbar;
  253. XBitmapHandle _xBmpToolbar;
  254. //
  255. // Scope pane
  256. //
  257. CCISnapinData & _SnapinData;
  258. //
  259. // Per-result pane state.
  260. //
  261. CListViewHeader _CatalogsHeader;
  262. CListViewHeader _CatalogScopeHeader;
  263. CListViewHeader _CatalogPropertyHeader;
  264. enum CatalogNodeType
  265. {
  266. Catalogs,
  267. Scopes,
  268. Properties,
  269. Nothing
  270. };
  271. CatalogNodeType GetCurrentView() { return _CurrentView; }
  272. CatalogNodeType _CurrentView;
  273. CCatalog * _CurrentCatalog; // Valid only when _CurrentView == Scopes
  274. HWND _hFrameWindow;
  275. //
  276. // Links
  277. //
  278. CCISnapin * _pNext;
  279. //
  280. // Refcounting
  281. //
  282. long _uRefs;
  283. };
  284. //
  285. // Functions
  286. //
  287. SCODE InitImageResources( IImageList * pImageList );
  288. SCODE MakeOLESTR(LPOLESTR *lpBuffer, WCHAR const * pwszText);