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.

349 lines
7.7 KiB

  1. /*++
  2. Copyright (c) 1998 - 1999 Microsoft Corporation
  3. Module Name:
  4. request.cpp
  5. Abstract:
  6. Implements all the methods on ITRequest interfaces.
  7. Author:
  8. mquinton - 6/3/98
  9. Notes:
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. #include "windows.h"
  14. #include "wownt32.h"
  15. #include "stdarg.h"
  16. #include "stdio.h"
  17. #include "shellapi.h"
  18. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  19. //
  20. //
  21. //
  22. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  23. STDMETHODIMP
  24. CRequest::MakeCall(
  25. BSTR pDestAddress,
  26. #ifdef NEWREQUEST
  27. long lAddressType,
  28. #endif
  29. BSTR pAppName,
  30. BSTR pCalledParty,
  31. BSTR pComment
  32. )
  33. {
  34. return TapiMakeCall(
  35. pDestAddress,
  36. pAppName,
  37. pCalledParty,
  38. pComment
  39. );
  40. }
  41. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  42. //
  43. //
  44. //
  45. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  46. STDMETHODIMP
  47. CRequestEvent::get_RegistrationInstance(
  48. long * plRegistrationInstance
  49. )
  50. {
  51. if ( TAPIIsBadWritePtr( plRegistrationInstance, sizeof(long) ) )
  52. {
  53. LOG((TL_ERROR, "get_RegistrationInstance - bad pointer"));
  54. return E_POINTER;
  55. }
  56. *plRegistrationInstance = m_lRegistrationInstance;
  57. return S_OK;
  58. }
  59. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  60. //
  61. //
  62. //
  63. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  64. STDMETHODIMP
  65. CRequestEvent::get_RequestMode(long * plRequestMode )
  66. {
  67. if ( TAPIIsBadWritePtr( plRequestMode, sizeof(long) ) )
  68. {
  69. LOG((TL_ERROR, "get_RequestMode - bad pointer"));
  70. return E_POINTER;
  71. }
  72. Lock();
  73. *plRequestMode = m_lRequestMode;
  74. Unlock();
  75. return S_OK;
  76. }
  77. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  78. //
  79. //
  80. //
  81. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  82. STDMETHODIMP
  83. CRequestEvent::get_DestAddress(BSTR * ppDestAddress )
  84. {
  85. if ( TAPIIsBadWritePtr( ppDestAddress, sizeof (BSTR) ) )
  86. {
  87. LOG((TL_ERROR, "get_DestAddress - bad pointer"));
  88. return E_POINTER;
  89. }
  90. Lock();
  91. *ppDestAddress = SysAllocString( m_pReqMakeCall->szDestAddress );
  92. Unlock();
  93. if ( ( NULL == *ppDestAddress ) && ( NULL != m_pReqMakeCall->szDestAddress ) )
  94. {
  95. LOG((TL_ERROR, "get_DestAddress - SysAllocString Failed"));
  96. return E_OUTOFMEMORY;
  97. }
  98. return S_OK;
  99. }
  100. #ifdef NEWREQUEST
  101. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  102. //
  103. //
  104. //
  105. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  106. STDMETHODIMP
  107. CRequestEvent::get_AddressType(long * plAddressType )
  108. {
  109. return E_NOTIMPL;
  110. }
  111. #endif
  112. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  113. //
  114. //
  115. //
  116. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  117. STDMETHODIMP
  118. CRequestEvent::get_AppName(BSTR * ppAppName )
  119. {
  120. if ( TAPIIsBadWritePtr( ppAppName, sizeof (BSTR) ) )
  121. {
  122. LOG((TL_ERROR, "get_AppName - bad pointer"));
  123. return E_POINTER;
  124. }
  125. Lock();
  126. *ppAppName = SysAllocString( m_pReqMakeCall->szAppName );
  127. Unlock();
  128. if ( ( NULL == *ppAppName ) && ( NULL != m_pReqMakeCall->szAppName ) )
  129. {
  130. LOG((TL_ERROR, "get_AppName - SysAllocString Failed"));
  131. return E_OUTOFMEMORY;
  132. }
  133. return S_OK;
  134. }
  135. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  136. //
  137. //
  138. //
  139. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  140. STDMETHODIMP
  141. CRequestEvent::get_CalledParty(BSTR * ppCalledParty )
  142. {
  143. if ( TAPIIsBadWritePtr( ppCalledParty, sizeof (BSTR) ) )
  144. {
  145. LOG((TL_ERROR, "get_CalledParty - bad pointer"));
  146. return E_POINTER;
  147. }
  148. Lock();
  149. *ppCalledParty = SysAllocString( m_pReqMakeCall->szCalledParty );
  150. Unlock();
  151. if ( ( NULL == *ppCalledParty ) && ( NULL != m_pReqMakeCall->szCalledParty ) )
  152. {
  153. LOG((TL_ERROR, "get_CalledParty - SysAllocString Failed"));
  154. return E_OUTOFMEMORY;
  155. }
  156. return S_OK;
  157. }
  158. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  159. //
  160. //
  161. //
  162. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  163. STDMETHODIMP
  164. CRequestEvent::get_Comment(BSTR * ppComment )
  165. {
  166. if ( TAPIIsBadWritePtr( ppComment, sizeof (BSTR) ) )
  167. {
  168. LOG((TL_ERROR, "get_Comment - bad pointer"));
  169. return E_POINTER;
  170. }
  171. Lock();
  172. *ppComment = SysAllocString( m_pReqMakeCall->szComment );
  173. Unlock();
  174. if ( ( NULL == *ppComment ) && ( NULL != m_pReqMakeCall->szComment ) )
  175. {
  176. LOG((TL_ERROR, "get_Comment - SysAllocString Failed"));
  177. return E_OUTOFMEMORY;
  178. }
  179. return S_OK;
  180. }
  181. HRESULT
  182. CRequestEvent::FireEvent(
  183. CTAPI * pTapi,
  184. DWORD dwReg,
  185. LPLINEREQMAKECALLW pReqMakeCall
  186. )
  187. {
  188. HRESULT hr;
  189. IDispatch * pDisp;
  190. CComObject< CRequestEvent > * p;
  191. hr = CComObject< CRequestEvent >::CreateInstance( &p );
  192. if ( NULL == p )
  193. {
  194. return E_OUTOFMEMORY;
  195. }
  196. p->m_lRegistrationInstance = dwReg;
  197. p->m_lRequestMode = LINEREQUESTMODE_MAKECALL;
  198. p->m_pReqMakeCall = pReqMakeCall;
  199. #if DBG
  200. p->m_pDebug = (PWSTR)ClientAlloc(1);
  201. #endif
  202. //
  203. // get the dispatch interface
  204. //
  205. hr = p->_InternalQueryInterface( IID_IDispatch, (void **)&pDisp );
  206. if (!SUCCEEDED(hr))
  207. {
  208. STATICLOG((TL_ERROR, "RequestEvent - could not get IDispatch %lx", hr));
  209. return hr;
  210. }
  211. //
  212. // fire the event
  213. //
  214. pTapi->Event(
  215. TE_REQUEST,
  216. pDisp
  217. );
  218. //
  219. // release our reference
  220. //
  221. pDisp->Release();
  222. return S_OK;
  223. }
  224. void
  225. CRequestEvent::FinalRelease()
  226. {
  227. if ( NULL != m_pReqMakeCall )
  228. {
  229. ClientFree( m_pReqMakeCall );
  230. }
  231. #if DBG
  232. if ( NULL != m_pDebug )
  233. {
  234. ClientFree( m_pDebug );
  235. }
  236. #endif
  237. }
  238. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  239. //
  240. //
  241. //
  242. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  243. void HandleLineRequest( CTAPI * pTapi, PASYNCEVENTMSG pParams )
  244. {
  245. HRESULT hr;
  246. LINEREQMAKECALLW * pReqMakeCall;
  247. LOG((TL_TRACE, "HandleLineRequest - enter"));
  248. if ( CTAPI::FindTapiObject( pTapi ) )
  249. {
  250. while( 1 )
  251. {
  252. hr = LineGetRequest( pTapi->GetHLineApp(), LINEREQUESTMODE_MAKECALL, &pReqMakeCall );
  253. if ( !SUCCEEDED(hr) )
  254. {
  255. LOG((TL_ERROR, "LineGetRequest failed - %lx", hr));
  256. //release the reference added by FindTapiObject.
  257. pTapi->Release();
  258. return;
  259. }
  260. LOG((TL_INFO, "HandleLineRequest - destAddress: %S", pReqMakeCall->szDestAddress));
  261. LOG((TL_INFO, "HandleLineRequest - AppName : %S", pReqMakeCall->szAppName));
  262. LOG((TL_INFO, "HandleLineRequest - CalledParty: %S", pReqMakeCall->szCalledParty));
  263. LOG((TL_INFO, "HandleLineRequest - Comment : %S", pReqMakeCall->szComment));
  264. LOG((TL_INFO, "HandleLineRequest - about to fire event"));
  265. hr = CRequestEvent::FireEvent(
  266. pTapi,
  267. pParams->OpenContext,
  268. pReqMakeCall
  269. );
  270. LOG((TL_INFO, "HandleLineRequest - fire event result %d", hr));
  271. }
  272. //release the reference added by FindTapiObject.
  273. pTapi->Release();
  274. }
  275. LOG((TL_TRACE, "HandleLineRequest - exit"));
  276. }