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.

365 lines
13 KiB

  1. /////////////////////////////////////////////////////////////////////
  2. // compdata.h : Declaration of CFileMgmtComponentData
  3. //
  4. // HISTORY
  5. // 01-Jan-1996 ??? Creation
  6. // 29-May-1997 t-danm Added Command Line override.
  7. //
  8. /////////////////////////////////////////////////////////////////////
  9. #ifndef __COMPDATA_H_INCLUDED__
  10. #define __COMPDATA_H_INCLUDED__
  11. #include "stdcdata.h" // CComponentData
  12. #include "persist.h" // PersistStorage, PersistStream
  13. #include "cookie.h" // CFileMgmtCookie
  14. #include <activeds.h> // IADsContainer
  15. typedef enum _SHAREPUBLISH_SCHEMA
  16. {
  17. SHAREPUBLISH_SCHEMA_UNASSIGNED = 0,
  18. SHAREPUBLISH_SCHEMA_SUPPORTED,
  19. SHAREPUBLISH_SCHEMA_UNSUPPORTED
  20. } SHAREPUBLISH_SCHEMA;
  21. // forward declarations
  22. class FileServiceProvider;
  23. class CFileMgmtComponentData :
  24. public CComponentData,
  25. public CHasMachineName,
  26. public IExtendContextMenu,
  27. public IExtendPropertySheet,
  28. #ifdef PERSIST_TO_STORAGE
  29. public PersistStorage
  30. #else
  31. public PersistStream
  32. #endif
  33. {
  34. friend class CFileMgmtDataObject;
  35. public:
  36. CFileMgmtComponentData();
  37. ~CFileMgmtComponentData();
  38. BEGIN_COM_MAP(CFileMgmtComponentData)
  39. COM_INTERFACE_ENTRY(IExtendContextMenu)
  40. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  41. #ifdef PERSIST_TO_STORAGE
  42. COM_INTERFACE_ENTRY(IPersistStorage)
  43. #else
  44. COM_INTERFACE_ENTRY(IPersistStream)
  45. #endif
  46. COM_INTERFACE_ENTRY_CHAIN(CComponentData)
  47. END_COM_MAP()
  48. #if DBG==1
  49. ULONG InternalAddRef()
  50. {
  51. return CComObjectRoot::InternalAddRef();
  52. }
  53. ULONG InternalRelease()
  54. {
  55. return CComObjectRoot::InternalRelease();
  56. }
  57. int dbg_InstID;
  58. #endif // DBG==1
  59. // IComponentData
  60. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  61. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  62. // needed for Initialize()
  63. virtual HRESULT LoadIcons(LPIMAGELIST pImageList, BOOL fLoadLargeIcons);
  64. // needed for Notify()
  65. virtual HRESULT OnNotifyExpand(LPDATAOBJECT lpDataObject, BOOL bExpanding, HSCOPEITEM hParent);
  66. virtual HRESULT OnNotifyDelete(LPDATAOBJECT lpDataObject);
  67. virtual HRESULT OnNotifyRelease(LPDATAOBJECT lpDataObject, HSCOPEITEM hItem);
  68. virtual HRESULT AddScopeNodes( LPCTSTR lpcszTargetServer,
  69. HSCOPEITEM hParent,
  70. CFileMgmtCookie* pParentCookie );
  71. // added 01/19/00 JonN
  72. virtual HRESULT OnNotifyPreload(LPDATAOBJECT lpDataObject,
  73. HSCOPEITEM hRootScopeItem);
  74. // needed for GetDisplayInfo(), must be defined by subclass
  75. virtual BSTR QueryResultColumnText(CCookie& basecookieref, int nCol );
  76. virtual int QueryImage(CCookie& basecookieref, BOOL fOpenImage);
  77. // needed for OnNotifyExpand
  78. HRESULT ReInit(LPCTSTR lpcszTargetServer);
  79. HRESULT AddScopeCookie( HSCOPEITEM hParnet,
  80. LPCTSTR lpcszTargetServer,
  81. FileMgmtObjectType objecttype,
  82. CFileMgmtCookie* pParentCookie );
  83. // utility routines for QueryResultColumnText
  84. BSTR MakeTransportResult(FILEMGMT_TRANSPORT transport);
  85. CString& ResultStorageString();
  86. BOOL IsExtendedNodetype( GUID& refguid );
  87. #ifdef SNAPIN_PROTOTYPER
  88. #define RegStringLen 1000
  89. #define DefMenuStart 100
  90. #define TaskMenuStart 200
  91. #define NewMenuStart 300
  92. HRESULT Prototyper_HrEnumerateScopeChildren(CFileMgmtCookie * pParentCookie, HSCOPEITEM hParent);
  93. BOOL TraverseRegistry(CPrototyperScopeCookie *pParentCookie, HKEY parentRegkey);
  94. BOOL ReadLeafData(CPrototyperResultCookie *pParentCookie, HKEY parentRegkey);
  95. BOOL Prototyper_FOpenRegistry(CFileMgmtCookie * pCookie, AMC::CRegKey *m_regkeySnapinDemoRoot);
  96. BOOL Prototyper_ContextMenuCommand(LONG lCommandID, IDataObject* piDataObject);
  97. #endif // SNAPIN_PROTOTYPER
  98. // IExtendContextMenu
  99. STDMETHOD(AddMenuItems)(
  100. IDataObject* piDataObject,
  101. IContextMenuCallback* piCallback,
  102. long* pInsertionAllowed);
  103. STDMETHOD(Command)(
  104. LONG lCommandID,
  105. IDataObject* piDataObject );
  106. HRESULT DoAddMenuItems( IContextMenuCallback* piCallback,
  107. FileMgmtObjectType objecttype,
  108. DATA_OBJECT_TYPES dataobjecttype,
  109. long* pInsertionAllowed,
  110. IDataObject * piDataObject);
  111. HRESULT OnChangeComputer( IDataObject * piDataObject );
  112. BOOL NewShare( LPDATAOBJECT piDataObject );
  113. BOOL DisconnectAllSessions( LPDATAOBJECT pDataObject );
  114. BOOL DisconnectAllResources( LPDATAOBJECT pDataObject );
  115. BOOL ConfigSfm( LPDATAOBJECT pDataObject );
  116. // IExtendPropertySheet
  117. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK pCall, LONG_PTR handle, LPDATAOBJECT pDataObject);
  118. STDMETHOD(QueryPagesFor)(LPDATAOBJECT pDataObject);
  119. // IPersistStream or IPersistStorage
  120. STDMETHOD(GetClassID)(CLSID __RPC_FAR *pClassID) = 0;
  121. #ifdef PERSIST_TO_STORAGE
  122. STDMETHOD(Load)(IStorage __RPC_FAR *pStg);
  123. STDMETHOD(Save)(IStorage __RPC_FAR *pStgSave, BOOL fSameAsLoad);
  124. #else
  125. STDMETHOD(Load)(IStream __RPC_FAR *pStg);
  126. STDMETHOD(Save)(IStream __RPC_FAR *pStgSave, BOOL fSameAsLoad);
  127. #endif
  128. virtual CCookie& QueryBaseRootCookie();
  129. inline CFileMgmtScopeCookie& QueryRootCookie()
  130. {
  131. return (CFileMgmtScopeCookie&)QueryBaseRootCookie();
  132. }
  133. inline FileServiceProvider* GetFileServiceProvider(
  134. FILEMGMT_TRANSPORT transport )
  135. {
  136. ASSERT( IsValidTransport(transport) &&
  137. NULL != m_apFileServiceProviders[transport] );
  138. return m_apFileServiceProviders[transport];
  139. }
  140. inline FileServiceProvider* GetFileServiceProvider(
  141. INT iTransport )
  142. {
  143. return GetFileServiceProvider((FILEMGMT_TRANSPORT)iTransport);
  144. }
  145. virtual BOOL IsServiceSnapin() = 0;
  146. virtual BOOL IsExtensionSnapin() { return FALSE; }
  147. static void LoadGlobalStrings();
  148. inline CFileMgmtCookie* ActiveCookie( CFileMgmtCookie* pCookie )
  149. {
  150. return (CFileMgmtCookie*)ActiveBaseCookie( (CCookie*)pCookie );
  151. }
  152. BOOL GetSchemaSupportSharePublishing();
  153. IADsContainer *GetIADsContainer();
  154. inline BOOL GetIsSimpleUI() { return m_bIsSimpleUI; }
  155. inline void SetIsSimpleUI(BOOL bSimpleUI) { m_bIsSimpleUI = bSimpleUI; }
  156. HRESULT ChangeRootNodeName (const CString& newName);
  157. DECLARE_FORWARDS_MACHINE_NAME( m_pRootCookie )
  158. // It would be great if these could be global. but MFC's global-destructor
  159. // apparently doesn't like deleting handles in DLL_PROCESS_DETACH with
  160. // DEBUG_CRTS set. Win32 ::LoadBitmap should use copy-on-write semantics
  161. // for multiple copies of a bitmap.
  162. // CODEWORK could break these out into the subclasses
  163. BOOL m_fLoadedFileMgmtToolbarBitmap;
  164. CBitmap m_bmpFileMgmtToolbar;
  165. BOOL m_fLoadedSvcMgmtToolbarBitmap;
  166. CBitmap m_bmpSvcMgmtToolbar;
  167. protected:
  168. friend class CFileMgmtComponent;
  169. // Variables for System Services
  170. SC_HANDLE m_hScManager; // Handle to service control manager database
  171. BOOL m_fQueryServiceConfig2; // TRUE => Machine support QueryServiceConfig2() API
  172. SHAREPUBLISH_SCHEMA m_SchemaSupportSharePublishing;
  173. CComPtr<IADsContainer> m_spiADsContainer; // improv PERF when deleting multi-selected shares
  174. // m_bIsSimpleUI is used to disable acl-related context menu items on shares
  175. // whenever SimpleSharingUI is on (i.e., when ForceGuest bit really functions)
  176. // when snapin targeted at local machine.
  177. BOOL m_bIsSimpleUI;
  178. public:
  179. APIERR Service_EOpenScManager(LPCTSTR pszMachineName);
  180. void Service_CloseScManager();
  181. BOOL Service_FGetServiceInfoFromIDataObject(IDataObject * pDataObject, CString * pstrMachineName, CString * pstrServiceName, CString * pstrServiceDisplayName);
  182. BOOL Service_FAddMenuItems(IContextMenuCallback * pContextMenuCallback, IDataObject * pDataObject, BOOL fIs3rdPartyContextMenuExtension = FALSE);
  183. BOOL Service_FDispatchMenuCommand(INT nCommandId, IDataObject * pDataObject);
  184. BOOL Service_FInsertPropertyPages(LPPROPERTYSHEETCALLBACK pCallBack, IDataObject * pDataObject, LONG_PTR lNotifyHandle);
  185. HRESULT Service_PopulateServices(LPRESULTDATA pResultData, CFileMgmtScopeCookie* pcookie);
  186. HRESULT Service_AddServiceItems(LPRESULTDATA pResultData, CFileMgmtScopeCookie* pParentCookie, ENUM_SERVICE_STATUS * rgESS, DWORD nDataItems);
  187. private:
  188. // for extensions, the list of child scope cookies is in
  189. // m_pRootCookie->m_listScopeCookieBlocks
  190. CFileMgmtScopeCookie* m_pRootCookie;
  191. protected:
  192. // The following members are used to support Command Line override.
  193. enum // Bit fields for m_dwFlagsPersist
  194. {
  195. mskfAllowOverrideMachineName = 0x0001
  196. };
  197. DWORD m_dwFlagsPersist; // General-purpose flags to be persisted into .msc file
  198. CString m_strMachineNamePersist; // Machine name to persist into .msc file
  199. public:
  200. BOOL m_fAllowOverrideMachineName; // TRUE => Allow the machine name to be overriden by the command line
  201. void SetPersistentFlags(DWORD dwFlags)
  202. {
  203. m_dwFlagsPersist = dwFlags;
  204. m_fAllowOverrideMachineName = !!(m_dwFlagsPersist & mskfAllowOverrideMachineName);
  205. }
  206. DWORD GetPersistentFlags()
  207. {
  208. if (m_fAllowOverrideMachineName)
  209. m_dwFlagsPersist |= mskfAllowOverrideMachineName;
  210. else
  211. m_dwFlagsPersist &= ~mskfAllowOverrideMachineName;
  212. return m_dwFlagsPersist;
  213. }
  214. private:
  215. #ifdef SNAPIN_PROTOTYPER
  216. bool m_RegistryParsedYet;
  217. //CPrototyperScopeCookieBlock m_RootCookieBlock;
  218. #else
  219. //CFileMgmtScopeCookieBlock m_RootCookieBlock;
  220. #endif
  221. FileServiceProvider* m_apFileServiceProviders[FILEMGMT_NUM_TRANSPORTS];
  222. }; // CFileMgmtComponentData
  223. BSTR MakeDwordResult(DWORD dw);
  224. BSTR MakeElapsedTimeResult(DWORD dwTime);
  225. BSTR MakePermissionsResult( DWORD dwPermissions );
  226. void TranslateIPToComputerName(LPCTSTR ptszIP, CString& strComputerName);
  227. /////////////////////////////////////////////////////////////////////
  228. class CFileSvcMgmtSnapin: public CFileMgmtComponentData,
  229. public CComCoClass<CFileSvcMgmtSnapin, &CLSID_FileServiceManagement>
  230. {
  231. public:
  232. CFileSvcMgmtSnapin();
  233. ~CFileSvcMgmtSnapin();
  234. // Use DECLARE_NOT_AGGREGATABLE(CFileSvcMgmtSnapin) if you don't want your object
  235. // to support aggregation
  236. DECLARE_AGGREGATABLE(CFileSvcMgmtSnapin)
  237. DECLARE_REGISTRY(CFileSvcMgmtSnapin, _T("FILEMGMT.FileSvcMgmtObject.1"), _T("FILEMGMT.FileSvcMgmtObject.1"), IDS_FILEMGMT_DESC, THREADFLAGS_BOTH)
  238. virtual BOOL IsServiceSnapin() { return FALSE; }
  239. // IPersistStream or IPersistStorage
  240. STDMETHOD(GetClassID)(CLSID __RPC_FAR *pClassID)
  241. {
  242. *pClassID=CLSID_FileServiceManagement;
  243. return S_OK;
  244. }
  245. };
  246. class CServiceMgmtSnapin:
  247. public CFileMgmtComponentData,
  248. public CComCoClass<CServiceMgmtSnapin,
  249. #ifdef SNAPIN_PROTOTYPER
  250. &CLSID_SnapinPrototyper>
  251. #else
  252. &CLSID_SystemServiceManagement>
  253. #endif
  254. {
  255. public:
  256. CServiceMgmtSnapin();
  257. ~CServiceMgmtSnapin();
  258. // Use DECLARE_NOT_AGGREGATABLE(CServiceMgmtSnapin) if you don't want your object
  259. // to support aggregation
  260. DECLARE_AGGREGATABLE(CServiceMgmtSnapin)
  261. DECLARE_REGISTRY(CServiceMgmtSnapin, _T("SVCVWR.SvcVwrObject.1"), _T("SVCVWR.SvcVwrObject.1"), IDS_SVCVWR_DESC, THREADFLAGS_BOTH)
  262. virtual BOOL IsServiceSnapin() { return TRUE; }
  263. // IPersistStream or IPersistStorage
  264. STDMETHOD(GetClassID)(CLSID __RPC_FAR *pClassID)
  265. {
  266. *pClassID=CLSID_SystemServiceManagement;
  267. return S_OK;
  268. }
  269. };
  270. class CFileSvcMgmtExtension: public CFileMgmtComponentData,
  271. public CComCoClass<CFileSvcMgmtSnapin, &CLSID_FileServiceManagementExt>
  272. {
  273. public:
  274. CFileSvcMgmtExtension();
  275. ~CFileSvcMgmtExtension();
  276. // Use DECLARE_NOT_AGGREGATABLE(CFileSvcMgmtExtension) if you don't want your object
  277. // to support aggregation
  278. DECLARE_AGGREGATABLE(CFileSvcMgmtExtension)
  279. DECLARE_REGISTRY(CFileSvcMgmtExtension, _T("FILEMGMT.FileSvcMgmtExtObject.1"), _T("FILEMGMT.FileSvcMgmtExtObject.1"), IDS_FILEMGMT_DESC, THREADFLAGS_BOTH)
  280. virtual BOOL IsServiceSnapin() { return FALSE; }
  281. virtual BOOL IsExtensionSnapin() { return TRUE; }
  282. // IPersistStream or IPersistStorage
  283. STDMETHOD(GetClassID)(CLSID __RPC_FAR *pClassID)
  284. {
  285. *pClassID=CLSID_FileServiceManagementExt;
  286. return S_OK;
  287. }
  288. };
  289. class CServiceMgmtExtension: public CFileMgmtComponentData,
  290. public CComCoClass<CServiceMgmtExtension, &CLSID_SystemServiceManagementExt>
  291. {
  292. public:
  293. CServiceMgmtExtension();
  294. ~CServiceMgmtExtension();
  295. // Use DECLARE_NOT_AGGREGATABLE(CServiceMgmtExtension) if you don't want your object
  296. // to support aggregation
  297. DECLARE_AGGREGATABLE(CServiceMgmtExtension)
  298. DECLARE_REGISTRY(CServiceMgmtExtension, _T("SVCVWR.SvcVwrExtObject.1"), _T("SVCVWR.SvcVwrExtObject.1"), IDS_SVCVWR_DESC, THREADFLAGS_BOTH)
  299. virtual BOOL IsServiceSnapin() { return TRUE; }
  300. virtual BOOL IsExtensionSnapin() { return TRUE; }
  301. // IPersistStream or IPersistStorage
  302. STDMETHOD(GetClassID)(CLSID __RPC_FAR *pClassID)
  303. {
  304. *pClassID=CLSID_SystemServiceManagementExt;
  305. return S_OK;
  306. }
  307. };
  308. #endif // ~__COMPDATA_H_INCLUDED__