Source code of Windows XP (NT5)
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.

2050 lines
46 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. callevnt.cpp
  5. Abstract:
  6. Implementation of the Call events for TAPI 3.0.
  7. Author:
  8. mquinton - 9/4/98
  9. Notes:
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  14. //
  15. // CCallStateEvent -
  16. // implementation of the ITCallStateEvent interface
  17. // This object is given to applications for call state events
  18. //
  19. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  20. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21. //
  22. // CCallStateEvent::FireEvent
  23. // static function to create and fire a new CCallStateEvent
  24. //
  25. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  26. HRESULT
  27. CCallStateEvent::FireEvent(
  28. ITCallInfo * pCall,
  29. CALL_STATE state,
  30. CALL_STATE_EVENT_CAUSE cause,
  31. CTAPI * pTapi,
  32. long lCallbackInstance
  33. )
  34. {
  35. CComObject< CCallStateEvent > * p;
  36. IDispatch * pDisp;
  37. HRESULT hr;
  38. CCall * pCCall;
  39. STATICLOG((TL_TRACE, "Create - enter" ));
  40. STATICLOG((TL_INFO, " CallState -------------> %d", state ));
  41. STATICLOG((TL_INFO, " CallStateEventCause ---> %d", cause ));
  42. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  43. if (NULL == pCCall)
  44. {
  45. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  46. return E_FAIL;
  47. }
  48. if( pCCall->DontExpose())
  49. {
  50. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  51. return S_OK;
  52. }
  53. //
  54. // Check the event filter mask
  55. // This event is not filtered by TapiSrv because is
  56. // related with TE_CALLSTATE.
  57. //
  58. DWORD dwEventFilterMask = 0;
  59. dwEventFilterMask = pCCall->GetSubEventsMask( TE_CALLSTATE );
  60. STATICLOG((TL_INFO, " CallStateEventMask ---> %ld", dwEventFilterMask ));
  61. if( !( dwEventFilterMask & GET_SUBEVENT_FLAG(state)))
  62. {
  63. STATICLOG((TL_WARN, "FireEvent - filtering out this event [%lx]", cause));
  64. return S_OK;
  65. }
  66. //
  67. // create the event object
  68. //
  69. CComObject< CCallStateEvent >::CreateInstance( &p );
  70. if (NULL == p)
  71. {
  72. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  73. return E_OUTOFMEMORY;
  74. }
  75. //
  76. // save info
  77. //
  78. p->m_pCall = pCall;
  79. pCall->AddRef();
  80. p->m_CallState = state;
  81. p->m_CallStateEventCause = cause;
  82. p->m_lCallbackInstance = lCallbackInstance;
  83. #if DBG
  84. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  85. #endif
  86. //
  87. // get the dispatch interface
  88. //
  89. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  90. if (!SUCCEEDED(hr))
  91. {
  92. delete p;
  93. STATICLOG((TL_ERROR, "CallStateEvent - could not get IDispatch %lx", hr));
  94. return hr;
  95. }
  96. //
  97. // fire the event
  98. //
  99. pTapi->Event(
  100. TE_CALLSTATE,
  101. pDisp
  102. );
  103. //
  104. // release our reference
  105. //
  106. pDisp->Release();
  107. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  108. return S_OK;
  109. }
  110. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  111. //
  112. // FinalRelease
  113. //
  114. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  115. void
  116. CCallStateEvent::FinalRelease()
  117. {
  118. m_pCall->Release();
  119. #if DBG
  120. ClientFree( m_pDebug );
  121. #endif
  122. }
  123. // ITCallStateEvent methods
  124. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  125. //
  126. // get_Call
  127. //
  128. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  129. HRESULT
  130. CCallStateEvent::get_Call(
  131. ITCallInfo ** ppCallInfo
  132. )
  133. {
  134. HRESULT hr = S_OK;
  135. LOG((TL_TRACE, "get_Call - enter" ));
  136. LOG((TL_TRACE, " ppCallInfo ---> %p", ppCallInfo ));
  137. if (TAPIIsBadWritePtr( ppCallInfo, sizeof( ITCallInfo * ) ) )
  138. {
  139. LOG((TL_ERROR, "get_Call - bad pointer"));
  140. return E_POINTER;
  141. }
  142. *ppCallInfo = m_pCall;
  143. m_pCall->AddRef();
  144. LOG((TL_TRACE, "get_Call - exit - returing %lx", hr ));
  145. return hr;
  146. }
  147. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  148. //
  149. // get_State
  150. //
  151. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  152. HRESULT
  153. CCallStateEvent::get_State(
  154. CALL_STATE * pCallState
  155. )
  156. {
  157. HRESULT hr = S_OK;
  158. LOG((TL_TRACE, "get_State - enter" ));
  159. LOG((TL_TRACE, " pCallState ---> %p", pCallState ));
  160. if (TAPIIsBadWritePtr( pCallState, sizeof(CALL_STATE) ) )
  161. {
  162. LOG((TL_ERROR, "get_State - bad pointer"));
  163. return E_POINTER;
  164. }
  165. *pCallState = m_CallState;
  166. LOG((TL_TRACE, "get_State - exit - returing %lx", hr ));
  167. return hr;
  168. }
  169. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  170. //
  171. // get_Cause
  172. //
  173. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  174. HRESULT
  175. CCallStateEvent::get_Cause(
  176. CALL_STATE_EVENT_CAUSE * pCEC
  177. )
  178. {
  179. HRESULT hr = S_OK;
  180. LOG((TL_TRACE, "get_Cause - enter" ));
  181. LOG((TL_TRACE, " pCEC ---> %p", pCEC ));
  182. if (TAPIIsBadWritePtr( pCEC, sizeof( CALL_STATE_EVENT_CAUSE ) ) )
  183. {
  184. LOG((TL_ERROR, "get_Cause - bad pointer"));
  185. return E_POINTER;
  186. }
  187. *pCEC = m_CallStateEventCause;
  188. LOG((TL_TRACE, "get_Cause - exit - returning %lx", hr ));
  189. return hr;
  190. }
  191. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  192. //
  193. // get_callbackinstance
  194. //
  195. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  196. HRESULT
  197. CCallStateEvent::get_CallbackInstance(
  198. long * plCallbackInstance
  199. )
  200. {
  201. HRESULT hr = S_OK;
  202. if (TAPIIsBadWritePtr( plCallbackInstance, sizeof(long) ) )
  203. {
  204. LOG((TL_ERROR, "get_CallbackInstance - bad pointer"));
  205. return E_POINTER;
  206. }
  207. *plCallbackInstance = m_lCallbackInstance;
  208. return hr;
  209. }
  210. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  211. //
  212. // CCallNotificationEvent
  213. // Implements the ITCallNotificationEvent interface
  214. //
  215. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  216. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  217. //
  218. // FireEvent
  219. //
  220. // Creates and fires a ITCallNotificationEvent object
  221. //
  222. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  223. HRESULT
  224. CCallNotificationEvent::FireEvent(
  225. ITCallInfo * pCall,
  226. CALL_NOTIFICATION_EVENT CallNotificationEvent,
  227. CTAPI * pTapi,
  228. long lCallbackInstance
  229. )
  230. {
  231. CComObject< CCallNotificationEvent > * p;
  232. IDispatch * pDisp;
  233. HRESULT hr;
  234. CCall * pCCall;
  235. STATICLOG((TL_TRACE, "FireEvent - enter" ));
  236. STATICLOG((TL_INFO, " CallNotification -------------> %d", CallNotificationEvent ));
  237. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  238. if (NULL == pCCall)
  239. {
  240. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  241. return E_FAIL;
  242. }
  243. if( pCCall->DontExpose())
  244. {
  245. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  246. return S_OK;
  247. }
  248. //
  249. // Check the event filter mask
  250. // This event is not filtered by TapiSrv because is
  251. // related with TE_CALLSTATE.
  252. //
  253. DWORD dwEventFilterMask = 0;
  254. dwEventFilterMask = pCCall->GetSubEventsMask( TE_CALLNOTIFICATION );
  255. if( !( dwEventFilterMask & GET_SUBEVENT_FLAG(CallNotificationEvent)))
  256. {
  257. STATICLOG((TL_WARN, "FireEvent - filtering out this event [%lx]", CallNotificationEvent));
  258. return S_OK;
  259. }
  260. //
  261. // create the event object
  262. //
  263. CComObject< CCallNotificationEvent >::CreateInstance( &p );
  264. if (NULL == p)
  265. {
  266. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  267. return E_OUTOFMEMORY;
  268. }
  269. //
  270. // save info
  271. //
  272. p->m_pCall = pCall;
  273. pCall->AddRef();
  274. p->m_CallNotificationEvent = CallNotificationEvent;
  275. p->m_lCallbackInstance = lCallbackInstance;
  276. #if DBG
  277. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  278. #endif
  279. //
  280. // get the dispatch interface
  281. //
  282. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  283. if (!SUCCEEDED(hr))
  284. {
  285. delete p;
  286. STATICLOG((TL_ERROR, "CallNotificationEvent - could not get IDispatch %lx", hr));
  287. return hr;
  288. }
  289. //
  290. // fire the event
  291. //
  292. pTapi->Event(
  293. TE_CALLNOTIFICATION,
  294. pDisp
  295. );
  296. //
  297. // release our reference
  298. //
  299. pDisp->Release();
  300. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  301. return S_OK;
  302. }
  303. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  304. //
  305. // finalrelease
  306. //
  307. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  308. void
  309. CCallNotificationEvent::FinalRelease()
  310. {
  311. LOG((TL_INFO, "CallNotificationEvent - FinalRelease"));
  312. m_pCall->Release();
  313. #if DBG
  314. ClientFree( m_pDebug );
  315. #endif
  316. }
  317. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  318. //
  319. // get_call
  320. //
  321. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  322. HRESULT
  323. CCallNotificationEvent::get_Call(
  324. ITCallInfo ** ppCall
  325. )
  326. {
  327. HRESULT hr = S_OK;
  328. if (TAPIIsBadWritePtr( ppCall, sizeof( ITCallInfo *) ) )
  329. {
  330. LOG((TL_ERROR, "get_Call - bad pointer"));
  331. return E_POINTER;
  332. }
  333. *ppCall = m_pCall;
  334. (*ppCall)->AddRef();
  335. return hr;
  336. }
  337. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  338. //
  339. // get_Event
  340. //
  341. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  342. HRESULT
  343. CCallNotificationEvent::get_Event(
  344. CALL_NOTIFICATION_EVENT * pCallNotificationEvent
  345. )
  346. {
  347. HRESULT hr = S_OK;
  348. if (TAPIIsBadWritePtr(pCallNotificationEvent, sizeof(CALL_NOTIFICATION_EVENT) ) )
  349. {
  350. LOG((TL_ERROR, "get_Event - bad pointer"));
  351. return E_POINTER;
  352. }
  353. *pCallNotificationEvent = m_CallNotificationEvent;
  354. return hr;
  355. }
  356. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  357. //
  358. // get_callbackinstance
  359. //
  360. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  361. HRESULT
  362. CCallNotificationEvent::get_CallbackInstance(
  363. long * plCallbackInstance
  364. )
  365. {
  366. HRESULT hr = S_OK;
  367. if (TAPIIsBadWritePtr( plCallbackInstance, sizeof(long) ) )
  368. {
  369. LOG((TL_ERROR, "get_CallbackInstance bad pointer"));
  370. return E_POINTER;
  371. }
  372. *plCallbackInstance = m_lCallbackInstance;
  373. return hr;
  374. }
  375. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  376. //
  377. // CQOSEvent::FireEvent
  378. //
  379. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  380. HRESULT
  381. CQOSEvent::FireEvent(
  382. ITCallInfo * pCall,
  383. QOS_EVENT QosEvent,
  384. long lMediaMode,
  385. CTAPI * pTapi
  386. )
  387. {
  388. CComObject<CQOSEvent> * p;
  389. HRESULT hr = S_OK;
  390. IDispatch * pDisp;
  391. CCall * pCCall;
  392. //
  393. // We don't need to filter the event because it's already done
  394. // by TapiSrv
  395. //
  396. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  397. if (NULL == pCCall)
  398. {
  399. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  400. return E_FAIL;
  401. }
  402. if( pCCall->DontExpose())
  403. {
  404. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  405. return S_OK;
  406. }
  407. CComObject< CQOSEvent >::CreateInstance( &p );
  408. if (NULL == p)
  409. {
  410. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  411. return E_OUTOFMEMORY;
  412. }
  413. //
  414. // save info
  415. //
  416. p->m_pCall = pCall;
  417. pCall->AddRef();
  418. p->m_QosEvent = QosEvent;
  419. p->m_lMediaMode = lMediaMode;
  420. //
  421. // get the dispatch interface
  422. //
  423. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  424. if (!SUCCEEDED(hr))
  425. {
  426. delete p;
  427. STATICLOG((TL_ERROR, "CallStateEvent - could not get IDispatch %lx", hr));
  428. return hr;
  429. }
  430. //
  431. // fire the event
  432. //
  433. pTapi->Event(
  434. TE_QOSEVENT,
  435. pDisp
  436. );
  437. //
  438. // release our reference
  439. //
  440. pDisp->Release();
  441. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  442. return S_OK;
  443. }
  444. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  445. //
  446. // CQOSEvent::get_Call
  447. //
  448. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  449. STDMETHODIMP
  450. CQOSEvent::get_Call(
  451. ITCallInfo ** ppCall
  452. )
  453. {
  454. if ( TAPIIsBadWritePtr( ppCall, sizeof (ITCallInfo *) ) )
  455. {
  456. LOG((TL_ERROR, "get_Call - bad pointer"));
  457. return E_POINTER;
  458. }
  459. *ppCall = m_pCall;
  460. m_pCall->AddRef();
  461. return S_OK;
  462. }
  463. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  464. //
  465. // CQOSEvent::get_Event
  466. //
  467. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  468. STDMETHODIMP
  469. CQOSEvent::get_Event(
  470. QOS_EVENT * pQosEvent
  471. )
  472. {
  473. if ( TAPIIsBadWritePtr( pQosEvent, sizeof( QOS_EVENT ) ) )
  474. {
  475. LOG((TL_ERROR, "get_Event - bad pointer"));
  476. return E_POINTER;
  477. }
  478. *pQosEvent = m_QosEvent;
  479. return S_OK;
  480. }
  481. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  482. //
  483. // CQOSEvent::get_MediaType
  484. //
  485. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  486. STDMETHODIMP
  487. CQOSEvent::get_MediaType(
  488. long * plMediaMode
  489. )
  490. {
  491. if ( TAPIIsBadWritePtr( plMediaMode, sizeof( long ) ) )
  492. {
  493. LOG((TL_ERROR, "get_MediaMode - bad pointer"));
  494. return E_POINTER;
  495. }
  496. *plMediaMode = m_lMediaMode;
  497. return S_OK;
  498. }
  499. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  500. //
  501. // CQOSEvent::FinalRelease
  502. //
  503. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  504. void
  505. CQOSEvent::FinalRelease()
  506. {
  507. m_pCall->Release();
  508. }
  509. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  510. //
  511. // CCall::CallInfoChangeEvent
  512. //
  513. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  514. HRESULT
  515. CCall::CallInfoChangeEvent( CALLINFOCHANGE_CAUSE cic )
  516. {
  517. if ( DontExpose() )
  518. {
  519. return S_OK;
  520. }
  521. if (NULL != m_pAddress)
  522. {
  523. return CCallInfoChangeEvent::FireEvent(
  524. this,
  525. cic,
  526. m_pAddress->GetTapi(),
  527. (m_pAddressLine)?(m_pAddressLine->lCallbackInstance):0
  528. );
  529. }
  530. else
  531. {
  532. return E_FAIL;
  533. }
  534. }
  535. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  536. //
  537. // CCallInfoChangeEvent::FireEvent
  538. //
  539. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  540. HRESULT
  541. CCallInfoChangeEvent::FireEvent(
  542. ITCallInfo * pCall,
  543. CALLINFOCHANGE_CAUSE Cause,
  544. CTAPI * pTapi,
  545. long lCallbackInstance
  546. )
  547. {
  548. HRESULT hr = S_OK;
  549. CComObject<CCallInfoChangeEvent> * p;
  550. IDispatch * pDisp;
  551. CCall * pCCall;
  552. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  553. if (NULL == pCCall)
  554. {
  555. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  556. return E_FAIL;
  557. }
  558. if( pCCall->DontExpose())
  559. {
  560. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  561. return S_OK;
  562. }
  563. //
  564. // Check the event filter mask
  565. // This event is not filtered by TapiSrv because is
  566. // related with TE_CALLSTATE.
  567. //
  568. DWORD dwEventFilterMask = 0;
  569. dwEventFilterMask = pCCall->GetSubEventsMask( TE_CALLINFOCHANGE );
  570. STATICLOG((TL_INFO, " CallInfochangeEventMask ---> %ld", dwEventFilterMask ));
  571. if( !( dwEventFilterMask & GET_SUBEVENT_FLAG(Cause)))
  572. {
  573. STATICLOG((TL_WARN, "FireEvent - filtering out this event [%lx]", Cause));
  574. return S_OK;
  575. }
  576. //
  577. // create event
  578. //
  579. hr = CComObject<CCallInfoChangeEvent>::CreateInstance( &p );
  580. if ( !SUCCEEDED(hr) )
  581. {
  582. STATICLOG((TL_ERROR, "Could not create CallInfoStateChange object - %lx", hr));
  583. return hr;
  584. }
  585. //
  586. // initialize
  587. //
  588. p->m_Cause = Cause;
  589. p->m_pCall = pCall;
  590. p->m_pCall->AddRef();
  591. p->m_lCallbackInstance = lCallbackInstance;
  592. #if DBG
  593. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  594. #endif
  595. //
  596. // get idisp interface
  597. //
  598. hr = p->QueryInterface(
  599. IID_IDispatch,
  600. (void **)&pDisp
  601. );
  602. if ( !SUCCEEDED(hr) )
  603. {
  604. STATICLOG((TL_ERROR, "Could not get disp interface of CallInfoStateChange object %lx", hr));
  605. delete p;
  606. return hr;
  607. }
  608. //
  609. // fire event
  610. //
  611. pTapi->Event(
  612. TE_CALLINFOCHANGE,
  613. pDisp
  614. );
  615. //
  616. // release stuff
  617. //
  618. pDisp->Release();
  619. return S_OK;
  620. }
  621. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  622. //
  623. // CCallInfoChangeEvent::FinalRelease
  624. //
  625. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  626. void
  627. CCallInfoChangeEvent::FinalRelease()
  628. {
  629. m_pCall->Release();
  630. #if DBG
  631. ClientFree( m_pDebug );
  632. #endif
  633. }
  634. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  635. //
  636. // CCallInfoChangeEvent::get_Call
  637. //
  638. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  639. STDMETHODIMP
  640. CCallInfoChangeEvent::get_Call( ITCallInfo ** ppCallInfo)
  641. {
  642. if ( TAPIIsBadWritePtr( ppCallInfo, sizeof (ITCallInfo *) ) )
  643. {
  644. return E_POINTER;
  645. }
  646. m_pCall->QueryInterface(
  647. IID_ITCallInfo,
  648. (void **) ppCallInfo
  649. );
  650. return S_OK;
  651. }
  652. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  653. //
  654. // CCallInfoChangeEvent::get_Cause
  655. //
  656. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  657. STDMETHODIMP
  658. CCallInfoChangeEvent::get_Cause( CALLINFOCHANGE_CAUSE * pCallInfoChangeCause )
  659. {
  660. if ( TAPIIsBadWritePtr( pCallInfoChangeCause, sizeof (CALLINFOCHANGE_CAUSE) ) )
  661. {
  662. return E_POINTER;
  663. }
  664. *pCallInfoChangeCause = m_Cause;
  665. return S_OK;
  666. }
  667. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  668. //
  669. // CCallInfoChangeEvent::get_CallbackInstance
  670. //
  671. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  672. STDMETHODIMP
  673. CCallInfoChangeEvent::get_CallbackInstance( long * plCallbackInstance )
  674. {
  675. if ( TAPIIsBadWritePtr( plCallbackInstance, sizeof(long) ) )
  676. {
  677. return E_POINTER;
  678. }
  679. *plCallbackInstance = m_lCallbackInstance;
  680. return S_OK;
  681. }
  682. HRESULT
  683. CCallMediaEvent::FireEvent(
  684. ITCallInfo * pCall,
  685. CALL_MEDIA_EVENT Event,
  686. CALL_MEDIA_EVENT_CAUSE Cause,
  687. CTAPI * pTapi,
  688. ITTerminal * pTerminal,
  689. ITStream * pStream,
  690. HRESULT hrEvent
  691. )
  692. {
  693. CComObject< CCallMediaEvent > * p;
  694. IDispatch * pDisp;
  695. HRESULT hr;
  696. CCall * pCCall;
  697. STATICLOG((TL_TRACE, "FireEvent - enter" ));
  698. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  699. if (NULL == pCCall)
  700. {
  701. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  702. return E_FAIL;
  703. }
  704. if( pCCall->DontExpose())
  705. {
  706. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  707. return S_OK;
  708. }
  709. //
  710. // Check the event filter mask
  711. // These is a MSP event and it is not filter
  712. // by TapiSrv
  713. //
  714. DWORD dwEventFilterMask = 0;
  715. dwEventFilterMask = pCCall->GetSubEventsMask( TE_CALLMEDIA );
  716. if( !( dwEventFilterMask & GET_SUBEVENT_FLAG(Event)))
  717. {
  718. STATICLOG((TL_ERROR, "FireEvent exit - "
  719. "This event is filtered - %lx", Event));
  720. return S_OK;
  721. }
  722. //
  723. // create the event object
  724. //
  725. CComObject< CCallMediaEvent >::CreateInstance( &p );
  726. if (NULL == p)
  727. {
  728. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  729. return E_OUTOFMEMORY;
  730. }
  731. //
  732. // save info
  733. //
  734. p->m_pCall = pCall;
  735. p->m_Event = Event;
  736. p->m_Cause = Cause;
  737. p->m_hr = hrEvent;
  738. p->m_pTerminal = pTerminal;
  739. p->m_pStream = pStream;
  740. if ( NULL != pCall )
  741. {
  742. pCall->AddRef();
  743. }
  744. if ( NULL != pTerminal )
  745. {
  746. pTerminal->AddRef();
  747. }
  748. if ( NULL != pStream )
  749. {
  750. pStream->AddRef();
  751. }
  752. #if DBG
  753. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  754. #endif
  755. //
  756. // get the dispatch interface
  757. //
  758. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  759. if (!SUCCEEDED(hr))
  760. {
  761. STATICLOG((TL_ERROR, "CallMediaEvent - could not get IDispatch %lx", hr));
  762. return hr;
  763. }
  764. //
  765. // fire the event
  766. //
  767. pTapi->Event(
  768. TE_CALLMEDIA,
  769. pDisp
  770. );
  771. //
  772. // release our reference
  773. //
  774. pDisp->Release();
  775. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  776. return S_OK;
  777. }
  778. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  779. //
  780. // get_Call
  781. //
  782. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  783. STDMETHODIMP
  784. CCallMediaEvent::get_Call(ITCallInfo ** ppCallInfo)
  785. {
  786. if ( TAPIIsBadWritePtr( ppCallInfo, sizeof( ITCallInfo *) ) )
  787. {
  788. LOG((TL_ERROR, "get_Call - bad pointer"));
  789. return E_POINTER;
  790. }
  791. *ppCallInfo = m_pCall;
  792. if ( NULL != m_pCall )
  793. {
  794. m_pCall->AddRef();
  795. }
  796. return S_OK;
  797. }
  798. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  799. //
  800. // get_Event
  801. //
  802. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  803. STDMETHODIMP
  804. CCallMediaEvent::get_Event(CALL_MEDIA_EVENT * pCallMediaEvent)
  805. {
  806. if ( TAPIIsBadWritePtr( pCallMediaEvent, sizeof( CALL_MEDIA_EVENT ) ) )
  807. {
  808. LOG((TL_ERROR, "get_Event - bad pointer"));
  809. return E_POINTER;
  810. }
  811. *pCallMediaEvent = m_Event;
  812. return S_OK;
  813. }
  814. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  815. //
  816. // get_Cause
  817. //
  818. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  819. STDMETHODIMP
  820. CCallMediaEvent::get_Cause(CALL_MEDIA_EVENT_CAUSE * pCause)
  821. {
  822. if ( TAPIIsBadWritePtr( pCause, sizeof( CALL_MEDIA_EVENT_CAUSE ) ) )
  823. {
  824. LOG((TL_ERROR, "get_Cause - bad pointer"));
  825. return E_POINTER;
  826. }
  827. *pCause = m_Cause;
  828. return S_OK;
  829. }
  830. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  831. //
  832. // get_Error
  833. //
  834. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  835. STDMETHODIMP
  836. CCallMediaEvent::get_Error(HRESULT * phrError)
  837. {
  838. if ( TAPIIsBadWritePtr( phrError, sizeof( HRESULT ) ) )
  839. {
  840. LOG((TL_ERROR, "get_Error - bad pointer"));
  841. return E_POINTER;
  842. }
  843. *phrError = m_hr;
  844. return S_OK;
  845. }
  846. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  847. //
  848. // get_Terminal
  849. //
  850. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  851. STDMETHODIMP
  852. CCallMediaEvent::get_Terminal(ITTerminal ** ppTerminal)
  853. {
  854. HRESULT hr = S_OK;
  855. if ( TAPIIsBadWritePtr( ppTerminal, sizeof( ITTerminal *) ) )
  856. {
  857. LOG((TL_ERROR, "get_Terminal - bad pointer"));
  858. return E_POINTER;
  859. }
  860. *ppTerminal = m_pTerminal;
  861. if ( NULL != m_pTerminal )
  862. {
  863. m_pTerminal->AddRef();
  864. }
  865. return hr;
  866. }
  867. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  868. //
  869. // get_Stream
  870. //
  871. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  872. STDMETHODIMP
  873. CCallMediaEvent::get_Stream(ITStream ** ppStream)
  874. {
  875. if ( TAPIIsBadWritePtr( ppStream, sizeof( ITStream *) ) )
  876. {
  877. LOG((TL_ERROR, "get_Stream - bad pointer"));
  878. return E_POINTER;
  879. }
  880. *ppStream = m_pStream;
  881. if ( NULL != m_pStream )
  882. {
  883. m_pStream->AddRef();
  884. }
  885. return S_OK;
  886. }
  887. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  888. //
  889. // FinalRelease
  890. //
  891. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  892. void
  893. CCallMediaEvent::FinalRelease()
  894. {
  895. if ( NULL != m_pCall )
  896. {
  897. m_pCall->Release();
  898. }
  899. if ( NULL != m_pTerminal )
  900. {
  901. m_pTerminal->Release();
  902. }
  903. if ( NULL != m_pStream )
  904. {
  905. m_pStream->Release();
  906. }
  907. #if DBG
  908. ClientFree( m_pDebug );
  909. #endif
  910. }
  911. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  912. //
  913. // CDigitDetectionEvent::FireEvent
  914. //
  915. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  916. HRESULT
  917. CDigitDetectionEvent::FireEvent(
  918. ITCallInfo * pCall,
  919. unsigned char ucDigit,
  920. TAPI_DIGITMODE DigitMode,
  921. long lTickCount,
  922. CTAPI * pTapi,
  923. long lCallbackInstance
  924. )
  925. {
  926. CComObject< CDigitDetectionEvent > * p;
  927. IDispatch * pDisp;
  928. HRESULT hr;
  929. CCall * pCCall;
  930. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  931. if (NULL == pCCall)
  932. {
  933. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  934. return E_FAIL;
  935. }
  936. if( pCCall->DontExpose())
  937. {
  938. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  939. return S_OK;
  940. }
  941. //
  942. // create the event object
  943. //
  944. CComObject< CDigitDetectionEvent >::CreateInstance( &p );
  945. if (NULL == p)
  946. {
  947. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  948. return E_OUTOFMEMORY;
  949. }
  950. //
  951. // save info
  952. //
  953. p->m_pCall = pCall;
  954. pCall->AddRef();
  955. p->m_Digit = ucDigit;
  956. p->m_DigitMode = DigitMode;
  957. p->m_lTickCount = lTickCount;
  958. p->m_lCallbackInstance = lCallbackInstance;
  959. #if DBG
  960. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  961. #endif
  962. //
  963. // get the dispatch interface
  964. //
  965. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  966. if (!SUCCEEDED(hr))
  967. {
  968. STATICLOG((TL_ERROR, "DigitDetectionEvent - could not get IDispatch %lx", hr));
  969. delete p;
  970. pCall->Release();
  971. return hr;
  972. }
  973. //
  974. // fire the event
  975. //
  976. pTapi->Event(
  977. TE_DIGITEVENT,
  978. pDisp
  979. );
  980. //
  981. // release our reference
  982. //
  983. pDisp->Release();
  984. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  985. return S_OK;
  986. }
  987. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  988. //
  989. // CDigitDetectionEvent::FinalRelease
  990. //
  991. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  992. void
  993. CDigitDetectionEvent::FinalRelease()
  994. {
  995. if ( NULL != m_pCall )
  996. {
  997. m_pCall->Release();
  998. }
  999. #if DBG
  1000. ClientFree( m_pDebug );
  1001. #endif
  1002. }
  1003. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1004. //
  1005. // CDigitDetectionEvent::get_Call
  1006. //
  1007. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1008. STDMETHODIMP
  1009. CDigitDetectionEvent::get_Call( ITCallInfo ** ppCallInfo )
  1010. {
  1011. LOG((TL_TRACE, "get_Call - enter"));
  1012. if ( TAPIIsBadWritePtr( ppCallInfo, sizeof( ITCallInfo * ) ) )
  1013. {
  1014. LOG((TL_ERROR, "get_Call - bad pointer"));
  1015. return E_POINTER;
  1016. }
  1017. *ppCallInfo = m_pCall;
  1018. m_pCall->AddRef();
  1019. LOG((TL_TRACE, "get_Call - exit - return SUCCESS"));
  1020. return S_OK;
  1021. }
  1022. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1023. //
  1024. // CDigitDetectionEvent::get_Digit
  1025. //
  1026. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1027. STDMETHODIMP
  1028. CDigitDetectionEvent::get_Digit( unsigned char * pucDigit )
  1029. {
  1030. LOG((TL_TRACE, "get_Digit - enter"));
  1031. if ( TAPIIsBadWritePtr( pucDigit, sizeof( unsigned char ) ) )
  1032. {
  1033. LOG((TL_ERROR, "get_Digit - bad pointer"));
  1034. return E_POINTER;
  1035. }
  1036. *pucDigit = m_Digit;
  1037. LOG((TL_TRACE, "get_Digit - exit - return SUCCESS"));
  1038. return S_OK;
  1039. }
  1040. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1041. //
  1042. // CDigitDetectionEvent::get_DigitMode
  1043. //
  1044. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1045. STDMETHODIMP
  1046. CDigitDetectionEvent::get_DigitMode( TAPI_DIGITMODE * pDigitMode )
  1047. {
  1048. HRESULT hr = S_OK;
  1049. LOG((TL_TRACE, "get_DigitMode - enter"));
  1050. if ( TAPIIsBadWritePtr( pDigitMode, sizeof( TAPI_DIGITMODE ) ) )
  1051. {
  1052. LOG((TL_ERROR, "get_DigitMode - bad pointer"));
  1053. return E_POINTER;
  1054. }
  1055. *pDigitMode = m_DigitMode;
  1056. LOG((TL_TRACE, "get_DigitMode - exit - return %lx", hr));
  1057. return hr;
  1058. }
  1059. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1060. //
  1061. // CDigitDetectionEvent::get_TickCount
  1062. //
  1063. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1064. STDMETHODIMP
  1065. CDigitDetectionEvent::get_TickCount( long * plTickCount )
  1066. {
  1067. HRESULT hr = S_OK;
  1068. LOG((TL_TRACE, "get_TickCount - enter"));
  1069. if ( TAPIIsBadWritePtr( plTickCount, sizeof( long ) ) )
  1070. {
  1071. LOG((TL_ERROR, "get_DigitMode - bad pointer"));
  1072. return E_POINTER;
  1073. }
  1074. *plTickCount = m_lTickCount;
  1075. LOG((TL_TRACE, "get_TickCount - exit - return %lx", hr));
  1076. return hr;
  1077. }
  1078. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1079. //
  1080. // CDigitDetectionEvent::get_CallbackInstance
  1081. //
  1082. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1083. STDMETHODIMP
  1084. CDigitDetectionEvent::get_CallbackInstance( long * plCallbackInstance )
  1085. {
  1086. HRESULT hr = S_OK;
  1087. LOG((TL_TRACE, "get_CallbackInstance - enter"));
  1088. if ( TAPIIsBadWritePtr( plCallbackInstance, sizeof( long ) ) )
  1089. {
  1090. LOG((TL_ERROR, "get_DigitMode - bad pointer"));
  1091. return E_POINTER;
  1092. }
  1093. *plCallbackInstance = m_lCallbackInstance;
  1094. LOG((TL_TRACE, "get_CallbackInstance - exit - return %lx", hr));
  1095. return hr;
  1096. }
  1097. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1098. //
  1099. // CDigitGenerationEvent::FireEvent
  1100. //
  1101. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1102. HRESULT
  1103. CDigitGenerationEvent::FireEvent(
  1104. ITCallInfo * pCall,
  1105. long lGenerationTermination,
  1106. long lTickCount,
  1107. long lCallbackInstance,
  1108. CTAPI * pTapi
  1109. )
  1110. {
  1111. CComObject< CDigitGenerationEvent > * p;
  1112. IDispatch * pDisp;
  1113. HRESULT hr;
  1114. CCall * pCCall;
  1115. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  1116. if (NULL == pCCall)
  1117. {
  1118. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  1119. return E_FAIL;
  1120. }
  1121. if( pCCall->DontExpose())
  1122. {
  1123. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  1124. return S_OK;
  1125. }
  1126. //
  1127. // create the event object
  1128. //
  1129. CComObject< CDigitGenerationEvent >::CreateInstance( &p );
  1130. if (NULL == p)
  1131. {
  1132. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  1133. return E_OUTOFMEMORY;
  1134. }
  1135. //
  1136. // get the dispatch interface
  1137. //
  1138. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  1139. if (!SUCCEEDED(hr))
  1140. {
  1141. STATICLOG((TL_ERROR, "FireEvent - could not get IDispatch %lx", hr));
  1142. delete p;
  1143. return hr;
  1144. }
  1145. //
  1146. // save info
  1147. //
  1148. p->m_pCall = pCall;
  1149. pCall->AddRef();
  1150. p->m_lGenerationTermination = lGenerationTermination;
  1151. p->m_lTickCount = lTickCount;
  1152. p->m_lCallbackInstance = lCallbackInstance;
  1153. #if DBG
  1154. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  1155. #endif
  1156. //
  1157. // fire the event
  1158. //
  1159. pTapi->Event(
  1160. TE_GENERATEEVENT,
  1161. pDisp
  1162. );
  1163. //
  1164. // release our reference
  1165. //
  1166. pDisp->Release();
  1167. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  1168. return S_OK;
  1169. }
  1170. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1171. //
  1172. // CDigitGenerationEvent::FinalRelease
  1173. //
  1174. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1175. void
  1176. CDigitGenerationEvent::FinalRelease()
  1177. {
  1178. if ( NULL != m_pCall )
  1179. {
  1180. m_pCall->Release();
  1181. }
  1182. #if DBG
  1183. ClientFree( m_pDebug );
  1184. #endif
  1185. }
  1186. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1187. //
  1188. // CDigitGenerationEvent::get_Call
  1189. //
  1190. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1191. STDMETHODIMP
  1192. CDigitGenerationEvent::get_Call( ITCallInfo ** ppCallInfo )
  1193. {
  1194. LOG((TL_TRACE, "get_Call - enter"));
  1195. if ( TAPIIsBadWritePtr( ppCallInfo, sizeof( ITCallInfo * ) ) )
  1196. {
  1197. LOG((TL_ERROR, "get_Call - bad pointer"));
  1198. return E_POINTER;
  1199. }
  1200. *ppCallInfo = m_pCall;
  1201. m_pCall->AddRef();
  1202. LOG((TL_TRACE, "get_Call - exit - return SUCCESS"));
  1203. return S_OK;
  1204. }
  1205. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1206. //
  1207. // CDigitGenerationEvent::get_GenerationTermination
  1208. //
  1209. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1210. STDMETHODIMP
  1211. CDigitGenerationEvent::get_GenerationTermination( long * plGenerationTermination )
  1212. {
  1213. HRESULT hr = S_OK;
  1214. LOG((TL_TRACE, "get_GenerationTermination - enter"));
  1215. if ( TAPIIsBadWritePtr( plGenerationTermination, sizeof( long ) ) )
  1216. {
  1217. LOG((TL_ERROR, "get_DigitMode - bad pointer"));
  1218. return E_POINTER;
  1219. }
  1220. *plGenerationTermination = m_lGenerationTermination;
  1221. LOG((TL_TRACE, "get_GenerationTermination - exit - return %lx", hr));
  1222. return hr;
  1223. }
  1224. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1225. //
  1226. // CDigitGenerationEvent::get_TickCount
  1227. //
  1228. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1229. STDMETHODIMP
  1230. CDigitGenerationEvent::get_TickCount( long * plTickCount )
  1231. {
  1232. HRESULT hr = S_OK;
  1233. LOG((TL_TRACE, "get_TickCount - enter"));
  1234. if ( TAPIIsBadWritePtr( plTickCount, sizeof( long ) ) )
  1235. {
  1236. LOG((TL_ERROR, "get_DigitMode - bad pointer"));
  1237. return E_POINTER;
  1238. }
  1239. *plTickCount = m_lTickCount;
  1240. LOG((TL_TRACE, "get_TickCount - exit - return %lx", hr));
  1241. return hr;
  1242. }
  1243. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1244. //
  1245. // CDigitGenerationEvent::get_CallbackInstance
  1246. //
  1247. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1248. STDMETHODIMP
  1249. CDigitGenerationEvent::get_CallbackInstance( long * plCallbackInstance )
  1250. {
  1251. HRESULT hr = S_OK;
  1252. LOG((TL_TRACE, "get_CallbackInstance - enter"));
  1253. if ( TAPIIsBadWritePtr( plCallbackInstance, sizeof( long ) ) )
  1254. {
  1255. LOG((TL_ERROR, "get_DigitMode - bad pointer"));
  1256. return E_POINTER;
  1257. }
  1258. *plCallbackInstance = m_lCallbackInstance;
  1259. LOG((TL_TRACE, "get_CallbackInstance - exit - return %lx", hr));
  1260. return hr;
  1261. }
  1262. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1263. //
  1264. // CDigitsGatheredEvent::FireEvent
  1265. //
  1266. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1267. HRESULT
  1268. CDigitsGatheredEvent::FireEvent(
  1269. ITCallInfo * pCall,
  1270. BSTR pDigits,
  1271. TAPI_GATHERTERM GatherTermination,
  1272. long lTickCount,
  1273. long lCallbackInstance,
  1274. CTAPI * pTapi
  1275. )
  1276. {
  1277. CComObject< CDigitsGatheredEvent > * p;
  1278. IDispatch * pDisp;
  1279. HRESULT hr;
  1280. CCall * pCCall;
  1281. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  1282. if (NULL == pCCall)
  1283. {
  1284. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  1285. return E_FAIL;
  1286. }
  1287. if( pCCall->DontExpose())
  1288. {
  1289. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  1290. return S_OK;
  1291. }
  1292. //
  1293. // create the event object
  1294. //
  1295. CComObject< CDigitsGatheredEvent >::CreateInstance( &p );
  1296. if (NULL == p)
  1297. {
  1298. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  1299. return E_OUTOFMEMORY;
  1300. }
  1301. //
  1302. // get the dispatch interface
  1303. //
  1304. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  1305. if (!SUCCEEDED(hr))
  1306. {
  1307. STATICLOG((TL_ERROR, "CDigitsGatheredEvent - could not get IDispatch %lx", hr));
  1308. delete p;
  1309. return hr;
  1310. }
  1311. //
  1312. // save info
  1313. //
  1314. p->m_pCall = pCall;
  1315. pCall->AddRef();
  1316. p->m_pDigits = pDigits;
  1317. p->m_GatherTermination = GatherTermination;
  1318. p->m_lTickCount = lTickCount;
  1319. p->m_lCallbackInstance = lCallbackInstance;
  1320. #if DBG
  1321. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  1322. #endif
  1323. //
  1324. // fire the event
  1325. //
  1326. pTapi->Event(
  1327. TE_GATHERDIGITS,
  1328. pDisp
  1329. );
  1330. //
  1331. // release our reference
  1332. //
  1333. pDisp->Release();
  1334. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  1335. return S_OK;
  1336. }
  1337. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1338. //
  1339. // CDigitsGatheredEvent::FinalRelease
  1340. //
  1341. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1342. void
  1343. CDigitsGatheredEvent::FinalRelease()
  1344. {
  1345. if ( NULL != m_pCall )
  1346. {
  1347. m_pCall->Release();
  1348. }
  1349. #if DBG
  1350. ClientFree( m_pDebug );
  1351. #endif
  1352. }
  1353. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1354. //
  1355. // CDigitsGatheredEvent::get_Call
  1356. //
  1357. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1358. STDMETHODIMP
  1359. CDigitsGatheredEvent::get_Call( ITCallInfo ** ppCallInfo )
  1360. {
  1361. LOG((TL_TRACE, "get_Call - enter"));
  1362. if ( TAPIIsBadWritePtr( ppCallInfo, sizeof( ITCallInfo * ) ) )
  1363. {
  1364. LOG((TL_ERROR, "get_Call - bad pointer"));
  1365. return E_POINTER;
  1366. }
  1367. *ppCallInfo = m_pCall;
  1368. m_pCall->AddRef();
  1369. LOG((TL_TRACE, "get_Call - exit - return SUCCESS"));
  1370. return S_OK;
  1371. }
  1372. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1373. //
  1374. // CDigitsGatheredEvent::get_Digits
  1375. //
  1376. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1377. STDMETHODIMP
  1378. CDigitsGatheredEvent::get_Digits( BSTR * ppDigits )
  1379. {
  1380. LOG((TL_TRACE, "get_Digits - enter"));
  1381. if ( TAPIIsBadWritePtr( ppDigits, sizeof( BSTR ) ) )
  1382. {
  1383. LOG((TL_ERROR, "get_Digits - bad pointer"));
  1384. return E_POINTER;
  1385. }
  1386. *ppDigits = m_pDigits;
  1387. LOG((TL_TRACE, "get_Digits - exit - return SUCCESS"));
  1388. return S_OK;
  1389. }
  1390. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1391. //
  1392. // CDigitsGatheredEvent::get_GatherTermination
  1393. //
  1394. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1395. STDMETHODIMP
  1396. CDigitsGatheredEvent::get_GatherTermination( TAPI_GATHERTERM *pGatherTermination )
  1397. {
  1398. LOG((TL_TRACE, "get_GatherTermination - enter"));
  1399. if ( TAPIIsBadWritePtr( pGatherTermination, sizeof( TAPI_GATHERTERM ) ) )
  1400. {
  1401. LOG((TL_ERROR, "get_GatherTermination - bad pointer"));
  1402. return E_POINTER;
  1403. }
  1404. *pGatherTermination = m_GatherTermination;
  1405. LOG((TL_TRACE, "get_GatherTermination - exit - return SUCCESS"));
  1406. return S_OK;
  1407. }
  1408. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1409. //
  1410. // CDigitsGatheredEvent::get_TickCount
  1411. //
  1412. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1413. STDMETHODIMP
  1414. CDigitsGatheredEvent::get_TickCount( long * plTickCount )
  1415. {
  1416. LOG((TL_TRACE, "get_TickCount - enter"));
  1417. if ( TAPIIsBadWritePtr( plTickCount, sizeof( long ) ) )
  1418. {
  1419. LOG((TL_ERROR, "get_TickCount - bad pointer"));
  1420. return E_POINTER;
  1421. }
  1422. *plTickCount = m_lTickCount;
  1423. LOG((TL_TRACE, "get_TickCount - exit - return SUCCESS"));
  1424. return S_OK;
  1425. }
  1426. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1427. //
  1428. // CDigitsGatheredEvent::get_CallbackInstance
  1429. //
  1430. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1431. STDMETHODIMP
  1432. CDigitsGatheredEvent::get_CallbackInstance( long * plCallbackInstance )
  1433. {
  1434. LOG((TL_TRACE, "get_CallbackInstance - enter"));
  1435. if ( TAPIIsBadWritePtr( plCallbackInstance, sizeof( long ) ) )
  1436. {
  1437. LOG((TL_ERROR, "get_CallbackInstance - bad pointer"));
  1438. return E_POINTER;
  1439. }
  1440. *plCallbackInstance = m_lCallbackInstance;
  1441. LOG((TL_TRACE, "get_CallbackInstance - exit - return SUCCESS"));
  1442. return S_OK;
  1443. }
  1444. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1445. //
  1446. // CToneDetectionEvent::FireEvent
  1447. //
  1448. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1449. HRESULT
  1450. CToneDetectionEvent::FireEvent(
  1451. ITCallInfo * pCall,
  1452. long lAppSpecific,
  1453. long lTickCount,
  1454. long lCallbackInstance,
  1455. CTAPI * pTapi
  1456. )
  1457. {
  1458. CComObject< CToneDetectionEvent > * p;
  1459. IDispatch * pDisp;
  1460. HRESULT hr;
  1461. CCall * pCCall;
  1462. pCCall = dynamic_cast<CComObject<CCall>*>(pCall);
  1463. if (NULL == pCCall)
  1464. {
  1465. STATICLOG((TL_ERROR, "FireEvent - bad call pointer" ));
  1466. return E_FAIL;
  1467. }
  1468. if( pCCall->DontExpose())
  1469. {
  1470. STATICLOG((TL_INFO, "FireEvent - Don't expose this call %p", pCCall));
  1471. return S_OK;
  1472. }
  1473. //
  1474. // create the event object
  1475. //
  1476. CComObject< CToneDetectionEvent >::CreateInstance( &p );
  1477. if (NULL == p)
  1478. {
  1479. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  1480. return E_OUTOFMEMORY;
  1481. }
  1482. //
  1483. // get the dispatch interface
  1484. //
  1485. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  1486. if (!SUCCEEDED(hr))
  1487. {
  1488. STATICLOG((TL_ERROR, "CToneDetectionEvent - could not get IDispatch %lx", hr));
  1489. delete p;
  1490. return hr;
  1491. }
  1492. //
  1493. // save info
  1494. //
  1495. p->m_pCall = pCall;
  1496. pCall->AddRef();
  1497. p->m_lAppSpecific = lAppSpecific;
  1498. p->m_lTickCount = lTickCount;
  1499. p->m_lCallbackInstance = lCallbackInstance;
  1500. #if DBG
  1501. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  1502. #endif
  1503. //
  1504. // fire the event
  1505. //
  1506. pTapi->Event(
  1507. TE_TONEEVENT,
  1508. pDisp
  1509. );
  1510. //
  1511. // release our reference
  1512. //
  1513. pDisp->Release();
  1514. STATICLOG((TL_TRACE, "FireEvent - exit - returing SUCCESS" ));
  1515. return S_OK;
  1516. }
  1517. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1518. //
  1519. // CToneDetectionEvent::FinalRelease
  1520. //
  1521. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1522. void
  1523. CToneDetectionEvent::FinalRelease()
  1524. {
  1525. if ( NULL != m_pCall )
  1526. {
  1527. m_pCall->Release();
  1528. }
  1529. #if DBG
  1530. ClientFree( m_pDebug );
  1531. #endif
  1532. }
  1533. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1534. //
  1535. // CToneDetectionEvent::get_Call
  1536. //
  1537. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1538. STDMETHODIMP
  1539. CToneDetectionEvent::get_Call( ITCallInfo ** ppCallInfo )
  1540. {
  1541. LOG((TL_TRACE, "get_Call - enter"));
  1542. if ( TAPIIsBadWritePtr( ppCallInfo, sizeof( ITCallInfo * ) ) )
  1543. {
  1544. LOG((TL_ERROR, "get_Call - bad pointer"));
  1545. return E_POINTER;
  1546. }
  1547. *ppCallInfo = m_pCall;
  1548. m_pCall->AddRef();
  1549. LOG((TL_TRACE, "get_Call - exit - return SUCCESS"));
  1550. return S_OK;
  1551. }
  1552. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1553. //
  1554. // CToneDetectionEvent::get_AppSpecific
  1555. //
  1556. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1557. STDMETHODIMP
  1558. CToneDetectionEvent::get_AppSpecific( long * plAppSpecific )
  1559. {
  1560. LOG((TL_TRACE, "get_AppSpecific - enter"));
  1561. if ( TAPIIsBadWritePtr( plAppSpecific, sizeof( long ) ) )
  1562. {
  1563. LOG((TL_ERROR, "get_AppSpecific - bad pointer"));
  1564. return E_POINTER;
  1565. }
  1566. *plAppSpecific = m_lAppSpecific;
  1567. LOG((TL_TRACE, "get_AppSpecific - exit - return SUCCESS"));
  1568. return S_OK;
  1569. }
  1570. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1571. //
  1572. // CToneDetectionEvent::get_TickCount
  1573. //
  1574. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1575. STDMETHODIMP
  1576. CToneDetectionEvent::get_TickCount( long * plTickCount )
  1577. {
  1578. LOG((TL_TRACE, "get_TickCount - enter"));
  1579. if ( TAPIIsBadWritePtr( plTickCount, sizeof( long ) ) )
  1580. {
  1581. LOG((TL_ERROR, "get_TickCount - bad pointer"));
  1582. return E_POINTER;
  1583. }
  1584. *plTickCount = m_lTickCount;
  1585. LOG((TL_TRACE, "get_TickCount - exit - return SUCCESS"));
  1586. return S_OK;
  1587. }
  1588. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1589. //
  1590. // CToneDetectionEvent::get_CallbackInstance
  1591. //
  1592. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  1593. STDMETHODIMP
  1594. CToneDetectionEvent::get_CallbackInstance( long * plCallbackInstance )
  1595. {
  1596. LOG((TL_TRACE, "get_CallbackInstance - enter"));
  1597. if ( TAPIIsBadWritePtr( plCallbackInstance, sizeof( long ) ) )
  1598. {
  1599. LOG((TL_ERROR, "get_CallbackInstance - bad pointer"));
  1600. return E_POINTER;
  1601. }
  1602. *plCallbackInstance = m_lCallbackInstance;
  1603. LOG((TL_TRACE, "get_CallbackInstance - exit - return SUCCESS"));
  1604. return S_OK;
  1605. }