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.

475 lines
10 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. // UpdateCall
  107. //
  108. // check the call's state and privelege, and update the call
  109. //
  110. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  111. void CT3testDlg::UpdateCall( ITCallInfo * pCall )
  112. {
  113. HTREEITEM hItem, hParent;
  114. TV_ITEM item;
  115. CALL_PRIVILEGE cp;
  116. CALL_STATE cs;
  117. TV_INSERTSTRUCT tvi;
  118. //
  119. // get the first call
  120. //
  121. item.mask = TVIF_HANDLE | TVIF_PARAM;
  122. hItem = TreeView_GetChild(
  123. ghCallsWnd,
  124. ghCallsRoot
  125. );
  126. //
  127. // go through all the calls
  128. // and look for the one that matches
  129. // the one passed in
  130. //
  131. while (NULL != hItem)
  132. {
  133. item.hItem = hItem;
  134. TreeView_GetItem(
  135. ghCallsWnd,
  136. &item
  137. );
  138. if ( item.lParam == (LPARAM)pCall )
  139. {
  140. break;
  141. }
  142. hItem = TreeView_GetNextSibling(
  143. ghCallsWnd,
  144. hItem
  145. );
  146. }
  147. //
  148. // did we find it?
  149. //
  150. if (NULL == hItem)
  151. {
  152. return;
  153. }
  154. hParent = hItem;
  155. //
  156. // delete the current children of the call
  157. // node (these are the old privelege and state
  158. //
  159. hItem = TreeView_GetChild(
  160. ghCallsWnd,
  161. hItem
  162. );
  163. while (NULL != hItem)
  164. {
  165. HTREEITEM hNewItem;
  166. hNewItem = TreeView_GetNextSibling(
  167. ghCallsWnd,
  168. hItem
  169. );
  170. TreeView_DeleteItem(
  171. ghCallsWnd,
  172. hItem
  173. );
  174. hItem = hNewItem;
  175. }
  176. tvi.hInsertAfter = TVI_LAST;
  177. //
  178. // get the current privilege
  179. //
  180. tvi.item.pszText = GetCallPrivilegeName( pCall );
  181. //
  182. // add it as a child of the
  183. // call node
  184. //
  185. tvi.hParent = hParent;
  186. tvi.item.mask = TVIF_TEXT;
  187. TreeView_InsertItem(
  188. ghCallsWnd,
  189. &tvi
  190. );
  191. SysFreeString( tvi.item.pszText );
  192. //
  193. // get the current callstate
  194. //
  195. tvi.item.pszText = GetCallStateName( pCall );
  196. //
  197. // add it as a child of the call
  198. // node
  199. //
  200. tvi.hParent = hParent;
  201. tvi.item.mask = TVIF_TEXT;
  202. TreeView_InsertItem(
  203. ghCallsWnd,
  204. &tvi
  205. );
  206. SysFreeString( tvi.item.pszText );
  207. }
  208. void CT3testDlg::UpdateTerminals(
  209. ITAddress * pAddress,
  210. long lMediaType
  211. )
  212. {
  213. ITTerminalSupport * pTerminalSupport;
  214. IEnumTerminal * pEnumTerminals;
  215. HRESULT hr;
  216. ITTerminal * pTerminal;
  217. //
  218. // get the terminalsupport interface
  219. //
  220. hr = pAddress->QueryInterface(
  221. IID_ITTerminalSupport,
  222. (void **) &pTerminalSupport
  223. );
  224. if ( !SUCCEEDED(hr) )
  225. {
  226. return;
  227. }
  228. //
  229. // enumerate the terminals
  230. //
  231. pTerminalSupport->EnumerateStaticTerminals( &pEnumTerminals );
  232. //
  233. // go through the terminals
  234. //
  235. while (TRUE)
  236. {
  237. VARIANT_BOOL bSupport;
  238. BSTR bstr;
  239. long l;
  240. hr = pEnumTerminals->Next( 1, &pTerminal, NULL);
  241. if (S_OK != hr)
  242. {
  243. break;
  244. }
  245. //
  246. // get the name
  247. //
  248. hr = pTerminal->get_Name( &bstr );
  249. //
  250. // if it's a unimodem or a direct sound
  251. // device don't show it, cause they bother
  252. // me
  253. //
  254. if (wcsstr( bstr, L"Voice Modem" ) || wcsstr( bstr, L"ds:" ) )
  255. {
  256. pTerminal->Release();
  257. SysFreeString( bstr );
  258. continue;
  259. }
  260. //
  261. // free the name
  262. //
  263. SysFreeString( bstr );
  264. //
  265. // get the mediatype of the terminal
  266. //
  267. pTerminal->get_MediaType( &l );
  268. //
  269. // if it's the same as the selected mediatype
  270. // show it
  271. //
  272. if ( l == lMediaType )
  273. {
  274. AddTerminal(pTerminal);
  275. }
  276. //
  277. // release
  278. //
  279. pTerminal->Release();
  280. }
  281. //
  282. // release enumerator
  283. //
  284. pEnumTerminals->Release();
  285. //
  286. // release
  287. //
  288. pTerminalSupport->Release();
  289. //
  290. // select
  291. //
  292. SelectFirstItem(
  293. ghTerminalsWnd,
  294. ghTerminalsRoot
  295. );
  296. }
  297. void CT3testDlg::UpdateTerminalClasses(
  298. ITAddress * pAddress,
  299. long lMediaType
  300. )
  301. {
  302. IEnumTerminalClass * pEnumTerminalClasses;
  303. HRESULT hr;
  304. ITTerminalSupport * pTerminalSupport;
  305. hr = pAddress->QueryInterface(
  306. IID_ITTerminalSupport,
  307. (void **)&pTerminalSupport
  308. );
  309. if (!SUCCEEDED(hr))
  310. {
  311. return;
  312. }
  313. //
  314. // now enum dymnamic
  315. //
  316. hr = pTerminalSupport->EnumerateDynamicTerminalClasses( &pEnumTerminalClasses );
  317. if (S_OK == hr)
  318. {
  319. //
  320. // go through all the classes
  321. //
  322. while (TRUE)
  323. {
  324. GUID * pDynTerminalClass = new GUID;
  325. hr = pEnumTerminalClasses->Next(
  326. 1,
  327. pDynTerminalClass,
  328. NULL
  329. );
  330. if (S_OK != hr)
  331. {
  332. delete pDynTerminalClass;
  333. break;
  334. }
  335. //
  336. // manually match up mediatype and
  337. // class
  338. //
  339. if ( (lMediaType == (long)LINEMEDIAMODE_VIDEO) &&
  340. (*pDynTerminalClass == CLSID_VideoWindowTerm) )
  341. {
  342. AddTerminalClass(
  343. pDynTerminalClass
  344. );
  345. }
  346. #ifdef ENABLE_DIGIT_DETECTION_STUFF
  347. else if ( (lMediaType == (long)LINEMEDIAMODE_AUTOMATEDVOICE) &&
  348. ( *pDynTerminalClass == CLSID_DigitTerminal ) )
  349. {
  350. AddTerminalClass(
  351. pDynTerminalClass
  352. );
  353. }
  354. else if ( ((lMediaType == (long)LINEMEDIAMODE_DATAMODEM) ||
  355. (lMediaType == (long)LINEMEDIAMODE_G3FAX)) &&
  356. (*pDynTerminalClass == CLSID_DataTerminal) )
  357. {
  358. AddTerminalClass( pDynTerminalClass );
  359. }
  360. #endif // ENABLE_DIGIT_DETECTION_STUFF
  361. else
  362. {
  363. delete pDynTerminalClass;
  364. }
  365. }
  366. //
  367. // release enumerator
  368. //
  369. pEnumTerminalClasses->Release();
  370. }
  371. //
  372. // release this interface
  373. //
  374. pTerminalSupport->Release();
  375. }