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.

270 lines
8.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxServer.h
  5. Abstract:
  6. Declaration of the CFaxServer Class.
  7. Author:
  8. Iv Garber (IvG) Jun, 2000
  9. Revision History:
  10. --*/
  11. #ifndef __FAXSERVER_H_
  12. #define __FAXSERVER_H_
  13. #include "resource.h" // main symbols
  14. #include "FaxFolders.h"
  15. #include "FaxReceiptOptions.h"
  16. #include "FaxLoggingOptions.h"
  17. #include "FaxActivity.h"
  18. #include "FaxSecurity.h"
  19. #include "FaxInboundRouting.h"
  20. #include "FaxOutboundRouting.h"
  21. #include <atlwin.h>
  22. #include "FXSCOMEXCP.h"
  23. //
  24. //================= WINDOW FOR NOTIFICATIONS =================================
  25. //
  26. //
  27. // Forward Declaration
  28. //
  29. class CFaxServer;
  30. class CNotifyWindow : public CWindowImpl<CNotifyWindow>
  31. {
  32. public:
  33. CNotifyWindow(CFaxServer *pServer)
  34. {
  35. DBG_ENTER(_T("CNotifyWindow::Ctor"));
  36. m_pServer = pServer;
  37. m_MessageId = RegisterWindowMessage(_T("{2E037B27-CF8A-4abd-B1E0-5704943BEA6F}"));
  38. if (m_MessageId == 0)
  39. {
  40. m_MessageId = WM_USER + 876;
  41. }
  42. }
  43. BEGIN_MSG_MAP(CNotifyWindow)
  44. MESSAGE_HANDLER(m_MessageId, OnMessage)
  45. END_MSG_MAP()
  46. UINT GetMessageId(void) { return m_MessageId; };
  47. private:
  48. UINT m_MessageId;
  49. CFaxServer *m_pServer;
  50. LRESULT OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
  51. };
  52. //
  53. //================= REGISTRATION OF ROUTING EXTENSION METHODS ===========================
  54. //
  55. #define DELIMITER _T(";")
  56. #define EXCEPTION_INVALID_METHOD_DATA 0xE0000001
  57. BOOL CALLBACK RegisterMethodCallback(HANDLE FaxHandle, LPVOID Context, LPWSTR MethodName,
  58. LPWSTR FriendlyName, LPWSTR FunctionName, LPWSTR Guid);
  59. //
  60. //=============== FAX SERVER ==================================================
  61. //
  62. class ATL_NO_VTABLE CFaxServer :
  63. public CComObjectRootEx<CComSingleThreadModel>,
  64. public CComCoClass<CFaxServer, &CLSID_FaxServer>,
  65. public ISupportErrorInfo,
  66. public IDispatchImpl<IFaxServer, &IID_IFaxServer, &LIBID_FAXCOMEXLib>,
  67. public IFaxServerInner,
  68. public CFaxInitInner, // for Debug purposes only
  69. public IConnectionPointContainerImpl<CFaxServer>,
  70. public CProxyIFaxServerNotify< CFaxServer >
  71. {
  72. public:
  73. CFaxServer() : CFaxInitInner(_T("FAX SERVER")),
  74. m_faxHandle(NULL),
  75. m_pFolders(NULL),
  76. m_pActivity(NULL),
  77. m_pSecurity(NULL),
  78. m_pReceiptOptions(NULL),
  79. m_pLoggingOptions(NULL),
  80. m_pInboundRouting(NULL),
  81. m_pOutboundRouting(NULL),
  82. m_bVersionValid(false),
  83. m_pNotifyWindow(NULL),
  84. m_hEvent(NULL),
  85. m_lLastRegisteredMethod(0),
  86. m_EventTypes(fsetNONE)
  87. {
  88. }
  89. ~CFaxServer()
  90. {
  91. //
  92. // Disconnect
  93. //
  94. if (m_faxHandle)
  95. {
  96. Disconnect();
  97. }
  98. //
  99. // free all the allocated objects
  100. //
  101. if (m_pFolders)
  102. {
  103. delete m_pFolders;
  104. }
  105. if (m_pActivity)
  106. {
  107. delete m_pActivity;
  108. }
  109. if (m_pSecurity)
  110. {
  111. delete m_pSecurity;
  112. }
  113. if (m_pReceiptOptions)
  114. {
  115. delete m_pReceiptOptions;
  116. }
  117. if (m_pLoggingOptions)
  118. {
  119. delete m_pLoggingOptions;
  120. }
  121. if (m_pInboundRouting)
  122. {
  123. delete m_pInboundRouting;
  124. }
  125. if (m_pOutboundRouting)
  126. {
  127. delete m_pOutboundRouting;
  128. }
  129. }
  130. DECLARE_REGISTRY_RESOURCEID(IDR_FAXSERVER)
  131. DECLARE_PROTECT_FINAL_CONSTRUCT()
  132. BEGIN_COM_MAP(CFaxServer)
  133. COM_INTERFACE_ENTRY(IFaxServer)
  134. COM_INTERFACE_ENTRY(IDispatch)
  135. COM_INTERFACE_ENTRY(IFaxServerInner)
  136. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  137. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  138. END_COM_MAP()
  139. BEGIN_CONNECTION_POINT_MAP(CFaxServer)
  140. CONNECTION_POINT_ENTRY(DIID_IFaxServerNotify)
  141. END_CONNECTION_POINT_MAP()
  142. // Interfaces
  143. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  144. STDMETHOD(Disconnect)();
  145. STDMETHOD(Connect)(BSTR bstrServerName);
  146. STDMETHOD(GetDevices)(/*[out, retval]*/ IFaxDevices **ppDevices);
  147. STDMETHOD(get_Folders)(/*[out, retval]*/ IFaxFolders **ppFolders);
  148. STDMETHOD(get_Activity)(/*[out, retval]*/ IFaxActivity **ppActivity);
  149. STDMETHOD(get_Security)(/*[out, retval]*/ IFaxSecurity **ppSecurity);
  150. STDMETHOD(get_ReceiptOptions)(/*[out, retval]*/ IFaxReceiptOptions **ppReceiptOptions);
  151. STDMETHOD(get_LoggingOptions)(/*[out, retval]*/ IFaxLoggingOptions **ppLoggingOptions);
  152. STDMETHOD(get_InboundRouting)(/*[out, retval]*/ IFaxInboundRouting **ppInboundRouting);
  153. STDMETHOD(GetDeviceProviders)(/*[out, retval]*/ IFaxDeviceProviders **ppDeviceProviders);
  154. STDMETHOD(get_OutboundRouting)(/*[out, retval]*/ IFaxOutboundRouting **ppFaxOutboundRouting);
  155. STDMETHOD(get_Debug)(/*[out, retval]*/ VARIANT_BOOL *pbDebug);
  156. STDMETHOD(get_MajorBuild)(/*[out, retval]*/ long *plMajorBuild);
  157. STDMETHOD(get_MinorBuild)(/*[out, retval]*/ long *plMinorBuild);
  158. STDMETHOD(get_ServerName)(/*[out, retval]*/ BSTR *pbstrServerName);
  159. STDMETHOD(get_MajorVersion)(/*[out, retval]*/ long *plMajorVersion);
  160. STDMETHOD(get_MinorVersion)(/*[out, retval]*/ long *plMinorVersion);
  161. STDMETHOD(get_APIVersion)(/*[out,retval]*/ FAX_SERVER_APIVERSION_ENUM *pAPIVersion);
  162. STDMETHOD(SetExtensionProperty)(/*[in]*/ BSTR bstrGUID, /*[in]*/ VARIANT vProperty);
  163. STDMETHOD(GetExtensionProperty)(/*[in]*/ BSTR bstrGUID, /*[out, retval]*/ VARIANT *pvProperty);
  164. STDMETHOD(UnregisterDeviceProvider)(BSTR bstrProviderUniqueName);
  165. STDMETHOD(UnregisterInboundRoutingExtension)(BSTR bstrExtensionUniqueName);
  166. STDMETHOD(RegisterDeviceProvider)(
  167. /*[in]*/ BSTR bstrGUID,
  168. /*[in]*/ BSTR bstrFriendlyName,
  169. /*[in]*/ BSTR bstrImageName,
  170. /*[in]*/ BSTR TspName,
  171. /*[in]*/ long lFSPIVersion);
  172. STDMETHOD(RegisterInboundRoutingExtension)(
  173. /*[in]*/ BSTR bstrExtensionName,
  174. /*[in]*/ BSTR bstrFriendlyName,
  175. /*[in]*/ BSTR bstrImageName,
  176. /*[in]*/ VARIANT vMethods);
  177. STDMETHOD(ListenToServerEvents)(/*[in]*/ FAX_SERVER_EVENTS_TYPE_ENUM EventTypes);
  178. STDMETHOD(get_RegisteredEvents)(/*[out, retval]*/ FAX_SERVER_EVENTS_TYPE_ENUM *pEventTypes);
  179. // Internal Use
  180. STDMETHOD(GetHandle)(/*[out, retval]*/ HANDLE* pFaxHandle);
  181. BOOL GetRegisteredData(LPWSTR MethodName, LPWSTR FriendlyName, LPWSTR FunctionName, LPWSTR Guid);
  182. HRESULT ProcessMessage(FAX_EVENT_EX *pFaxEventInfo);
  183. private:
  184. HANDLE m_faxHandle;
  185. CComBSTR m_bstrServerName;
  186. FAX_VERSION m_Version;
  187. FAX_SERVER_APIVERSION_ENUM m_APIVersion;
  188. bool m_bVersionValid;
  189. long m_lLastRegisteredMethod;
  190. SAFEARRAY *m_pRegMethods;
  191. FAX_SERVER_EVENTS_TYPE_ENUM m_EventTypes;
  192. //
  193. // All these objects requires alive Server Object
  194. // so their Reference Counting is done by the Server
  195. //
  196. CComContainedObject2<CFaxFolders> *m_pFolders;
  197. CComContainedObject2<CFaxActivity> *m_pActivity;
  198. CComContainedObject2<CFaxSecurity> *m_pSecurity;
  199. CComContainedObject2<CFaxReceiptOptions> *m_pReceiptOptions;
  200. CComContainedObject2<CFaxLoggingOptions> *m_pLoggingOptions;
  201. CComContainedObject2<CFaxInboundRouting> *m_pInboundRouting;
  202. CComContainedObject2<CFaxOutboundRouting> *m_pOutboundRouting;
  203. //
  204. // Window for Notifications
  205. //
  206. CNotifyWindow *m_pNotifyWindow;
  207. HANDLE m_hEvent;
  208. // Functions
  209. STDMETHOD(GetVersion)();
  210. void GetMethodData(/*[in]*/ BSTR bstrAllString, /*[out]*/ LPWSTR strWhereToPut);
  211. void ClearNotifyWindow(void);
  212. typedef enum LOCATION { IN_QUEUE, OUT_QUEUE, IN_ARCHIVE, OUT_ARCHIVE } LOCATION;
  213. HRESULT ProcessJobNotification(DWORDLONG dwlJobId, FAX_ENUM_JOB_EVENT_TYPE eventType,
  214. LOCATION place, FAX_JOB_STATUS *pJobStatus = NULL);
  215. };
  216. #endif //__FAXSERVER_H_