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.

555 lines
11 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. // GetMediaTypeName
  10. //
  11. // Convert the mediatype bstr to a string, like
  12. // "audio in"
  13. //
  14. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  15. void CT3testDlg::GetMediaTypeName(
  16. long lMediaType,
  17. LPWSTR szString
  18. )
  19. {
  20. if (lMediaType == (long)LINEMEDIAMODE_AUTOMATEDVOICE)
  21. {
  22. lstrcpyW(
  23. szString,
  24. L"Audio"
  25. );
  26. }
  27. else if (lMediaType == (long)LINEMEDIAMODE_VIDEO)
  28. {
  29. lstrcpyW(
  30. szString,
  31. L"Video"
  32. );
  33. }
  34. else if (lMediaType == (long)LINEMEDIAMODE_DATAMODEM)
  35. {
  36. lstrcpyW(
  37. szString,
  38. L"DataModem"
  39. );
  40. }
  41. else if (lMediaType == (long)LINEMEDIAMODE_G3FAX)
  42. {
  43. lstrcpyW(
  44. szString,
  45. L"G3Fax"
  46. );
  47. }
  48. else
  49. {
  50. lstrcpyW(
  51. szString,
  52. L"Unknown MediaType - "
  53. );
  54. }
  55. }
  56. LPWSTR CT3testDlg::GetCallPrivilegeName(
  57. ITCallInfo * pCall
  58. )
  59. {
  60. CALL_PRIVILEGE cp;
  61. HRESULT hr;
  62. hr = pCall->get_Privilege( &cp );
  63. if ( SUCCEEDED(hr) )
  64. {
  65. if (CP_OWNER == cp)
  66. {
  67. return SysAllocString(L"OWNER");
  68. }
  69. else
  70. {
  71. return SysAllocString(L"MONITOR");
  72. }
  73. }
  74. return NULL;
  75. }
  76. LPWSTR CT3testDlg::GetPhonePrivilegeName(
  77. ITPhone * pPhone
  78. )
  79. {
  80. PHONE_PRIVILEGE pp;
  81. HRESULT hr;
  82. hr = pPhone->get_Privilege( &pp );
  83. if ( SUCCEEDED(hr) )
  84. {
  85. if (PP_OWNER == pp)
  86. {
  87. return SysAllocString(L"OWNER");
  88. }
  89. else
  90. {
  91. return SysAllocString(L"MONITOR");
  92. }
  93. }
  94. return NULL;
  95. }
  96. LPWSTR CT3testDlg::GetCallStateName(
  97. ITCallInfo * pCall
  98. )
  99. {
  100. CALL_STATE cs;
  101. //
  102. // get the current call state
  103. //
  104. pCall->get_CallState( &cs );
  105. //
  106. // make the name
  107. //
  108. switch( cs )
  109. {
  110. case CS_INPROGRESS:
  111. return SysAllocString( L"INPROGRESS" );
  112. break;
  113. case CS_CONNECTED:
  114. return SysAllocString ( L"CONNECTED" );
  115. break;
  116. case CS_DISCONNECTED:
  117. return SysAllocString ( L"DISCONNECTED" );
  118. break;
  119. case CS_OFFERING:
  120. return SysAllocString ( L"OFFERING" );
  121. break;
  122. case CS_IDLE:
  123. return SysAllocString( L"IDLE" );
  124. break;
  125. default:
  126. return SysAllocString( L"<Unknown Call State>" );
  127. break;
  128. }
  129. return NULL;
  130. }
  131. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  132. //
  133. // GetAddress
  134. //
  135. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  136. BOOL CT3testDlg::GetAddress( ITAddress ** ppAddress )
  137. {
  138. HTREEITEM hItem;
  139. TV_ITEM item;
  140. hItem = TreeView_GetSelection(
  141. ghAddressesWnd
  142. );
  143. if (NULL == hItem)
  144. {
  145. return FALSE;
  146. }
  147. item.mask = TVIF_HANDLE | TVIF_PARAM;
  148. item.hItem = hItem;
  149. TreeView_GetItem(
  150. ghAddressesWnd,
  151. &item
  152. );
  153. *ppAddress = (ITAddress *)item.lParam;
  154. if (NULL == *ppAddress)
  155. {
  156. // ::MessageBox(NULL, L"Select an Address", NULL, MB_OK);
  157. return FALSE;
  158. }
  159. return TRUE;
  160. }
  161. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  162. //
  163. // GetTerminal
  164. //
  165. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  166. BOOL CT3testDlg::GetTerminal( ITTerminal ** ppTerminal )
  167. {
  168. HTREEITEM hItem;
  169. TV_ITEM item;
  170. hItem = TreeView_GetSelection(
  171. ghTerminalsWnd
  172. );
  173. if (NULL == hItem)
  174. {
  175. return FALSE;
  176. }
  177. item.mask = TVIF_HANDLE | TVIF_PARAM;
  178. item.hItem = hItem;
  179. TreeView_GetItem(
  180. ghTerminalsWnd,
  181. &item
  182. );
  183. *ppTerminal = (ITTerminal *)item.lParam;
  184. if (NULL == *ppTerminal)
  185. {
  186. ::MessageBox(NULL, L"Select a Terminal", NULL, MB_OK);
  187. return FALSE;
  188. }
  189. return TRUE;
  190. }
  191. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  192. //
  193. // GetPhone
  194. //
  195. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  196. BOOL CT3testDlg::GetPhone( ITPhone ** ppPhone )
  197. {
  198. HTREEITEM hItem;
  199. TV_ITEM item;
  200. hItem = TreeView_GetSelection(
  201. ghPhonesWnd
  202. );
  203. if (NULL == hItem)
  204. {
  205. return FALSE;
  206. }
  207. item.mask = TVIF_HANDLE | TVIF_PARAM;
  208. item.hItem = hItem;
  209. TreeView_GetItem(
  210. ghPhonesWnd,
  211. &item
  212. );
  213. *ppPhone = (ITPhone *)item.lParam;
  214. if (NULL == *ppPhone)
  215. {
  216. //::MessageBox(NULL, L"Select a Phone", NULL, MB_OK);
  217. return FALSE;
  218. }
  219. return TRUE;
  220. }
  221. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  222. //
  223. // GetCall
  224. //
  225. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  226. BOOL CT3testDlg::GetCall( ITCallInfo ** ppCallInfo )
  227. {
  228. HTREEITEM hItem;
  229. TV_ITEM item;
  230. hItem = TreeView_GetSelection(
  231. ghCallsWnd
  232. );
  233. if (NULL == hItem)
  234. {
  235. return FALSE;
  236. }
  237. item.mask = TVIF_HANDLE | TVIF_PARAM;
  238. item.hItem = hItem;
  239. TreeView_GetItem(
  240. ghCallsWnd,
  241. &item
  242. );
  243. *ppCallInfo = (ITCallInfo *)item.lParam;
  244. if (NULL == *ppCallInfo)
  245. {
  246. //::MessageBox(NULL, L"Select a Call", NULL, MB_OK);
  247. return FALSE;
  248. }
  249. return TRUE;
  250. }
  251. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  252. //
  253. // GetMediaType
  254. //
  255. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  256. BOOL CT3testDlg::GetMediaType( long * plMediaType )
  257. {
  258. HTREEITEM hItem;
  259. TV_ITEM item;
  260. hItem = TreeView_GetSelection(
  261. ghMediaTypesWnd
  262. );
  263. if (NULL == hItem)
  264. {
  265. return FALSE;
  266. }
  267. item.mask = TVIF_HANDLE | TVIF_PARAM;
  268. item.hItem = hItem;
  269. TreeView_GetItem(
  270. ghMediaTypesWnd,
  271. &item
  272. );
  273. *plMediaType = (long)(item.lParam);
  274. if (0 == *plMediaType)
  275. {
  276. return FALSE;
  277. }
  278. return TRUE;
  279. }
  280. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  281. //
  282. // GetTerminalClass
  283. //
  284. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  285. BOOL CT3testDlg::GetTerminalClass( BSTR * pbstrClass )
  286. {
  287. HTREEITEM hItem;
  288. TV_ITEM item;
  289. GUID * pguid;
  290. hItem = TreeView_GetSelection(
  291. ghClassesWnd
  292. );
  293. if (NULL == hItem)
  294. {
  295. return FALSE;
  296. }
  297. item.mask = TVIF_HANDLE | TVIF_PARAM;
  298. item.hItem = hItem;
  299. TreeView_GetItem(
  300. ghClassesWnd,
  301. &item
  302. );
  303. pguid = (GUID *)item.lParam;
  304. if (NULL == pguid)
  305. {
  306. return FALSE;
  307. }
  308. LPWSTR lphold;
  309. StringFromIID(
  310. *pguid,
  311. &lphold
  312. );
  313. *pbstrClass = SysAllocString(lphold);
  314. CoTaskMemFree(lphold);
  315. return TRUE;
  316. }
  317. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  318. //
  319. // GetCreatedTerminal
  320. //
  321. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  322. BOOL CT3testDlg::GetCreatedTerminal( ITTerminal ** ppTerminal )
  323. {
  324. HTREEITEM hItem;
  325. TV_ITEM item;
  326. hItem = TreeView_GetSelection(
  327. ghCreatedWnd
  328. );
  329. if (NULL == hItem)
  330. {
  331. return FALSE;
  332. }
  333. item.mask = TVIF_HANDLE | TVIF_PARAM;
  334. item.hItem = hItem;
  335. TreeView_GetItem(
  336. ghCreatedWnd,
  337. &item
  338. );
  339. *ppTerminal = (ITTerminal *)item.lParam;
  340. if (NULL == *ppTerminal)
  341. {
  342. return FALSE;
  343. }
  344. return TRUE;
  345. }
  346. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  347. //
  348. // GetSelectedTerminal
  349. //
  350. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  351. BOOL CT3testDlg::GetSelectedTerminal( ITTerminal ** ppTerminal )
  352. {
  353. HTREEITEM hItem;
  354. TV_ITEM item;
  355. hItem = TreeView_GetSelection(
  356. ghSelectedWnd
  357. );
  358. if (NULL == hItem)
  359. {
  360. return FALSE;
  361. }
  362. item.mask = TVIF_HANDLE | TVIF_PARAM;
  363. item.hItem = hItem;
  364. TreeView_GetItem(
  365. ghSelectedWnd,
  366. &item
  367. );
  368. *ppTerminal = (ITTerminal *)item.lParam;
  369. if (NULL == *ppTerminal)
  370. {
  371. return FALSE;
  372. }
  373. return TRUE;
  374. }
  375. BSTR CT3testDlg::GetTerminalClassName( GUID * pguid )
  376. {
  377. if (IsEqualIID( *pguid, CLSID_VideoWindowTerm ))
  378. {
  379. return SysAllocString( L"Video" );
  380. }
  381. #ifdef ENABLE_DIGIT_DETECTION_STUFF
  382. else if (IsEqualIID( *pguid, CLSID_DigitTerminal ))
  383. {
  384. return SysAllocString( L"Digit Terminal" );
  385. }
  386. else if (IsEqualIID( *pguid, CLSID_DataTerminal ))
  387. {
  388. return SysAllocString( L"Data Terminal" );
  389. }
  390. #endif // ENABLE_DIGIT_DETECTION_STUFF
  391. else
  392. {
  393. return SysAllocString( L"Unknown Dynamic Type" );
  394. }
  395. return NULL;
  396. }
  397. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  398. //
  399. // GetSelectedCall
  400. //
  401. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
  402. BOOL CT3testDlg::GetSelectedCall( ITCallInfo ** ppCall )
  403. {
  404. HTREEITEM hItem;
  405. TV_ITEM item;
  406. hItem = TreeView_GetSelection(
  407. ghSelectedCallsWnd
  408. );
  409. if (NULL == hItem)
  410. {
  411. return FALSE;
  412. }
  413. item.mask = TVIF_HANDLE | TVIF_PARAM;
  414. item.hItem = hItem;
  415. TreeView_GetItem(
  416. ghSelectedCallsWnd,
  417. &item
  418. );
  419. *ppCall = (ITCallInfo *)item.lParam;
  420. if (NULL == *ppCall)
  421. {
  422. //::MessageBox(NULL, L"Select a Call", NULL, MB_OK);
  423. return FALSE;
  424. }
  425. return TRUE;
  426. }