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.

374 lines
11 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ExtDll.h
  7. //
  8. // Abstract:
  9. // Definition of the extension classes.
  10. //
  11. // Implementation File:
  12. // ExtDll.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) May 31, 1996
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef _EXTDLL_H_
  23. #define _EXTDLL_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Include Files
  26. /////////////////////////////////////////////////////////////////////////////
  27. #ifndef __cluadmex_h__
  28. #include <CluAdmEx.h> // for extension DLL definitions
  29. #endif
  30. #ifndef __cluadmid_h__
  31. #include "CluAdmID.h"
  32. #endif
  33. #ifndef _DATAOBJ_H_
  34. #include "DataObj.h" // for CDataObject
  35. #endif
  36. #ifndef _TRACETAG_H_
  37. #include "TraceTag.h" // for CTraceTag, Trace
  38. #endif
  39. /////////////////////////////////////////////////////////////////////////////
  40. // Forward Class Declarations
  41. /////////////////////////////////////////////////////////////////////////////
  42. class CExtension;
  43. class CExtensionDll;
  44. /////////////////////////////////////////////////////////////////////////////
  45. // External Class Declarations
  46. /////////////////////////////////////////////////////////////////////////////
  47. class CClusterItem;
  48. class CBaseSheet;
  49. class CBasePropertySheet;
  50. class CBaseWizard;
  51. class CExtMenuItem;
  52. class CExtMenuItemList;
  53. /////////////////////////////////////////////////////////////////////////////
  54. // Type Definitions
  55. /////////////////////////////////////////////////////////////////////////////
  56. #define CAEXT_MENU_FIRST_ID 35000
  57. typedef CList<CComObject<CExtensionDll> *, CComObject<CExtensionDll> *> CExtDllList;
  58. /////////////////////////////////////////////////////////////////////////////
  59. // Global Variable Definitions
  60. /////////////////////////////////////////////////////////////////////////////
  61. #ifdef _DEBUG
  62. extern CTraceTag g_tagExtDll;
  63. extern CTraceTag g_tagExtDllRef;
  64. #endif
  65. /////////////////////////////////////////////////////////////////////////////
  66. //
  67. // class CExtensions
  68. //
  69. // Purpose:
  70. // Encapsulates access to a list of extension DLLs.
  71. //
  72. /////////////////////////////////////////////////////////////////////////////
  73. class CExtensions : public CObject
  74. {
  75. friend class CExtensionDll;
  76. DECLARE_DYNAMIC(CExtensions);
  77. // Attributes
  78. private:
  79. const CStringList * m_plstrExtensions; // List of extensions.
  80. CClusterItem * m_pci; // Cluster item being administered.
  81. HFONT m_hfont; // Font for dialog text.
  82. HICON m_hicon; // Icon for upper left corner.
  83. protected:
  84. const CStringList * PlstrExtensions(void) const { return m_plstrExtensions; }
  85. CClusterItem * Pci(void) const { return m_pci; }
  86. HFONT Hfont(void) const { return m_hfont; }
  87. HICON Hicon(void) const { return m_hicon; }
  88. // Operations
  89. public:
  90. CExtensions(void);
  91. virtual ~CExtensions(void);
  92. void Init(
  93. IN const CStringList & rlstrExtensions,
  94. IN OUT CClusterItem * pci,
  95. IN HFONT hfont,
  96. IN HICON hicon
  97. );
  98. void UnloadExtensions(void);
  99. // IWEExtendPropertySheet interface routines.
  100. void CreatePropertySheetPages(
  101. IN OUT CBasePropertySheet * psht,
  102. IN const CStringList & rlstrExtensions,
  103. IN OUT CClusterItem * pci,
  104. IN HFONT hfont,
  105. IN HICON hicon
  106. );
  107. // IWEExtendWizard interface routines.
  108. void CreateWizardPages(
  109. IN OUT CBaseWizard * psht,
  110. IN const CStringList & rlstrExtensions,
  111. IN OUT CClusterItem * pci,
  112. IN HFONT hfont,
  113. IN HICON hicon
  114. );
  115. // IWEExtendContextMenu interface routines.
  116. void AddContextMenuItems(
  117. IN OUT CMenu * pmenu,
  118. IN const CStringList & rlstrExtensions,
  119. IN OUT CClusterItem * pci
  120. );
  121. BOOL BExecuteContextMenuItem(IN ULONG nCommandID);
  122. BOOL BGetCommandString(IN ULONG nCommandID, OUT CString & rstrMessage);
  123. void SetPfGetResNetName(PFGETRESOURCENETWORKNAME pfGetResNetName, PVOID pvContext)
  124. {
  125. if (Pdo() != NULL)
  126. Pdo()->SetPfGetResNetName(pfGetResNetName, pvContext);
  127. }
  128. // Implementation
  129. private:
  130. CComObject<CDataObject> * m_pdoData; // Data object for exchanging data.
  131. CExtDllList * m_plextdll; // List of extension DLLs.
  132. CBaseSheet * m_psht; // Property sheet for IWEExtendPropertySheet.
  133. CMenu * m_pmenu; // Menu for IWEExtendContextMenu.
  134. CExtMenuItemList * m_plMenuItems;
  135. ULONG m_nFirstCommandID;
  136. ULONG m_nNextCommandID;
  137. ULONG m_nFirstMenuID;
  138. ULONG m_nNextMenuID;
  139. protected:
  140. CComObject<CDataObject> * Pdo(void) { return m_pdoData; }
  141. CExtDllList * Plextdll(void) const { return m_plextdll; }
  142. CBaseSheet * Psht(void) const { return m_psht; }
  143. CMenu * Pmenu(void) const { return m_pmenu; }
  144. CExtMenuItemList * PlMenuItems(void) const { return m_plMenuItems; }
  145. CExtMenuItem * PemiFromCommandID(ULONG nCommandID) const;
  146. #ifdef _DEBUG
  147. CExtMenuItem * PemiFromExtCommandID(ULONG nExtCommandID) const;
  148. #endif
  149. ULONG NFirstCommandID(void) const { return m_nFirstCommandID; }
  150. ULONG NNextCommandID(void) const { return m_nNextCommandID; }
  151. ULONG NFirstMenuID(void) const { return m_nFirstMenuID; }
  152. ULONG NNextMenuID(void) const { return m_nNextMenuID; }
  153. public:
  154. afx_msg void OnUpdateCommand(CCmdUI * pCmdUI);
  155. BOOL OnCmdMsg(UINT nID, int nCode, void * pExtra, AFX_CMDHANDLERINFO * pHandlerInfo);
  156. }; //*** class CExtensions
  157. /////////////////////////////////////////////////////////////////////////////
  158. //
  159. // class CExtensionDll
  160. //
  161. // Purpose:
  162. // Encapsulates access to an extension DLL.
  163. //
  164. /////////////////////////////////////////////////////////////////////////////
  165. class ATL_NO_VTABLE CExtensionDll :
  166. public CObject,
  167. public IWCPropertySheetCallback,
  168. public IWCWizardCallback,
  169. public IWCContextMenuCallback,
  170. public ISupportErrorInfo,
  171. public CComObjectRoot,
  172. public CComCoClass<CExtensionDll, &CLSID_CoCluAdmin>
  173. {
  174. friend class CExtensions;
  175. DECLARE_DYNAMIC(CExtensionDll);
  176. // Attributes
  177. private:
  178. CString m_strCLSID; // Name of extension DLL.
  179. protected:
  180. const CString & StrCLSID(void) const { return m_strCLSID; }
  181. CClusterItem * Pci(void) const { return Pext()->Pci(); }
  182. // Operations
  183. public:
  184. CExtensionDll(void);
  185. virtual ~CExtensionDll(void);
  186. BEGIN_COM_MAP(CExtensionDll)
  187. COM_INTERFACE_ENTRY(IWCPropertySheetCallback)
  188. COM_INTERFACE_ENTRY(IWCWizardCallback)
  189. COM_INTERFACE_ENTRY(IWCContextMenuCallback)
  190. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  191. END_COM_MAP()
  192. //DECLARE_NOT_AGGREGATABLE(CExtensionDll)
  193. // Remove the comment from the line above if you don't want your object to
  194. // support aggregation. The default is to support it
  195. DECLARE_REGISTRY(CExtensionDll, _T("CLUADMIN.Extensions"), _T("CLUADMIN.Extensions"), IDS_CLUADMIN_DESC, THREADFLAGS_BOTH)
  196. void Init(
  197. IN const CString & rstrExtension,
  198. IN OUT CExtensions * pext
  199. );
  200. IUnknown * LoadInterface(IN const REFIID riid);
  201. void UnloadExtension(void);
  202. // IWEExtendPropertySheet interface routines.
  203. void CreatePropertySheetPages(void);
  204. // IWEExtendWizard interface routines.
  205. void CreateWizardPages(void);
  206. // IWEExtendContextMenu interface routines.
  207. void AddContextMenuItems(void);
  208. // ISupportsErrorInfo
  209. public:
  210. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  211. // IWCPropertySheetCallback
  212. public:
  213. STDMETHOD(AddPropertySheetPage)(
  214. IN LONG * hpage // really should be HPROPSHEETPAGE
  215. );
  216. // IWCWizardCallback
  217. public:
  218. STDMETHOD(AddWizardPage)(
  219. IN LONG * hpage // really should be HPROPSHEETPAGE
  220. );
  221. STDMETHOD(EnableNext)(
  222. IN LONG * hpage,
  223. IN BOOL bEnable
  224. );
  225. // IWCContextMenuCallback
  226. public:
  227. STDMETHOD(AddExtensionMenuItem)(
  228. IN BSTR lpszName,
  229. IN BSTR lpszStatusBarText,
  230. IN ULONG nCommandID,
  231. IN ULONG nSubmenuCommandID,
  232. IN ULONG uFlags
  233. );
  234. // Implementation
  235. private:
  236. CExtensions * m_pext;
  237. CLSID m_clsid;
  238. IWEExtendPropertySheet * m_piExtendPropSheet; // Pointer to an IWEExtendPropertySheet interface.
  239. IWEExtendWizard * m_piExtendWizard; // Pointer to an IWEExtendWizard interface.
  240. IWEExtendContextMenu * m_piExtendContextMenu; // Pointer to an IWEExtendContextMenu interface.
  241. IWEInvokeCommand * m_piInvokeCommand; // Pointer to an IWEInvokeCommand interface.
  242. AFX_MODULE_STATE * m_pModuleState; // Required for resetting our state during callbacks.
  243. protected:
  244. CExtensions * Pext(void) const { ASSERT_VALID(m_pext); return m_pext; }
  245. const CLSID & Rclsid(void) const { return m_clsid; }
  246. IWEExtendPropertySheet * PiExtendPropSheet(void) const { return m_piExtendPropSheet; }
  247. IWEExtendWizard * PiExtendWizard(void) const { return m_piExtendWizard; }
  248. IWEExtendContextMenu * PiExtendContextMenu(void) const { return m_piExtendContextMenu; }
  249. IWEInvokeCommand * PiInvokeCommand(void) const { return m_piInvokeCommand; }
  250. CComObject<CDataObject> * Pdo(void) const { return Pext()->Pdo(); }
  251. CBaseSheet * Psht(void) const { return Pext()->Psht(); }
  252. CMenu * Pmenu(void) const { return Pext()->Pmenu(); }
  253. CExtMenuItemList * PlMenuItems(void) const { return Pext()->PlMenuItems(); }
  254. ULONG NFirstCommandID(void) const { return Pext()->NFirstCommandID(); }
  255. ULONG NNextCommandID(void) const { return Pext()->NNextCommandID(); }
  256. ULONG NFirstMenuID(void) const { return Pext()->NFirstMenuID(); }
  257. ULONG NNextMenuID(void) const { return Pext()->NNextMenuID(); }
  258. void ReleaseInterface(
  259. IN OUT IUnknown ** ppi
  260. #ifdef _DEBUG
  261. , IN LPCTSTR szClassName
  262. #endif
  263. )
  264. {
  265. ASSERT(ppi != NULL);
  266. if (*ppi != NULL)
  267. {
  268. #ifdef _DEBUG
  269. ULONG ulNewRefCount;
  270. Trace(g_tagExtDllRef, _T("Releasing %s"), szClassName);
  271. ulNewRefCount =
  272. #endif
  273. (*ppi)->Release();
  274. *ppi = NULL;
  275. #ifdef _DEBUG
  276. Trace(g_tagExtDllRef, _T(" Reference count = %d"), ulNewRefCount);
  277. Trace(g_tagExtDllRef, _T("ReleaseInterface() - %s = %08.8x"), szClassName, *ppi);
  278. #endif
  279. } // if: interface specified
  280. }
  281. void ReleaseInterface(IN OUT IWEExtendPropertySheet ** ppi)
  282. {
  283. ReleaseInterface(
  284. (IUnknown **) ppi
  285. #ifdef _DEBUG
  286. , _T("IWEExtendPropertySheet")
  287. #endif
  288. );
  289. }
  290. void ReleaseInterface(IN OUT IWEExtendWizard ** ppi)
  291. {
  292. ReleaseInterface(
  293. (IUnknown **) ppi
  294. #ifdef _DEBUG
  295. , _T("IWEExtendWizard")
  296. #endif
  297. );
  298. }
  299. void ReleaseInterface(IN OUT IWEExtendContextMenu ** ppi)
  300. {
  301. ReleaseInterface(
  302. (IUnknown **) ppi
  303. #ifdef _DEBUG
  304. , _T("IWEExtendContextMenu")
  305. #endif
  306. );
  307. }
  308. void ReleaseInterface(IN OUT IWEInvokeCommand ** ppi)
  309. {
  310. ReleaseInterface(
  311. (IUnknown **) ppi
  312. #ifdef _DEBUG
  313. , _T("IWEInvokeCommand")
  314. #endif
  315. );
  316. }
  317. }; //*** class CExtensionDll
  318. /////////////////////////////////////////////////////////////////////////////
  319. #endif // _EXTDLL_H_