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.

405 lines
12 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. CCISnapin * _pChild;
  111. private:
  112. friend class CCIAdminCF;
  113. ~CCISnapinData();
  114. void ShowFolder( CCIAdminDO * pDO, BOOL fExpanded, HSCOPEITEM hScopeItem );
  115. BOOL IsRoot( CCIAdminDO * pDO )
  116. {
  117. return ( 0 == pDO );
  118. }
  119. void Refresh();
  120. void MaybeEnableCI( CMachineAdmin & MachineAdmin );
  121. //
  122. // MMC Interfaces
  123. //
  124. IConsole * _pFrame;
  125. HWND _hFrameWindow;
  126. IConsoleNameSpace * _pScopePane;
  127. //
  128. // Result pane(s)
  129. //
  130. CRootNode _rootNode;
  131. CCatalogs _Catalogs;
  132. XGrowable<WCHAR> _xwcsTitle;
  133. XGrowable<WCHAR> _xwcsType;
  134. XGrowable<WCHAR> _xwcsDescription;
  135. BOOL _fIsInitialized;
  136. BOOL _fIsExtension;
  137. LONG_PTR _notifHandle;
  138. //
  139. // Refcounting & child tracking
  140. //
  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. {
  173. public:
  174. //
  175. // IUnknown
  176. //
  177. virtual SCODE STDMETHODCALLTYPE QueryInterface( REFIID riid,
  178. void ** ppvObject);
  179. virtual ULONG STDMETHODCALLTYPE AddRef();
  180. virtual ULONG STDMETHODCALLTYPE Release();
  181. //
  182. // IComponent
  183. //
  184. virtual SCODE STDMETHODCALLTYPE Initialize( IConsole * lpConsole );
  185. virtual SCODE STDMETHODCALLTYPE Notify( IDataObject * pDO,
  186. MMC_NOTIFY_TYPE event,
  187. LPARAM arg,
  188. LPARAM param );
  189. virtual SCODE STDMETHODCALLTYPE Destroy( MMC_COOKIE cookie );
  190. virtual SCODE STDMETHODCALLTYPE QueryDataObject( MMC_COOKIE cookie,
  191. DATA_OBJECT_TYPES type,
  192. IDataObject * * ppDataObject );
  193. virtual SCODE STDMETHODCALLTYPE GetResultViewType( MMC_COOKIE cookie,
  194. BSTR * ppViewType,
  195. long * pViewOptions );
  196. virtual SCODE STDMETHODCALLTYPE GetDisplayInfo( RESULTDATAITEM * pResultDataItem );
  197. virtual SCODE STDMETHODCALLTYPE CompareObjects( IDataObject * lpDataObjectA,
  198. IDataObject * lpDataObjectB );
  199. //
  200. // IExtendPropertySheet
  201. //
  202. virtual SCODE STDMETHODCALLTYPE CreatePropertyPages( IPropertySheetCallback * lpProvider,
  203. LONG_PTR handle,
  204. IDataObject * lpIDataObject );
  205. virtual SCODE STDMETHODCALLTYPE QueryPagesFor( IDataObject * lpDataObject );
  206. //
  207. // IExtendContextMenu
  208. //
  209. virtual SCODE STDMETHODCALLTYPE AddMenuItems( IDataObject * piDataObject,
  210. IContextMenuCallback * piCallback,
  211. long * pInsertionAllowed );
  212. virtual SCODE STDMETHODCALLTYPE Command( long lCommandID,
  213. IDataObject * piDataObject );
  214. //
  215. // IExtendControlbar methods
  216. //
  217. virtual SCODE STDMETHODCALLTYPE SetControlbar( LPCONTROLBAR pControlbar);
  218. virtual SCODE STDMETHODCALLTYPE ControlbarNotify( MMC_NOTIFY_TYPE event,
  219. LPARAM arg,
  220. LPARAM param);
  221. //
  222. // Local methods
  223. //
  224. CCISnapin * Next() { return _pNext; }
  225. void Link( CCISnapin * pNext ) { _pNext = pNext; }
  226. void Refresh();
  227. IResultData* ResultPane() { return _pResultPane; }
  228. void ClearSnapinData() { _pSnapinData = 0; }
  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 * _pSnapinData; // can be 0 on shutdown.
  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);