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.

572 lines
12 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. // AddListen
  10. //
  11. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  12. void CT3testDlg::AddListen( long lMediaType )
  13. {
  14. WCHAR szName[256];
  15. TV_INSERTSTRUCT tvi;
  16. //
  17. // map the mediatype bstr to
  18. // a string name (like "audio in")
  19. //
  20. GetMediaTypeName(
  21. lMediaType,
  22. szName
  23. );
  24. //
  25. // insert that string into the
  26. // listen window
  27. //
  28. tvi.hParent = ghListenRoot;
  29. tvi.hInsertAfter = TVI_LAST;
  30. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  31. tvi.item.pszText = szName;
  32. tvi.item.lParam = (LPARAM) lMediaType;
  33. TreeView_InsertItem(
  34. ghListenWnd,
  35. &tvi
  36. );
  37. //
  38. // select the first item
  39. //
  40. SelectFirstItem(
  41. ghListenWnd,
  42. ghListenRoot
  43. );
  44. }
  45. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  46. //
  47. // AddAddressToTree
  48. //
  49. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  50. void CT3testDlg::AddAddressToTree( ITAddress * pAddress )
  51. {
  52. BSTR bstrName;
  53. TV_INSERTSTRUCT tvi;
  54. //
  55. // get the name of the address
  56. //
  57. pAddress->get_AddressName( &bstrName );
  58. //
  59. // set up struct
  60. //
  61. tvi.hParent = ghAddressesRoot;
  62. tvi.hInsertAfter = TVI_LAST;
  63. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  64. tvi.item.pszText = bstrName;
  65. tvi.item.lParam = (LPARAM) pAddress;
  66. //
  67. // addref
  68. //
  69. pAddress->AddRef();
  70. //
  71. // insert it
  72. //
  73. TreeView_InsertItem(
  74. ghAddressesWnd,
  75. &tvi
  76. );
  77. //
  78. // free name
  79. //
  80. SysFreeString( bstrName );
  81. }
  82. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  83. //
  84. // AddMediaType
  85. //
  86. // Add a mediatype to the mediatype tree
  87. //
  88. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  89. void CT3testDlg::AddMediaType( long lMediaType )
  90. {
  91. WCHAR szString[256];
  92. TV_INSERTSTRUCT tvi;
  93. //
  94. // get the displayable name
  95. //
  96. GetMediaTypeName(
  97. lMediaType,
  98. szString
  99. );
  100. //
  101. // set up struct
  102. //
  103. tvi.hParent = ghMediaTypesRoot;
  104. tvi.hInsertAfter = TVI_LAST;
  105. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  106. tvi.item.pszText = szString;
  107. tvi.item.lParam = (LPARAM) lMediaType;
  108. //
  109. // add the item
  110. //
  111. TreeView_InsertItem(
  112. ghMediaTypesWnd,
  113. &tvi
  114. );
  115. //
  116. // select the first item
  117. //
  118. SelectFirstItem(
  119. ghMediaTypesWnd,
  120. ghMediaTypesRoot
  121. );
  122. }
  123. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  124. //
  125. // AddCall
  126. //
  127. // Add a call to the call tree
  128. //
  129. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  130. void CT3testDlg::AddCall( ITCallInfo * pCall )
  131. {
  132. TV_INSERTSTRUCT tvi;
  133. HTREEITEM hItem;
  134. CALL_PRIVILEGE cp;
  135. CALL_STATE cs;
  136. WCHAR pszName[16];
  137. //
  138. // for the name of the call, use
  139. // the pointer!
  140. //
  141. wsprintf(
  142. pszName,
  143. L"0x%lx",
  144. pCall
  145. );
  146. //
  147. // set up struct
  148. //
  149. tvi.hParent = ghCallsRoot;
  150. tvi.hInsertAfter = TVI_LAST;
  151. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  152. tvi.item.pszText = pszName;
  153. tvi.item.lParam = (LPARAM) pCall;
  154. //
  155. // save a reference
  156. //
  157. pCall->AddRef();
  158. //
  159. // insert the item
  160. //
  161. hItem = TreeView_InsertItem(
  162. ghCallsWnd,
  163. &tvi
  164. );
  165. if (NULL != hItem)
  166. {
  167. //
  168. // select the item
  169. //
  170. TreeView_SelectItem(
  171. ghCallsWnd,
  172. hItem
  173. );
  174. }
  175. }
  176. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  177. //
  178. // AddTerminal
  179. //
  180. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  181. void CT3testDlg::AddTerminal( ITTerminal * pTerminal )
  182. {
  183. BSTR bstrName;
  184. BSTR bstrClass;
  185. TV_INSERTSTRUCT tvi;
  186. TERMINAL_DIRECTION td;
  187. WCHAR szName[256];
  188. //
  189. // get the name of the terminal
  190. //
  191. pTerminal->get_Name( &bstrName );
  192. pTerminal->get_Direction( &td );
  193. if (td == TD_RENDER)
  194. {
  195. wsprintfW(szName, L"%s [Playback]", bstrName);
  196. }
  197. else if (td == TD_CAPTURE)
  198. {
  199. wsprintfW(szName, L"%s [Record]", bstrName);
  200. }
  201. else //if (TD == TD_BOTH)
  202. {
  203. lstrcpyW(szName, bstrName);
  204. }
  205. //
  206. // set up the structure
  207. //
  208. tvi.hParent = ghTerminalsRoot;
  209. tvi.hInsertAfter = TVI_LAST;
  210. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  211. tvi.item.pszText = szName;
  212. tvi.item.lParam = (LPARAM) pTerminal;
  213. //
  214. // keep a refence to the terminal
  215. //
  216. pTerminal->AddRef();
  217. //
  218. // add it
  219. //
  220. TreeView_InsertItem(
  221. ghTerminalsWnd,
  222. &tvi
  223. );
  224. //
  225. // free the name
  226. //
  227. SysFreeString( bstrName );
  228. //
  229. // select
  230. //
  231. SelectFirstItem(
  232. ghTerminalsWnd,
  233. ghTerminalsRoot
  234. );
  235. }
  236. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  237. //
  238. // AddPhone
  239. //
  240. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  241. void CT3testDlg::AddPhone( ITPhone * pPhone )
  242. {
  243. BSTR bstrName;
  244. TV_INSERTSTRUCT tvi;
  245. TERMINAL_DIRECTION td;
  246. WCHAR szName[256];
  247. //
  248. // get the name of the phone
  249. //
  250. pPhone->get_PhoneCapsString ( PCS_PHONENAME, &bstrName );
  251. lstrcpyW(szName, bstrName);
  252. //
  253. // set up the structure
  254. //
  255. tvi.hParent = ghPhonesRoot;
  256. tvi.hInsertAfter = TVI_LAST;
  257. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  258. tvi.item.pszText = szName;
  259. tvi.item.lParam = (LPARAM) pPhone;
  260. //
  261. // keep a refence to the phone
  262. //
  263. pPhone->AddRef();
  264. //
  265. // add it
  266. //
  267. TreeView_InsertItem(
  268. ghPhonesWnd,
  269. &tvi
  270. );
  271. //
  272. // free the name
  273. //
  274. SysFreeString( bstrName );
  275. //
  276. // select
  277. //
  278. SelectFirstItem(
  279. ghPhonesWnd,
  280. ghPhonesRoot
  281. );
  282. }
  283. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  284. //
  285. // AddTerminalClass
  286. //
  287. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  288. void CT3testDlg::AddTerminalClass( GUID * pguid )
  289. {
  290. TV_INSERTSTRUCT tvi;
  291. //
  292. // get the name
  293. //
  294. tvi.item.pszText = GetTerminalClassName( pguid );
  295. //
  296. // set up the struct
  297. //
  298. tvi.hParent = ghClassesRoot;
  299. tvi.hInsertAfter = TVI_LAST;
  300. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  301. tvi.item.lParam = (LPARAM) pguid;
  302. //
  303. // insert the item
  304. //
  305. TreeView_InsertItem(
  306. ghClassesWnd,
  307. &tvi
  308. );
  309. SysFreeString( tvi.item.pszText );
  310. //
  311. // select item
  312. //
  313. SelectFirstItem(
  314. ghClassesWnd,
  315. ghClassesRoot
  316. );
  317. }
  318. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  319. //
  320. // AddCreatedTerminal
  321. //
  322. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  323. void CT3testDlg::AddCreatedTerminal( ITTerminal * pTerminal )
  324. {
  325. BSTR bstrName;
  326. TV_INSERTSTRUCT tvi;
  327. //
  328. // get the name
  329. //
  330. pTerminal->get_Name( &bstrName );
  331. //
  332. // set up the structure
  333. //
  334. tvi.hParent = ghCreatedRoot;
  335. tvi.hInsertAfter = TVI_LAST;
  336. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  337. if ( ( NULL == bstrName ) || (NULL == bstrName[0] ))
  338. {
  339. tvi.item.pszText = L"<No Name Given>";
  340. }
  341. else
  342. {
  343. tvi.item.pszText = bstrName;
  344. }
  345. tvi.item.lParam = (LPARAM) pTerminal;
  346. //
  347. // keep reference
  348. //
  349. pTerminal->AddRef();
  350. //
  351. // insert
  352. //
  353. TreeView_InsertItem(
  354. ghCreatedWnd,
  355. &tvi
  356. );
  357. SysFreeString( bstrName );
  358. //
  359. // select
  360. //
  361. SelectFirstItem(
  362. ghCreatedWnd,
  363. ghCreatedRoot
  364. );
  365. }
  366. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  367. //
  368. // AddSelectedTerminal
  369. //
  370. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  371. void CT3testDlg::AddSelectedTerminal(
  372. ITTerminal * pTerminal
  373. )
  374. {
  375. BSTR bstrName;
  376. BSTR pMediaType;
  377. TV_INSERTSTRUCT tvi;
  378. TERMINAL_DIRECTION td;
  379. WCHAR szName[256];
  380. //
  381. // get the name
  382. //
  383. pTerminal->get_Name( &bstrName );
  384. pTerminal->get_Direction( &td );
  385. if (td == TD_RENDER)
  386. {
  387. wsprintfW(szName, L"%s [Playback]", bstrName);
  388. }
  389. else if (td == TD_CAPTURE)
  390. {
  391. wsprintfW(szName, L"%s [Record]", bstrName);
  392. }
  393. else //if (TD == TD_BOTH)
  394. {
  395. lstrcpyW(szName, bstrName);
  396. }
  397. //
  398. // set up the struct
  399. //
  400. tvi.hParent = ghSelectedRoot;
  401. tvi.hInsertAfter = TVI_LAST;
  402. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  403. tvi.item.pszText = szName;
  404. tvi.item.lParam = (LPARAM) pTerminal;
  405. //
  406. // keep reference
  407. //
  408. pTerminal->AddRef();
  409. //
  410. // insert item
  411. //
  412. TreeView_InsertItem(
  413. ghSelectedWnd,
  414. &tvi
  415. );
  416. //
  417. // free name
  418. //
  419. SysFreeString( bstrName );
  420. //
  421. // select
  422. //
  423. SelectFirstItem(
  424. ghSelectedWnd,
  425. ghSelectedRoot
  426. );
  427. }
  428. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  429. //
  430. // AddSelectedCall
  431. //
  432. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  433. void CT3testDlg::AddSelectedCall(
  434. ITCallInfo * pCall
  435. )
  436. {
  437. TV_INSERTSTRUCT tvi;
  438. WCHAR pszName[16];
  439. //
  440. // for the name of the call, use
  441. // the pointer!
  442. //
  443. wsprintf(
  444. pszName,
  445. L"0x%lx",
  446. pCall
  447. );
  448. //
  449. // set up the struct
  450. //
  451. tvi.hParent = ghSelectedCallsRoot;
  452. tvi.hInsertAfter = TVI_LAST;
  453. tvi.item.mask = TVIF_TEXT | TVIF_PARAM;
  454. tvi.item.pszText = pszName;
  455. tvi.item.lParam = (LPARAM) pCall;
  456. //
  457. // keep reference
  458. //
  459. pCall->AddRef();
  460. //
  461. // insert item
  462. //
  463. TreeView_InsertItem(
  464. ghSelectedCallsWnd,
  465. &tvi
  466. );
  467. //
  468. // select
  469. //
  470. SelectFirstItem(
  471. ghSelectedCallsWnd,
  472. ghSelectedCallsRoot
  473. );
  474. }