Source code of Windows XP (NT5)
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.

591 lines
16 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. config.c
  5. Abstract:
  6. TAPI Service Provider functions related to tsp config.
  7. TSPI_providerConfig
  8. TUISPI_providerConfig
  9. Environment:
  10. User Mode - Win32
  11. --*/
  12. ///////////////////////////////////////////////////////////////////////////////
  13. // //
  14. // Include files //
  15. // //
  16. ///////////////////////////////////////////////////////////////////////////////
  17. #ifndef UNICODE
  18. #define UNICODE // make this a UNICODE module...
  19. #endif
  20. #ifndef _UNICODE
  21. #define _UNICODE // make this a UNICODE module...
  22. #endif
  23. #include "globals.h"
  24. #include "provider.h"
  25. #include "callback.h"
  26. #include "registry.h"
  27. #include "termcaps.h"
  28. #include "version.h"
  29. #include "line.h"
  30. #include "config.h"
  31. #include <tchar.h>
  32. ///////////////////////////////////////////////////////////////////////////////
  33. // //
  34. // Public procedures //
  35. // //
  36. ///////////////////////////////////////////////////////////////////////////////
  37. INT_PTR
  38. CALLBACK
  39. ProviderConfigDlgProc(
  40. HWND hDlg,
  41. UINT uMsg,
  42. WPARAM wParam,
  43. LPARAM lParam
  44. )
  45. {
  46. HKEY hKey;
  47. LONG lStatus;
  48. DWORD dwValue;
  49. DWORD dwValueSize;
  50. DWORD dwValueType;
  51. LPTSTR pszValue;
  52. TCHAR szAddr[H323_MAXDESTNAMELEN];
  53. static const DWORD IDD_GATEWAY_HelpIDs[]=
  54. {
  55. IDC_GATEWAY_GROUP, IDH_H323SP_USE_GATEWAY, // group
  56. IDC_USEGATEWAY, IDH_H323SP_USE_GATEWAY, // checkbox
  57. IDC_H323_GATEWAY, IDH_H323SP_USE_GATEWAY_COMPUTER, // edit box
  58. IDC_PROXY_GROUP, IDH_H323SP_USE_PROXY, // group
  59. IDC_USEPROXY, IDH_H323SP_USE_PROXY, // checkbox
  60. IDC_H323_PROXY, IDH_H323SP_USE_PROXY_COMPUTER, // edit box
  61. IDC_STATIC, IDH_NOHELP, // graphic(s)
  62. 0, 0
  63. };
  64. // decode
  65. switch (uMsg) {
  66. case WM_HELP:
  67. // F1 key or the "?" button is pressed
  68. (void) WinHelp(
  69. ((LPHELPINFO) lParam)->hItemHandle,
  70. H323SP_HELP_FILE,
  71. HELP_WM_HELP,
  72. (DWORD_PTR) (LPVOID)IDD_GATEWAY_HelpIDs
  73. );
  74. break;
  75. case WM_CONTEXTMENU:
  76. // Right-mouse click on a dialog control
  77. (void) WinHelp(
  78. (HWND) wParam,
  79. H323SP_HELP_FILE,
  80. HELP_CONTEXTMENU,
  81. (DWORD_PTR) (LPVOID) IDD_GATEWAY_HelpIDs
  82. );
  83. break;
  84. case WM_INITDIALOG:
  85. // open registry subkey
  86. lStatus = RegOpenKeyEx(
  87. HKEY_LOCAL_MACHINE,
  88. H323_REGKEY_ROOT,
  89. 0,
  90. KEY_READ,
  91. &hKey
  92. );
  93. // validate return code
  94. if (lStatus != ERROR_SUCCESS) {
  95. TCHAR szErrorMsg[256];
  96. H323DBG((
  97. DEBUG_LEVEL_WARNING,
  98. "error 0x%08lx opening tsp registry key.\n",
  99. lStatus
  100. ));
  101. // load error string
  102. LoadString(g_hInstance,
  103. IDS_REGOPENKEY,
  104. szErrorMsg,
  105. sizeof(szErrorMsg)
  106. );
  107. // pop up error dialog
  108. MessageBox(hDlg,szErrorMsg,NULL,MB_OK);
  109. // stop dialog
  110. EndDialog(hDlg, 0);
  111. break;
  112. }
  113. // initialize value name
  114. pszValue = H323_REGVAL_GATEWAYADDR;
  115. // initialize type
  116. dwValueType = REG_SZ;
  117. dwValueSize = sizeof(szAddr);
  118. // query for registry value
  119. lStatus = RegQueryValueEx(
  120. hKey,
  121. pszValue,
  122. NULL,
  123. &dwValueType,
  124. (LPBYTE)szAddr,
  125. &dwValueSize
  126. );
  127. // validate return code
  128. if (lStatus == ERROR_SUCCESS) {
  129. // display gateway address
  130. SetDlgItemText(hDlg,IDC_H323_GATEWAY,szAddr);
  131. }
  132. // initialize value name
  133. pszValue = H323_REGVAL_GATEWAYENABLED;
  134. // initialize type
  135. dwValueType = REG_DWORD;
  136. dwValueSize = sizeof(DWORD);
  137. // query for registry value
  138. lStatus = RegQueryValueEx(
  139. hKey,
  140. pszValue,
  141. NULL,
  142. &dwValueType,
  143. (LPBYTE)&dwValue,
  144. &dwValueSize
  145. );
  146. // validate return code
  147. if (lStatus != ERROR_SUCCESS) {
  148. // default
  149. dwValue = 0;
  150. }
  151. // enable check box
  152. SendDlgItemMessage(
  153. hDlg,
  154. IDC_USEGATEWAY,
  155. BM_SETCHECK,
  156. (dwValue != 0),
  157. 0
  158. );
  159. // display string
  160. EnableWindow(
  161. GetDlgItem(hDlg,IDC_H323_GATEWAY),
  162. (dwValue != 0)
  163. );
  164. // initialize value name
  165. pszValue = H323_REGVAL_PROXYADDR;
  166. // initialize type
  167. dwValueType = REG_SZ;
  168. dwValueSize = sizeof(szAddr);
  169. // query for registry value
  170. lStatus = RegQueryValueEx(
  171. hKey,
  172. pszValue,
  173. NULL,
  174. &dwValueType,
  175. (LPBYTE)szAddr,
  176. &dwValueSize
  177. );
  178. // validate return code
  179. if (lStatus == ERROR_SUCCESS) {
  180. // display gateway address
  181. SetDlgItemText(hDlg,IDC_H323_PROXY,szAddr);
  182. }
  183. // initialize value name
  184. pszValue = H323_REGVAL_PROXYENABLED;
  185. // initialize type
  186. dwValueType = REG_DWORD;
  187. dwValueSize = sizeof(DWORD);
  188. // query for registry value
  189. lStatus = RegQueryValueEx(
  190. hKey,
  191. pszValue,
  192. NULL,
  193. &dwValueType,
  194. (LPBYTE)&dwValue,
  195. &dwValueSize
  196. );
  197. // validate return code
  198. if (lStatus != ERROR_SUCCESS) {
  199. // default
  200. dwValue = 0;
  201. }
  202. // enable check box
  203. SendDlgItemMessage(
  204. hDlg,
  205. IDC_USEPROXY,
  206. BM_SETCHECK,
  207. (dwValue != 0),
  208. 0
  209. );
  210. // display string
  211. EnableWindow(
  212. GetDlgItem(hDlg,IDC_H323_PROXY),
  213. (dwValue != 0)
  214. );
  215. // close registry
  216. RegCloseKey(hKey);
  217. break;
  218. case WM_COMMAND:
  219. // decode command
  220. switch (LOWORD(wParam)) {
  221. case IDOK:
  222. // open registry subkey
  223. lStatus = RegOpenKeyEx(
  224. HKEY_LOCAL_MACHINE,
  225. H323_REGKEY_ROOT,
  226. 0,
  227. KEY_WRITE,
  228. &hKey
  229. );
  230. // validate return code
  231. if (lStatus != ERROR_SUCCESS) {
  232. TCHAR szErrorMsg[256];
  233. H323DBG((
  234. DEBUG_LEVEL_WARNING,
  235. "error 0x%08lx opening tsp registry key.\n",
  236. lStatus
  237. ));
  238. // load error string
  239. LoadString(g_hInstance,
  240. IDS_REGOPENKEY,
  241. szErrorMsg,
  242. sizeof(szErrorMsg)
  243. );
  244. // pop up error dialog
  245. MessageBox(hDlg,szErrorMsg,NULL,MB_OK);
  246. // stop dialog
  247. EndDialog(hDlg, 0);
  248. break;
  249. }
  250. // initialize value name
  251. pszValue = H323_REGVAL_GATEWAYADDR;
  252. // retrieve gateway address from dialog
  253. GetDlgItemText(hDlg,IDC_H323_GATEWAY,szAddr,sizeof(szAddr));
  254. // initialize type
  255. dwValueType = REG_SZ;
  256. dwValueSize = (_tcslen(szAddr) + 1) * sizeof(TCHAR);
  257. // query for registry value
  258. lStatus = RegSetValueEx(
  259. hKey,
  260. pszValue,
  261. 0,
  262. dwValueType,
  263. (LPBYTE)szAddr,
  264. dwValueSize
  265. );
  266. // validate return code
  267. if (lStatus != ERROR_SUCCESS) {
  268. H323DBG((
  269. DEBUG_LEVEL_ERROR,
  270. "error 0x%08lx writing gateway address\n",
  271. lStatus
  272. ));
  273. }
  274. // initialize value name
  275. pszValue = H323_REGVAL_GATEWAYENABLED;
  276. // initialize type
  277. dwValueType = REG_DWORD;
  278. dwValueSize = sizeof(DWORD);
  279. // examine check box
  280. dwValue = SendDlgItemMessage(
  281. hDlg,
  282. IDC_USEGATEWAY,
  283. BM_GETCHECK,
  284. 0,
  285. 0
  286. ) ? 1 : 0;
  287. // query for registry value
  288. lStatus = RegSetValueEx(
  289. hKey,
  290. pszValue,
  291. 0,
  292. dwValueType,
  293. (LPBYTE)&dwValue,
  294. dwValueSize
  295. );
  296. // validate return code
  297. if (lStatus != ERROR_SUCCESS) {
  298. H323DBG((
  299. DEBUG_LEVEL_ERROR,
  300. "error 0x%08lx writing gateway flag\n",
  301. lStatus
  302. ));
  303. }
  304. // initialize value name
  305. pszValue = H323_REGVAL_PROXYADDR;
  306. // retrieve gateway address from dialog
  307. GetDlgItemText(hDlg,IDC_H323_PROXY,szAddr,sizeof(szAddr));
  308. // initialize type
  309. dwValueType = REG_SZ;
  310. dwValueSize = (_tcslen(szAddr) + 1) * sizeof(TCHAR);
  311. // query for registry value
  312. lStatus = RegSetValueEx(
  313. hKey,
  314. pszValue,
  315. 0,
  316. dwValueType,
  317. (LPBYTE)szAddr,
  318. dwValueSize
  319. );
  320. // validate return code
  321. if (lStatus != ERROR_SUCCESS) {
  322. H323DBG((
  323. DEBUG_LEVEL_ERROR,
  324. "error 0x%08lx writing proxy address\n",
  325. lStatus
  326. ));
  327. }
  328. // initialize value name
  329. pszValue = H323_REGVAL_PROXYENABLED;
  330. // initialize type
  331. dwValueType = REG_DWORD;
  332. dwValueSize = sizeof(DWORD);
  333. // examine check box
  334. dwValue = SendDlgItemMessage(
  335. hDlg,
  336. IDC_USEPROXY,
  337. BM_GETCHECK,
  338. 0,
  339. 0
  340. ) ? 1 : 0;
  341. // query for registry value
  342. lStatus = RegSetValueEx(
  343. hKey,
  344. pszValue,
  345. 0,
  346. dwValueType,
  347. (LPBYTE)&dwValue,
  348. dwValueSize
  349. );
  350. // validate return code
  351. if (lStatus != ERROR_SUCCESS) {
  352. H323DBG((
  353. DEBUG_LEVEL_ERROR,
  354. "error 0x%08lx writing proxy flag\n",
  355. lStatus
  356. ));
  357. }
  358. // close registry
  359. RegCloseKey(hKey);
  360. // close dialog
  361. EndDialog(hDlg, 0);
  362. break;
  363. case IDCANCEL:
  364. // close dialog
  365. EndDialog(hDlg, 0);
  366. break;
  367. case IDC_USEGATEWAY:
  368. // display string if check box enabled
  369. EnableWindow(GetDlgItem(hDlg,IDC_H323_GATEWAY),
  370. (BOOL)SendDlgItemMessage(
  371. hDlg,
  372. IDC_USEGATEWAY,
  373. BM_GETCHECK,
  374. (WPARAM)0,
  375. (LPARAM)0
  376. ));
  377. break;
  378. case IDC_USEPROXY:
  379. // display string if check box enabled
  380. EnableWindow(GetDlgItem(hDlg,IDC_H323_PROXY),
  381. (BOOL)SendDlgItemMessage(
  382. hDlg,
  383. IDC_USEPROXY,
  384. BM_GETCHECK,
  385. (WPARAM)0,
  386. (LPARAM)0
  387. ));
  388. break;
  389. }
  390. break;
  391. }
  392. // success
  393. return FALSE;
  394. }
  395. ///////////////////////////////////////////////////////////////////////////////
  396. // //
  397. // TSPI procedures //
  398. // //
  399. ///////////////////////////////////////////////////////////////////////////////
  400. LONG
  401. TSPIAPI
  402. TSPI_providerConfig(
  403. HWND hwndOwner,
  404. DWORD dwPermanentProviderID
  405. )
  406. /*++
  407. Routine Description:
  408. The original TSPI UI-generating functions (TSPI_lineConfigDialog,
  409. TSPI_lineConfigDialogEdit, TSPI_phoneConfigDialog, TSPI_providerConfig,
  410. TSPI_providerInstall, and TSPI_providerRemove) are obsolete and will
  411. never be called by TAPISRV.EXE. However, if the service provider desires
  412. to be listed as one that can be added by the Telephony control panel,
  413. it must export TSPI_providerInstall; if it wants to have the Remove
  414. button enabled in the Telephony CPL when it is selected, it must export
  415. TSPI_providerRemove, and it if wants the Setup button to be enabled
  416. in the Telephony CPL when it is selected, it must export
  417. TSPI_providerConfig.
  418. The Telephony CPL checks for the presence of these functions in the
  419. service provider TSP file in order to adjust its user interface to
  420. reflect which operations can be performed.
  421. See TUISPI_lineConfigDialog for dialog code.
  422. Arguments:
  423. hwndOwner - Specifies the handle of the parent window in which the function
  424. may create any dialog windows required during the configuration.
  425. dwPermanentProviderID - Specifies the permanent ID, unique within the
  426. service providers on this system, of the service provider being
  427. configured.
  428. Return Values:
  429. Returns zero if the request is successful or a negative error number if
  430. an error has occurred. Possible return values are:
  431. LINEERR_NOMEM - Unable to allocate or lock memory.
  432. LINEERR_OPERATIONFAILED - The specified operation failed for unknown
  433. reasons.
  434. --*/
  435. {
  436. UNREFERENCED_PARAMETER(hwndOwner); // no dialog here
  437. UNREFERENCED_PARAMETER(dwPermanentProviderID); // not needed anymore
  438. // success
  439. return NOERROR;
  440. }
  441. LONG
  442. TSPIAPI
  443. TUISPI_providerConfig(
  444. TUISPIDLLCALLBACK pfnUIDLLCallback,
  445. HWND hwndOwner,
  446. DWORD dwPermanentProviderID
  447. )
  448. {
  449. INT_PTR nResult;
  450. UNREFERENCED_PARAMETER(pfnUIDLLCallback);
  451. UNREFERENCED_PARAMETER(dwPermanentProviderID);
  452. // invoke dialog box
  453. nResult = DialogBoxW(
  454. g_hInstance,
  455. MAKEINTRESOURCE(IDD_TSPCONFIG),
  456. hwndOwner,
  457. ProviderConfigDlgProc,
  458. );
  459. // status based on whether dialog executed properly
  460. return ((DWORD)nResult == 0) ? NOERROR : LINEERR_OPERATIONFAILED;
  461. }