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.

307 lines
7.9 KiB

  1. //
  2. #include "stdafx.h"
  3. #include "t3test.h"
  4. #include "t3testd.h"
  5. #include "callnot.h"
  6. #include "control.h"
  7. #ifdef _DEBUG
  8. #ifndef _WIN64 // mfc 4.2's heap debugging features generate warnings on win64
  9. #define new DEBUG_NEW
  10. #endif
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. extern CWnd * gpmainwnd;
  15. HandleVideoWindowCrap(
  16. ITCallInfo * pCallInfo
  17. );
  18. HRESULT
  19. STDMETHODCALLTYPE
  20. CTAPIEventNotification::Event(
  21. TAPI_EVENT TapiEvent,
  22. IDispatch * pEvent
  23. )
  24. {
  25. HRESULT hr;
  26. pEvent->AddRef();
  27. hr = PostMessage( gpmainwnd->m_hWnd, WM_USER+101, (WPARAM)TapiEvent, (LPARAM)pEvent );
  28. return hr;
  29. }
  30. afx_msg LONG CT3testDlg::OnTapiEvent(UINT u, LONG_PTR l)
  31. {
  32. HRESULT hr;
  33. TAPI_EVENT TapiEvent;
  34. IDispatch * pEvent;
  35. TapiEvent = (TAPI_EVENT)u;
  36. pEvent = (IDispatch *)l;
  37. switch (TapiEvent)
  38. {
  39. case TE_CALLNOTIFICATION:
  40. {
  41. ITAddress * pAddress;
  42. ITAddress * pCallAddress;
  43. ITCallInfo * pCallInfo;
  44. ITCallNotificationEvent * pCallNotify;
  45. //
  46. // get the currently selected address
  47. //
  48. if (CT3testDlg::GetAddress( &pAddress ))
  49. {
  50. //
  51. // get the event
  52. //
  53. pEvent->QueryInterface(IID_ITCallNotificationEvent, (void **)&pCallNotify );
  54. //
  55. // get the call
  56. //
  57. pCallNotify->get_Call( &pCallInfo );
  58. //
  59. // get the call's event
  60. //
  61. pCallInfo->get_Address( &pCallAddress );
  62. //
  63. // if this call is supposed to be on this
  64. // address, add it to the UI
  65. //
  66. if (pAddress == pCallAddress)
  67. {
  68. // need to add a second reference for
  69. // the tree view
  70. CT3testDlg::AddCall( pCallInfo );
  71. }
  72. CALL_PRIVILEGE cp;
  73. CALL_STATE cs;
  74. pCallInfo->get_Privilege( &cp );
  75. if ( CP_OWNER == cp )
  76. {
  77. DoAutoAnswer( pCallInfo );
  78. }
  79. pCallInfo->get_CallState(&cs);
  80. //
  81. // release our references
  82. // keep refernce to the call or it will
  83. // be destroyed
  84. //
  85. pCallAddress->Release();
  86. pCallNotify->Release();
  87. }
  88. }
  89. break;
  90. case TE_CALLSTATE:
  91. {
  92. ITCallStateEvent * pCallStateEvent;
  93. ITCallInfo * pCallInfo;
  94. CALL_STATE cs;
  95. hr = pEvent->QueryInterface(IID_ITCallStateEvent, (void **)&pCallStateEvent);
  96. pCallStateEvent->get_Call( &pCallInfo );
  97. CT3testDlg::UpdateCall( pCallInfo );
  98. pCallStateEvent->get_State(
  99. &cs
  100. );
  101. if (CS_CONNECTED == cs)
  102. {
  103. // HandleVideoWindowCrap( pCallInfo );
  104. }
  105. pCallInfo->Release();
  106. pCallStateEvent->Release();
  107. break;
  108. }
  109. case TE_CALLHUB:
  110. {
  111. CT3testDlg::HandleCallHubEvent( pEvent );
  112. break;
  113. }
  114. case TE_TAPIOBJECT:
  115. {
  116. CT3testDlg::HandleTapiObjectMessage( pEvent );
  117. break;
  118. }
  119. case TE_ADDRESS:
  120. {
  121. CT3testDlg::HandleAddressEvent( pEvent );
  122. break;
  123. }
  124. case TE_PHONEEVENT:
  125. {
  126. CT3testDlg::HandlePhoneEvent( pEvent );
  127. break;
  128. }
  129. break;
  130. case TE_CALLMEDIA:
  131. {
  132. WCHAR * pwstrEvent;
  133. WCHAR * pwstrCause;
  134. ITCallMediaEvent * pCallMediaEvent;
  135. hr = pEvent->QueryInterface( IID_ITCallMediaEvent,
  136. (void **)&pCallMediaEvent );
  137. if (FAILED(hr))
  138. {
  139. pwstrEvent = pwstrCause = L"can't get event interface";
  140. }
  141. else
  142. {
  143. CALL_MEDIA_EVENT cme;
  144. hr = pCallMediaEvent->get_Event( &cme );
  145. if (FAILED(hr))
  146. {
  147. pwstrEvent = L"can't get event type";
  148. }
  149. else
  150. {
  151. switch ( cme )
  152. {
  153. case CME_NEW_STREAM:
  154. pwstrEvent = L"CME_NEW_STREAM";
  155. break;
  156. case CME_STREAM_FAIL:
  157. pwstrEvent = L"CME_STREAM_FAIL";
  158. break;
  159. case CME_TERMINAL_FAIL:
  160. pwstrEvent = L"CME_TERMINAL_FAIL";
  161. break;
  162. case CME_STREAM_NOT_USED:
  163. pwstrEvent = L"CME_STREAM_NOT_USED";
  164. break;
  165. case CME_STREAM_ACTIVE:
  166. pwstrEvent = L"CME_STREAM_ACTIVE";
  167. break;
  168. case CME_STREAM_INACTIVE:
  169. pwstrEvent = L"CME_STREAM_INACTIVE";
  170. break;
  171. default:
  172. pwstrEvent = L"type undefined";
  173. break;
  174. }
  175. }
  176. }
  177. CALL_MEDIA_EVENT_CAUSE cmec;
  178. hr = pCallMediaEvent->get_Cause( &cmec );
  179. pCallMediaEvent->Release();
  180. if (FAILED(hr))
  181. {
  182. pwstrCause = L"can't get event cause";
  183. }
  184. else
  185. {
  186. switch ( cmec )
  187. {
  188. case CMC_UNKNOWN:
  189. pwstrCause = L"CMC_UNKNOWN";
  190. break;
  191. case CMC_BAD_DEVICE:
  192. pwstrCause = L"CMC_BAD_DEVICE";
  193. break;
  194. case CMC_CONNECT_FAIL:
  195. pwstrCause = L"CMC_CONNECT_FAIL";
  196. break;
  197. case CMC_LOCAL_REQUEST:
  198. pwstrCause = L"CMC_LOCAL_REQUEST";
  199. break;
  200. case CMC_REMOTE_REQUEST:
  201. pwstrCause = L"CMC_REMOTE_REQUEST";
  202. break;
  203. case CMC_MEDIA_TIMEOUT:
  204. pwstrCause = L"CMC_MEDIA_TIMEOUT";
  205. break;
  206. case CMC_MEDIA_RECOVERED:
  207. pwstrCause = L"CMC_MEDIA_RECOVERED";
  208. break;
  209. default:
  210. pwstrCause = L"cause undefined";
  211. break;
  212. }
  213. }
  214. ::MessageBox(NULL, pwstrEvent, pwstrCause, MB_OK);
  215. break;
  216. }
  217. default:
  218. break;
  219. }
  220. pEvent->Release();
  221. return S_OK;
  222. }
  223. #ifdef ENABLE_DIGIT_DETECTION_STUFF
  224. HRESULT
  225. STDMETHODCALLTYPE
  226. CDigitDetectionNotification::DigitDetected(
  227. unsigned char ucDigit,
  228. TAPI_DIGITMODE DigitMode,
  229. long ulTickCount
  230. )
  231. {
  232. return S_OK;
  233. }
  234. #endif // ENABLE_DIGIT_DETECTION_STUFF