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.

429 lines
13 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. tapiobj.h
  5. Abstract:
  6. Declaration of the CTAPI class
  7. Author:
  8. mquinton 06-12-97
  9. Notes:
  10. Revision History:
  11. --*/
  12. #ifndef __TAPIOBJ_H_
  13. #define __TAPIOBJ_H_
  14. #include "resource.h" // main symbols
  15. #include "address.h"
  16. #include "connect.h"
  17. #include "callcent.h"
  18. #include "utils.h"
  19. #include "shellapi.h"
  20. #include "atlctl.h"
  21. #include "TAPIObjectSafety.h"
  22. #define TAPIFLAG_INITIALIZED 0x00000001
  23. #define TAPIFLAG_CALLHUBNOTIFY 0x00000002
  24. #define TAPIFLAG_ALLCALLHUBTRACKING 0x00000004
  25. #define TAPIFLAG_ALLCALLNOTIFY 0x00000008
  26. #define TAPIFLAG_REINIT 0x00000010
  27. #define TAPIFLAG_CALLCENTER_INITIALIZED 0x00000020
  28. #define ALL_EVENT_FILTER_MASK (TE_TAPIOBJECT | \
  29. TE_ADDRESS | \
  30. TE_CALLNOTIFICATION | \
  31. TE_CALLSTATE | \
  32. TE_CALLMEDIA | \
  33. TE_CALLHUB | \
  34. TE_CALLINFOCHANGE | \
  35. TE_PRIVATE | \
  36. TE_REQUEST | \
  37. TE_AGENT | \
  38. TE_AGENTSESSION | \
  39. TE_QOSEVENT | \
  40. TE_AGENTHANDLER | \
  41. TE_ACDGROUP | \
  42. TE_QUEUE | \
  43. TE_DIGITEVENT | \
  44. TE_GENERATEEVENT | \
  45. TE_ASRTERMINAL | \
  46. TE_TTSTERMINAL | \
  47. TE_FILETERMINAL | \
  48. TE_TONETERMINAL | \
  49. TE_PHONEEVENT | \
  50. TE_TONEEVENT | \
  51. TE_GATHERDIGITS | \
  52. TE_ADDRESSDEVSPECIFIC | \
  53. TE_PHONEDEVSPECIFIC )
  54. class CCallHub;
  55. HRESULT
  56. WINAPI
  57. MyCallCenterQI(void* pvClassObject, REFIID riid, LPVOID* ppv, DWORD_PTR dw);
  58. /////////////////////////////////////////////////////////////////
  59. // Intermediate classes used for DISPID encoding
  60. template <class T>
  61. class /*ATL_NO_VTABLE*/ ITapi2Vtbl : public ITTAPI2
  62. {
  63. };
  64. template <class T>
  65. class /*ATL_NO_VTABLE*/ ICallCenterVtbl : public ITTAPICallCenter
  66. {
  67. };
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CTAPI
  70. class CTAPI :
  71. public CTAPIComObjectRoot<CTAPI>,
  72. public CComCoClass<CTAPI, &CLSID_TAPI>,
  73. //public CComDualImpl<ITTAPI, &IID_ITTAPI, &LIBID_TAPI3Lib>,
  74. //public CComDualImpl<IConnectionPointContainer, &IID_IConnectionPointContainer, &LIBID_TAPI3Lib>,
  75. //public CComDualImpl<ITTAPICallCenter, &IID_ITTAPICallCenter, &LIBID_TAPI3Lib>,
  76. public IDispatchImpl<IConnectionPointContainer, &IID_IConnectionPointContainer, &LIBID_TAPI3Lib>,
  77. public IDispatchImpl<ITapi2Vtbl<CTAPI>, &IID_ITTAPI2, &LIBID_TAPI3Lib>,
  78. public IDispatchImpl<ICallCenterVtbl<CTAPI>, &IID_ITTAPICallCenter, &LIBID_TAPI3Lib>,
  79. public CTAPIObjectSafety,
  80. public IProvideClassInfo2Impl<&CLSID_TAPI, &DIID_ITTAPIDispatchEventNotification,&LIBID_TAPI3Lib>
  81. {
  82. public:
  83. CTAPI() : m_hLineApp(NULL),
  84. m_hPhoneApp(NULL),
  85. m_pLineInitData(NULL),
  86. m_pPhoneInitData(NULL),
  87. m_dwLineInitDataHandle(0),
  88. m_dwPhoneInitDataHandle(0),
  89. m_dwLineDevs(0),
  90. m_dwPhoneDevs(0),
  91. m_dwFlags(0),
  92. m_pCP(NULL),
  93. m_pAddressCapCache(NULL),
  94. m_pLineCapCache(NULL),
  95. m_pPhoneCapCache(NULL),
  96. m_dwEventFilterMask(0)
  97. {
  98. LOG((TL_TRACE, "CTAPI[%p] - enter", this));
  99. LOG((TL_TRACE, "CTAPI - finish"));
  100. }
  101. ~CTAPI()
  102. {
  103. LOG((TL_TRACE, "~CTAPI[%p] - enter", this));
  104. LOG((TL_TRACE, "~CTAPI - finish"));
  105. }
  106. void FinalRelease();
  107. DECLARE_REGISTRY_RESOURCEID(IDR_TAPI)
  108. DECLARE_QI()
  109. DECLARE_MARSHALQI(CTAPI)
  110. DECLARE_TRACELOG_CLASS(CTAPI)
  111. BEGIN_COM_MAP(CTAPI)
  112. COM_INTERFACE_ENTRY2(IDispatch, ITTAPI2)
  113. COM_INTERFACE_ENTRY(ITTAPI)
  114. COM_INTERFACE_ENTRY(ITTAPI2)
  115. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  116. COM_INTERFACE_ENTRY_FUNC(IID_ITTAPICallCenter, 0, MyCallCenterQI)
  117. COM_INTERFACE_ENTRY(ITTAPICallCenter)
  118. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  119. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  120. COM_INTERFACE_ENTRY(IObjectSafety)
  121. COM_INTERFACE_ENTRY(IObjectWithSite)
  122. COM_INTERFACE_ENTRY(IProvideClassInfo)
  123. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  124. END_COM_MAP()
  125. static BOOL IsValidTapiObject(CTAPI *pTapiObject);
  126. static void FinalTapiCleanup();
  127. void AddCallHub( CCallHub * pCallHub );
  128. void RemoveCallHub( CCallHub * pCallHub );
  129. BOOL DoCallHubNotifications()
  130. {
  131. BOOL bReturn;
  132. Lock();
  133. bReturn = (m_dwFlags & TAPIFLAG_CALLHUBNOTIFY);
  134. Unlock();
  135. return bReturn;
  136. }
  137. HRESULT Event(
  138. TAPI_EVENT te,
  139. IDispatch * pEvent
  140. );
  141. HRESULT EventFire(
  142. TAPI_EVENT te,
  143. IDispatch * pEvent
  144. );
  145. HRESULT UpdateAgentHandlerArray(void);
  146. void DoLineCreate( DWORD dwDeviceID );
  147. void DoLineRemove( DWORD dwDeviceID );
  148. void DoPhoneCreate( DWORD dwDeviceID );
  149. void DoPhoneRemove( DWORD dwDeviceID );
  150. void HandleReinit();
  151. HLINEAPP GetHLineApp(){ return (HLINEAPP)m_dwLineInitDataHandle; }
  152. static FindTapiObject( CTAPI * pTapi );
  153. HRESULT GetBuffer( DWORD, UINT_PTR, LPVOID * );
  154. HRESULT SetBuffer( DWORD, UINT_PTR, LPVOID );
  155. HRESULT InvalidateBuffer( DWORD, UINT_PTR );
  156. BOOL FindRegistration( PVOID );
  157. HRESULT GetPhoneArray(
  158. PhoneArray *pPhoneArray
  159. );
  160. private:
  161. DWORD m_dwPhoneDevs;
  162. DWORD m_dwLineDevs;
  163. HLINEAPP m_hLineApp;
  164. HPHONEAPP m_hPhoneApp;
  165. PT3INIT_DATA m_pLineInitData;
  166. PT3INIT_DATA m_pPhoneInitData;
  167. //
  168. // the 32-bit handles (corresponding m_pLineInitData and m_pPhoneInitData)
  169. // that are marshaled to tapisrv in place of the actual ptr values
  170. // (which can be 64 bit).
  171. //
  172. // we want to keep them around in order to be able
  173. // to remove the handle table entries on tapi shutdown
  174. //
  175. DWORD m_dwLineInitDataHandle;
  176. DWORD m_dwPhoneInitDataHandle;
  177. AddressArray m_AddressArray;
  178. PhoneArray m_PhoneArray;
  179. DWORD m_dwFlags;
  180. CTAPIConnectionPoint * m_pCP;
  181. PtrList m_RegisterItemPtrList;
  182. CallHubArrayNR m_CallHubArray;
  183. AgentHandlerArray m_AgentHandlerArray;
  184. CStructCache * m_pAddressCapCache;
  185. CStructCache * m_pLineCapCache;
  186. CStructCache * m_pPhoneCapCache;
  187. DWORD m_dwEventFilterMask;
  188. HRESULT NewInitialize(void);
  189. HRESULT NewShutdown(void);
  190. HRESULT CreateAllAddressesOnAllLines(void);
  191. HRESULT CreateAddressesOnSingleLine( DWORD dwDeviceID, BOOL bFireEvent );
  192. HRESULT CreateAllPhones(void);
  193. HRESULT CreatePhone( DWORD dwDeviceID, BOOL bFireEvent );
  194. void ReleaseGIT();
  195. //
  196. // allocate and cleanup functions for address, phone, and line caps caches
  197. //
  198. HRESULT AllocateInitializeAllCaches();
  199. void FreeAllCaches();
  200. // ITAPI
  201. public:
  202. static TAPIObjectArrayNR m_sTAPIObjectArray;
  203. // ITTapi Methods
  204. STDMETHOD(Initialize)( void );
  205. STDMETHOD(Shutdown)( void );
  206. STDMETHOD(get_Addresses)(VARIANT * pVariant);
  207. STDMETHOD(EnumerateAddresses)(
  208. IEnumAddress ** ppEnumAddresses
  209. );
  210. STDMETHOD(RegisterCallHubNotifications)(
  211. VARIANT_BOOL bNotify
  212. );
  213. STDMETHOD(RegisterCallNotifications)(
  214. ITAddress * pAddress,
  215. VARIANT_BOOL fMonitor,
  216. VARIANT_BOOL fOwner,
  217. long lMediaTypes,
  218. long ulAdvise,
  219. long * pulRegister
  220. );
  221. STDMETHOD(get_CallHubs)(VARIANT * pVariant);
  222. STDMETHOD(EnumerateCallHubs)(IEnumCallHub ** ppCallHub);
  223. STDMETHOD(UnregisterNotifications)(long ulRegister);
  224. STDMETHOD(SetCallHubTracking)(
  225. VARIANT pAddresses,
  226. VARIANT_BOOL bSet
  227. );
  228. STDMETHOD(EnumeratePrivateTAPIObjects)(IEnumUnknown**);
  229. STDMETHOD(get_PrivateTAPIObjects)(VARIANT * pVariant);
  230. STDMETHOD(RegisterRequestRecipient)(
  231. long lRegistrationInstance,
  232. long lRequestMode,
  233. #ifdef NEWREQUEST
  234. long lAddressTypes,
  235. #endif
  236. VARIANT_BOOL fEnable
  237. );
  238. STDMETHOD(SetAssistedTelephonyPriority)(
  239. BSTR pAppFilename,
  240. VARIANT_BOOL fPriority
  241. );
  242. STDMETHOD(SetApplicationPriority)(
  243. BSTR pAppFilename,
  244. long lMediaType,
  245. VARIANT_BOOL fPriority
  246. );
  247. STDMETHOD(put_EventFilter)(
  248. long lFilterMask
  249. );
  250. STDMETHOD(get_EventFilter)(
  251. long * plFilterMask
  252. );
  253. // ITTAPI2 methods
  254. STDMETHOD(get_Phones)(VARIANT * pPhones);
  255. STDMETHOD(EnumeratePhones)(IEnumPhone ** ppEnumPhone);
  256. STDMETHOD(CreateEmptyCollectionObject)(
  257. ITCollection2 ** ppCollection
  258. );
  259. // IConnectionPointContainer Methods
  260. STDMETHOD(EnumConnectionPoints)(IEnumConnectionPoints **ppEnum) ;
  261. STDMETHOD(FindConnectionPoint)(REFIID riid, IConnectionPoint **ppCP) ;
  262. // ITTAPICallCenter Methods
  263. STDMETHOD(EnumerateAgentHandlers) (IEnumAgentHandler ** ppEnumAgentHandler);
  264. STDMETHOD(get_AgentHandlers) (VARIANT * pVariant);
  265. // IDispatch Methods
  266. STDMETHOD(GetIDsOfNames)(REFIID riid,
  267. LPOLESTR* rgszNames,
  268. UINT cNames,
  269. LCID lcid,
  270. DISPID* rgdispid
  271. );
  272. STDMETHOD(Invoke)(DISPID dispidMember,
  273. REFIID riid,
  274. LCID lcid,
  275. WORD wFlags,
  276. DISPPARAMS* pdispparams,
  277. VARIANT* pvarResult,
  278. EXCEPINFO* pexcepinfo,
  279. UINT* puArgErr
  280. );
  281. private:
  282. //
  283. // Event Filtering helper methods
  284. //
  285. HRESULT SetEventFilterToAddresses(
  286. DWORD dwEventFilterMask);
  287. };
  288. class CTapiObjectEvent :
  289. public CTAPIComObjectRoot<CTapiObjectEvent>,
  290. public CComDualImpl<ITTAPIObjectEvent2, &IID_ITTAPIObjectEvent2, &LIBID_TAPI3Lib>,
  291. public CObjectSafeImpl
  292. {
  293. public:
  294. DECLARE_MARSHALQI(CTapiObjectEvent)
  295. DECLARE_TRACELOG_CLASS(CTapiObjectEvent)
  296. BEGIN_COM_MAP(CTapiObjectEvent)
  297. COM_INTERFACE_ENTRY2(IDispatch, ITTAPIObjectEvent2)
  298. COM_INTERFACE_ENTRY(ITTAPIObjectEvent)
  299. COM_INTERFACE_ENTRY(ITTAPIObjectEvent2)
  300. COM_INTERFACE_ENTRY(IObjectSafety)
  301. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  302. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  303. END_COM_MAP()
  304. static HRESULT FireEvent(
  305. CTAPI * pTapi,
  306. TAPIOBJECT_EVENT Event,
  307. ITAddress * pAddress,
  308. long lCallbackInstance,
  309. ITPhone * pPhone
  310. );
  311. void FinalRelease();
  312. protected:
  313. ITTAPI * m_pTapi;
  314. TAPIOBJECT_EVENT m_Event;
  315. ITAddress * m_pAddress;
  316. long m_lCallbackInstance;
  317. ITPhone * m_pPhone;
  318. #if DBG
  319. PWSTR m_pDebug;
  320. #endif
  321. public:
  322. //
  323. // itaddressstateevent
  324. //
  325. STDMETHOD(get_TAPIObject)( ITTAPI ** ppTapi );
  326. STDMETHOD(get_Event)( TAPIOBJECT_EVENT * pEvent );
  327. STDMETHOD(get_Address)( ITAddress ** ppAddress );
  328. STDMETHOD(get_CallbackInstance)( long * plCallbackInstance );
  329. //
  330. // itaddressstateevent2
  331. //
  332. STDMETHOD(get_Phone)( ITPhone ** ppPhone );
  333. };
  334. #endif //__TAPIOBJ_H_