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.

428 lines
14 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : C_Snapin.h (from Snapin.h) //
  3. // //
  4. // DESCRIPTION : Header file for //
  5. // CSnapinPage //
  6. // CSnapinData //
  7. // CSnapinExtData //
  8. // CSnapinComponent //
  9. // CSnapin //
  10. // CSnapinAbout //
  11. // //
  12. // AUTHOR : ATL Snapin class wizard //
  13. // //
  14. // HISTORY : //
  15. // May 25 1998 adik Init. //
  16. // Aug 24 1998 adik Use Comet version. //
  17. // Sep 14 1998 yossg seperate common source to an included file //
  18. // Oct 18 1998 adik Merged with new wizard version. //
  19. // Jan 12 1999 adik Add ParentArrayInterfaceFromDataObject. //
  20. // Mar 28 1999 adik Remove persistence support. //
  21. // Mar 30 1999 adik Supporting ICometSnapinNode. //
  22. // Apr 27 1999 adik Help support. //
  23. // May 23 1999 adik Use ifndef _IN_NEMMCUTIL in few places. //
  24. // Jun 10 1999 AvihaiL Fix warnings. //
  25. // Jun 14 1999 roytal used UNREFERENCED_PARAMETER to fix build wrn //
  26. // Jul 29 1999 adik Release extensions. //
  27. // //
  28. // Oct 13 1999 yossg Welcome to Fax Server //
  29. // Dec 12 1999 yossg add CSnapin::Notify //
  30. // Apr 14 2000 yossg Add support for primary snapin mode //
  31. // Jun 25 2000 yossg Add stream and command line primary snapin //
  32. // machine targeting. //
  33. // //
  34. // Copyright (C) 1998 - 2000 Microsoft Corporation All Rights Reserved //
  35. /////////////////////////////////////////////////////////////////////////////
  36. #ifndef C_SNAPIN_H_INCLUDED
  37. #define C_SNAPIN_H_INCLUDED
  38. #include <stdio.h>
  39. //#include <ATLSnap.h>
  40. #include "..\inc\atlsnap.h"
  41. #include "cVerNum.h"
  42. EXTERN_C const CLSID CLSID_Snapin;
  43. EXTERN_C const CLSID CLSID_SnapinAbout;
  44. #define FXS_HINT_DELETE_ALL_RSLT_ITEMS -1
  45. class CSnapin;
  46. ////////////////////////////////////////////////////////////////////
  47. // CSnapinExtData
  48. //
  49. class CSnapinExtData : public CSnapInItemImpl<CSnapinExtData, TRUE>
  50. {
  51. public:
  52. static const GUID* m_NODETYPE;
  53. static const OLECHAR* m_SZNODETYPE;
  54. static const OLECHAR* m_SZDISPLAY_NAME;
  55. static const CLSID* m_SNAPIN_CLASSID;
  56. CSnapin *m_pComponentData;
  57. BEGIN_SNAPINCOMMAND_MAP(CSnapinExtData, FALSE)
  58. END_SNAPINCOMMAND_MAP()
  59. SNAPINMENUID(IDR_SNAPIN_MENU)
  60. BEGIN_SNAPINTOOLBARID_MAP(CSnapinExtData)
  61. // Create toolbar resources with button dimensions 16x16
  62. // and add an entry to the MAP. You can add multiple toolbars
  63. // SNAPINTOOLBARID_ENTRY(Toolbar ID)
  64. END_SNAPINTOOLBARID_MAP()
  65. CSnapinExtData()
  66. {
  67. memset(&m_scopeDataItem, 0, sizeof(SCOPEDATAITEM));
  68. memset(&m_resultDataItem, 0, sizeof(RESULTDATAITEM));
  69. }
  70. ~CSnapinExtData()
  71. {
  72. }
  73. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  74. LONG_PTR handle,
  75. IUnknown* pUnk,
  76. DATA_OBJECT_TYPES type);
  77. STDMETHOD(QueryPagesFor)(DATA_OBJECT_TYPES type)
  78. {
  79. if (type == CCT_SCOPE || type == CCT_RESULT)
  80. return S_OK;
  81. return S_FALSE;
  82. }
  83. IDataObject* m_pDataObject;
  84. virtual void InitDataClass(IDataObject* pDataObject, CSnapInItem* pDefault)
  85. {
  86. m_pDataObject = pDataObject;
  87. UNREFERENCED_PARAMETER(pDefault);
  88. // The default code stores off the pointer to the Dataobject the class is wrapping
  89. // at the time.
  90. // Alternatively you could convert the dataobject to the internal format
  91. // it represents and store that information
  92. }
  93. CSnapInItem* GetExtNodeObject(IDataObject* pDataObject, CSnapInItem* pDefault);
  94. }; // endclass CSnapinExtData
  95. ////////////////////////////////////////////////////////////////////
  96. // CSnapinComponent
  97. //
  98. class CSnapinComponent :
  99. public CComObjectRootEx<CComSingleThreadModel>,
  100. public CSnapInObjectRoot<2, CSnapin>,
  101. public IExtendPropertySheetImpl<CSnapinComponent>,
  102. public IExtendContextMenuImpl<CSnapinComponent>,
  103. public IExtendControlbarImpl<CSnapinComponent>,
  104. public IComponentImpl<CSnapinComponent>
  105. //, public IExtendTaskPadImpl<CSnapinComponent>
  106. {
  107. public:
  108. BEGIN_COM_MAP(CSnapinComponent)
  109. COM_INTERFACE_ENTRY(IComponent)
  110. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  111. COM_INTERFACE_ENTRY(IExtendContextMenu)
  112. COM_INTERFACE_ENTRY(IExtendControlbar)
  113. // COM_INTERFACE_ENTRY(IExtendTaskPad)
  114. END_COM_MAP()
  115. public:
  116. // A pointer to the currently selected node used for refreshing views.
  117. // When we need to update the view, we tell MMC to reselect this node.
  118. CSnapInItem * m_pSelectedNode;
  119. CSnapinComponent();
  120. ~CSnapinComponent();
  121. // Handlers for notifications which we want to handle on a
  122. // per-IComponent basis.
  123. public:
  124. // We are overiding ATLsnap.h's IComponentImpl implementation of this
  125. // in order to correctly handle messages which it is incorrectly
  126. // ignoring (e.g. MMCN_COLUMN_CLICK and MMCN_SNAPINHELP)
  127. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event,
  128. LPARAM arg, LPARAM param);
  129. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA,
  130. LPDATAOBJECT lpDataObjectB);
  131. protected:
  132. virtual HRESULT OnColumnClick(LPARAM arg, LPARAM param);
  133. virtual HRESULT OnCutOrMove(LPARAM arg, LPARAM param);
  134. virtual HRESULT OnSnapinHelp(LPARAM arg, LPARAM param);
  135. virtual HRESULT OnViewChange(LPARAM arg, LPARAM param);
  136. virtual HRESULT OnPropertyChange(LPARAM arg, LPARAM param);
  137. // virtual HRESULT OnAddImages(LPARAM arg, LPARAM param);
  138. public:
  139. // Related to TaskPad implementation.
  140. // We have to override this because the default implementation
  141. // gives back the wrong answer when the cookie is NULL.
  142. // NULL cookie means root node, and for our root node
  143. // we want a taskpad.
  144. // STDMETHOD(GetResultViewType)(long cookie,
  145. // LPOLESTR *ppViewType,
  146. // long *pViewOptions);
  147. STDMETHOD(GetTitle)(LPOLESTR pszGroup,
  148. LPOLESTR *pszTitle);
  149. STDMETHOD(GetBanner)(LPOLESTR pszGroup,
  150. LPOLESTR *pszBitmapResource);
  151. }; // endclass CSnapinComponent
  152. class CFaxServerNode;
  153. ////////////////////////////////////////////////////////////////////
  154. // CSnapin
  155. //
  156. class CSnapin : public CComObjectRootEx<CComSingleThreadModel>,
  157. public CSnapInObjectRoot<1, CSnapin>,
  158. public IComponentDataImpl<CSnapin, CSnapinComponent>,
  159. public IExtendPropertySheetImpl<CSnapin>,
  160. public IExtendContextMenuImpl<CSnapin>,
  161. public IExtendControlbarImpl<CSnapin>,
  162. public IPersistStream,
  163. public ISnapinHelp,
  164. public CComCoClass<CSnapin, &CLSID_Snapin>
  165. {
  166. public:
  167. CSnapin();
  168. ~CSnapin();
  169. EXTENSION_SNAPIN_DATACLASS(CSnapinExtData)
  170. BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP(CSnapin)
  171. EXTENSION_SNAPIN_NODEINFO_ENTRY(CSnapinExtData)
  172. END_EXTENSION_SNAPIN_NODEINFO_MAP()
  173. CFaxServerNode* m_pPrimaryFaxServerNode;
  174. BEGIN_COM_MAP(CSnapin)
  175. COM_INTERFACE_ENTRY(IComponentData)
  176. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  177. COM_INTERFACE_ENTRY(IExtendContextMenu)
  178. COM_INTERFACE_ENTRY(IExtendControlbar)
  179. COM_INTERFACE_ENTRY(ISnapinHelp)
  180. COM_INTERFACE_ENTRY(IPersistStream)
  181. END_COM_MAP()
  182. DECLARE_REGISTRY_RESOURCEID(IDR_SNAPIN)
  183. DECLARE_NOT_AGGREGATABLE(CSnapin)
  184. STDMETHOD(GetClassID)(CLSID *pClassID)
  185. {
  186. ATLTRACE(_T("CSnapin::GetClassID"));
  187. ATLASSERT(pClassID);
  188. *pClassID = CLSID_Snapin;
  189. return S_OK;
  190. }
  191. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  192. static void WINAPI ObjectMain(bool bStarting)
  193. {
  194. if (bStarting)
  195. CSnapInItem::Init();
  196. }
  197. //
  198. // ISnapinHelp Interface
  199. //
  200. STDMETHOD(GetHelpTopic)(LPOLESTR* lpCompiledHelpFile);
  201. virtual WCHAR *GetHelpFile();
  202. virtual WCHAR *GetHelpTopic();
  203. //
  204. // Override IComponentDataImpl's Notify
  205. // for lpDataObject == NULL && event == MMCN_PROPERTY_CHANGE
  206. //
  207. STDMETHOD(Notify)(
  208. LPDATAOBJECT lpDataObject,
  209. MMC_NOTIFY_TYPE event,
  210. LPARAM arg,
  211. LPARAM param);
  212. //
  213. // IPersistStream:
  214. // These originally pure virtual functions
  215. // must been defined here
  216. //
  217. STDMETHOD(IsDirty)();
  218. STDMETHOD(Load)(IStream *pStm);
  219. STDMETHOD(Save)(IStream *pStm, BOOL /*fClearDirty*/);
  220. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  221. private:
  222. CComBSTR m_bstrServerName;
  223. BOOL m_fAllowOverrideServerName;
  224. }; // endclass CSnapin
  225. ////////////////////////////////////////////////////////////////////
  226. // CSnapinAbout
  227. //
  228. class ATL_NO_VTABLE CSnapinAbout : public ISnapinAbout,
  229. public CComObjectRoot,
  230. public CComCoClass< CSnapinAbout, &CLSID_SnapinAbout>
  231. {
  232. public:
  233. DECLARE_REGISTRY(CSnapinAbout, _T("SnapinAbout.1"), _T("SnapinAbout.1"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH);
  234. BEGIN_COM_MAP(CSnapinAbout)
  235. COM_INTERFACE_ENTRY(ISnapinAbout)
  236. END_COM_MAP()
  237. HBITMAP m_hSmallImage;
  238. HBITMAP m_hSmallImageOpen;
  239. HBITMAP m_hLargeImage;
  240. CSnapinAbout(): m_hSmallImage(NULL), m_hSmallImageOpen(NULL), m_hLargeImage(NULL)
  241. {
  242. }
  243. ~CSnapinAbout()
  244. {
  245. if(m_hSmallImage)
  246. {
  247. DeleteObject(m_hSmallImage);
  248. }
  249. if(m_hSmallImageOpen)
  250. {
  251. DeleteObject(m_hSmallImageOpen);
  252. }
  253. if(m_hLargeImage)
  254. {
  255. DeleteObject(m_hLargeImage);
  256. }
  257. }
  258. STDMETHOD(GetSnapinDescription)(LPOLESTR *lpDescription)
  259. {
  260. USES_CONVERSION;
  261. TCHAR szBuf[256];
  262. if (::LoadString(_Module.GetResourceInstance(), IDS_SNAPIN_DESC, szBuf, 256) == 0)
  263. return E_FAIL;
  264. *lpDescription = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  265. if (*lpDescription == NULL)
  266. return E_OUTOFMEMORY;
  267. ocscpy(*lpDescription, T2OLE(szBuf));
  268. return S_OK;
  269. }
  270. STDMETHOD(GetProvider)(LPOLESTR *lpName)
  271. {
  272. USES_CONVERSION;
  273. WCHAR szBuf[256];
  274. if (::LoadString(_Module.GetResourceInstance(), IDS_SNAPIN_PROVIDER, szBuf, 256) == 0)
  275. return E_FAIL;
  276. *lpName = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  277. if (*lpName == NULL)
  278. return E_OUTOFMEMORY;
  279. ocscpy(*lpName, T2OLE(szBuf));
  280. return S_OK;
  281. }
  282. STDMETHOD(GetSnapinVersion)(LPOLESTR *lpVersion)
  283. {
  284. USES_CONVERSION;
  285. TCHAR szBuf[256];
  286. TCHAR szFmt[200];
  287. if (::LoadString(_Module.GetResourceInstance(), IDS_SNAPIN_VERSION, szFmt, 200) == 0)
  288. return E_FAIL;
  289. swprintf(szBuf, szFmt, rmj, rmm, rup);
  290. *lpVersion = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  291. if (*lpVersion == NULL)
  292. return E_OUTOFMEMORY;
  293. ocscpy(*lpVersion, T2OLE(szBuf));
  294. return S_OK;
  295. }
  296. STDMETHOD(GetSnapinImage)(HICON *hAppIcon)
  297. {
  298. *hAppIcon = ::LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON_FAXSERVER));
  299. return S_OK;
  300. }
  301. STDMETHOD(GetStaticFolderImage)(HBITMAP* hSmallImage,
  302. HBITMAP* hSmallImageOpen,
  303. HBITMAP* hLargeImage,
  304. COLORREF* cMask)
  305. {
  306. if(!hSmallImage || !hSmallImageOpen || !hLargeImage || !cMask)
  307. {
  308. return S_FALSE;
  309. }
  310. HINSTANCE hInst = _Module.GetResourceInstance();
  311. if(m_hSmallImage)
  312. {
  313. *hSmallImage = m_hSmallImage;
  314. }
  315. else
  316. {
  317. m_hSmallImage = *hSmallImage = ::LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FAX_BITMAP_16));
  318. }
  319. if(m_hSmallImageOpen)
  320. {
  321. *hSmallImageOpen = m_hSmallImageOpen;
  322. }
  323. else
  324. {
  325. m_hSmallImageOpen = *hSmallImageOpen = ::LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FAX_BITMAP_16));
  326. }
  327. if(m_hLargeImage)
  328. {
  329. *hLargeImage = m_hLargeImage;
  330. }
  331. else
  332. {
  333. m_hLargeImage = *hLargeImage = ::LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FAX_BITMAP_32));
  334. }
  335. *cMask = RGB(255, 255, 255);
  336. return S_OK;
  337. }
  338. }; // endclass CSnapinAbout
  339. HRESULT AddBitmaps(IImageList *pImageList);
  340. #endif // ! C_SNAPIN_H_INCLUDED