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.

328 lines
8.9 KiB

  1. //
  2. // compdata.h : Declaration of ComponentData
  3. //
  4. // This COM object is primarily concerned with
  5. // the scope pane items.
  6. //
  7. // Cory West <[email protected]>
  8. // Copyright (c) Microsoft Corporation 1997
  9. //
  10. #ifndef __COMPDATA_H_INCLUDED__
  11. #define __COMPDATA_H_INCLUDED__
  12. #include "stdcdata.h" // CComponentData
  13. #include "persist.h" // PersistStream
  14. #include "cookie.h" // Cookie
  15. #include "resource.h" // IDS_SCHMMGMT_DESC
  16. #include "cmponent.h" // LoadIconsIntoImageList
  17. #include "schmutil.h"
  18. // Messages used in UpdateAllViews
  19. enum
  20. {
  21. SCHMMGMT_UPDATEVIEW_REFRESH = 0, // This MUST be zero
  22. SCHMMGMT_UPDATEVIEW_DELETE_RESULT_ITEM
  23. };
  24. ///////////////////////////////////////////////////////////////////////////////
  25. // ComponentData
  26. class ComponentData
  27. :
  28. public CComponentData,
  29. public IExtendPropertySheet,
  30. public IExtendContextMenu,
  31. public PersistStream,
  32. public CHasMachineName,
  33. public CComCoClass< ComponentData, &CLSID_SchmMgmt >
  34. {
  35. public:
  36. friend class ClassGeneralPage;
  37. friend class CreateAttributeDialog;
  38. friend class CSchmMgmtAdvanced;
  39. friend class CSchmMgmtAttributeMembership;
  40. friend class CSchmMgmtClassRelationship;
  41. friend class CCookieList;
  42. //
  43. // Use DECLARE_AGGREGATABLE(ComponentData)
  44. // if you want your object to support aggregation,
  45. // though I don't know why you'd do this.
  46. //
  47. DECLARE_NOT_AGGREGATABLE( ComponentData )
  48. //
  49. // What is this?
  50. //
  51. DECLARE_REGISTRY( ComponentData,
  52. _T("SCHMMGMT.SchemaObject.1"),
  53. _T("SCHMMGMT.SchemaObject.1"),
  54. IDS_SCHMMGMT_DESC,
  55. THREADFLAGS_BOTH )
  56. ComponentData();
  57. ~ComponentData();
  58. BEGIN_COM_MAP( ComponentData )
  59. COM_INTERFACE_ENTRY( IExtendPropertySheet )
  60. COM_INTERFACE_ENTRY( IPersistStream )
  61. COM_INTERFACE_ENTRY( IExtendContextMenu )
  62. COM_INTERFACE_ENTRY_CHAIN( CComponentData )
  63. END_COM_MAP()
  64. #if DBG==1
  65. ULONG InternalAddRef() {
  66. return CComObjectRoot::InternalAddRef();
  67. }
  68. ULONG InternalRelease() {
  69. return CComObjectRoot::InternalRelease();
  70. }
  71. int dbg_InstID;
  72. #endif
  73. //
  74. // IComponentData
  75. //
  76. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  77. STDMETHOD(CreateComponent)( LPCOMPONENT* ppComponent );
  78. STDMETHOD(QueryDataObject)( MMC_COOKIE cookie,
  79. DATA_OBJECT_TYPES type,
  80. LPDATAOBJECT* ppDataObject );
  81. //
  82. // IExtendPropertySheet
  83. //
  84. STDMETHOD(CreatePropertyPages)( LPPROPERTYSHEETCALLBACK pCall,
  85. LONG_PTR handle,
  86. LPDATAOBJECT pDataObject );
  87. STDMETHOD(QueryPagesFor)( LPDATAOBJECT pDataObject );
  88. //
  89. // IPersistStream
  90. //
  91. HRESULT
  92. STDMETHODCALLTYPE GetClassID( CLSID __RPC_FAR *pClassID ) {
  93. *pClassID=CLSID_SchmMgmt;
  94. return S_OK;
  95. }
  96. HRESULT STDMETHODCALLTYPE Load( IStream __RPC_FAR *pStg );
  97. HRESULT STDMETHODCALLTYPE Save( IStream __RPC_FAR *pStgSave,
  98. BOOL fSameAsLoad );
  99. //
  100. // IExtendContextMenu
  101. //
  102. STDMETHOD(AddMenuItems)( LPDATAOBJECT piDataObject,
  103. LPCONTEXTMENUCALLBACK piCallback,
  104. long *pInsertionAllowed );
  105. STDMETHOD(Command)( long lCommandID,
  106. LPDATAOBJECT piDataObject );
  107. //
  108. // ISnapinHelp2
  109. //
  110. STDMETHOD(GetLinkedTopics)(LPOLESTR* lpCompiledHelpFile);
  111. //
  112. // Needed for Initialize().
  113. //
  114. virtual HRESULT LoadIcons( LPIMAGELIST pImageList,
  115. BOOL fLoadLargeIcons );
  116. //
  117. // Needed for Notify().
  118. //
  119. virtual HRESULT OnNotifyExpand( LPDATAOBJECT lpDataObject,
  120. BOOL bExpanding,
  121. HSCOPEITEM hParent );
  122. virtual HRESULT OnNotifyRelease(
  123. LPDATAOBJECT lpDataObject,
  124. HSCOPEITEM hItem );
  125. virtual HRESULT OnNotifyDelete(
  126. LPDATAOBJECT lpDataObject);
  127. //
  128. // Needed for GetDisplayInfo(), must be defined by subclass.
  129. //
  130. virtual BSTR QueryResultColumnText( CCookie& basecookieref,
  131. int nCol );
  132. virtual int QueryImage( CCookie& basecookieref,
  133. BOOL fOpenImage );
  134. virtual CCookie& QueryBaseRootCookie( );
  135. inline
  136. Cookie* ActiveCookie( CCookie* pBaseCookie ) {
  137. return ( Cookie*)ActiveBaseCookie( pBaseCookie );
  138. }
  139. inline Cookie& QueryRootCookie() { return *m_pRootCookie; }
  140. //
  141. // CHasMachineName. Used by the snapin framework to store, retrieve
  142. // and compare machine names
  143. //
  144. DECLARE_FORWARDS_MACHINE_NAME( m_pRootCookie )
  145. //
  146. // Ads handling routines for inserting dynamic nodes.
  147. //
  148. HRESULT
  149. FastInsertClassScopeCookies(
  150. Cookie* pParentCookie,
  151. HSCOPEITEM hParentScopeItem
  152. );
  153. VOID
  154. RefreshScopeView(
  155. VOID
  156. );
  157. VOID
  158. InitializeRootTree( HSCOPEITEM hParent, Cookie * pParentCookie );
  159. private:
  160. // context manu item helpers
  161. HRESULT _OnRefresh(LPDATAOBJECT lpDataObject);
  162. void _OnRetarget(LPDATAOBJECT lpDataObject);
  163. void _OnEditFSMO();
  164. void _OnSecurity();
  165. // generic helpers
  166. HRESULT _InitBasePaths();
  167. public:
  168. //
  169. // This is the per snap-in instance data.
  170. //
  171. //
  172. // This cookie lists contains the currently
  173. // visible scope data items.
  174. //
  175. CCookieList g_ClassCookieList;
  176. bool m_fViewDefunct;
  177. HRESULT DeleteClass( Cookie* pcookie );
  178. //
  179. // Error/Status Handling
  180. //
  181. private:
  182. // both should be empty if everything is ok.
  183. CString m_sErrorTitle;
  184. CString m_sErrorText;
  185. CString m_sStatusText;
  186. HSCOPEITEM m_hItem;
  187. public:
  188. // Set's error title & body text. Call it with NULL, NULL to remove
  189. void SetError( UINT idsErrorTitle, UINT idsErrorText );
  190. const CString & GetErrorTitle() const { return m_sErrorTitle; }
  191. const CString & GetErrorText() const { return m_sErrorText; }
  192. BOOL IsErrorSet( void ) const { return !GetErrorTitle().IsEmpty() || !GetErrorText().IsEmpty(); }
  193. void SetDelayedRefreshOnShow( HSCOPEITEM hItem )
  194. { m_hItem = hItem; }
  195. BOOL IsSetDelayedRefreshOnShow() { return NULL != m_hItem; }
  196. HSCOPEITEM GetDelayedRefreshOnShowItem() { ASSERT(IsSetDelayedRefreshOnShow()); return m_hItem; }
  197. // Set/Clear Status Text
  198. // void SetStatusText( UINT idsStatusText = 0 );
  199. // void ClearStatusText( ) { SetStatusText(); }
  200. //
  201. // Access permissions
  202. //
  203. private:
  204. BOOL m_fCanChangeOperationsMaster;
  205. BOOL m_fCanCreateClass;
  206. BOOL m_fCanCreateAttribute;
  207. public:
  208. BOOL CanChangeOperationsMaster() { return m_fCanChangeOperationsMaster; }
  209. BOOL CanCreateClass() { return m_fCanCreateClass; }
  210. BOOL CanCreateAttribute() { return m_fCanCreateAttribute; }
  211. void SetCanChangeOperationsMaster( BOOL fCanChangeOperationsMaster = FALSE )
  212. { m_fCanChangeOperationsMaster = fCanChangeOperationsMaster; }
  213. void SetCanCreateClass( BOOL fCanCreateClass = FALSE )
  214. { m_fCanCreateClass = fCanCreateClass; }
  215. void SetCanCreateAttribute( BOOL fCanCreateAttribute = FALSE )
  216. { m_fCanCreateAttribute = fCanCreateAttribute; }
  217. //
  218. // The schema cache.
  219. //
  220. SchemaObjectCache g_SchemaCache;
  221. BOOLEAN IsSchemaLoaded() { return g_SchemaCache.IsSchemaLoaded(); }
  222. HRESULT ForceDsSchemaCacheUpdate( VOID );
  223. BOOLEAN AsynchForceDsSchemaCacheUpdate( VOID );
  224. MyBasePathsInfo* GetBasePathsInfo() { return &m_basePathsInfo;}
  225. //
  226. // Function to add escape char to the special chars in CN
  227. //
  228. HRESULT GetSchemaObjectPath( const CString & strCN,
  229. CString & strPath,
  230. ADS_FORMAT_ENUM formatType = ADS_FORMAT_X500 );
  231. HRESULT GetLeafObjectFromDN( const BSTR bstrDN, CString & strCN );
  232. // Determine what operations are allowed. Optionally returns IADs * to Schema Container
  233. HRESULT CheckSchemaPermissions( IADs ** ppADs = NULL );
  234. private:
  235. MyBasePathsInfo m_basePathsInfo;
  236. Cookie* m_pRootCookie;
  237. IADsPathname * m_pPathname;
  238. };
  239. #endif // __COMPDATA_H_INCLUDED__