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.

264 lines
8.9 KiB

  1. // cmponent.h : Declaration of CFileMgmtComponent
  2. #ifndef __CMPONENT_H_INCLUDED__
  3. #define __CMPONENT_H_INCLUDED__
  4. #include "cookie.h" // CFileMgmtCookie
  5. #include "stdcmpnt.h" // CComponent
  6. extern CString g_strResultColumnText;
  7. extern CString g_strTransportSMB;
  8. extern CString g_strTransportSFM;
  9. extern CString g_strTransportFPNW;
  10. // forward declarations
  11. class FileServiceProvider;
  12. class CFileMgmtComponentData;
  13. class CFileMgmtComponent :
  14. public CComponent,
  15. public IExtendContextMenu,
  16. public IExtendPropertySheet,
  17. public IExtendControlbar,
  18. public INodeProperties,
  19. public IResultDataCompare
  20. {
  21. public:
  22. CFileMgmtComponent();
  23. ~CFileMgmtComponent();
  24. BEGIN_COM_MAP(CFileMgmtComponent)
  25. COM_INTERFACE_ENTRY(IExtendContextMenu)
  26. COM_INTERFACE_ENTRY(IExtendControlbar)
  27. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  28. COM_INTERFACE_ENTRY(IResultDataCompare)
  29. COM_INTERFACE_ENTRY(INodeProperties)
  30. COM_INTERFACE_ENTRY_CHAIN(CComponent)
  31. END_COM_MAP()
  32. #if DBG==1
  33. ULONG InternalAddRef()
  34. {
  35. return CComObjectRoot::InternalAddRef();
  36. }
  37. ULONG InternalRelease()
  38. {
  39. return CComObjectRoot::InternalRelease();
  40. }
  41. int dbg_InstID;
  42. #endif // DBG==1
  43. // IComponent implemented in CComponent
  44. // support methods for IComponent
  45. virtual HRESULT ReleaseAll();
  46. virtual HRESULT OnPropertyChange( LPARAM param );
  47. virtual HRESULT OnViewChange( LPDATAOBJECT lpDataObject, LPARAM data, LPARAM hint );
  48. virtual HRESULT OnNotifyRefresh( LPDATAOBJECT lpDataObject );
  49. virtual HRESULT OnNotifySelect( LPDATAOBJECT lpDataObject, BOOL fSelected );
  50. virtual HRESULT Show(CCookie* pcookie, LPARAM arg, HSCOPEITEM hScopeItem);
  51. virtual HRESULT OnNotifyAddImages( LPDATAOBJECT lpDataObject,
  52. LPIMAGELIST lpImageList,
  53. HSCOPEITEM hSelectedItem );
  54. virtual HRESULT OnNotifySnapinHelp (LPDATAOBJECT pDataObject);
  55. virtual HRESULT OnNotifyColumnClick( LPDATAOBJECT lpDataObject, LPARAM iColumn, LPARAM uFlags );
  56. HRESULT PopulateListbox(CFileMgmtScopeCookie* pcookie);
  57. HRESULT RefreshAllViewsOnSelectedObject( LPDATAOBJECT piDataObject );
  58. virtual HRESULT RefreshAllViews( LPDATAOBJECT lpDataObject );
  59. HRESULT RefreshNewResultCookies( CCookie& refparentcookie );
  60. void UpdateDefaultVerbs();
  61. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  62. STDMETHOD(GetResultViewType)(MMC_COOKIE cookie, LPOLESTR* ppViewType, long* pViewOptions);
  63. #ifdef SNAPIN_PROTOTYPER
  64. CString m_strDemoName; // Name of the SnapIn prototyper demo
  65. CString m_strKeyPrototyper; // "HKLM\Software\Microsoft\MMC\DemoSnapInKey" + m_strDemoName
  66. int m_cColumns; // Number of columns in the result pane
  67. int m_iImageListLast; // Index of the last image in the imagelist
  68. BOOL Prototyper_FInsertColumns(CFileMgmtCookie * pCookie);
  69. HRESULT Prototyper_HrPopulateResultPane(CFileMgmtCookie * pCookie);
  70. BOOL Prototyper_FAddResultPaneItem(CFileMgmtCookie * pParentCookie, LPCTSTR pszItemName, AMC::CRegKey& regkeySnapinItem);
  71. BOOL Prototyper_FAddMenuItems(IContextMenuCallback * pContextMenuCallback, IDataObject * pDataObject);
  72. BOOL Prototyper_ContextMenuCommand(LONG lCommandID, IDataObject* piDataObject);
  73. int Prototyper_AddIconToImageList(LPCTSTR pszIconPath);
  74. #endif // SNAPIN_PROTOTYPER
  75. HRESULT LoadIcons();
  76. static HRESULT LoadStrings();
  77. HRESULT LoadColumns( CFileMgmtCookie* pcookie );
  78. HRESULT GetSnapinMultiSelectDataObject(
  79. LPDATAOBJECT i_pMMCMultiSelectDataObject,
  80. LPDATAOBJECT *o_ppSnapinMultiSelectDataObject
  81. );
  82. BOOL DeleteShare(LPDATAOBJECT piDataObject);
  83. BOOL DeleteThisOneShare(LPDATAOBJECT piDataObject, BOOL bQuietMode);
  84. BOOL CloseSession( LPDATAOBJECT piDataObject );
  85. BOOL CloseThisOneSession(LPDATAOBJECT piDataObject, BOOL bQuietMode);
  86. BOOL CloseResource( LPDATAOBJECT piDataObject );
  87. BOOL CloseThisOneResource(LPDATAOBJECT piDataObject, BOOL bQuietMode);
  88. // IExtendContextMenu
  89. STDMETHOD(AddMenuItems)(
  90. IDataObject* piDataObject,
  91. IContextMenuCallback* piCallback,
  92. long* pInsertionAllowed);
  93. STDMETHOD(Command)(
  94. LONG lCommandID,
  95. IDataObject* piDataObject );
  96. // IExtendPropertySheet
  97. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK pCall, LONG_PTR handle, LPDATAOBJECT pDataObject);
  98. STDMETHOD(QueryPagesFor)(LPDATAOBJECT pDataObject);
  99. // IExtendControlbar
  100. STDMETHOD(SetControlbar)(LPCONTROLBAR pControlbar);
  101. STDMETHOD(ControlbarNotify)(MMC_NOTIFY_TYPE event,LPARAM arg,LPARAM param);
  102. HRESULT AddToolbar(LPDATAOBJECT pdoScopeIsSelected, BOOL fSelected);
  103. HRESULT UpdateToolbar(LPDATAOBJECT pdoResultIsSelected, BOOL fSelected);
  104. HRESULT OnToolbarButton(LPDATAOBJECT pDataObject, UINT idButton);
  105. HRESULT ServiceToolbarButtonState( LPDATAOBJECT pServiceDataObject, BOOL fSelected );
  106. // IResultDataCompare
  107. STDMETHOD(Compare)(LPARAM lUserParam, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int* pnResult);
  108. // FILEMGMT_NodeProperties
  109. STDMETHOD(GetProperty)(
  110. /* [in] */ LPDATAOBJECT pDataObject,
  111. /* [in] */ BSTR szPropertyName,
  112. /* [out] */ BSTR* pbstrProperty);
  113. CFileMgmtComponentData& QueryComponentDataRef()
  114. {
  115. return (CFileMgmtComponentData&)QueryBaseComponentDataRef();
  116. }
  117. public:
  118. LPCONTROLBAR m_pControlbar; // CODEWORK should use smartpointer
  119. LPTOOLBAR m_pSvcMgmtToolbar; // CODEWORK should use smartpointer
  120. LPTOOLBAR m_pFileMgmtToolbar; // CODEWORK should use smartpointer
  121. int m_iSortColumn;
  122. DWORD m_dwSortFlags;
  123. CFileMgmtScopeCookie* m_pViewedCookie;
  124. CFileMgmtCookie* m_pSelectedCookie;
  125. static const GUID m_ObjectTypeGUIDs[FILEMGMT_NUMTYPES];
  126. static const BSTR m_ObjectTypeStrings[FILEMGMT_NUMTYPES];
  127. BOOL IsServiceSnapin();
  128. FileServiceProvider* GetFileServiceProvider( FILEMGMT_TRANSPORT transport );
  129. inline FileServiceProvider* GetFileServiceProvider(
  130. INT iTransport )
  131. {
  132. return GetFileServiceProvider((FILEMGMT_TRANSPORT)iTransport);
  133. }
  134. }; // class CFileMgmtComponent
  135. /*
  136. //
  137. // A pointer to this structure is passed from the property sheets
  138. // to the views via MMCPropertyChangeNotify. Two notifications will be passed to all of
  139. // the views; first one where fClear==TRUE will instruct all relevant views to dump all
  140. // of their cookies, then a second with fClear==FALSE instructs them to reload.
  141. //
  142. typedef struct _FILEMGMTPROPERTYCHANGE
  143. {
  144. BOOL fServiceChange; // TRUE -> SvcMgmt change, FALSE -> FileMgmt change
  145. LPCTSTR lpcszMachineName; // machine whose properties must be refreshed
  146. BOOL fClear; // TRUE -> clear view, FALSE -> reload view
  147. } FILEMGMTPROPERTYCHANGE;
  148. */
  149. // Enumeration for the icons used
  150. enum
  151. {
  152. iIconSharesFolder = 0,
  153. iIconSharesFolderOpen,
  154. iIconSMBShare,
  155. iIconSFMShare,
  156. iIconFPNWShare,
  157. iIconSMBResource,
  158. iIconSFMResource,
  159. iIconFPNWResource,
  160. iIconSMBSession,
  161. iIconSFMSession,
  162. iIconFPNWSession,
  163. iIconService,
  164. #ifdef SNAPIN_PROTOTYPER
  165. iIconPrototyperContainerClosed,
  166. iIconPrototyperContainerOpen,
  167. iIconPrototyperHTML,
  168. iIconPrototyperLeaf,
  169. #endif
  170. iIconLast // Must be last
  171. };
  172. typedef enum _COLNUM_ROOT {
  173. COLNUM_ROOT_NAME = 0
  174. } COLNUM_ROOT;
  175. typedef enum _COLNUM_SHARES {
  176. COLNUM_SHARES_SHARED_FOLDER = 0,
  177. COLNUM_SHARES_SHARED_PATH,
  178. COLNUM_SHARES_TRANSPORT,
  179. COLNUM_SHARES_NUM_SESSIONS,
  180. COLNUM_SHARES_COMMENT
  181. } COLNUM_SHARES;
  182. typedef enum _COLNUM_SESSIONS {
  183. COLNUM_SESSIONS_USERNAME = 0,
  184. COLNUM_SESSIONS_COMPUTERNAME,
  185. COLNUM_SESSIONS_TRANSPORT,
  186. COLNUM_SESSIONS_NUM_FILES,
  187. COLNUM_SESSIONS_CONNECTED_TIME,
  188. COLNUM_SESSIONS_IDLE_TIME,
  189. COLNUM_SESSIONS_IS_GUEST
  190. } COLNUM_SESSIONS;
  191. typedef enum _COLNUM_RESOURCES {
  192. COLNUM_RESOURCES_FILENAME = 0,
  193. COLNUM_RESOURCES_USERNAME,
  194. COLNUM_RESOURCES_TRANSPORT,
  195. COLNUM_RESOURCES_NUM_LOCKS, // we don't try to display sharename for now, since
  196. // only FPNW has this information
  197. COLNUM_RESOURCES_OPEN_MODE
  198. } COLNUM_RESOURCES;
  199. //typedef enum _COLNUM_SERVICES {
  200. // COLNUM_SERVICES_SERVICENAME = 0,
  201. // COLNUM_SERVICES_DESCRIPTION,
  202. // COLNUM_SERVICES_STATUS,
  203. // COLNUM_SERVICES_STARTUPTYPE,
  204. // COLNUM_SERVICES_SECURITYCONTEXT,
  205. //} COLNUM_SERVICES;
  206. //
  207. // For context menu
  208. //
  209. enum
  210. {
  211. cmServiceStart = 100,
  212. cmServiceStop,
  213. cmServicePause,
  214. cmServiceResume,
  215. cmServiceRestart, // Stop + Start
  216. cmServiceStartTask,
  217. cmServiceStopTask,
  218. cmServicePauseTask,
  219. cmServiceResumeTask,
  220. cmServiceRestartTask, // Stop + Start
  221. };
  222. #ifdef SNAPIN_PROTOTYPER
  223. BOOL Prototyper_AddMenuItems(IContextMenuCallback* pContextMenuCallback, IDataObject* piDataObject);
  224. #endif
  225. #endif // ~__CMPONENT_H_INCLUDED__