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.

306 lines
8.4 KiB

  1. #ifndef __T30CONFIG_H_
  2. #define __T30CONFIG_H_
  3. #include "resource.h"
  4. //#include <atlsnap.h>
  5. #include "..\inc\atlsnap.h"
  6. #include "cVerNum.h"
  7. #include <atlapp.h>
  8. #include <atlctrls.h>
  9. #include <faxmmc.h>
  10. #include <faxutil.h>
  11. #include <fxsapip.h>
  12. class CT30ConfigPage : public CSnapInPropertyPageImpl<CT30ConfigPage>
  13. {
  14. public :
  15. CT30ConfigPage(LONG_PTR lNotifyHandle, bool bDeleteHandle = false, TCHAR* pTitle = NULL ) :
  16. CSnapInPropertyPageImpl<CT30ConfigPage> (pTitle),
  17. m_lNotifyHandle(lNotifyHandle),
  18. m_bDeleteHandle(bDeleteHandle) // Should be true for only page.
  19. {
  20. m_hFax = NULL;
  21. m_dwDeviceId = 0;
  22. m_bAdaptiveAnsweringEnabled = 0;
  23. }
  24. HRESULT Init(LPCTSTR lpctstrServerName, DWORD dwDeviceId);
  25. ~CT30ConfigPage()
  26. {
  27. DEBUG_FUNCTION_NAME(TEXT("CT30ConfigPage::~CT30ConfigPage"));
  28. if (m_hFax)
  29. {
  30. if (!FaxClose(m_hFax))
  31. {
  32. DWORD ec = GetLastError();
  33. DebugPrintEx(
  34. DEBUG_ERR,
  35. TEXT("FaxClose() failed on fax handle (0x%08X : %s). (ec: %ld)"),
  36. m_hFax,
  37. m_bstrServerName,
  38. ec);
  39. }
  40. m_hFax = NULL;
  41. }
  42. if (m_bDeleteHandle)
  43. MMCFreeNotifyHandle(m_lNotifyHandle);
  44. }
  45. enum { IDD = IDD_T30CONFIG };
  46. BEGIN_MSG_MAP(CT30ConfigPage)
  47. MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
  48. COMMAND_HANDLER(IDC_ADAPTIVE_ANSWERING, BN_CLICKED, OnClickedAdaptiveAnswering)
  49. MESSAGE_HANDLER( WM_CONTEXTMENU, OnHelpRequest)
  50. MESSAGE_HANDLER( WM_HELP, OnHelpRequest)
  51. CHAIN_MSG_MAP(CSnapInPropertyPageImpl<CT30ConfigPage>)
  52. END_MSG_MAP()
  53. // Handler prototypes:
  54. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  55. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  56. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  57. HRESULT PropertyChangeNotify(long param)
  58. {
  59. return MMCPropertyChangeNotify(m_lNotifyHandle, param);
  60. }
  61. BOOL OnApply();
  62. LRESULT OnClickedAdaptiveAnswering(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  63. {
  64. SetModified(TRUE);
  65. return 0;
  66. }
  67. LRESULT OnInitDialog(
  68. UINT uiMsg,
  69. WPARAM wParam,
  70. LPARAM lParam,
  71. BOOL& fHandled );
  72. LRESULT OnHelpRequest (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  73. public:
  74. LONG_PTR m_lNotifyHandle;
  75. bool m_bDeleteHandle;
  76. private:
  77. CComBSTR m_bstrServerName;
  78. HANDLE m_hFax; // Handle to fax server connection
  79. DWORD m_dwDeviceId; // The device id for which the properties are displayed
  80. BOOL m_bAdaptiveAnsweringEnabled; // Holds the AdaptiveAnswerEnable value untill we can put it in the ui.
  81. //
  82. // Controls
  83. //
  84. CButton m_btnAdaptiveEnabled;
  85. };
  86. class CT30ConfigExtData : public CSnapInItemImpl<CT30ConfigExtData, TRUE>
  87. {
  88. public:
  89. static const GUID* m_NODETYPE;
  90. static const OLECHAR* m_SZNODETYPE;
  91. static const OLECHAR* m_SZDISPLAY_NAME;
  92. static const CLSID* m_SNAPIN_CLASSID;
  93. CLIPFORMAT m_CCF_FSP_GUID;
  94. CLIPFORMAT m_CCF_FSP_DEVICE_ID;
  95. CLIPFORMAT m_CCF_SERVER_NAME;
  96. CT30ConfigExtData()
  97. {
  98. memset(&m_scopeDataItem, 0, sizeof(SCOPEDATAITEM));
  99. memset(&m_resultDataItem, 0, sizeof(RESULTDATAITEM));
  100. m_CCF_FSP_GUID = 0;
  101. m_CCF_FSP_DEVICE_ID = 0;
  102. m_CCF_SERVER_NAME = 0;
  103. }
  104. ~CT30ConfigExtData()
  105. {
  106. }
  107. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  108. LONG_PTR handle,
  109. IUnknown* pUnk,
  110. DATA_OBJECT_TYPES type);
  111. STDMETHOD(QueryPagesFor)(DATA_OBJECT_TYPES type);
  112. IDataObject* m_pDataObject;
  113. virtual void InitDataClass(IDataObject* pDataObject, CSnapInItem* pDefault)
  114. {
  115. DEBUG_FUNCTION_NAME(TEXT("CT30ConfigExtData::InitDataClass"));
  116. m_pDataObject = pDataObject;
  117. // The default code stores off the pointer to the Dataobject the class is wrapping
  118. // at the time.
  119. // Alternatively you could convert the dataobject to the internal format
  120. // it represents and store that information
  121. //
  122. // Register clipboard formats if they are not registered yet
  123. if (!m_CCF_FSP_GUID)
  124. {
  125. m_CCF_FSP_GUID = (CLIPFORMAT)RegisterClipboardFormat(CF_MSFAXSRV_FSP_GUID);
  126. if (!m_CCF_FSP_GUID)
  127. {
  128. DebugPrintEx(
  129. DEBUG_ERR,
  130. TEXT("Failed to registet clipformat : %s (ec: %ld)"),
  131. CF_MSFAXSRV_FSP_GUID,
  132. GetLastError());
  133. }
  134. }
  135. if (!m_CCF_FSP_DEVICE_ID)
  136. {
  137. m_CCF_FSP_DEVICE_ID = (CLIPFORMAT)RegisterClipboardFormat(CF_MSFAXSRV_DEVICE_ID);
  138. if (!m_CCF_FSP_DEVICE_ID)
  139. {
  140. DebugPrintEx(
  141. DEBUG_ERR,
  142. TEXT("Failed to registet clipformat : %s (ec: %ld)"),
  143. CF_MSFAXSRV_DEVICE_ID,
  144. GetLastError());
  145. }
  146. }
  147. if (!m_CCF_SERVER_NAME)
  148. {
  149. m_CCF_SERVER_NAME = (CLIPFORMAT)RegisterClipboardFormat(CF_MSFAXSRV_SERVER_NAME);
  150. if (!m_CCF_SERVER_NAME)
  151. {
  152. DebugPrintEx(
  153. DEBUG_ERR,
  154. TEXT("Failed to registet clipformat : %s (ec: %ld)"),
  155. CF_MSFAXSRV_SERVER_NAME,
  156. GetLastError());
  157. }
  158. }
  159. }
  160. CSnapInItem* GetExtNodeObject(IDataObject* pDataObject, CSnapInItem* pDefault)
  161. {
  162. // Modify to return a different CSnapInItem* pointer.
  163. return pDefault;
  164. }
  165. };
  166. class CT30Config : public CComObjectRootEx<CComSingleThreadModel>,
  167. public CSnapInObjectRoot<0, CT30Config>,
  168. public IExtendPropertySheetImpl<CT30Config>,
  169. public CComCoClass<CT30Config, &CLSID_T30Config>
  170. {
  171. public:
  172. CT30Config()
  173. {
  174. m_pComponentData = this;
  175. }
  176. EXTENSION_SNAPIN_DATACLASS(CT30ConfigExtData)
  177. BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP(CT30Config)
  178. EXTENSION_SNAPIN_NODEINFO_ENTRY(CT30ConfigExtData)
  179. END_EXTENSION_SNAPIN_NODEINFO_MAP()
  180. BEGIN_COM_MAP(CT30Config)
  181. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  182. END_COM_MAP()
  183. DECLARE_REGISTRY_RESOURCEID(IDR_T30CONFIG)
  184. DECLARE_NOT_AGGREGATABLE(CT30Config)
  185. static void WINAPI ObjectMain(bool bStarting)
  186. {
  187. if (bStarting)
  188. CSnapInItem::Init();
  189. }
  190. };
  191. class ATL_NO_VTABLE CT30ConfigAbout : public ISnapinAbout,
  192. public CComObjectRoot,
  193. public CComCoClass< CT30ConfigAbout, &CLSID_T30ConfigAbout>
  194. {
  195. public:
  196. DECLARE_REGISTRY(CT30ConfigAbout, _T("T30ConfigAbout.1"), _T("T30ConfigAbout.1"), IDS_T30CONFIG_DESC, THREADFLAGS_BOTH);
  197. BEGIN_COM_MAP(CT30ConfigAbout)
  198. COM_INTERFACE_ENTRY(ISnapinAbout)
  199. END_COM_MAP()
  200. STDMETHOD(GetSnapinDescription)(LPOLESTR *lpDescription)
  201. {
  202. USES_CONVERSION;
  203. TCHAR szBuf[256];
  204. if (::LoadString(_Module.GetResourceInstance(), IDS_T30CONFIG_DESC, szBuf, 256) == 0)
  205. return E_FAIL;
  206. *lpDescription = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  207. if (*lpDescription == NULL)
  208. return E_OUTOFMEMORY;
  209. ocscpy(*lpDescription, T2OLE(szBuf));
  210. return S_OK;
  211. }
  212. STDMETHOD(GetProvider)(LPOLESTR *lpName)
  213. {
  214. USES_CONVERSION;
  215. TCHAR szBuf[256];
  216. if (::LoadString(_Module.GetResourceInstance(), IDS_T30CONFIG_PROVIDER, szBuf, 256) == 0)
  217. return E_FAIL;
  218. *lpName = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  219. if (*lpName == NULL)
  220. return E_OUTOFMEMORY;
  221. ocscpy(*lpName, T2OLE(szBuf));
  222. return S_OK;
  223. }
  224. STDMETHOD(GetSnapinVersion)(LPOLESTR *lpVersion)
  225. {
  226. USES_CONVERSION;
  227. TCHAR szBuf[256];
  228. swprintf(szBuf, TEXT(" %d.%d.%d"), rmj, rmm, rup);
  229. *lpVersion = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  230. if (*lpVersion == NULL)
  231. return E_OUTOFMEMORY;
  232. ocscpy(*lpVersion, T2OLE(szBuf));
  233. return S_OK;
  234. }
  235. STDMETHOD(GetSnapinImage)(HICON *hAppIcon)
  236. {
  237. *hAppIcon = ::LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_T30_SNAPIN));
  238. return S_OK;
  239. }
  240. STDMETHOD(GetStaticFolderImage)(HBITMAP *hSmallImage,
  241. HBITMAP *hSmallImageOpen,
  242. HBITMAP *hLargeImage,
  243. COLORREF *cMask)
  244. {
  245. *hSmallImageOpen = *hLargeImage = *hLargeImage = 0;
  246. return S_OK;
  247. }
  248. };
  249. #endif