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.

1025 lines
34 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. Call.h
  5. Abstract:
  6. Declaration of the CAgentSession & CCall class
  7. Author:
  8. mquinton 06-12-97
  9. Notes:
  10. Revision History:
  11. --*/
  12. #ifndef __CALL_H_
  13. #define __CALL_H_
  14. #include "resource.h" // main symbols
  15. #include "address.h"
  16. #ifdef USE_PHONEMSP
  17. #include "terminal.h"
  18. #endif USE_PHONEMSP
  19. #include "callhub.h"
  20. #include "callevnt.h"
  21. extern CHashTable * gpCallHashTable;
  22. extern CHashTable * gpHandleHashTable;
  23. extern void RemoveHandleFromHashTable(ULONG_PTR Handle);
  24. //
  25. // helper function for converting array of bytes to a byte array. the caller
  26. // must ClientFree *ppBuffer when done.
  27. //
  28. HRESULT
  29. MakeBufferFromVariant(
  30. IN VARIANT var,
  31. OUT DWORD * pdwSize,
  32. OUT BYTE ** ppBuffer
  33. );
  34. typedef enum
  35. {
  36. STREAM_RENDERAUDIO = 0,
  37. STREAM_RENDERVIDEO,
  38. STREAM_CAPTUREAUDIO,
  39. STREAM_CAPTUREVIDEO,
  40. STREAM_NONE
  41. } CALL_STREAMS;
  42. HRESULT
  43. WINAPI
  44. MyBasicCallControlQI(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw);
  45. // the app needs to be notified of this call
  46. #define CALLFLAG_NEEDTONOTIFY 0x00000001
  47. // the call is an incoming call
  48. #define CALLFLAG_INCOMING 0x00000002
  49. // A Consultation Call
  50. #define CALLFLAG_CONSULTCALL 0x00000008
  51. // A Consultation Call used in a transfer
  52. #define CALLFLAG_TRANSFCONSULT 0x00000010
  53. // A Consultation Call used in a conference
  54. #define CALLFLAG_CONFCONSULT 0x00000020
  55. // received line_callinfo message
  56. #define CALLFLAG_CALLINFODIRTY 0x00000040
  57. // Don't send the app any notifications about this call
  58. #define CALLFLAG_DONTEXPOSE 0x00000100
  59. // don't close m_addresslinestruct
  60. #define CALLFLAG_NOTMYLINE 0x00000200
  61. // Need to do a line accept before transitioning to CS_OFFERING
  62. #define CALLFLAG_ACCEPTTOALERT 0x00000400
  63. #define ISHOULDUSECALLPARAMS() ( ( NULL != m_pCallParams ) && ( CS_IDLE == m_CallState ) )
  64. /////////////////////////////////////////////////////////////////
  65. // Intermediate classes used for DISPID encoding
  66. template <class T>
  67. class ITCallInfoVtbl : public ITCallInfo
  68. {
  69. };
  70. template <class T>
  71. class ITCallInfo2Vtbl : public ITCallInfo2
  72. {
  73. };
  74. template <class T>
  75. class ITBasicCallControlVtbl : public ITBasicCallControl
  76. {
  77. };
  78. template <class T>
  79. class ITLegacyCallMediaControl2Vtbl : public ITLegacyCallMediaControl2
  80. {
  81. };
  82. template <class T>
  83. class ITBasicCallControl2Vtbl : public ITBasicCallControl2
  84. {
  85. };
  86. class CAddress;
  87. class CCallHub;
  88. class CCallStateEvent;
  89. class CCallNotificationEvent;
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CCall
  92. /////////////////////////////////////////////////////////////////////////////
  93. class CCall :
  94. public CTAPIComObjectRoot<CCall>,
  95. public IDispatchImpl<ITCallInfo2Vtbl<CCall>, &IID_ITCallInfo2, &LIBID_TAPI3Lib>,
  96. public IDispatchImpl<ITBasicCallControl2Vtbl<CCall>, &IID_ITBasicCallControl2, &LIBID_TAPI3Lib>,
  97. public IDispatchImpl<ITLegacyCallMediaControl2Vtbl<CCall>, &IID_ITLegacyCallMediaControl2, &LIBID_TAPI3Lib>,
  98. public CObjectSafeImpl
  99. {
  100. public:
  101. CCall() : m_pMSPCall(NULL),
  102. m_CallState(CS_IDLE),
  103. m_pAddressLine(NULL),
  104. m_dwCallFlags(CALLFLAG_CALLINFODIRTY),
  105. m_dwMediaMode(0),
  106. m_pPrivate(NULL),
  107. m_pCallHub(NULL),
  108. m_pCallInfo(NULL),
  109. m_pCallParams(NULL),
  110. m_hConnectedEvent(NULL),
  111. m_szDestAddress(NULL),
  112. m_dwCountryCode(0),
  113. m_bReleased(FALSE),
  114. m_dwMinRate(0),
  115. m_dwMaxRate(0),
  116. m_pRelatedCall(NULL)
  117. {
  118. LOG((TL_TRACE, "CCall[%p] - enter", this));
  119. LOG((TL_TRACE, "CCall - exit"));
  120. }
  121. ~CCall()
  122. {
  123. LOG((TL_TRACE, "~CCall[%p] - enter", this));
  124. LOG((TL_TRACE, "~CCall - exit"));
  125. }
  126. DECLARE_DEBUG_ADDREF_RELEASE(CCall)
  127. DECLARE_QI()
  128. DECLARE_MARSHALQI(CCall)
  129. DECLARE_TRACELOG_CLASS(CCall)
  130. BEGIN_COM_MAP(CCall)
  131. COM_INTERFACE_ENTRY2(IDispatch, ITCallInfo2)
  132. COM_INTERFACE_ENTRY(ITCallInfo)
  133. COM_INTERFACE_ENTRY(ITCallInfo2)
  134. COM_INTERFACE_ENTRY_FUNC(IID_ITBasicCallControl, 0, MyBasicCallControlQI)
  135. COM_INTERFACE_ENTRY(ITBasicCallControl)
  136. COM_INTERFACE_ENTRY_FUNC(IID_ITBasicCallControl2, 0, MyBasicCallControlQI)
  137. COM_INTERFACE_ENTRY(ITBasicCallControl2)
  138. COM_INTERFACE_ENTRY(ITLegacyCallMediaControl)
  139. COM_INTERFACE_ENTRY(ITLegacyCallMediaControl2)
  140. COM_INTERFACE_ENTRY(IObjectSafety)
  141. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  142. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  143. COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pMSPCall)
  144. COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pPrivate)
  145. END_COM_MAP()
  146. //
  147. // check the aggregated objects to see if they support the interface requested.
  148. // if they do, return the non-delegating IUnknown of the first object that
  149. // supports the interface.
  150. //
  151. // it needs to be released by the caller.
  152. //
  153. HRESULT QIOnAggregates(REFIID riid, IUnknown **ppNonDelegatingUnknown);
  154. void FinalRelease(){}
  155. BOOL ExternalFinalRelease();
  156. //
  157. // public access functions to call object
  158. // these are used by the address and callhub objects
  159. // mostly to access stuff in the call
  160. //
  161. HRESULT Initialize(
  162. CAddress * pAddress,
  163. BSTR lpszDestAddress,
  164. long lAddressType,
  165. long lMediaType,
  166. CALL_PRIVILEGE cp,
  167. BOOL bNeedToNotify,
  168. BOOL bExpose,
  169. HCALL hCall,
  170. CEventMasks* pEventMasks
  171. );
  172. HRESULT CallStateEvent( PASYNCEVENTMSG pParams );
  173. HRESULT MediaModeEvent( PASYNCEVENTMSG pParam );
  174. HRESULT GatherDigitsEvent( PASYNCEVENTMSG pParams );
  175. HRESULT CallInfoChangeEvent( CALLINFOCHANGE_CAUSE cic );
  176. HRESULT CreateMSPCall( long lMediaType );
  177. HCALL GetHCall();
  178. AddressLineStruct * GetPAddressLine();
  179. BOOL DontExpose();
  180. CCall * GetOtherParty();
  181. void FinishSettingUpCall( HCALL hCall );
  182. void SetCallHub( CCallHub * pCallHub );
  183. void SetCallInfoDirty();
  184. CAddress * GetCAddress();
  185. ITStreamControl * GetStreamControl();
  186. IUnknown * GetMSPCall();
  187. CCallHub * GetCallHub();
  188. //
  189. // this function is called by the address object when it is notified of
  190. // tapi object's shutdown. in this function, the call object gets a chance
  191. // to clean up.
  192. //
  193. void CallOnTapiShutdown();
  194. protected:
  195. // IUnknown * m_pFTM;
  196. private:
  197. // owning address object
  198. CAddress * m_pAddress;
  199. // dest address
  200. PWSTR m_szDestAddress;
  201. // current call state
  202. CALL_STATE m_CallState;
  203. // current call priv
  204. CALL_PRIVILEGE m_CallPrivilege;
  205. // current mediamode
  206. DWORD m_dwMediaMode;
  207. // the MSP call
  208. IUnknown * m_pMSPCall;
  209. // Context handle passed to MSP Call
  210. MSP_HANDLE m_MSPCallHandle;
  211. // call flags ( see defines above )
  212. DWORD m_dwCallFlags;
  213. // this call's t3call
  214. T3CALL m_t3Call;
  215. // used in consult calls to ID the original call (needed to complete transf etc)
  216. HCALL m_hAdditionalCall;
  217. // related call
  218. CCall * m_pRelatedCall;
  219. // address line being used
  220. AddressLineStruct * m_pAddressLine;
  221. // private object
  222. IUnknown * m_pPrivate;
  223. // related call hub
  224. CCallHub * m_pCallHub;
  225. // cached callinfo structure
  226. LINECALLINFO * m_pCallInfo;
  227. // cached callparams structure
  228. LINECALLPARAMS * m_pCallParams;
  229. // used size of m_pcallparams
  230. DWORD m_dwCallParamsUsedSize;
  231. // if call is sync, need an event to signal
  232. HANDLE m_hConnectedEvent;
  233. // country code - the app can set this, but it's not part of callparams
  234. DWORD m_dwCountryCode;
  235. // protect against releasing twice
  236. BOOL m_bReleased;
  237. // Can't get these from TAPISRV so remember what gets set
  238. DWORD m_dwMinRate;
  239. DWORD m_dwMaxRate;
  240. // queue for GatherDigits buffers
  241. CTArray<LPWSTR> m_GatherDigitsQueue;
  242. //
  243. // private functions inside the call object.
  244. //
  245. void SetMediaMode( DWORD dwMediaMode );
  246. void SetCallState( CALL_STATE cs );
  247. void ResetCallParams();
  248. void FinishCallParams();
  249. void ClearConnectedEvent();
  250. void SetRelatedCall(CCall* pCall, DWORD callFlags);
  251. void ResetRelatedCall();
  252. void AddCallToHashTable();
  253. void RemoveCallFromHashTable();
  254. //
  255. // get an addreffed address line that corresponds to this address line
  256. // handle
  257. //
  258. AddressLineStruct *GetAddRefAddressLine(DWORD dwAddressLineHandle);
  259. public:
  260. //
  261. // get addreff'ed address line that belongs to this call.
  262. //
  263. AddressLineStruct *GetAddRefMyAddressLine();
  264. //
  265. // release address line received from GetAddRefAddressLine or GetAddRefMyAddressLine
  266. //
  267. HRESULT ReleaseAddressLine(AddressLineStruct *pLine);
  268. public:
  269. //
  270. // get the callback instance associated with the address line represented
  271. // by dwAddressLineHandle handle
  272. //
  273. HRESULT GetCallBackInstance(IN DWORD dwAddressLineHandle,
  274. OUT long *plCallbackInstance);
  275. public:
  276. BOOL OnWaveMSPCall(); // called in event handler
  277. private:
  278. #ifdef USE_PHONEMSP
  279. BOOL OnPhoneMSPCall();
  280. #endif USE_PHONEMSP
  281. CCall * FindConferenceControllerCall();
  282. HANDLE CreateConnectedEvent();
  283. HRESULT TryToFindACallHub();
  284. HRESULT DialConsultCall(BOOL bSync);
  285. HRESULT WaitForCallState( CALL_STATE requiredCS );
  286. HRESULT CheckAndCreateFakeCallHub();
  287. HRESULT UpdateStateAndPrivilege();
  288. HRESULT OnConnect();
  289. HRESULT OnDisconnect();
  290. HRESULT OnConference();
  291. HRESULT OnOffering();
  292. HRESULT ProcessNewCallState(
  293. DWORD dwCallState,
  294. DWORD dwDetail,
  295. CALL_STATE CurrentCallState,
  296. CALL_STATE * pCallState,
  297. CALL_STATE_EVENT_CAUSE * pCallStateCause
  298. );
  299. HRESULT RefreshCallInfo();
  300. HRESULT ResizeCallParams( DWORD );
  301. HRESULT SendUserUserInfo(HCALL hCall, long lSize, BYTE * pBuffer);
  302. HRESULT SaveUserUserInfo(long lSize,BYTE * pBuffer);
  303. HRESULT SyncWait( HANDLE hEvent );
  304. HRESULT StartWaveMSPStream();
  305. HRESULT StopWaveMSPStream();
  306. HRESULT SuspendWaveMSPStream();
  307. public:
  308. HRESULT ResumeWaveMSPStream(); // called in event handler
  309. private:
  310. #ifdef USE_PHONEMSP
  311. HRESULT StartPhoneMSPStream();
  312. HRESULT StopPhoneMSPStream();
  313. #endif USE_PHONEMSP
  314. HRESULT DialAsConsultationCall(
  315. CCall * pRelatedCall,
  316. DWORD dwCallFeatures,
  317. BOOL bConference,
  318. BOOL bSync
  319. );
  320. HRESULT OneStepTransfer(
  321. CCall *pConsultationCall,
  322. VARIANT_BOOL bSync
  323. );
  324. public:
  325. #ifdef NEWCALLINFO
  326. STDMETHOD(get_Address)(ITAddress ** ppAddress);
  327. STDMETHOD(get_CallState)(CALL_STATE * pCallState);
  328. STDMETHOD(get_Privilege)(CALL_PRIVILEGE * pPrivilege);
  329. STDMETHOD(get_CallHub)(ITCallHub ** ppCallHub);
  330. STDMETHOD(get_CallInfoLong)(
  331. CALLINFO_LONG CallInfoLong,
  332. long * plCallInfoLongVal
  333. );
  334. STDMETHOD(put_CallInfoLong)(
  335. CALLINFO_LONG CallInfoLong,
  336. long lCallInfoLongVal
  337. );
  338. STDMETHOD(get_CallInfoString)(
  339. CALLINFO_STRING CallInfoString,
  340. BSTR * ppCallInfoString
  341. );
  342. STDMETHOD(put_CallInfoString)(
  343. CALLINFO_STRING CallInfoString,
  344. BSTR pCallInfoString
  345. );
  346. STDMETHOD(get_CallInfoBuffer)(
  347. CALLINFO_BUFFER CallInfoBuffer,
  348. VARIANT * ppCallInfoBuffer
  349. );
  350. STDMETHOD(put_CallInfoBuffer)(
  351. CALLINFO_BUFFER CallInfoBuffer,
  352. VARIANT pCallInfoBuffer
  353. );
  354. STDMETHOD(GetCallInfoBuffer)(
  355. CALLINFO_BUFFER CallInfoBuffer,
  356. DWORD * pdwSize,
  357. BYTE ** ppCallInfoBuffer
  358. );
  359. STDMETHOD(SetCallInfoBuffer)(
  360. CALLINFO_BUFFER CallInfoBuffer,
  361. DWORD dwSize,
  362. BYTE * pCallInfoBuffer
  363. );
  364. STDMETHOD(ReleaseUserUserInfo)();
  365. HRESULT get_MediaTypesAvailable(long * plMediaTypes);
  366. HRESULT get_CallerIDAddressType(long * plAddressType );
  367. HRESULT get_CalledIDAddressType(long * plAddressType );
  368. HRESULT get_ConnectedIDAddressType(long * plAddressType );
  369. HRESULT get_RedirectionIDAddressType(long * plAddressType );
  370. HRESULT get_RedirectingIDAddressType(long * plAddressType );
  371. HRESULT get_BearerMode(long * plBearerMode);
  372. HRESULT put_BearerMode(long lBearerMode);
  373. HRESULT get_Origin(long * plOrigin );
  374. HRESULT get_Reason(long * plReason );
  375. HRESULT get_CallerIDName(BSTR * ppCallerIDName );
  376. HRESULT get_CallerIDNumber(BSTR * ppCallerIDNumber );
  377. HRESULT get_CalledIDName(BSTR * ppCalledIDName );
  378. HRESULT get_CalledIDNumber(BSTR * ppCalledIDNumber );
  379. HRESULT get_ConnectedIDName(BSTR * ppConnectedIDName );
  380. HRESULT get_ConnectedIDNumber(BSTR * ppConnectedIDNumber );
  381. HRESULT get_RedirectionIDName(BSTR * ppRedirectionIDName );
  382. HRESULT get_RedirectionIDNumber(BSTR * ppRedirectionIDNumber );
  383. HRESULT get_RedirectingIDName(BSTR * ppRedirectingIDName );
  384. HRESULT get_RedirectingIDNumber(BSTR * ppRedirectingIDNumber );
  385. HRESULT get_CalledPartyFriendlyName(BSTR * ppCalledPartyFriendlyName );
  386. HRESULT put_CalledPartyFriendlyName(BSTR pCalledPartyFriendlyName );
  387. HRESULT get_Comment(BSTR * ppComment );
  388. HRESULT put_Comment(BSTR pComment );
  389. HRESULT GetUserUserInfo(DWORD * pdwSize, BYTE ** ppBuffer );
  390. HRESULT SetUserUserInfo(long lSize, BYTE * pBuffer );
  391. HRESULT get_UserUserInfo(VARIANT * pUUI);
  392. HRESULT put_UserUserInfo(VARIANT UUI);
  393. HRESULT get_AppSpecific(long * plAppSpecific );
  394. HRESULT put_AppSpecific(long lAppSpecific );
  395. HRESULT GetDevSpecificBuffer(DWORD * pdwSize, BYTE ** ppDevSpecificBuffer);
  396. HRESULT SetDevSpecificBuffer(long lSize, BYTE * pDevSpecificBuffer);
  397. HRESULT get_DevSpecificBuffer(VARIANT * pBuffer);
  398. HRESULT put_DevSpecificBuffer(VARIANT Buffer);
  399. HRESULT SetCallParamsFlags(long lFlags);
  400. HRESULT GetCallParamsFlags(long * plFlags);
  401. HRESULT put_DisplayableAddress(BSTR pDisplayableAddress);
  402. HRESULT get_DisplayableAddress(BSTR * ppDisplayableAddress);
  403. HRESULT GetCallDataBuffer(DWORD * pdwSize, BYTE ** ppBuffer);
  404. HRESULT SetCallDataBuffer(long lSize, BYTE * pBuffer);
  405. HRESULT put_CallDataBuffer(VARIANT Buffer);
  406. HRESULT get_CallDataBuffer(VARIANT * pBuffer);
  407. HRESULT put_CallingPartyID(BSTR pCallingPartyID);
  408. HRESULT get_CallingPartyID(BSTR * ppCallingPartyID);
  409. HRESULT put_CallTreatment(long lTreatment);
  410. HRESULT get_CallTreatment(long * plTreatment);
  411. HRESULT put_MinRate(long lMinRate);
  412. HRESULT get_MinRate(long * plMinRate);
  413. HRESULT put_MaxRate(long lMaxRate);
  414. HRESULT get_MaxRate(long * plMaxRate);
  415. HRESULT put_CountryCode(long lCountryCode);
  416. HRESULT get_CountryCode(long * plCountryCode);
  417. HRESULT get_CallId(long * plCallId );
  418. HRESULT get_RelatedCallId(long * plCallId );
  419. HRESULT get_CompletionId(long * plCompletionId );
  420. HRESULT get_NumberOfOwners(long * plNumberOfOwners );
  421. HRESULT get_NumberOfMonitors(long * plNumberOfMonitors );
  422. HRESULT get_Trunk(long * plTrunk );
  423. HRESULT GetChargingInfoBuffer(DWORD * pdwSize, BYTE ** ppBuffer);
  424. HRESULT get_ChargingInfoBuffer(VARIANT * pBuffer );
  425. HRESULT SetHighLevelCompatibilityBuffer(long lSize, BYTE * pBuffer);
  426. HRESULT GetHighLevelCompatibilityBuffer(DWORD * pdwSize, BYTE ** ppBuffer);
  427. HRESULT put_HighLevelCompatibilityBuffer(VARIANT Buffer );
  428. HRESULT get_HighLevelCompatibilityBuffer(VARIANT * pBuffer );
  429. HRESULT SetLowLevelCompatibilityBuffer(long lSize, BYTE * pBuffer);
  430. HRESULT GetLowLevelCompatibilityBuffer(DWORD * pdwSize, BYTE ** ppBuffer);
  431. HRESULT put_LowLevelCompatibilityBuffer(VARIANT Buffer );
  432. HRESULT get_LowLevelCompatibilityBuffer(VARIANT * pBuffer );
  433. HRESULT get_Rate(long * plRate );
  434. HRESULT put_GenerateDigitDuration( long lGenerateDigitDuration );
  435. HRESULT get_GenerateDigitDuration( long * plGenerateDigitDuration );
  436. HRESULT get_MonitorDigitModes( long * plMonitorDigitModes );
  437. HRESULT get_MonitorMediaModes( long * plMonitorMediaModes );
  438. #else
  439. // ITCallInfo methods
  440. STDMETHOD(get_Address)(ITAddress ** ppAddress);
  441. STDMETHOD(get_CallState)(CALL_STATE * pCallState);
  442. STDMETHOD(get_Privilege)(CALL_PRIVILEGE * pPrivilege);
  443. STDMETHOD(get_MediaTypesAvailable)(long * plMediaTypes);
  444. STDMETHOD(get_CallHub)(ITCallHub ** ppCallHub);
  445. STDMETHOD(get_AddressType)(long * plAddressType );
  446. STDMETHOD(put_AddressType)(long lAddressType );
  447. STDMETHOD(get_BearerMode)(long * plBearerMode);
  448. STDMETHOD(put_BearerMode)(long lBearerMode);
  449. STDMETHOD(get_Origin)(long * plOrigin );
  450. STDMETHOD(get_Reason)(long * plReason );
  451. STDMETHOD(get_CallerIDName)(BSTR * ppCallerIDName );
  452. STDMETHOD(get_CallerIDNumber)(BSTR * ppCallerIDNumber );
  453. STDMETHOD(get_CalledIDName)(BSTR * ppCalledIDName );
  454. STDMETHOD(get_CalledIDNumber)(BSTR * ppCalledIDNumber );
  455. STDMETHOD(get_ConnectedIDName)(BSTR * ppConnectedIDName );
  456. STDMETHOD(get_ConnectedIDNumber)(BSTR * ppConnectedIDNumber );
  457. STDMETHOD(get_RedirectionIDName)(BSTR * ppRedirectionIDName );
  458. STDMETHOD(get_RedirectionIDNumber)(BSTR * ppRedirectionIDNumber );
  459. STDMETHOD(get_RedirectingIDName)(BSTR * ppRedirectingIDName );
  460. STDMETHOD(get_RedirectingIDNumber)(BSTR * ppRedirectingIDNumber );
  461. STDMETHOD(get_CalledPartyFriendlyName)(BSTR * ppCalledPartyFriendlyName );
  462. STDMETHOD(put_CalledPartyFriendlyName)(BSTR pCalledPartyFriendlyName );
  463. STDMETHOD(get_Comment)(BSTR * ppComment );
  464. STDMETHOD(put_Comment)(BSTR pComment );
  465. STDMETHOD(GetUserUserInfoSize)(long * plSize );
  466. STDMETHOD(GetUserUserInfo)(long lSize, BYTE * pBuffer );
  467. STDMETHOD(SetUserUserInfo)(long lSize, BYTE * pBuffer );
  468. STDMETHOD(get_UserUserInfo)(VARIANT * pUUI);
  469. STDMETHOD(put_UserUserInfo)(VARIANT UUI);
  470. STDMETHOD(ReleaseUserUserInfo)();
  471. STDMETHOD(get_AppSpecific)(long * plAppSpecific );
  472. STDMETHOD(put_AppSpecific)(long lAppSpecific );
  473. STDMETHOD(GetDevSpecificBufferSize)(long * plDevSpecificSize );
  474. STDMETHOD(GetDevSpecificBuffer)(long lSize, BYTE * pDevSpecificBuffer);
  475. STDMETHOD(SetDevSpecificBuffer)(long lSize, BYTE * pDevSpecificBuffer);
  476. STDMETHOD(get_DevSpecificBuffer)(VARIANT * pBuffer);
  477. STDMETHOD(put_DevSpecificBuffer)(VARIANT Buffer);
  478. STDMETHOD(SetCallParamsFlags)(long lFlags);
  479. STDMETHOD(put_DisplayableAddress)(BSTR pDisplayableAddress);
  480. STDMETHOD(get_DisplayableAddress)(BSTR * ppDisplayableAddress);
  481. STDMETHOD(GetCallDataBufferSize)(long * plSize);
  482. STDMETHOD(GetCallDataBuffer)(long lSize, BYTE * pBuffer);
  483. STDMETHOD(SetCallDataBuffer)(long lSize, BYTE * pBuffer);
  484. STDMETHOD(put_CallDataBuffer)(VARIANT Buffer);
  485. STDMETHOD(get_CallDataBuffer)(VARIANT * pBuffer);
  486. STDMETHOD(put_CallingPartyID)(BSTR pCallingPartyID);
  487. STDMETHOD(get_CallingPartyID)(BSTR * ppCallingPartyID);
  488. STDMETHOD(put_CallTreatment)(long lTreatment);
  489. STDMETHOD(get_CallTreatment)(long * plTreatment);
  490. STDMETHOD(put_MinRate)(long lMinRate);
  491. STDMETHOD(get_MinRate)(long * plMinRate);
  492. STDMETHOD(put_MaxRate)(long lMaxRate);
  493. STDMETHOD(get_MaxRate)(long * plMaxRate);
  494. STDMETHOD(put_CountryCode)(long lCountryCode);
  495. STDMETHOD (get_CallId)(long * plCallId );
  496. STDMETHOD (get_RelatedCallId)(long * plCallId );
  497. STDMETHOD (get_CompletionId)(long * plCompletionId );
  498. STDMETHOD (get_NumberOfOwners)(long * plNumberOfOwners );
  499. STDMETHOD (get_NumberOfMonitors)(long * plNumberOfMonitors );
  500. STDMETHOD (get_Trunk)(long * plTrunk );
  501. STDMETHOD (GetChargingInfoBufferSize)(long * plSize );
  502. STDMETHOD (GetChargingInfoBuffer)(long lSize, BYTE * pBuffer);
  503. STDMETHOD (get_ChargingInfoBuffer)(VARIANT * pBuffer );
  504. STDMETHOD (GetHighLevelCompatibilityBufferSize)(long * plSize );
  505. STDMETHOD (SetHighLevelCompatibilityBuffer)(long lSize, BYTE * pBuffer);
  506. STDMETHOD (GetHighLevelCompatibilityBuffer)(long lSize, BYTE * pBuffer);
  507. STDMETHOD (put_HighLevelCompatibilityBuffer)(VARIANT Buffer );
  508. STDMETHOD (get_HighLevelCompatibilityBuffer)(VARIANT * pBuffer );
  509. STDMETHOD (GetLowLevelCompatibilityBufferSize)(long * plSize );
  510. STDMETHOD (SetLowLevelCompatibilityBuffer)(long lSize, BYTE * pBuffer);
  511. STDMETHOD (GetLowLevelCompatibilityBuffer)(long lSize, BYTE * pBuffer);
  512. STDMETHOD (put_LowLevelCompatibilityBuffer)(VARIANT Buffer );
  513. STDMETHOD (get_LowLevelCompatibilityBuffer)(VARIANT * pBuffer );
  514. STDMETHOD (get_Rate)(long * plRate );
  515. #endif
  516. // ITCallInfo2
  517. STDMETHOD(get_EventFilter)(
  518. TAPI_EVENT TapiEvent,
  519. long lSubEvent,
  520. VARIANT_BOOL* pEnable
  521. );
  522. STDMETHOD(put_EventFilter)(
  523. TAPI_EVENT TapiEvent,
  524. long lSubEvent,
  525. VARIANT_BOOL bEnable
  526. );
  527. // ITBasicCallControl methods
  528. STDMETHOD(Connect)(VARIANT_BOOL bSync);
  529. STDMETHOD(Answer)(void);
  530. STDMETHOD(Disconnect)(DISCONNECT_CODE code);
  531. STDMETHOD(Hold)(VARIANT_BOOL bHold);
  532. STDMETHOD(HandoffDirect)(BSTR pApplicationName);
  533. STDMETHOD(HandoffIndirect)(long lMediaType);
  534. STDMETHOD(Conference)(
  535. ITBasicCallControl * pCall,
  536. VARIANT_BOOL bSync
  537. );
  538. STDMETHOD(CreateConference)(
  539. CCall * pConsultationCall,
  540. VARIANT_BOOL bSync
  541. );
  542. STDMETHOD(AddToConference)(
  543. CCall * pConsultationCall,
  544. VARIANT_BOOL bSync
  545. );
  546. STDMETHOD(BlindTransfer)(BSTR pDestAddress);
  547. STDMETHOD(Transfer)(
  548. ITBasicCallControl * pCall,
  549. VARIANT_BOOL bSync
  550. );
  551. STDMETHOD(SwapHold)(ITBasicCallControl * pCall);
  552. STDMETHOD(ParkDirect)(BSTR pParkAddress);
  553. STDMETHOD(ParkIndirect)(BSTR * ppNonDirAddress);
  554. STDMETHOD(Unpark)();
  555. STDMETHOD(SetQOS)(
  556. long lMediaType,
  557. QOS_SERVICE_LEVEL ServiceLevel
  558. );
  559. STDMETHOD(Pickup)( BSTR pGroupID );
  560. STDMETHOD(Dial)( BSTR pDestAddress );
  561. STDMETHOD(Finish)(FINISH_MODE finishMode);
  562. STDMETHOD(RemoveFromConference)(void);
  563. // ITBasicCallControl2
  564. STDMETHOD(RequestTerminal)(
  565. IN BSTR bstrTerminalClassGUID,
  566. IN long lMediaType,
  567. IN TERMINAL_DIRECTION Direction,
  568. OUT ITTerminal** ppTerminal
  569. );
  570. STDMETHOD(SelectTerminalOnCall)(
  571. IN ITTerminal *pTerminal
  572. );
  573. STDMETHOD(UnselectTerminalOnCall)(
  574. IN ITTerminal *pTerminal
  575. );
  576. // ITLegacyCallMediaControl
  577. STDMETHOD(DetectDigits)(TAPI_DIGITMODE DigitMode);
  578. STDMETHOD(GenerateDigits)(
  579. BSTR pDigits,
  580. TAPI_DIGITMODE DigitMode
  581. );
  582. STDMETHOD(GetID)(
  583. BSTR pDeviceClass,
  584. DWORD * pdwSize,
  585. BYTE ** ppDeviceID
  586. );
  587. STDMETHOD(SetMediaType)(long lMediaType);
  588. STDMETHOD(MonitorMedia)(long lMediaType);
  589. // ITLegacyCallMediaControl2
  590. STDMETHOD(GenerateDigits2)(
  591. BSTR pDigits,
  592. TAPI_DIGITMODE DigitMode,
  593. long lDuration
  594. );
  595. STDMETHOD(GatherDigits)(
  596. TAPI_DIGITMODE DigitMode,
  597. long lNumDigits,
  598. BSTR pTerminationDigits,
  599. long lFirstDigitTimeout,
  600. long lInterDigitTimeout
  601. );
  602. STDMETHOD(DetectTones)(
  603. TAPI_DETECTTONE * pToneList,
  604. long lNumTones
  605. );
  606. STDMETHOD(DetectTonesByCollection)(
  607. ITCollection2 * pDetectToneCollection
  608. );
  609. STDMETHOD(GenerateTone)(
  610. TAPI_TONEMODE ToneMode,
  611. long lDuration
  612. );
  613. STDMETHOD(GenerateCustomTones)(
  614. TAPI_CUSTOMTONE * pToneList,
  615. long lNumTones,
  616. long lDuration
  617. );
  618. STDMETHOD(GenerateCustomTonesByCollection)(
  619. ITCollection2 * pCustomToneCollection,
  620. long lDuration
  621. );
  622. STDMETHOD(CreateDetectToneObject)(
  623. ITDetectTone ** ppDetectTone
  624. );
  625. STDMETHOD(CreateCustomToneObject)(
  626. ITCustomTone ** ppCustomTone
  627. );
  628. STDMETHOD(GetIDAsVariant)(IN BSTR bstrDeviceClass,
  629. OUT VARIANT *pVarDeviceID);
  630. // IDispatch Methods
  631. STDMETHOD(GetIDsOfNames)(REFIID riid,
  632. LPOLESTR* rgszNames,
  633. UINT cNames,
  634. LCID lcid,
  635. DISPID* rgdispid
  636. );
  637. STDMETHOD(Invoke)(DISPID dispidMember,
  638. REFIID riid,
  639. LCID lcid,
  640. WORD wFlags,
  641. DISPPARAMS* pdispparams,
  642. VARIANT* pvarResult,
  643. EXCEPINFO* pexcepinfo,
  644. UINT* puArgErr
  645. );
  646. STDMETHOD_(ULONG, InternalAddRef)()
  647. {
  648. DWORD dwR;
  649. dwR = InterlockedIncrement(&m_dwRef);;
  650. #if DBG
  651. LogDebugAddRef(m_dwRef);
  652. #endif
  653. return dwR;
  654. }
  655. STDMETHOD_(ULONG, InternalRelease)()
  656. {
  657. Lock();
  658. LOG((TL_INFO, "InternalRelease - enter m_dwRef = %ld", m_dwRef));
  659. gpCallHashTable->Lock();
  660. gpHandleHashTable->Lock();
  661. DWORD dwR = InterlockedDecrement(&m_dwRef);
  662. // if ref count is 1 (means we entered function with 2) then we final release
  663. if (1 == dwR)
  664. {
  665. // make sure we only call ExternalFinalRelease & delete once
  666. if(m_bReleased == FALSE)
  667. {
  668. m_bReleased = TRUE;
  669. LOG((TL_TRACE, "InternalRelease - final" ));
  670. // remove from the hash table, so any more messages
  671. // from tapisrv are ignored
  672. //
  673. gpCallHashTable->Remove( (ULONG_PTR)(m_t3Call.hCall) );
  674. gpCallHashTable->Unlock();
  675. // remove from the handle hash table, so any more messages
  676. // from msp are ignored
  677. //
  678. RemoveHandleFromHashTable((ULONG_PTR)m_MSPCallHandle);
  679. gpHandleHashTable->Unlock();
  680. ExternalFinalRelease();
  681. dwR = m_dwRef = 0;
  682. Unlock();
  683. }
  684. else
  685. {
  686. gpCallHashTable->Unlock();
  687. gpHandleHashTable->Unlock();
  688. Unlock();
  689. LOG((TL_INFO, "InternalRelease - m_bReleased is TRUE. dwR[%ld]", dwR));
  690. }
  691. }
  692. else
  693. {
  694. gpCallHashTable->Unlock();
  695. gpHandleHashTable->Unlock();
  696. Unlock();
  697. }
  698. #if DBG
  699. LogDebugRelease( dwR );
  700. #endif
  701. LOG((TL_INFO, "InternalRelease - exit. refcount %ld", dwR));
  702. return dwR;
  703. }
  704. protected:
  705. HRESULT SelectSingleTerminalOnCall(
  706. IN ITTerminal* pTerminal,
  707. OUT long* pMediaType,
  708. OUT TERMINAL_DIRECTION* pDirection);
  709. HRESULT SelectMultiTerminalOnCall(
  710. IN ITMultiTrackTerminal* pTerminal);
  711. HRESULT IsRightStream(
  712. IN ITStream* pStream,
  713. IN ITTerminal* pTerminal,
  714. OUT long* pMediaType = NULL,
  715. OUT TERMINAL_DIRECTION* pDirection = NULL);
  716. int GetStreamIndex(
  717. IN long lMediaType,
  718. IN TERMINAL_DIRECTION Direction);
  719. HRESULT UnSelectSingleTerminalFromCall(
  720. IN ITTerminal* pTerminal);
  721. HRESULT UnSelectMultiTerminalFromCall(
  722. IN ITMultiTrackTerminal* pTerminal);
  723. //
  724. // Helper methods for CreateTerminal
  725. //
  726. BOOL IsStaticGUID(
  727. BSTR bstrTerminalGUID);
  728. HRESULT CreateStaticTerminal(
  729. IN BSTR bstrTerminalClassGUID,
  730. IN TERMINAL_DIRECTION Direction,
  731. IN long lMediaType,
  732. OUT ITTerminal** ppTerminal
  733. );
  734. HRESULT CreateDynamicTerminal(
  735. IN BSTR bstrTerminalClassGUID,
  736. IN TERMINAL_DIRECTION Direction,
  737. IN long lMediaType,
  738. OUT ITTerminal** ppTerminal
  739. );
  740. public:
  741. //
  742. // Sets the subevent flag
  743. //
  744. HRESULT SetSubEventFlag(
  745. IN TAPI_EVENT TapiEvent,
  746. IN DWORD dwSubEvent,
  747. IN BOOL bEnable
  748. );
  749. HRESULT GetSubEventFlag(
  750. TAPI_EVENT TapiEvent,
  751. DWORD dwSubEvent,
  752. BOOL* pEnable
  753. );
  754. // Get subevents mask
  755. DWORD GetSubEventsMask(
  756. IN TAPI_EVENT TapiEvent
  757. );
  758. //Get the conference controller call object if one exists.
  759. CCall* GetConfControlCall();
  760. private:
  761. //
  762. // Helper methods for event filtering
  763. //
  764. CEventMasks m_EventMasks;
  765. HRESULT IsTerminalSelected(
  766. IN ITTerminal* pTerminal,
  767. OUT BOOL* pSelected
  768. );
  769. };
  770. /////////////////////////////////////////////////////////////////////////////
  771. // CDetectTone
  772. /////////////////////////////////////////////////////////////////////////////
  773. class CDetectTone :
  774. public CTAPIComObjectRoot<CDetectTone>,
  775. public IDispatchImpl<ITDetectTone, &IID_ITDetectTone, &LIBID_TAPI3Lib>,
  776. public CObjectSafeImpl
  777. {
  778. public:
  779. CDetectTone()
  780. {
  781. m_lAppSpecific = 0;
  782. m_lDuration = 0;
  783. m_lFrequency[0] = 0;
  784. m_lFrequency[1] = 0;
  785. m_lFrequency[2] = 0;
  786. }
  787. DECLARE_MARSHALQI(CDetectTone)
  788. DECLARE_QI()
  789. DECLARE_TRACELOG_CLASS(CDetectTone)
  790. BEGIN_COM_MAP(CDetectTone)
  791. COM_INTERFACE_ENTRY(IDispatch)
  792. COM_INTERFACE_ENTRY(ITDetectTone)
  793. COM_INTERFACE_ENTRY(IObjectSafety)
  794. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  795. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  796. END_COM_MAP()
  797. protected:
  798. long m_lAppSpecific;
  799. long m_lDuration;
  800. long m_lFrequency[3];
  801. public:
  802. STDMETHOD(put_AppSpecific)( long lAppSpecific );
  803. STDMETHOD(get_AppSpecific)( long * plAppSpecific );
  804. STDMETHOD(put_Duration)( long lDuration );
  805. STDMETHOD(get_Duration)( long * plDuration );
  806. STDMETHOD(put_Frequency)(
  807. long Index,
  808. long lFrequency
  809. );
  810. STDMETHOD(get_Frequency)(
  811. long Index,
  812. long * plFrequency
  813. );
  814. };
  815. /////////////////////////////////////////////////////////////////////////////
  816. // CCustomTone
  817. /////////////////////////////////////////////////////////////////////////////
  818. class CCustomTone :
  819. public CTAPIComObjectRoot<CCustomTone>,
  820. public IDispatchImpl<ITCustomTone, &IID_ITCustomTone, &LIBID_TAPI3Lib>,
  821. public CObjectSafeImpl
  822. {
  823. public:
  824. CCustomTone()
  825. {
  826. m_lFrequency = 0;
  827. m_lCadenceOn = 0;
  828. m_lCadenceOff = 0;
  829. m_lVolume = 0;
  830. }
  831. DECLARE_MARSHALQI(CCustomTone)
  832. DECLARE_QI()
  833. DECLARE_TRACELOG_CLASS(CCustomTone)
  834. BEGIN_COM_MAP(CCustomTone)
  835. COM_INTERFACE_ENTRY2(IDispatch, ITCustomTone)
  836. COM_INTERFACE_ENTRY(ITCustomTone)
  837. COM_INTERFACE_ENTRY(IObjectSafety)
  838. COM_INTERFACE_ENTRY_FUNC(IID_IMarshal, 0, IMarshalQI)
  839. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  840. END_COM_MAP()
  841. protected:
  842. long m_lFrequency;
  843. long m_lCadenceOn;
  844. long m_lCadenceOff;
  845. long m_lVolume;
  846. public:
  847. STDMETHOD(put_Frequency)( long lFrequency );
  848. STDMETHOD(get_Frequency)( long * plFrequency );
  849. STDMETHOD(put_CadenceOn)( long lCadenceOn );
  850. STDMETHOD(get_CadenceOn)( long * plCadenceOn );
  851. STDMETHOD(put_CadenceOff)( long lCadenceOff );
  852. STDMETHOD(get_CadenceOff)( long * plCadenceOff );
  853. STDMETHOD(put_Volume)( long lVolume );
  854. STDMETHOD(get_Volume)( long * plVolume );
  855. };
  856. #endif //__CALL_H_