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.

878 lines
20 KiB

  1. /*++
  2. Copyright (c) 1997 - 1999 Microsoft Corporation
  3. Module Name:
  4. queue.cpp
  5. Abstract:
  6. Implementation of the Queue object for TAPI 3.0.
  7. CQueue class
  8. Author:
  9. noela - 11/04/97
  10. Notes:
  11. optional-notes
  12. Revision History:
  13. --*/
  14. #include "stdafx.h"
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CQueue
  17. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  18. // Class : CQueue
  19. // Method : Constructor
  20. //
  21. //
  22. //
  23. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  24. CQueue::CQueue()
  25. {
  26. Lock();
  27. m_dwHandle = 0;
  28. m_bRequiresUpdating = TRUE;
  29. m_dwMeasurementPeriod = 0;
  30. m_dwTotalCallsQueued = 0;
  31. m_dwCurrentCallsQueued = 0;
  32. m_dwTotalCallsAdandoned = 0;
  33. m_dwTotalCallsFlowedIn = 0;
  34. m_dwTotalCallsFlowedOut = 0;
  35. m_dwLongestEverWaitTime = 0;
  36. m_dwCurrentLongestWaitTime = 0;
  37. m_dwAverageWaitTime = 0;
  38. m_dwFinalDisposition = 0;
  39. Unlock();
  40. }
  41. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  42. // Class : CQueue
  43. // Method : UpdateInfo
  44. //
  45. //
  46. //
  47. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  48. STDMETHODIMP CQueue::UpdateInfo()
  49. {
  50. HRESULT hr = S_OK;
  51. LINEQUEUEINFO QueueInfo;
  52. LOG((TL_TRACE, "UpdateInfo - enter" ));
  53. QueueInfo.dwTotalSize = sizeof(LINEQUEUEINFO);
  54. QueueInfo.dwNeededSize = sizeof(LINEQUEUEINFO);
  55. QueueInfo.dwUsedSize = sizeof(LINEQUEUEINFO);
  56. // **************************************************
  57. // Get Queue Info from Proxy
  58. hr = lineGetQueueInfo(
  59. m_pHandler->getHLine(),
  60. m_dwHandle,
  61. &QueueInfo);
  62. if( SUCCEEDED(hr) )
  63. {
  64. // wait for async reply
  65. hr = WaitForReply( hr );
  66. if ( SUCCEEDED(hr) )
  67. {
  68. Lock();
  69. m_dwMeasurementPeriod = QueueInfo.dwMeasurementPeriod;
  70. m_dwTotalCallsQueued = QueueInfo.dwTotalCallsQueued;
  71. m_dwCurrentCallsQueued = QueueInfo.dwCurrentCallsQueued;
  72. m_dwTotalCallsAdandoned = QueueInfo.dwTotalCallsAbandoned;
  73. m_dwTotalCallsFlowedIn = QueueInfo.dwTotalCallsFlowedIn;
  74. m_dwTotalCallsFlowedOut = QueueInfo.dwTotalCallsFlowedOut;
  75. m_dwLongestEverWaitTime = QueueInfo.dwLongestEverWaitTime;
  76. m_dwCurrentLongestWaitTime = QueueInfo.dwCurrentLongestWaitTime;
  77. m_dwAverageWaitTime = QueueInfo.dwAverageWaitTime;
  78. m_dwFinalDisposition = QueueInfo.dwFinalDisposition;
  79. m_bRequiresUpdating = FALSE;
  80. Unlock();
  81. }
  82. else
  83. {
  84. LOG((TL_ERROR, "UpdateInfo - call to LineGetQueueInfo failed async" ));
  85. }
  86. }
  87. else
  88. {
  89. LOG((TL_ERROR, "UpdateInfo - call to LineGetQueueInfo failed" ));
  90. }
  91. LOG((TL_TRACE, hr, "UpdateInfo - exit" ));
  92. return hr;
  93. }
  94. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  95. // Class : CQueue
  96. // Method : CheckIfUpToDate
  97. //
  98. //
  99. //
  100. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  101. STDMETHODIMP CQueue::CheckIfUpToDate()
  102. {
  103. HRESULT hr = S_OK;
  104. if (m_bRequiresUpdating)
  105. {
  106. hr = UpdateInfo();
  107. }
  108. return hr;
  109. }
  110. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  111. // Class : CQueue
  112. // Method : Initialize
  113. //
  114. //
  115. //
  116. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  117. STDMETHODIMP CQueue::Initialize
  118. (
  119. DWORD dwQueueID,
  120. PWSTR pszName,
  121. CAgentHandler * pHandler
  122. )
  123. {
  124. HRESULT hr = S_OK;
  125. LOG((TL_TRACE, "Initialize - enter" ));
  126. m_dwHandle = dwQueueID;
  127. m_pHandler = pHandler;
  128. m_bRequiresUpdating = TRUE;
  129. // copy the destination address
  130. if (pszName != NULL)
  131. {
  132. m_szName = (PWSTR) ClientAlloc((lstrlenW(pszName) + 1) * sizeof (WCHAR));
  133. if (m_szName != NULL)
  134. {
  135. lstrcpyW(m_szName,pszName);
  136. }
  137. else
  138. {
  139. LOG((TL_ERROR, "Initialize - Alloc m_szName failed" ));
  140. hr = E_OUTOFMEMORY;
  141. }
  142. }
  143. else
  144. {
  145. LOG((TL_ERROR, "Initialize - name is NULL" ));
  146. m_szName = NULL;
  147. }
  148. // Add this object into the Agnet Handler Hash table
  149. m_pHandler->AddQueueToHash(m_dwHandle, this);
  150. // Get Queue Info from Proxy
  151. // UpdateInfo();
  152. if ( SUCCEEDED(hr) )
  153. {
  154. CQueueEvent::FireEvent(this, ACDQE_NEW_QUEUE);
  155. }
  156. LOG((TL_TRACE, hr, "Initialize - exit" ));
  157. return hr;
  158. }
  159. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  160. // Class : CQueue
  161. // Method : FinalRelease
  162. //
  163. //
  164. //
  165. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  166. void CQueue::FinalRelease()
  167. {
  168. LOG((TL_TRACE, "FinalRelease Queue - %S", m_szName ));
  169. if ( m_szName != NULL )
  170. {
  171. ClientFree(m_szName);
  172. }
  173. // Add this object into the Agnet Handler Hash table
  174. m_pHandler->RemoveQueueFromHash(m_dwHandle);
  175. LOG((TL_TRACE, "FinalRelease Queue - exit"));
  176. }
  177. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  178. // Class : CQueue
  179. // Interface : ITQueue
  180. // Method : get_Name
  181. //
  182. //
  183. //
  184. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  185. STDMETHODIMP CQueue::get_Name(BSTR * Name)
  186. {
  187. HRESULT hr = S_OK;
  188. LOG((TL_TRACE, "Name - enter" ));
  189. Lock();
  190. if (!TAPIIsBadWritePtr( Name, sizeof(BSTR ) ) )
  191. {
  192. *Name = SysAllocString(m_szName);
  193. if (*Name == NULL)
  194. {
  195. hr = E_OUTOFMEMORY;
  196. }
  197. }
  198. else
  199. {
  200. LOG((TL_ERROR, "Name - bad Name pointer"));
  201. hr = E_POINTER;
  202. }
  203. Unlock();
  204. LOG((TL_TRACE, hr, "Name - exit" ));
  205. return hr;
  206. }
  207. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  208. // Class : CQueue
  209. // Interface : ITQueue
  210. // Method : put_MeasurementPeriod
  211. //
  212. //
  213. //
  214. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  215. STDMETHODIMP CQueue::put_MeasurementPeriod(long ulPeriod)
  216. {
  217. HRESULT hr = S_OK;
  218. LOG((TL_TRACE, "put_MeasurementPeriod - enter" ));
  219. // ***************************************************
  220. // Tell Proxy
  221. hr = lineSetQueueMeasurementPeriod(
  222. m_pHandler->getHLine(),
  223. m_dwHandle,
  224. ulPeriod);
  225. if( SUCCEEDED(hr) )
  226. {
  227. // wait for async reply
  228. hr = WaitForReply( hr );
  229. if ( SUCCEEDED(hr) )
  230. {
  231. Lock();
  232. m_dwMeasurementPeriod = ulPeriod;
  233. Unlock();
  234. }
  235. else
  236. {
  237. LOG((TL_ERROR, "put_MeasurementPeriod - call to LineSetQueueMeasurementPeriod failed async" ));
  238. }
  239. }
  240. else
  241. {
  242. LOG((TL_ERROR, "put_MeasurementPeriod - call to LineSetQueueMeasurementPeriod failed" ));
  243. }
  244. LOG((TL_TRACE, hr, "put_MeasurementPeriod - exit" ));
  245. return hr;
  246. }
  247. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  248. // Class : CQueue
  249. // Interface : ITQueue
  250. // Method : get_MeasurementPeriod
  251. //
  252. //
  253. //
  254. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  255. STDMETHODIMP CQueue::get_MeasurementPeriod (long * pulPeriod)
  256. {
  257. HRESULT hr = S_OK;
  258. LOG((TL_TRACE, "get_MeasurementPeriod - enter" ));
  259. if (!TAPIIsBadWritePtr( pulPeriod, sizeof(long) ) )
  260. {
  261. hr = CheckIfUpToDate();
  262. if ( SUCCEEDED(hr) )
  263. {
  264. Lock();
  265. *pulPeriod = m_dwMeasurementPeriod;
  266. Unlock();
  267. }
  268. else
  269. {
  270. LOG((TL_ERROR, "get_MeasurementPeriod - Object update failed"));
  271. }
  272. }
  273. else
  274. {
  275. LOG((TL_ERROR, "get_MeasurementPeriod - bad pulPeriod pointer"));
  276. hr = E_POINTER;
  277. }
  278. LOG((TL_TRACE, hr, "get_MeasurementPeriod - exit" ));
  279. return hr;
  280. }
  281. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  282. // Class : CQueue
  283. // Interface : ITQueue
  284. // Method : TotalCallsQueued
  285. //
  286. //
  287. //
  288. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  289. STDMETHODIMP CQueue::get_TotalCallsQueued (long * pulCalls)
  290. {
  291. HRESULT hr = S_OK;
  292. LOG((TL_TRACE, "TotalCallsQueued - enter" ));
  293. if (!TAPIIsBadWritePtr( pulCalls, sizeof(long) ) )
  294. {
  295. hr = CheckIfUpToDate();
  296. if ( SUCCEEDED(hr) )
  297. {
  298. Lock();
  299. *pulCalls = m_dwTotalCallsQueued;
  300. Unlock();
  301. }
  302. else
  303. {
  304. LOG((TL_ERROR, "get_TotalCallsQueued - Object update failed"));
  305. }
  306. }
  307. else
  308. {
  309. LOG((TL_ERROR, "get_TotalCallsQueued - bad pulCalls pointer"));
  310. hr = E_POINTER;
  311. }
  312. LOG((TL_TRACE, hr, "TotalCallsQueued - exit" ));
  313. return hr;
  314. }
  315. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  316. // Class : CQueue
  317. // Interface : ITQueue
  318. // Method : CurrentCallsQueued
  319. //
  320. //
  321. //
  322. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  323. STDMETHODIMP CQueue::get_CurrentCallsQueued (long * pulCalls)
  324. {
  325. HRESULT hr = S_OK;
  326. LOG((TL_TRACE, "CurrentCallsQueued - enter" ));
  327. if (!TAPIIsBadWritePtr( pulCalls, sizeof(long) ) )
  328. {
  329. hr = CheckIfUpToDate();
  330. if ( SUCCEEDED(hr) )
  331. {
  332. Lock();
  333. *pulCalls = m_dwCurrentCallsQueued;
  334. Unlock();
  335. }
  336. else
  337. {
  338. LOG((TL_ERROR, "get_CurrentCallsQueued - Object update failed"));
  339. }
  340. }
  341. else
  342. {
  343. LOG((TL_ERROR, "get_CurrentCallsQueued - bad pulCalls pointer"));
  344. hr = E_POINTER;
  345. }
  346. LOG((TL_TRACE, hr, "CurrentCallsQueued - exit" ));
  347. return hr;
  348. }
  349. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  350. // Class : CQueue
  351. // Interface : ITQueue
  352. // Method : TotalCallsAbandoned
  353. //
  354. //
  355. //
  356. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  357. STDMETHODIMP CQueue::get_TotalCallsAbandoned (long * pulCalls)
  358. {
  359. HRESULT hr = S_OK;
  360. LOG((TL_TRACE, "TotalCallsAbandoned - enter" ));
  361. if (!TAPIIsBadWritePtr( pulCalls, sizeof(long) ) )
  362. {
  363. hr = CheckIfUpToDate();
  364. if (SUCCEEDED(hr) )
  365. {
  366. Lock();
  367. *pulCalls = m_dwTotalCallsAdandoned;
  368. Unlock();
  369. }
  370. else
  371. {
  372. LOG((TL_ERROR, "get_TotalCallsAbandoned - Object update failed"));
  373. }
  374. }
  375. else
  376. {
  377. LOG((TL_ERROR, "get_TotalCallsAbandoned - bad pulCalls pointer"));
  378. hr = E_POINTER;
  379. }
  380. LOG((TL_TRACE, hr, "TotalCallsAbandoned - exit" ));
  381. return hr;
  382. }
  383. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  384. // Class : CQueue
  385. // Interface : ITQueue
  386. // Method : TotalCallsFlowedIn
  387. //
  388. //
  389. //
  390. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  391. STDMETHODIMP CQueue::get_TotalCallsFlowedIn (long * pulCalls)
  392. {
  393. HRESULT hr = S_OK;
  394. LOG((TL_TRACE, "TotalCallsFlowedIn - enter" ));
  395. if (!TAPIIsBadWritePtr( pulCalls, sizeof(long) ) )
  396. {
  397. hr = CheckIfUpToDate();
  398. if (SUCCEEDED(hr) )
  399. {
  400. Lock();
  401. *pulCalls = m_dwTotalCallsFlowedIn;
  402. Unlock();
  403. }
  404. else
  405. {
  406. LOG((TL_ERROR, "get_TotalCallsFlowedIn - Object update failed"));
  407. }
  408. }
  409. else
  410. {
  411. LOG((TL_ERROR, "get_TotalCallsFlowedIn - bad pulCalls pointer"));
  412. hr = E_POINTER;
  413. }
  414. LOG((TL_TRACE, hr, "TotalCallsFlowedIn - exit" ));
  415. return hr;
  416. }
  417. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  418. // Class : CQueue
  419. // Interface : ITQueue
  420. // Method : TotalCallsFlowedIn
  421. //
  422. //
  423. //
  424. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  425. STDMETHODIMP CQueue::get_TotalCallsFlowedOut (long * pulCalls)
  426. {
  427. HRESULT hr = S_OK;
  428. LOG((TL_TRACE, "TotalCallsFlowedOut - enter" ));
  429. if (!TAPIIsBadWritePtr( pulCalls, sizeof(long) ) )
  430. {
  431. hr = CheckIfUpToDate();
  432. if (SUCCEEDED(hr) )
  433. {
  434. Lock();
  435. *pulCalls = m_dwTotalCallsFlowedOut;
  436. Unlock();
  437. }
  438. else
  439. {
  440. LOG((TL_ERROR, "get_TotalCallsFlowedOut - Object update failed"));
  441. }
  442. }
  443. else
  444. {
  445. LOG((TL_ERROR, "get_TotalCallsFlowedOut - bad pulCalls pointer"));
  446. hr = E_POINTER;
  447. }
  448. LOG((TL_TRACE, hr, "TotalCallsFlowedOut - exit" ));
  449. return hr;
  450. }
  451. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  452. // Class : CQueue
  453. // Interface : ITQueue
  454. // Method : LongestEverWaitTime
  455. //
  456. //
  457. //
  458. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  459. STDMETHODIMP CQueue::get_LongestEverWaitTime (long * pulWaitTime)
  460. {
  461. HRESULT hr = S_OK;
  462. LOG((TL_TRACE, "LongestEverWaitTime - enter" ));
  463. if (!TAPIIsBadWritePtr( pulWaitTime, sizeof(long) ) )
  464. {
  465. hr = CheckIfUpToDate();
  466. if (SUCCEEDED(hr) )
  467. {
  468. Lock();
  469. *pulWaitTime = m_dwLongestEverWaitTime;
  470. Unlock();
  471. }
  472. else
  473. {
  474. LOG((TL_ERROR, "get_LongestEverWaitTime - Object update failed"));
  475. }
  476. }
  477. else
  478. {
  479. LOG((TL_ERROR, "get_LongestEverWaitTime - bad pulWaitTime pointer"));
  480. hr = E_POINTER;
  481. }
  482. LOG((TL_TRACE, hr, "LongestEverWaitTime - exit" ));
  483. return hr;
  484. }
  485. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  486. // Class : CQueue
  487. // Interface : ITQueue
  488. // Method : CurrentLongestWaitTime
  489. //
  490. //
  491. //
  492. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  493. STDMETHODIMP CQueue::get_CurrentLongestWaitTime (long * pulWaitTime)
  494. {
  495. HRESULT hr = S_OK;
  496. LOG((TL_TRACE, "CurrentLongestWaitTime - enter" ));
  497. if (!TAPIIsBadWritePtr( pulWaitTime, sizeof(long) ) )
  498. {
  499. hr = CheckIfUpToDate();
  500. if (SUCCEEDED(hr) )
  501. {
  502. Lock();
  503. *pulWaitTime = m_dwCurrentLongestWaitTime;
  504. Unlock();
  505. }
  506. else
  507. {
  508. LOG((TL_ERROR, "get_CurrentLongestWaitTime - Object update failed"));
  509. }
  510. }
  511. else
  512. {
  513. LOG((TL_ERROR, "get_CurrentLongestWaitTime - bad pulWaitTime pointer"));
  514. hr = E_POINTER;
  515. }
  516. LOG((TL_TRACE, hr, "CurrentLongestWaitTime - exit" ));
  517. return hr;
  518. }
  519. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  520. // Class : CQueue
  521. // Interface : ITQueue
  522. // Method : AverageWaitTime
  523. //
  524. //
  525. //
  526. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  527. STDMETHODIMP CQueue::get_AverageWaitTime (long * pulWaitTime)
  528. {
  529. HRESULT hr = S_OK;
  530. LOG((TL_TRACE, "AverageWaitTime - enter" ));
  531. if (!TAPIIsBadWritePtr( pulWaitTime, sizeof(long) ) )
  532. {
  533. hr = CheckIfUpToDate();
  534. if (SUCCEEDED(hr) )
  535. {
  536. Lock();
  537. *pulWaitTime = m_dwAverageWaitTime;
  538. Unlock();
  539. }
  540. else
  541. {
  542. LOG((TL_ERROR, "get_AverageWaitTime - Object update failed"));
  543. }
  544. }
  545. else
  546. {
  547. LOG((TL_ERROR, "get_AverageWaitTime - bad pulWaitTime pointer"));
  548. hr = E_POINTER;
  549. }
  550. LOG((TL_TRACE, hr, "AverageWaitTime - exit" ));
  551. return hr;
  552. }
  553. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  554. // Class : CQueue
  555. // Interface : ITQueue
  556. // Method : FinalDisposition
  557. //
  558. //
  559. //
  560. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  561. STDMETHODIMP CQueue::get_FinalDisposition (long * pulCalls)
  562. {
  563. HRESULT hr = S_OK;
  564. LOG((TL_TRACE, "FinalDisposition - enter" ));
  565. if (!TAPIIsBadWritePtr( pulCalls, sizeof(long) ) )
  566. {
  567. hr = CheckIfUpToDate();
  568. if (SUCCEEDED(hr) )
  569. {
  570. Lock();
  571. *pulCalls = m_dwFinalDisposition;
  572. Unlock();
  573. }
  574. else
  575. {
  576. LOG((TL_ERROR, "get_FinalDisposition - Object update failed"));
  577. }
  578. }
  579. else
  580. {
  581. LOG((TL_ERROR, "get_FinalDisposition - bad pulCalls pointer"));
  582. hr = E_POINTER;
  583. }
  584. LOG((TL_TRACE, hr, "FinalDisposition - exit" ));
  585. return hr;
  586. }
  587. /////////////////////////////////////////////////////////////////////////////
  588. // CQueueEvent
  589. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  590. // Class : CQueueEvent
  591. // Method : FireEvent
  592. //
  593. //
  594. //
  595. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  596. HRESULT CQueueEvent::FireEvent(CQueue* pQueue, ACDQUEUE_EVENT Event)
  597. {
  598. HRESULT hr = S_OK;
  599. CComObject<CQueueEvent> * pEvent;
  600. IDispatch * pIDispatch;
  601. if ( IsBadReadPtr(pQueue, sizeof(CQueue)) )
  602. {
  603. STATICLOG((TL_ERROR, "FireEvent - pQueue is an invalid pointer"));
  604. return E_POINTER;
  605. }
  606. //
  607. // create event
  608. //
  609. hr = CComObject<CQueueEvent>::CreateInstance( &pEvent );
  610. if ( SUCCEEDED(hr) )
  611. {
  612. //
  613. // initialize
  614. //
  615. pEvent->m_QueueEvent = Event;
  616. pEvent->m_pQueue= dynamic_cast<ITQueue *>(pQueue);
  617. pEvent->m_pQueue->AddRef();
  618. //
  619. // get idisp interface
  620. //
  621. hr = pEvent->QueryInterface( IID_IDispatch, (void **)&pIDispatch );
  622. if ( SUCCEEDED(hr) )
  623. {
  624. //
  625. // get callback & fire event
  626. //
  627. CTAPI *pTapi = (pQueue->GetAgentHandler() )->GetTapi();
  628. pTapi->Event( TE_QUEUE, pIDispatch );
  629. // release stuff
  630. //
  631. pIDispatch->Release();
  632. }
  633. else
  634. {
  635. STATICLOG((TL_ERROR, "FireEvent - Could not get disp interface of QueueEvent object"));
  636. delete pEvent;
  637. }
  638. }
  639. else
  640. {
  641. STATICLOG((TL_ERROR, "FireEvent - Could not create QueueEvent object"));
  642. }
  643. STATICLOG((TL_TRACE, hr, "FireEvent - exit"));
  644. return hr;
  645. }
  646. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  647. // Class : CQueueEvent
  648. // Method : FinalRelease
  649. //
  650. //
  651. //
  652. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  653. void CQueueEvent::FinalRelease()
  654. {
  655. m_pQueue->Release();
  656. }
  657. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  658. // Class : CQueueEvent
  659. // Interface : ITQueueEvent
  660. // Method : Queue
  661. //
  662. //
  663. //
  664. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  665. STDMETHODIMP CQueueEvent::get_Queue(ITQueue ** ppQueue)
  666. {
  667. HRESULT hr = S_OK;
  668. LOG((TL_TRACE, "(Event)Queue - enter" ));
  669. if (!TAPIIsBadWritePtr( ppQueue, sizeof(ITQueue *) ) )
  670. {
  671. *ppQueue = m_pQueue;
  672. m_pQueue->AddRef();
  673. }
  674. else
  675. {
  676. LOG((TL_ERROR, "(Event)Queue - bad ppQueue pointer"));
  677. hr = E_POINTER;
  678. }
  679. LOG((TL_TRACE, hr, "(Event)Queue - exit"));
  680. return hr;
  681. }
  682. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  683. // Class : CQueueEvent
  684. // Interface : ITQueueEvent
  685. // Method : Event
  686. //
  687. //
  688. //
  689. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  690. STDMETHODIMP CQueueEvent::get_Event(ACDQUEUE_EVENT * pEvent)
  691. {
  692. HRESULT hr = S_OK;
  693. LOG((TL_TRACE, "Event - enter" ));
  694. if (!TAPIIsBadWritePtr( pEvent, sizeof(ACDQUEUE_EVENT) ) )
  695. {
  696. *pEvent = m_QueueEvent;
  697. }
  698. else
  699. {
  700. LOG((TL_ERROR, "Event - bad pEvent pointer"));
  701. hr = E_POINTER;
  702. }
  703. LOG((TL_TRACE, hr, "Event - exit"));
  704. return hr;
  705. }