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.

411 lines
15 KiB

  1. #include "stdafx.h"
  2. #include "t3test.h"
  3. #include "t3testD.h"
  4. #include "externs.h"
  5. void
  6. CT3testDlg::HandleCallHubEvent( IDispatch * pEvent )
  7. {
  8. HRESULT hr;
  9. ITCallHubEvent * pCallHubEvent;
  10. CALLHUB_EVENT che;
  11. hr = pEvent->QueryInterface(
  12. IID_ITCallHubEvent,
  13. (void **)&pCallHubEvent
  14. );
  15. if (!SUCCEEDED(hr))
  16. {
  17. return;
  18. }
  19. hr = pCallHubEvent->get_Event( &che );
  20. if (!SUCCEEDED(hr))
  21. {
  22. return;
  23. }
  24. switch ( che )
  25. {
  26. case CHE_CALLHUBNEW:
  27. break;
  28. case CHE_CALLHUBIDLE:
  29. break;
  30. default:
  31. break;
  32. }
  33. pCallHubEvent->Release();
  34. }
  35. void
  36. CT3testDlg::HandleTapiObjectMessage( IDispatch * pEvent )
  37. {
  38. ITTAPIObjectEvent * pte;
  39. HRESULT hr;
  40. TAPIOBJECT_EVENT te;
  41. hr = pEvent->QueryInterface(
  42. IID_ITTAPIObjectEvent,
  43. (void**)&pte
  44. );
  45. if ( !SUCCEEDED(hr) )
  46. {
  47. return;
  48. }
  49. pte->get_Event( &te );
  50. switch (te)
  51. {
  52. case TE_ADDRESSCREATE:
  53. case TE_ADDRESSREMOVE:
  54. ReleaseMediaTypes();
  55. ReleaseTerminals();
  56. ReleaseCalls();
  57. ReleasePhones();
  58. ReleaseSelectedTerminals();
  59. ReleaseCreatedTerminals();
  60. ReleaseTerminalClasses();
  61. ReleaseListen();
  62. ReleaseAddresses();
  63. InitializeAddressTree();
  64. break;
  65. case TE_PHONECREATE:
  66. case TE_PHONEREMOVE:
  67. {
  68. ITAddress * pSelectedAddress;
  69. ITTAPIObjectEvent2 * pTAPIObjectEvent2;
  70. ITPhone * pPhone;
  71. BSTR bstrName = NULL;
  72. hr = pte->QueryInterface(IID_ITTAPIObjectEvent2, (void **)&pTAPIObjectEvent2);
  73. if (SUCCEEDED(hr))
  74. {
  75. hr = pTAPIObjectEvent2->get_Phone( &pPhone );
  76. if (SUCCEEDED(hr))
  77. {
  78. hr = pPhone->get_PhoneCapsString( PCS_PHONENAME, &bstrName );
  79. if (SUCCEEDED(hr))
  80. {
  81. switch(te)
  82. {
  83. case TE_PHONECREATE:
  84. ::MessageBox(NULL, bstrName, L"TE_PHONECREATE", MB_OK);
  85. break;
  86. case TE_PHONEREMOVE:
  87. ::MessageBox(NULL, bstrName, L"TE_PHONEREMOVE", MB_OK);
  88. break;
  89. }
  90. SysFreeString( bstrName );
  91. }
  92. pPhone->Release();
  93. }
  94. pTAPIObjectEvent2->Release();
  95. }
  96. if ( GetAddress( &pSelectedAddress ) )
  97. {
  98. ReleasePhones();
  99. UpdatePhones( pSelectedAddress );
  100. }
  101. }
  102. break;
  103. default:
  104. break;
  105. }
  106. pte->Release();
  107. }
  108. void
  109. CT3testDlg::HandleAddressEvent( IDispatch * pEvent )
  110. {
  111. ITAddressEvent * pAddressEvent;
  112. ITTerminal * pTerminal;
  113. ITAddress * pAddress;
  114. ITAddress * pSelectedAddress;
  115. LONG lMediaType;
  116. LONG lSelectedMediaType;
  117. BSTR bstrName = NULL;
  118. ADDRESS_EVENT ae;
  119. HRESULT hr;
  120. hr = pEvent->QueryInterface(IID_ITAddressEvent, (void **)&pAddressEvent);
  121. if (SUCCEEDED(hr))
  122. {
  123. hr = pAddressEvent->get_Event( &ae );
  124. if (SUCCEEDED(hr))
  125. {
  126. if ( (ae == AE_NEWTERMINAL) || (ae == AE_REMOVETERMINAL) )
  127. {
  128. hr = pAddressEvent->get_Terminal( &pTerminal );
  129. if (SUCCEEDED(hr))
  130. {
  131. hr = pTerminal->get_Name( &bstrName );
  132. if (SUCCEEDED(hr))
  133. {
  134. hr = pAddressEvent->get_Address( &pAddress );
  135. if (SUCCEEDED(hr))
  136. {
  137. hr = pTerminal->get_MediaType( &lMediaType );
  138. if (SUCCEEDED(hr))
  139. {
  140. if (CT3testDlg::GetMediaType( &lSelectedMediaType ) && ( lSelectedMediaType == lMediaType) &&
  141. CT3testDlg::GetAddress( &pSelectedAddress ) && ( pSelectedAddress == pAddress) )
  142. {
  143. switch(ae)
  144. {
  145. case AE_NEWTERMINAL:
  146. ::MessageBox(NULL, bstrName, L"AE_NEWTERMINAL", MB_OK);
  147. break;
  148. case AE_REMOVETERMINAL:
  149. ::MessageBox(NULL, bstrName, L"AE_REMOVETERMINAL", MB_OK);
  150. break;
  151. }
  152. CT3testDlg::ReleaseTerminals();
  153. CT3testDlg::UpdateTerminals( pAddress, lMediaType );
  154. }
  155. }
  156. pAddress->Release();
  157. }
  158. SysFreeString( bstrName );
  159. }
  160. pTerminal->Release();
  161. }
  162. }
  163. }
  164. pAddressEvent->Release();
  165. }
  166. }
  167. void
  168. CT3testDlg::HandlePhoneEvent( IDispatch * pEvent )
  169. {
  170. ITPhoneEvent * pPhoneEvent;
  171. ITPhone * pPhone;
  172. PHONE_EVENT pe;
  173. HRESULT hr;
  174. hr = pEvent->QueryInterface(IID_ITPhoneEvent, (void **)&pPhoneEvent);
  175. if (SUCCEEDED(hr))
  176. {
  177. hr = pPhoneEvent->get_Event( &pe );
  178. if (SUCCEEDED(hr))
  179. {
  180. hr = pPhoneEvent->get_Phone( &pPhone );
  181. if ( SUCCEEDED(hr) )
  182. {
  183. switch( pe )
  184. {
  185. case PE_DISPLAY:
  186. ::MessageBox(NULL, L"", L"PE_DISPLAY", MB_OK);
  187. break;
  188. case PE_LAMPMODE:
  189. ::MessageBox(NULL, L"", L"PE_LAMPMODE", MB_OK);
  190. break;
  191. case PE_RINGMODE:
  192. ::MessageBox(NULL, L"", L"PE_RINGMODE", MB_OK);
  193. break;
  194. case PE_RINGVOLUME:
  195. ::MessageBox(NULL, L"", L"PE_RINGVOLUME", MB_OK);
  196. break;
  197. case PE_HOOKSWITCH:
  198. {
  199. PHONE_HOOK_SWITCH_DEVICE HookSwitchDevice;
  200. PHONE_HOOK_SWITCH_STATE HookSwitchState;
  201. WCHAR szText[256];
  202. hr = pPhoneEvent->get_HookSwitchDevice( &HookSwitchDevice );
  203. if ( SUCCEEDED(hr) )
  204. {
  205. hr = pPhoneEvent->get_HookSwitchState( &HookSwitchState );
  206. if ( SUCCEEDED(hr) )
  207. {
  208. switch( HookSwitchDevice )
  209. {
  210. case PHSD_HANDSET:
  211. lstrcpyW(szText, L"PHSD_HANDSET");
  212. break;
  213. case PHSD_SPEAKERPHONE:
  214. lstrcpyW(szText, L"PHSD_SPEAKERPHONE");
  215. break;
  216. case PHSD_HEADSET:
  217. lstrcpyW(szText, L"PHSD_HEADSET");
  218. break;
  219. }
  220. switch( HookSwitchState )
  221. {
  222. case PHSS_ONHOOK:
  223. lstrcatW(szText, L" PHSS_ONHOOK");
  224. break;
  225. case PHSS_OFFHOOK:
  226. lstrcatW(szText, L" PHSS_OFFHOOK");
  227. break;
  228. }
  229. //::MessageBox(NULL, szText, L"PE_HOOKSWITCH", MB_OK);
  230. }
  231. }
  232. }
  233. break;
  234. case PE_CAPSCHANGE:
  235. ::MessageBox(NULL, L"", L"PE_CAPSCHANGE", MB_OK);
  236. break;
  237. case PE_BUTTON:
  238. {
  239. long lButtonId;
  240. BSTR pButtonText;
  241. WCHAR szText[256];
  242. PHONE_BUTTON_STATE ButtonState;
  243. hr = pPhoneEvent->get_ButtonLampId( &lButtonId );
  244. if ( SUCCEEDED(hr) )
  245. {
  246. hr = pPhone->get_ButtonText( lButtonId, &pButtonText );
  247. if ( SUCCEEDED( hr ) )
  248. {
  249. lstrcpyW(szText, pButtonText);
  250. //wsprintf(szText, L"%d", lButtonId);
  251. hr = pPhoneEvent->get_ButtonState( &ButtonState );
  252. if ( SUCCEEDED( hr ) )
  253. {
  254. switch( ButtonState )
  255. {
  256. case PBS_UP:
  257. lstrcatW(szText, L" PBS_UP");
  258. /*
  259. if ((lButtonId >= PT_KEYPADZERO) && (lButtonId <= PT_KEYPADPOUND))
  260. {
  261. ITAutomatedPhoneControl * pPhoneControl;
  262. //
  263. // get the automated phone control interface
  264. //
  265. hr = pPhone->QueryInterface(IID_ITAutomatedPhoneControl, (void **)&pPhoneControl);
  266. if (S_OK != hr)
  267. {
  268. ::MessageBox(NULL, L"QueryInterface failed", NULL, MB_OK);
  269. return;
  270. }
  271. PHONE_TONE Tone;
  272. pPhoneControl->get_Tone(&Tone);
  273. if ((long)Tone == lButtonId)
  274. {
  275. hr = pPhoneControl->StopTone();
  276. }
  277. pPhoneControl->Release();
  278. }
  279. */
  280. break;
  281. case PBS_DOWN:
  282. lstrcatW(szText, L" PBS_DOWN");
  283. /*
  284. if ((lButtonId >= PT_KEYPADZERO) && (lButtonId <= PT_KEYPADPOUND))
  285. {
  286. ITAutomatedPhoneControl * pPhoneControl;
  287. //
  288. // get the automated phone control interface
  289. //
  290. hr = pPhone->QueryInterface(IID_ITAutomatedPhoneControl, (void **)&pPhoneControl);
  291. if (S_OK != hr)
  292. {
  293. ::MessageBox(NULL, L"QueryInterface failed", NULL, MB_OK);
  294. return;
  295. }
  296. hr = pPhoneControl->StartTone((PHONE_TONE)lButtonId, 0);
  297. pPhoneControl->Release();
  298. }
  299. */
  300. break;
  301. case PBS_UNKNOWN:
  302. lstrcatW(szText, L" PBS_UNKNOWN");
  303. break;
  304. case PBS_UNAVAIL:
  305. lstrcatW(szText, L" PBS_UNAVAIL");
  306. break;
  307. }
  308. //::MessageBox(NULL, szText, L"PE_BUTTON", MB_OK);
  309. }
  310. //SysFreeString( pButtonText );
  311. }
  312. }
  313. }
  314. break;
  315. case PE_CLOSE:
  316. ::MessageBox(NULL, L"", L"PE_CLOSE", MB_OK);
  317. break;
  318. case PE_NUMBERGATHERED:
  319. {
  320. BSTR pNumberGathered;
  321. hr = pPhoneEvent->get_NumberGathered( &pNumberGathered );
  322. if ( SUCCEEDED(hr) && (pNumberGathered != NULL) )
  323. {
  324. ::MessageBox(NULL, pNumberGathered, L"PE_NUMBERGATHERED", MB_OK);
  325. }
  326. }
  327. break;
  328. }
  329. pPhone->Release();
  330. }
  331. }
  332. pPhoneEvent->Release();
  333. }
  334. }