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.

709 lines
16 KiB

  1. #include "stdafx.h"
  2. #include "t3test.h"
  3. #include "t3testD.h"
  4. #include "calldlg.h"
  5. #include "callnot.h"
  6. #include "externs.h"
  7. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  8. //
  9. // UpdateMediaTypes
  10. //
  11. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  12. void CT3testDlg::UpdateMediaTypes(
  13. ITAddress * pAddress
  14. )
  15. {
  16. long lMediaType;
  17. ITMediaSupport * pMediaSupport;
  18. HRESULT hr;
  19. //
  20. // get the media support interface
  21. //
  22. pAddress->QueryInterface(
  23. IID_ITMediaSupport,
  24. (void **)&pMediaSupport
  25. );
  26. //
  27. // get the mediatype enumerator
  28. //
  29. pMediaSupport->get_MediaTypes(&lMediaType);
  30. //
  31. // release the interface
  32. //
  33. pMediaSupport->Release();
  34. gbUpdatingStuff = TRUE;
  35. //
  36. // go through the supported mediatypes
  37. //
  38. DWORD dwMediaType = 1;
  39. DWORD dwHold = (DWORD)lMediaType;
  40. while (dwMediaType)
  41. {
  42. if ( dwMediaType & dwHold )
  43. {
  44. AddMediaType( (long) dwMediaType );
  45. }
  46. dwMediaType <<=1;
  47. }
  48. gbUpdatingStuff = FALSE;
  49. //
  50. // select the first
  51. // media type
  52. //
  53. SelectFirstItem(
  54. ghMediaTypesWnd,
  55. ghMediaTypesRoot
  56. );
  57. //
  58. // release and redo terminals
  59. //
  60. ReleaseTerminals();
  61. ReleaseTerminalClasses();
  62. if ( GetMediaType( &lMediaType ) )
  63. {
  64. UpdateTerminals( pAddress, lMediaType );
  65. UpdateTerminalClasses( pAddress, lMediaType );
  66. }
  67. }
  68. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  69. //
  70. // UpdateCalls
  71. //
  72. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  73. void CT3testDlg::UpdateCalls(
  74. ITAddress * pAddress
  75. )
  76. {
  77. IEnumCall * pEnumCall;
  78. HRESULT hr;
  79. ITCallInfo * pCallInfo;
  80. //
  81. // enumerate the current calls
  82. //
  83. pAddress->EnumerateCalls( &pEnumCall );
  84. //
  85. // go through the list
  86. // and add the calls to the tree
  87. //
  88. while (TRUE)
  89. {
  90. hr = pEnumCall->Next( 1, &pCallInfo, NULL);
  91. if (S_OK != hr)
  92. {
  93. break;
  94. }
  95. AddCall(pCallInfo);
  96. UpdateCall( pCallInfo );
  97. //
  98. // release this reference
  99. //
  100. pCallInfo->Release();
  101. }
  102. pEnumCall->Release();
  103. }
  104. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  105. //
  106. // UpdateSelectedCalls
  107. //
  108. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  109. void CT3testDlg::UpdateSelectedCalls(
  110. ITPhone * pPhone
  111. )
  112. {
  113. IEnumCall * pEnumCall;
  114. HRESULT hr;
  115. ITCallInfo * pCallInfo;
  116. ITAutomatedPhoneControl * pPhoneControl;
  117. //
  118. // get the automated phone control interface
  119. //
  120. hr = pPhone->QueryInterface(IID_ITAutomatedPhoneControl, (void **)&pPhoneControl);
  121. if (S_OK != hr)
  122. {
  123. return;
  124. }
  125. //
  126. // enumerate the current calls
  127. //
  128. pPhoneControl->EnumerateSelectedCalls( &pEnumCall );
  129. pPhoneControl->Release();
  130. //
  131. // go through the list
  132. // and add the calls to the tree
  133. //
  134. while (TRUE)
  135. {
  136. hr = pEnumCall->Next( 1, &pCallInfo, NULL);
  137. if (S_OK != hr)
  138. {
  139. break;
  140. }
  141. AddSelectedCall(pCallInfo);
  142. //
  143. // release this reference
  144. //
  145. pCallInfo->Release();
  146. }
  147. pEnumCall->Release();
  148. }
  149. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  150. //
  151. // UpdateCall
  152. //
  153. // check the call's state and privelege, and update the call
  154. //
  155. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  156. void CT3testDlg::UpdateCall( ITCallInfo * pCall )
  157. {
  158. HTREEITEM hItem, hParent;
  159. TV_ITEM item;
  160. CALL_PRIVILEGE cp;
  161. CALL_STATE cs;
  162. TV_INSERTSTRUCT tvi;
  163. //
  164. // get the first call
  165. //
  166. item.mask = TVIF_HANDLE | TVIF_PARAM;
  167. hItem = TreeView_GetChild(
  168. ghCallsWnd,
  169. ghCallsRoot
  170. );
  171. //
  172. // go through all the calls
  173. // and look for the one that matches
  174. // the one passed in
  175. //
  176. while (NULL != hItem)
  177. {
  178. item.hItem = hItem;
  179. TreeView_GetItem(
  180. ghCallsWnd,
  181. &item
  182. );
  183. if ( item.lParam == (LPARAM)pCall )
  184. {
  185. break;
  186. }
  187. hItem = TreeView_GetNextSibling(
  188. ghCallsWnd,
  189. hItem
  190. );
  191. }
  192. //
  193. // did we find it?
  194. //
  195. if (NULL == hItem)
  196. {
  197. return;
  198. }
  199. hParent = hItem;
  200. //
  201. // delete the current children of the call
  202. // node (these are the old privelege and state
  203. //
  204. hItem = TreeView_GetChild(
  205. ghCallsWnd,
  206. hItem
  207. );
  208. while (NULL != hItem)
  209. {
  210. HTREEITEM hNewItem;
  211. hNewItem = TreeView_GetNextSibling(
  212. ghCallsWnd,
  213. hItem
  214. );
  215. TreeView_DeleteItem(
  216. ghCallsWnd,
  217. hItem
  218. );
  219. hItem = hNewItem;
  220. }
  221. tvi.hInsertAfter = TVI_LAST;
  222. //
  223. // get the current privilege
  224. //
  225. tvi.item.pszText = GetCallPrivilegeName( pCall );
  226. //
  227. // add it as a child of the
  228. // call node
  229. //
  230. tvi.hParent = hParent;
  231. tvi.item.mask = TVIF_TEXT;
  232. TreeView_InsertItem(
  233. ghCallsWnd,
  234. &tvi
  235. );
  236. SysFreeString( tvi.item.pszText );
  237. //
  238. // get the current callstate
  239. //
  240. tvi.item.pszText = GetCallStateName( pCall );
  241. //
  242. // add it as a child of the call
  243. // node
  244. //
  245. tvi.hParent = hParent;
  246. tvi.item.mask = TVIF_TEXT;
  247. TreeView_InsertItem(
  248. ghCallsWnd,
  249. &tvi
  250. );
  251. SysFreeString( tvi.item.pszText );
  252. }
  253. void CT3testDlg::UpdatePhones(
  254. ITAddress * pAddress
  255. )
  256. {
  257. ITAddress2 * pAddress2;
  258. IEnumPhone * pEnumPhones;
  259. HRESULT hr;
  260. ITPhone * pPhone;
  261. //
  262. // get the address2 interface
  263. //
  264. hr = pAddress->QueryInterface(
  265. IID_ITAddress2,
  266. (void **) &pAddress2
  267. );
  268. if ( !SUCCEEDED(hr) )
  269. {
  270. return;
  271. }
  272. //
  273. // enumerate the phones
  274. //
  275. pAddress2->EnumeratePhones( &pEnumPhones );
  276. //
  277. // go through the phones
  278. //
  279. while (TRUE)
  280. {
  281. hr = pEnumPhones->Next( 1, &pPhone, NULL);
  282. if (S_OK != hr)
  283. {
  284. break;
  285. }
  286. AddPhone(pPhone);
  287. UpdatePhone(pPhone);
  288. //
  289. // release
  290. //
  291. pPhone->Release();
  292. }
  293. //
  294. // release enumerator
  295. //
  296. pEnumPhones->Release();
  297. //
  298. // release
  299. //
  300. pAddress2->Release();
  301. //
  302. // select
  303. //
  304. SelectFirstItem(
  305. ghPhonesWnd,
  306. ghPhonesRoot
  307. );
  308. }
  309. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  310. //
  311. // UpdatePhone
  312. //
  313. // check the call's state and privelege, and update the call
  314. //
  315. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  316. void CT3testDlg::UpdatePhone( ITPhone * pPhone )
  317. {
  318. HTREEITEM hItem, hParent;
  319. TV_ITEM item;
  320. PHONE_PRIVILEGE pp;
  321. TV_INSERTSTRUCT tvi;
  322. //
  323. // get the first phone
  324. //
  325. item.mask = TVIF_HANDLE | TVIF_PARAM;
  326. hItem = TreeView_GetChild(
  327. ghPhonesWnd,
  328. ghPhonesRoot
  329. );
  330. //
  331. // go through all the phones
  332. // and look for the one that matches
  333. // the one passed in
  334. //
  335. while (NULL != hItem)
  336. {
  337. item.hItem = hItem;
  338. TreeView_GetItem(
  339. ghPhonesWnd,
  340. &item
  341. );
  342. if ( item.lParam == (LPARAM)pPhone )
  343. {
  344. break;
  345. }
  346. hItem = TreeView_GetNextSibling(
  347. ghPhonesWnd,
  348. hItem
  349. );
  350. }
  351. //
  352. // did we find it?
  353. //
  354. if (NULL == hItem)
  355. {
  356. return;
  357. }
  358. hParent = hItem;
  359. //
  360. // delete the current children of the phone
  361. // node (these are the old privelege)
  362. //
  363. hItem = TreeView_GetChild(
  364. ghPhonesWnd,
  365. hItem
  366. );
  367. while (NULL != hItem)
  368. {
  369. HTREEITEM hNewItem;
  370. hNewItem = TreeView_GetNextSibling(
  371. ghPhonesWnd,
  372. hItem
  373. );
  374. TreeView_DeleteItem(
  375. ghPhonesWnd,
  376. hItem
  377. );
  378. hItem = hNewItem;
  379. }
  380. tvi.hInsertAfter = TVI_LAST;
  381. //
  382. // get the current privilege
  383. //
  384. if (tvi.item.pszText = GetPhonePrivilegeName( pPhone ))
  385. {
  386. //
  387. // add it as a child of the
  388. // call node
  389. //
  390. tvi.hParent = hParent;
  391. tvi.item.mask = TVIF_TEXT;
  392. TreeView_InsertItem(
  393. ghPhonesWnd,
  394. &tvi
  395. );
  396. SysFreeString( tvi.item.pszText );
  397. }
  398. }
  399. void CT3testDlg::UpdateTerminals(
  400. ITAddress * pAddress,
  401. long lMediaType
  402. )
  403. {
  404. ITTerminalSupport * pTerminalSupport;
  405. IEnumTerminal * pEnumTerminals;
  406. HRESULT hr;
  407. ITTerminal * pTerminal;
  408. //
  409. // get the terminalsupport interface
  410. //
  411. hr = pAddress->QueryInterface(
  412. IID_ITTerminalSupport,
  413. (void **) &pTerminalSupport
  414. );
  415. if ( !SUCCEEDED(hr) )
  416. {
  417. return;
  418. }
  419. //
  420. // enumerate the terminals
  421. //
  422. pTerminalSupport->EnumerateStaticTerminals( &pEnumTerminals );
  423. //
  424. // go through the terminals
  425. //
  426. while (TRUE)
  427. {
  428. VARIANT_BOOL bSupport;
  429. BSTR bstr;
  430. long l;
  431. hr = pEnumTerminals->Next( 1, &pTerminal, NULL);
  432. if (S_OK != hr)
  433. {
  434. break;
  435. }
  436. //
  437. // get the name
  438. //
  439. hr = pTerminal->get_Name( &bstr );
  440. //
  441. // if it's a unimodem or a direct sound
  442. // device don't show it, cause they bother
  443. // me
  444. //
  445. if (wcsstr( bstr, L"Voice Modem" ) || wcsstr( bstr, L"ds:" ) )
  446. {
  447. pTerminal->Release();
  448. SysFreeString( bstr );
  449. continue;
  450. }
  451. //
  452. // free the name
  453. //
  454. SysFreeString( bstr );
  455. //
  456. // get the mediatype of the terminal
  457. //
  458. pTerminal->get_MediaType( &l );
  459. //
  460. // if it's the same as the selected mediatype
  461. // show it
  462. //
  463. if ( l == lMediaType )
  464. {
  465. AddTerminal(pTerminal);
  466. }
  467. //
  468. // release
  469. //
  470. pTerminal->Release();
  471. }
  472. //
  473. // release enumerator
  474. //
  475. pEnumTerminals->Release();
  476. //
  477. // release
  478. //
  479. pTerminalSupport->Release();
  480. //
  481. // select
  482. //
  483. SelectFirstItem(
  484. ghTerminalsWnd,
  485. ghTerminalsRoot
  486. );
  487. }
  488. void CT3testDlg::UpdateTerminalClasses(
  489. ITAddress * pAddress,
  490. long lMediaType
  491. )
  492. {
  493. IEnumTerminalClass * pEnumTerminalClasses;
  494. HRESULT hr;
  495. ITTerminalSupport * pTerminalSupport;
  496. hr = pAddress->QueryInterface(
  497. IID_ITTerminalSupport,
  498. (void **)&pTerminalSupport
  499. );
  500. if (!SUCCEEDED(hr))
  501. {
  502. return;
  503. }
  504. //
  505. // now enum dymnamic
  506. //
  507. hr = pTerminalSupport->EnumerateDynamicTerminalClasses( &pEnumTerminalClasses );
  508. if (S_OK == hr)
  509. {
  510. //
  511. // go through all the classes
  512. //
  513. while (TRUE)
  514. {
  515. GUID * pDynTerminalClass = new GUID;
  516. hr = pEnumTerminalClasses->Next(
  517. 1,
  518. pDynTerminalClass,
  519. NULL
  520. );
  521. if (S_OK != hr)
  522. {
  523. delete pDynTerminalClass;
  524. break;
  525. }
  526. //
  527. // manually match up mediatype and
  528. // class
  529. //
  530. if ( (lMediaType == (long)LINEMEDIAMODE_VIDEO) &&
  531. (*pDynTerminalClass == CLSID_VideoWindowTerm) )
  532. {
  533. AddTerminalClass(
  534. pDynTerminalClass
  535. );
  536. }
  537. #ifdef ENABLE_DIGIT_DETECTION_STUFF
  538. else if ( (lMediaType == (long)LINEMEDIAMODE_AUTOMATEDVOICE) &&
  539. ( *pDynTerminalClass == CLSID_DigitTerminal ) )
  540. {
  541. AddTerminalClass(
  542. pDynTerminalClass
  543. );
  544. }
  545. else if ( ((lMediaType == (long)LINEMEDIAMODE_DATAMODEM) ||
  546. (lMediaType == (long)LINEMEDIAMODE_G3FAX)) &&
  547. (*pDynTerminalClass == CLSID_DataTerminal) )
  548. {
  549. AddTerminalClass( pDynTerminalClass );
  550. }
  551. #endif // ENABLE_DIGIT_DETECTION_STUFF
  552. else
  553. {
  554. delete pDynTerminalClass;
  555. }
  556. }
  557. //
  558. // release enumerator
  559. //
  560. pEnumTerminalClasses->Release();
  561. }
  562. //
  563. // release this interface
  564. //
  565. pTerminalSupport->Release();
  566. }