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.

362 lines
10 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. break;
  120. case TE_CALLMEDIA:
  121. {
  122. WCHAR * pwstrEvent;
  123. WCHAR * pwstrCause;
  124. ITCallMediaEvent * pCallMediaEvent;
  125. hr = pEvent->QueryInterface( IID_ITCallMediaEvent,
  126. (void **)&pCallMediaEvent );
  127. if (FAILED(hr))
  128. {
  129. pwstrEvent = pwstrCause = L"can't get event interface";
  130. }
  131. else
  132. {
  133. CALL_MEDIA_EVENT cme;
  134. hr = pCallMediaEvent->get_Event( &cme );
  135. if (FAILED(hr))
  136. {
  137. pwstrEvent = L"can't get event type";
  138. }
  139. else
  140. {
  141. switch ( cme )
  142. {
  143. case CME_NEW_STREAM:
  144. pwstrEvent = L"CME_NEW_STREAM";
  145. break;
  146. case CME_STREAM_FAIL:
  147. pwstrEvent = L"CME_STREAM_FAIL";
  148. break;
  149. case CME_TERMINAL_FAIL:
  150. pwstrEvent = L"CME_TERMINAL_FAIL";
  151. break;
  152. case CME_STREAM_NOT_USED:
  153. pwstrEvent = L"CME_STREAM_NOT_USED";
  154. break;
  155. case CME_STREAM_ACTIVE:
  156. pwstrEvent = L"CME_STREAM_ACTIVE";
  157. break;
  158. case CME_STREAM_INACTIVE:
  159. pwstrEvent = L"CME_STREAM_INACTIVE";
  160. break;
  161. default:
  162. pwstrEvent = L"type undefined";
  163. break;
  164. }
  165. }
  166. }
  167. CALL_MEDIA_EVENT_CAUSE cmec;
  168. hr = pCallMediaEvent->get_Cause( &cmec );
  169. pCallMediaEvent->Release();
  170. if (FAILED(hr))
  171. {
  172. pwstrCause = L"can't get event cause";
  173. }
  174. else
  175. {
  176. switch ( cmec )
  177. {
  178. case CMC_UNKNOWN:
  179. pwstrCause = L"CMC_UNKNOWN";
  180. break;
  181. case CMC_BAD_DEVICE:
  182. pwstrCause = L"CMC_BAD_DEVICE";
  183. break;
  184. case CMC_CONNECT_FAIL:
  185. pwstrCause = L"CMC_CONNECT_FAIL";
  186. break;
  187. case CMC_LOCAL_REQUEST:
  188. pwstrCause = L"CMC_LOCAL_REQUEST";
  189. break;
  190. case CMC_REMOTE_REQUEST:
  191. pwstrCause = L"CMC_REMOTE_REQUEST";
  192. break;
  193. case CMC_MEDIA_TIMEOUT:
  194. pwstrCause = L"CMC_MEDIA_TIMEOUT";
  195. break;
  196. case CMC_MEDIA_RECOVERED:
  197. pwstrCause = L"CMC_MEDIA_RECOVERED";
  198. break;
  199. default:
  200. pwstrCause = L"cause undefined";
  201. break;
  202. }
  203. }
  204. ::MessageBox(NULL, pwstrEvent, pwstrCause, MB_OK);
  205. break;
  206. }
  207. case TE_ADDRESS:
  208. {
  209. ITAddressEvent * pAddressEvent;
  210. ITTerminal * pTerminal;
  211. ITAddress * pAddress;
  212. LONG lMediaType;
  213. LONG lSelectedMediaType;
  214. BSTR bstrName = NULL;
  215. ADDRESS_EVENT ae;
  216. hr = pEvent->QueryInterface(IID_ITAddressEvent, (void **)&pAddressEvent);
  217. if (SUCCEEDED(hr))
  218. {
  219. hr = pAddressEvent->get_Event( &ae );
  220. if (SUCCEEDED(hr))
  221. {
  222. hr = pAddressEvent->get_Terminal( &pTerminal );
  223. if (SUCCEEDED(hr))
  224. {
  225. hr = pTerminal->get_Name( &bstrName );
  226. if (SUCCEEDED(hr))
  227. {
  228. switch(ae)
  229. {
  230. case AE_NEWTERMINAL:
  231. ::MessageBox(NULL, bstrName, L"AE_NEWTERMINAL", MB_OK);
  232. break;
  233. case AE_REMOVETERMINAL:
  234. ::MessageBox(NULL, bstrName, L"AE_REMOVETERMINAL", MB_OK);
  235. break;
  236. }
  237. SysFreeString( bstrName );
  238. hr = pAddressEvent->get_Address( &pAddress );
  239. if (SUCCEEDED(hr))
  240. {
  241. hr = pTerminal->get_MediaType( &lMediaType );
  242. if (SUCCEEDED(hr))
  243. {
  244. if (CT3testDlg::GetMediaType( &lSelectedMediaType ) && ( lSelectedMediaType == lMediaType))
  245. {
  246. CT3testDlg::ReleaseTerminals();
  247. CT3testDlg::UpdateTerminals( pAddress, lMediaType );
  248. }
  249. }
  250. pAddress->Release();
  251. }
  252. }
  253. pTerminal->Release();
  254. }
  255. }
  256. pAddressEvent->Release();
  257. }
  258. break;
  259. }
  260. default:
  261. break;
  262. }
  263. pEvent->Release();
  264. return S_OK;
  265. }
  266. #ifdef ENABLE_DIGIT_DETECTION_STUFF
  267. HRESULT
  268. STDMETHODCALLTYPE
  269. CDigitDetectionNotification::DigitDetected(
  270. unsigned char ucDigit,
  271. TAPI_DIGITMODE DigitMode,
  272. long ulTickCount
  273. )
  274. {
  275. return S_OK;
  276. }
  277. #endif // ENABLE_DIGIT_DETECTION_STUFF