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.

392 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. privobj.cpp
  5. Abstract:
  6. Author:
  7. mquinton - 11/13/97
  8. Notes:
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. extern CHashTable * gpCallHubHashTable;
  13. extern CHashTable * gpLineHashTable;
  14. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  15. //
  16. // CPrivateEvent -
  17. // implementation of the ITPrivateEvent interface
  18. // This object is given to applications for Private events
  19. //
  20. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  22. //
  23. // CPrivateEvent::FireEvent
  24. // static function to create and fire a new CPrivateEvent
  25. //
  26. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  27. HRESULT
  28. CPrivateEvent::FireEvent(
  29. CTAPI * pTapi,
  30. ITCallInfo * pCall,
  31. ITAddress * pAddress,
  32. ITCallHub * pCallHub,
  33. IDispatch * pEventInterface,
  34. long lEventCode
  35. )
  36. {
  37. CComObject< CPrivateEvent > * p;
  38. IDispatch * pDisp;
  39. HRESULT hr = S_OK;
  40. STATICLOG((TL_TRACE, "FireEvent - enter" ));
  41. STATICLOG((TL_INFO, " pCall -----------> %p", pCall ));
  42. STATICLOG((TL_INFO, " pAddress --------> %p", pAddress ));
  43. STATICLOG((TL_INFO, " pCallHub --------> %p", pCallHub ));
  44. STATICLOG((TL_INFO, " pEventInterface -> %p", pEventInterface ));
  45. STATICLOG((TL_INFO, " EventCode -------> %lX", lEventCode ));
  46. //
  47. // Check the event filter mask
  48. // These events are MSP events and are filter by
  49. // TapiSrv
  50. //
  51. DWORD dwEventFilterMask = 0;
  52. CAddress* pCAddress = (CAddress*)pAddress;
  53. if( pCAddress )
  54. {
  55. dwEventFilterMask = pCAddress->GetSubEventsMask( TE_PRIVATE );
  56. if( dwEventFilterMask == 0)
  57. {
  58. STATICLOG((TL_ERROR, "This private event is filtered"));
  59. return S_OK;
  60. }
  61. }
  62. CCall* pCCall = (CCall*)pCall;
  63. if( pCCall )
  64. {
  65. dwEventFilterMask = pCCall->GetSubEventsMask( TE_PRIVATE );
  66. if( dwEventFilterMask == 0)
  67. {
  68. STATICLOG((TL_ERROR, "This private event is filtered"));
  69. return S_OK;
  70. }
  71. }
  72. //
  73. // create the event object
  74. //
  75. hr = CComObject< CPrivateEvent >::CreateInstance( &p );
  76. if ( SUCCEEDED(hr) )
  77. {
  78. //
  79. // save event info
  80. //
  81. p->m_pCall = pCall;
  82. p->m_pAddress = pAddress;
  83. p->m_pCallHub = pCallHub;
  84. p->m_pEventInterface = pEventInterface;
  85. p->m_lEventCode = lEventCode;
  86. #if DBG
  87. p->m_pDebug = (PWSTR) ClientAlloc( 1 );
  88. #endif
  89. // AddRef pointers
  90. if(pCall)
  91. {
  92. pCall->AddRef();
  93. }
  94. if(pAddress)
  95. {
  96. pAddress->AddRef();
  97. }
  98. if(pEventInterface)
  99. {
  100. pEventInterface->AddRef();
  101. }
  102. if(pCallHub)
  103. {
  104. pCallHub->AddRef();
  105. }
  106. //
  107. // get the dispatch interface
  108. //
  109. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  110. if (SUCCEEDED(hr))
  111. {
  112. //
  113. // fire the event
  114. //
  115. if(pTapi)
  116. {
  117. pTapi->Event(TE_PRIVATE, pDisp);
  118. }
  119. // release our reference
  120. pDisp->Release();
  121. }
  122. else // couldn't get IDispatch
  123. {
  124. delete p;
  125. STATICLOG((TL_ERROR, "FireEvent - could not get IDispatch "));
  126. }
  127. }
  128. else // Couldn't create instance
  129. {
  130. STATICLOG((TL_ERROR, "FireEvent - could not createinstance" ));
  131. }
  132. STATICLOG((TL_TRACE, hr, "FireEvent - exit " ));
  133. return hr;
  134. }
  135. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  136. //
  137. // FinalRelease
  138. //
  139. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  140. void
  141. CPrivateEvent::FinalRelease()
  142. {
  143. if(m_pCall)
  144. {
  145. m_pCall->Release();
  146. }
  147. if(m_pAddress)
  148. {
  149. m_pAddress->Release();
  150. }
  151. if(m_pCallHub)
  152. {
  153. m_pCallHub->Release();
  154. }
  155. if(m_pEventInterface)
  156. {
  157. m_pEventInterface->Release();
  158. }
  159. #if DBG
  160. ClientFree( m_pDebug );
  161. #endif
  162. }
  163. // ITPrivateEvent methods
  164. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  165. //
  166. // get_Address
  167. //
  168. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  169. HRESULT
  170. CPrivateEvent::get_Address(
  171. ITAddress ** ppAddress
  172. )
  173. {
  174. HRESULT hr = S_OK;
  175. LOG((TL_TRACE, "get_Address - enter" ));
  176. LOG((TL_TRACE, " ppAddress ---> %p", ppAddress ));
  177. if (TAPIIsBadWritePtr( ppAddress, sizeof( ITAddress * ) ) )
  178. {
  179. LOG((TL_ERROR, "get_Address - bad pointer"));
  180. hr = E_POINTER;
  181. }
  182. else
  183. {
  184. *ppAddress = m_pAddress;
  185. if(m_pAddress)
  186. {
  187. m_pAddress->AddRef();
  188. }
  189. }
  190. LOG((TL_TRACE,hr, "get_Address - exit "));
  191. return hr;
  192. }
  193. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  194. //
  195. // get_Call
  196. //
  197. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  198. HRESULT
  199. CPrivateEvent::get_Call(
  200. ITCallInfo ** ppCallInfo
  201. )
  202. {
  203. HRESULT hr = S_OK;
  204. LOG((TL_TRACE, "get_Call - enter" ));
  205. LOG((TL_TRACE, " ppCallInfo ---> %p", ppCallInfo ));
  206. if (TAPIIsBadWritePtr( ppCallInfo, sizeof( ITCallInfo * ) ) )
  207. {
  208. LOG((TL_ERROR, "get_Call - bad pointer"));
  209. hr = E_POINTER;
  210. }
  211. else
  212. {
  213. *ppCallInfo = m_pCall;
  214. if(m_pCall)
  215. {
  216. m_pCall->AddRef();
  217. }
  218. }
  219. LOG((TL_TRACE,hr, "get_Call - exit "));
  220. return hr;
  221. }
  222. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  223. //
  224. // get_CallHub
  225. //
  226. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  227. HRESULT
  228. CPrivateEvent::get_CallHub(
  229. ITCallHub ** ppCallHub
  230. )
  231. {
  232. HRESULT hr = S_OK;
  233. LOG((TL_TRACE, "get_CallHub - enter" ));
  234. LOG((TL_TRACE, " ppCallHub ---> %p", ppCallHub ));
  235. if (TAPIIsBadWritePtr( ppCallHub, sizeof( ITCallHub * ) ) )
  236. {
  237. LOG((TL_ERROR, "get_CallHub - bad pointer"));
  238. hr = E_POINTER;
  239. }
  240. else
  241. {
  242. *ppCallHub = m_pCallHub;
  243. if(m_pCallHub)
  244. {
  245. m_pCallHub->AddRef();
  246. }
  247. else
  248. {
  249. LOG((TL_WARN, "get_CallHub - no callhub"));
  250. hr = TAPI_E_WRONGEVENT;
  251. }
  252. }
  253. LOG((TL_TRACE,hr, "get_CallHub - exit "));
  254. return hr;
  255. }
  256. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  257. //
  258. // get_EventInterface
  259. //
  260. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  261. HRESULT
  262. CPrivateEvent::get_EventInterface(
  263. IDispatch ** pEventInterface
  264. )
  265. {
  266. HRESULT hr = S_OK;
  267. LOG((TL_TRACE, "get_EventInterface - enter" ));
  268. LOG((TL_TRACE, " pEventInterface ---> %p", pEventInterface ));
  269. if (TAPIIsBadWritePtr( pEventInterface, sizeof( IDispatch * ) ) )
  270. {
  271. LOG((TL_ERROR, "get_EventInterface - bad pointer"));
  272. hr = E_POINTER;
  273. }
  274. else
  275. {
  276. *pEventInterface = m_pEventInterface;
  277. if(m_pEventInterface)
  278. {
  279. m_pEventInterface->AddRef();
  280. }
  281. }
  282. LOG((TL_TRACE,hr, "get_EventInterface - exit "));
  283. return hr;
  284. }
  285. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  286. //
  287. // get_EventCode
  288. //
  289. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  290. HRESULT
  291. CPrivateEvent::get_EventCode(
  292. long * plEventCode
  293. )
  294. {
  295. HRESULT hr = S_OK;
  296. LOG((TL_TRACE, "get_EventCode - enter" ));
  297. LOG((TL_TRACE, " pEventInterface ---> %p", plEventCode ));
  298. if (TAPIIsBadWritePtr( plEventCode, sizeof( long ) ) )
  299. {
  300. LOG((TL_ERROR, "get_EventCode - bad pointer"));
  301. hr = E_POINTER;
  302. }
  303. else
  304. {
  305. *plEventCode = m_lEventCode;
  306. }
  307. LOG((TL_TRACE,hr, "get_EventCode - exit "));
  308. return hr;
  309. }