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.

1962 lines
66 KiB

  1. /**************************************************************************
  2. Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  3. MODULE: PMCONFIG.CPP
  4. PURPOSE: Source module for Passport Manager config tool
  5. FUNCTIONS:
  6. COMMENTS:
  7. **************************************************************************/
  8. /**************************************************************************
  9. Include Files
  10. **************************************************************************/
  11. #include "pmcfg.h"
  12. #include <htmlhelp.h>
  13. #include <ntverp.h>
  14. /**************************************************************************
  15. Local Function Prototypes
  16. **************************************************************************/
  17. int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
  18. LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  19. LRESULT CALLBACK DlgMain(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  20. /**************************************************************************
  21. Global Variables
  22. **************************************************************************/
  23. // Globals
  24. HINSTANCE g_hInst;
  25. HWND g_hwndMain = 0;
  26. HWND g_hwndMainDlg = 0;
  27. PMSETTINGS g_OriginalSettings;
  28. PMSETTINGS g_CurrentSettings;
  29. TCHAR g_szDlgClassName[] = TEXT("PassportManagerAdminClass");
  30. TCHAR g_szClassName[] = TEXT("PassportManagerMainWindowClass");
  31. BOOL g_bCanUndo;
  32. TCHAR g_szInstallPath[MAX_PATH];
  33. TCHAR g_szPMVersion[MAX_REGISTRY_STRING];
  34. TCHAR g_szPMOpsHelpFileRelativePath[] = TEXT("sdk\\Passport_SDK.chm");
  35. TCHAR g_szPMAdminBookmark[] = TEXT("/Reference/operations/Passport_Admin.htm");
  36. TCHAR g_szRemoteComputer[MAX_PATH];
  37. TCHAR g_szNewRemoteComputer[MAX_PATH];
  38. TCHAR g_szConfigFile[MAX_PATH];
  39. TCHAR g_szConfigSet[MAX_CONFIGSETNAME];
  40. TCHAR g_szHelpFileName[MAX_PATH];
  41. PpMRU g_ComputerMRU(COMPUTER_MRU_SIZE);
  42. // Global constant strings
  43. TCHAR g_szYes[] = TEXT("Yes");
  44. TCHAR g_szNo[] = TEXT("No");
  45. TCHAR g_szUnknown[] = TEXT("Unknown");
  46. #define MAX_LCID_VALUE 10
  47. LANGIDMAP g_szLanguageIDMap[] =
  48. {
  49. {0x0409, TEXT("English")}, // This item will be the default selection below...
  50. {0x0407, TEXT("German")},
  51. {0x0411, TEXT("Japanese")},
  52. {0x0412, TEXT("Korean")},
  53. {0x0404, TEXT("Traditional Chinese")},
  54. {0x0804, TEXT("Simplified Chinese")},
  55. {0x040c, TEXT("French")},
  56. {0x0c0a, TEXT("Spanish")},
  57. {0x0416, TEXT("Brazilian")},
  58. {0x0410, TEXT("Italian")},
  59. {0x0413, TEXT("Dutch")},
  60. {0x041d, TEXT("Swedish")},
  61. {0x0406, TEXT("Danish")},
  62. {0x040b, TEXT("Finnish")},
  63. {0x040e, TEXT("Hungarian")},
  64. {0x0414, TEXT("Norwegian")},
  65. {0x0408, TEXT("Greek")},
  66. {0x0415, TEXT("Polish")},
  67. {0x0419, TEXT("Russian")},
  68. {0x0405, TEXT("Czech")},
  69. {0x0816, TEXT("Portuguese")},
  70. {0x041f, TEXT("Turkish")},
  71. {0x041b, TEXT("Slovak")},
  72. {0x0424, TEXT("Slovenian")},
  73. {0x0401, TEXT("Arabic")},
  74. {0x040d, TEXT("Hebrew")},
  75. {0x0401, TEXT("Arabic - Saudi Arabia")},
  76. {0x0801, TEXT("Arabic - Iraq")},
  77. {0x0c01, TEXT("Arabic - Egypt")},
  78. {0x1001, TEXT("Arabic - Libya")},
  79. {0x1401, TEXT("Arabic - Algeria")},
  80. {0x1801, TEXT("Arabic - Morocco")},
  81. {0x1c01, TEXT("Arabic - Tunisia")},
  82. {0x2001, TEXT("Arabic - Oman")},
  83. {0x2401, TEXT("Arabic - Yemen")},
  84. {0x2801, TEXT("Arabic - Syria")},
  85. {0x2c01, TEXT("Arabic - Jordan")},
  86. {0x3001, TEXT("Arabic - Lebanon")},
  87. {0x3401, TEXT("Arabic - Kuwait")},
  88. {0x3801, TEXT("Arabic - United Arab Emirates")},
  89. {0x3c01, TEXT("Arabic - Bahrain")},
  90. {0x4001, TEXT("Arabic - Qatar")},
  91. {0x0402, TEXT("Bulgarian - Bulgaria")},
  92. {0x0403, TEXT("Catalan - Spain")},
  93. {0x0404, TEXT("Chinese � Taiwan")},
  94. {0x0804, TEXT("Chinese - PRC")},
  95. {0x0c04, TEXT("Chinese - Hong Kong SAR, PRC")},
  96. {0x1004, TEXT("Chinese - Singapore")},
  97. {0x1404, TEXT("Chinese - Macao SAR")},
  98. {0x0405, TEXT("Czech - Czech Republic")},
  99. {0x0406, TEXT("Danish - Denmark")},
  100. {0x0407, TEXT("German - Germany")},
  101. {0x0807, TEXT("German - Switzerland")},
  102. {0x0c07, TEXT("German - Austria")},
  103. {0x1007, TEXT("German - Luxembourg")},
  104. {0x1407, TEXT("German - Liechtenstein")},
  105. {0x0408, TEXT("Greek - Greece")},
  106. {0x0409, TEXT("English - United States")},
  107. {0x0809, TEXT("English - United Kingdom")},
  108. {0x0c09, TEXT("English - Australia")},
  109. {0x1009, TEXT("English - Canada")},
  110. {0x1409, TEXT("English - New Zealand")},
  111. {0x1809, TEXT("English - Ireland")},
  112. {0x1c09, TEXT("English - South Africa")},
  113. {0x2009, TEXT("English - Jamaica")},
  114. {0x2409, TEXT("English - Caribbean")},
  115. {0x2809, TEXT("English - Belize")},
  116. {0x2c09, TEXT("English - Trinidad")},
  117. {0x3009, TEXT("English - Zimbabwe")},
  118. {0x3409, TEXT("English - Philippines")},
  119. {0x040a, TEXT("Spanish - Spain (Traditional Sort)")},
  120. {0x080a, TEXT("Spanish - Mexico")},
  121. {0x0c0a, TEXT("Spanish - Spain (Modern Sort)")},
  122. {0x100a, TEXT("Spanish - Guatemala")},
  123. {0x140a, TEXT("Spanish - Costa Rica")},
  124. {0x180a, TEXT("Spanish - Panama")},
  125. {0x1c0a, TEXT("Spanish - Dominican Republic")},
  126. {0x200a, TEXT("Spanish - Venezuela")},
  127. {0x240a, TEXT("Spanish - Colombia")},
  128. {0x280a, TEXT("Spanish - Peru")},
  129. {0x2c0a, TEXT("Spanish - Argentina")},
  130. {0x300a, TEXT("Spanish - Ecuador")},
  131. {0x340a, TEXT("Spanish - Chile")},
  132. {0x380a, TEXT("Spanish - Uruguay")},
  133. {0x3c0a, TEXT("Spanish - Paraguay")},
  134. {0x400a, TEXT("Spanish - Bolivia")},
  135. {0x440a, TEXT("Spanish - El Salvador")},
  136. {0x480a, TEXT("Spanish - Honduras")},
  137. {0x4c0a, TEXT("Spanish - Nicaragua")},
  138. {0x500a, TEXT("Spanish - Puerto Rico")},
  139. {0x040b, TEXT("Finnish - Finland")},
  140. {0x040c, TEXT("French - France")},
  141. {0x080c, TEXT("French - Belgium")},
  142. {0x0c0c, TEXT("French - Canada")},
  143. {0x100c, TEXT("French - Switzerland")},
  144. {0x140c, TEXT("French - Luxembourg")},
  145. {0x180c, TEXT("French - Monaco")},
  146. {0x040d, TEXT("Hebrew - Israel")},
  147. {0x040e, TEXT("Hungarian - Hungary")},
  148. {0x040f, TEXT("Icelandic - Iceland")},
  149. {0x0410, TEXT("Italian - Italy")},
  150. {0x0810, TEXT("Italian - Switzerland")},
  151. {0x0411, TEXT("Japanese - Japan")},
  152. {0x0412, TEXT("Korean (Extended Wansung) - Korea")},
  153. {0x0812, TEXT("Korean (Johab) - Korea")},
  154. {0x0413, TEXT("Dutch - Netherlands")},
  155. {0x0813, TEXT("Dutch - Belgium")},
  156. {0x0414, TEXT("Norwegian - Norway (Bokmal)")},
  157. {0x0814, TEXT("Norwegian - Norway (Nynorsk)")},
  158. {0x0415, TEXT("Polish - Poland")},
  159. {0x0416, TEXT("Portuguese - Brazil")},
  160. {0x0816, TEXT("Portuguese - Portugal")},
  161. {0x0417, TEXT("Rhaeto-Romanic - Rhaeto-Romanic")},
  162. {0x0418, TEXT("Romanian - Romania")},
  163. {0x0818, TEXT("Romanian - Moldavia")},
  164. {0x0419, TEXT("Russian - Russia")},
  165. {0x0819, TEXT("Russian - Moldavia")},
  166. {0x041a, TEXT("Croatian - Croatia")},
  167. {0x081a, TEXT("Serbian - Serbia (Latin)")},
  168. {0x0c1a, TEXT("Serbian - Serbia (Cyrillic)")},
  169. {0x041b, TEXT("Slovak - Slovakia")},
  170. {0x041c, TEXT("Albanian - Albania")},
  171. {0x041d, TEXT("Swedish - Sweden")},
  172. {0x081d, TEXT("Swedish - Finland")},
  173. {0x041e, TEXT("Thai - Thailand")},
  174. {0x041f, TEXT("Turkish - Turkey")},
  175. {0x0420, TEXT("Urdu - Urdu")},
  176. {0x0421, TEXT("Indonesian - Indonesia")},
  177. {0x0422, TEXT("Ukrainian - Ukraine")},
  178. {0x0423, TEXT("Belarussian - Belarus")},
  179. {0x0424, TEXT("Slovene - Slovenia")},
  180. {0x0425, TEXT("Estonian - Estonia")},
  181. {0x0426, TEXT("Latvian - Latvia")},
  182. {0x0427, TEXT("Lithuanian - Lithuania")},
  183. {0x0429, TEXT("Farsi - Iran")},
  184. {0x042a, TEXT("Vietnamese - Vietnam")},
  185. {0x042d, TEXT("Basque - Spain")},
  186. {0x042e, TEXT("Sorbian - Sorbian")},
  187. {0x042f, TEXT("FYRO Macedonian - Macedonian")},
  188. {0x0430, TEXT("Sutu - Sutu")},
  189. {0x0431, TEXT("Tsonga - Tsonga")},
  190. {0x0432, TEXT("Tswana - Tswana")},
  191. {0x0433, TEXT("Venda - Venda")},
  192. {0x0434, TEXT("Xhosa - Xhosa")},
  193. {0x0435, TEXT("Zulu - Zulu")},
  194. {0x0436, TEXT("Afrikaans - South Africa")},
  195. {0x0438, TEXT("Faeroese - Faeroe Islands")},
  196. {0x0439, TEXT("Hindi - Hindi")},
  197. {0x043a, TEXT("Maltese - Maltese")},
  198. {0x043b, TEXT("Saami - Saami (Lappish)")},
  199. {0x043c, TEXT("Gaelic - Scots")},
  200. {0x083c, TEXT("Gaelic - Irish")},
  201. {0x043d, TEXT("Yiddish - Yiddish")},
  202. {0x043e, TEXT("Malay - Malaysian")},
  203. {0x083e, TEXT("Malay - Brunei")},
  204. {0x0441, TEXT("Swahili - Kenya")}
  205. };
  206. const DWORD s_PMAdminHelpIDs[] =
  207. {
  208. IDC_SERVERNAME, IDH_SERVERNAME,
  209. IDC_INSTALLDIR, IDH_INSTALLDIR,
  210. IDC_VERSION, IDH_VERSION,
  211. IDC_TIMEWINDOW, IDH_TIMEWINDOW,
  212. IDC_FORCESIGNIN, IDH_FORCESIGNIN,
  213. IDC_LANGUAGEID, IDH_LANGUAGEID,
  214. IDC_COBRANDING_TEMPLATE, IDH_COBRANDING_TEMPLATE,
  215. IDC_SITEID, IDH_SITEID,
  216. IDC_RETURNURL, IDH_RETURNURL,
  217. IDC_COOKIEDOMAIN, IDH_COOKIEDOMAIN,
  218. IDC_COOKIEPATH, IDH_COOKIEPATH,
  219. IDC_PROFILEDOMAIN, IDH_PROFILEDOMAIN,
  220. IDC_PROFILEPATH, IDH_PROFILEPATH,
  221. IDC_SECUREDOMAIN, IDH_SECUREDOMAIN,
  222. IDC_SECUREPATH, IDH_SECUREPATH,
  223. IDC_STANDALONE, IDH_STANDALONE,
  224. IDC_DISABLECOOKIES, IDH_DISABLECOOKIES,
  225. IDC_DISASTERURL, IDH_DISASTERURL,
  226. IDC_COMMIT, IDH_COMMIT,
  227. IDC_UNDO, IDH_UNDO,
  228. IDC_CONFIGSETS, IDH_CONFIGSETS,
  229. IDC_NEWCONFIG, IDH_NEWCONFIG,
  230. IDC_REMOVECONFIG, IDH_REMOVECONFIG,
  231. IDC_HOSTNAMEEDIT, IDH_HOSTNAMEEDIT,
  232. IDC_HOSTIPEDIT, IDH_HOSTIPEDIT,
  233. 0, 0
  234. };
  235. #define SERVERNAME_CMD "/Server"
  236. #define CONFIGFILE_CMD "/Config"
  237. #define CONFIGSET_CMD "/Name"
  238. #define HELP_CMD "/?"
  239. // ############################################################################
  240. //
  241. // Spaces are returned as a token
  242. // modified to consider anything between paired double quotes to be a single token
  243. // For example, the following consists of 9 tokens (4 spaces and 5 cmds)
  244. //
  245. // first second "this is the third token" fourth "fifth"
  246. //
  247. // The quote marks are included in the returned string (pszOut)
  248. void GetCmdLineToken(LPTSTR *ppszCmd, LPTSTR pszOut)
  249. {
  250. LPTSTR c;
  251. int i = 0;
  252. BOOL fInQuote = FALSE;
  253. c = *ppszCmd;
  254. pszOut[0] = *c;
  255. if (!*c)
  256. return;
  257. if (*c == ' ')
  258. {
  259. pszOut[1] = '\0';
  260. *ppszCmd = c+1;
  261. return;
  262. }
  263. else if( '"' == *c )
  264. {
  265. fInQuote = TRUE;
  266. }
  267. NextChar:
  268. i++;
  269. c++;
  270. if( !*c || (!fInQuote && (*c == ' ')) )
  271. {
  272. pszOut[i] = '\0';
  273. *ppszCmd = c;
  274. return;
  275. }
  276. else if( fInQuote && (*c == '"') )
  277. {
  278. fInQuote = FALSE;
  279. pszOut[i] = *c;
  280. i++;
  281. c++;
  282. pszOut[i] = '\0';
  283. *ppszCmd = c;
  284. return;
  285. }
  286. else
  287. {
  288. pszOut[i] = *c;
  289. goto NextChar;
  290. }
  291. }
  292. // Process the incomming command line
  293. void Usage()
  294. {
  295. ReportError(NULL, IDS_USAGE);
  296. exit(0);
  297. }
  298. void ProcessCommandLineArgs
  299. (
  300. LPTSTR szCmdLine
  301. )
  302. {
  303. TCHAR szOut[MAX_PATH];
  304. // Get the first token
  305. GetCmdLineToken(&szCmdLine,szOut);
  306. while (szOut[0])
  307. {
  308. if (0 == lstrcmpi(&szOut[0],SERVERNAME_CMD))
  309. {
  310. if(g_szRemoteComputer[0] != '\0') Usage();
  311. // Get the Name of the Server
  312. GetCmdLineToken(&szCmdLine,szOut); // This one gets the space
  313. if (szOut[0])
  314. {
  315. GetCmdLineToken(&szCmdLine,g_szRemoteComputer);
  316. if(!g_szRemoteComputer[0]) Usage();
  317. }
  318. else
  319. Usage();
  320. }
  321. if (0 == lstrcmpi(&szOut[0],CONFIGFILE_CMD))
  322. {
  323. if(g_szConfigFile[0] != '\0') Usage();
  324. // Get the Config File name
  325. GetCmdLineToken(&szCmdLine, szOut); // This one gets the space
  326. if (szOut[0])
  327. {
  328. GetCmdLineToken(&szCmdLine, g_szConfigFile);
  329. if(!g_szConfigFile[0]) Usage();
  330. }
  331. else
  332. Usage();
  333. }
  334. if (0 == lstrcmpi(&szOut[0],CONFIGSET_CMD))
  335. {
  336. if(g_szConfigSet[0] != '\0') Usage();
  337. // Get the Config Set name
  338. GetCmdLineToken(&szCmdLine, szOut);
  339. if (szOut[0])
  340. {
  341. GetCmdLineToken(&szCmdLine, g_szConfigSet);
  342. if(!g_szConfigSet[0]) Usage();
  343. }
  344. else
  345. Usage();
  346. }
  347. if (0 == lstrcmpi(&szOut[0],HELP_CMD))
  348. Usage();
  349. // Eat the next token, it will be null if we are at the end
  350. GetCmdLineToken(&szCmdLine,szOut);
  351. }
  352. }
  353. BOOL RegisterAndSetIcon
  354. (
  355. HINSTANCE hInstance
  356. )
  357. {
  358. //
  359. // Fetch the default dialog class information.
  360. //
  361. WNDCLASS wndClass;
  362. if (!GetClassInfo (0, MAKEINTRESOURCE (32770), &wndClass))
  363. {
  364. return FALSE;
  365. }
  366. //
  367. // Assign the Icon.
  368. //
  369. wndClass.hInstance = hInstance;
  370. wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  371. wndClass.lpszClassName = (LPTSTR)g_szDlgClassName;
  372. wndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN_MENU);
  373. //
  374. // Register the window class.
  375. //
  376. return RegisterClass( &wndClass );
  377. }
  378. void InitializeComputerMRU(void)
  379. {
  380. g_ComputerMRU.load(TEXT("Computer MRU"), TEXT("msppcnfg.ini"));
  381. }
  382. void SaveComputerMRU(void)
  383. {
  384. g_ComputerMRU.save(TEXT("Computer MRU"), TEXT("msppcnfg.ini"));
  385. }
  386. void InsertComputerMRU
  387. (
  388. LPCTSTR szComputer
  389. )
  390. {
  391. g_ComputerMRU.insert(szComputer);
  392. }
  393. void InitializePMConfigStruct
  394. (
  395. LPPMSETTINGS lpPMConfig
  396. )
  397. {
  398. // Zero Init the structure
  399. ZeroMemory(lpPMConfig, sizeof(PMSETTINGS));
  400. // Setup the buffer sizes
  401. lpPMConfig->cbCoBrandTemplate = sizeof(lpPMConfig->szCoBrandTemplate);
  402. lpPMConfig->cbReturnURL = sizeof(lpPMConfig->szReturnURL);
  403. lpPMConfig->cbTicketDomain = sizeof(lpPMConfig->szTicketDomain);
  404. lpPMConfig->cbTicketPath = sizeof(lpPMConfig->szTicketPath);
  405. lpPMConfig->cbProfileDomain = sizeof(lpPMConfig->szProfileDomain);
  406. lpPMConfig->cbProfilePath = sizeof(lpPMConfig->szProfilePath);
  407. lpPMConfig->cbSecureDomain = sizeof(lpPMConfig->szSecureDomain);
  408. lpPMConfig->cbSecurePath = sizeof(lpPMConfig->szSecurePath);
  409. lpPMConfig->cbDisasterURL = sizeof(lpPMConfig->szDisasterURL);
  410. lpPMConfig->cbHostName = sizeof(lpPMConfig->szHostName);
  411. lpPMConfig->cbHostIP = sizeof(lpPMConfig->szHostIP);
  412. }
  413. void GetDefaultSettings
  414. (
  415. LPPMSETTINGS lpPMConfig
  416. )
  417. {
  418. InitializePMConfigStruct(lpPMConfig);
  419. lpPMConfig->dwSiteID = 1;
  420. lpPMConfig->dwLanguageID = 1033;
  421. lpPMConfig->dwTimeWindow = 14400;
  422. #ifdef DO_KEYSTUFF
  423. lpPMConfig->dwCurrentKey = 1;
  424. #endif
  425. }
  426. void InitInstance
  427. (
  428. HINSTANCE hInstance
  429. )
  430. {
  431. InitializeComputerMRU();
  432. InitializePMConfigStruct(&g_OriginalSettings);
  433. g_bCanUndo = FALSE;
  434. g_szInstallPath[0] = '\0';
  435. ZeroMemory(g_szPMVersion, sizeof(g_szPMVersion));
  436. ZeroMemory(g_szRemoteComputer, sizeof(g_szRemoteComputer));
  437. ZeroMemory(g_szNewRemoteComputer, sizeof(g_szNewRemoteComputer));
  438. ZeroMemory(g_szConfigFile, sizeof(g_szConfigFile));
  439. ZeroMemory(g_szHelpFileName, sizeof(g_szHelpFileName));
  440. // Load the Help File Name
  441. LoadString(hInstance, IDS_PMHELPFILE, g_szHelpFileName, sizeof(g_szHelpFileName));
  442. }
  443. INT WINAPI WinMain
  444. (
  445. HINSTANCE hInstance,
  446. HINSTANCE hPrevInstance,
  447. LPSTR lpszCmdLine,
  448. INT nCmdShow
  449. )
  450. {
  451. MSG msg;
  452. HACCEL hAccel;
  453. TCHAR szTitle[MAX_TITLE];
  454. TCHAR szMessage[MAX_MESSAGE];
  455. g_hInst = hInstance;
  456. //don't forget this
  457. InitCommonControls();
  458. if(!hPrevInstance)
  459. {
  460. //
  461. // Register this app's window and set the icon only 1 time for all instances
  462. //
  463. if (!RegisterAndSetIcon(hInstance))
  464. return FALSE;
  465. }
  466. // Initialize the necessary Instance Variables and settings;
  467. InitInstance(hInstance);
  468. // If there was a command line, then process it, otherwise show the GUI
  469. if (lpszCmdLine && (*lpszCmdLine != '\0'))
  470. {
  471. TCHAR szFile[MAX_PATH];
  472. ProcessCommandLineArgs(lpszCmdLine);
  473. if(g_szConfigFile[0] == TEXT('\0')) Usage();
  474. // Check to see if we got a fully qualified path name for the config file
  475. if (PathIsFileSpec(g_szConfigFile))
  476. {
  477. // Not qualified, so assume it exists in our CWD
  478. lstrcpy(szFile, g_szConfigFile);
  479. GetCurrentDirectory(sizeof(g_szConfigFile), g_szConfigFile);
  480. PathAppend(g_szConfigFile, szFile);
  481. }
  482. // Load the Config set specified
  483. if (ReadFileConfigSet(&g_OriginalSettings, g_szConfigFile))
  484. {
  485. // Commit the ConfigSet Read
  486. WriteRegConfigSet(NULL,
  487. &g_OriginalSettings,
  488. g_szRemoteComputer,
  489. g_szConfigSet);
  490. }
  491. }
  492. else
  493. {
  494. //
  495. // Create the dialog for this instance
  496. //
  497. DialogBox( hInstance,
  498. MAKEINTRESOURCE (IDD_MAIN),
  499. NULL,
  500. (DLGPROC)DlgMain );
  501. }
  502. SaveComputerMRU();
  503. return TRUE;
  504. }
  505. /**************************************************************************
  506. Utility functions for the dialogs
  507. **************************************************************************/
  508. /**************************************************************************
  509. About()
  510. **************************************************************************/
  511. LRESULT CALLBACK About
  512. (
  513. HWND hWnd,
  514. UINT uMessage,
  515. WPARAM wParam,
  516. LPARAM lParam
  517. )
  518. {
  519. switch (uMessage)
  520. {
  521. case WM_INITDIALOG:
  522. {
  523. TCHAR achProductVersionBuf[64];
  524. TCHAR achProductIDBuf[64];
  525. HKEY hkeyPassport;
  526. DWORD dwcbTemp;
  527. DWORD dwType;
  528. if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  529. g_szPassportReg,
  530. 0,
  531. KEY_READ,
  532. &hkeyPassport))
  533. {
  534. ReportError(hWnd, IDS_CONFIGREAD_ERROR);
  535. return TRUE;
  536. }
  537. // Load the Help File Name
  538. LoadString(g_hInst, IDS_PRODUCTID, achProductIDBuf, sizeof(achProductIDBuf));
  539. LoadString(g_hInst, IDS_PRODUCTVERSION, achProductVersionBuf, sizeof(achProductVersionBuf));
  540. // Display product version
  541. lstrcat(achProductVersionBuf, VER_PRODUCTVERSION_STR);
  542. SetDlgItemText(hWnd, IDC_PRODUCTVERSION, achProductVersionBuf);
  543. // Display product id
  544. dwcbTemp = PRODUCTID_LEN;
  545. dwType = REG_SZ;
  546. RegQueryValueEx(hkeyPassport,
  547. TEXT("ProductID"),
  548. NULL,
  549. &dwType,
  550. (LPBYTE)&(achProductIDBuf[lstrlen(achProductIDBuf)]),
  551. &dwcbTemp);
  552. RegCloseKey(hkeyPassport);
  553. SetDlgItemText(hWnd, IDC_PRODUCTID, achProductIDBuf);
  554. return TRUE;
  555. }
  556. case WM_COMMAND:
  557. switch(wParam)
  558. {
  559. case IDOK:
  560. case IDCANCEL:
  561. EndDialog(hWnd, wParam);
  562. return TRUE;
  563. }
  564. break;
  565. }
  566. return FALSE;
  567. }
  568. /**************************************************************************
  569. UpdateTimeWindowDisplay
  570. this function will update the "human" readable display of the time
  571. window setting.
  572. **************************************************************************/
  573. void UpdateTimeWindowDisplay
  574. (
  575. HWND hWndDlg,
  576. DWORD dwTimeWindow
  577. )
  578. {
  579. int days, hours, minutes, seconds;
  580. TCHAR szTemp[MAX_REGISTRY_STRING];
  581. // Format the Time display
  582. days = dwTimeWindow / SECONDS_PER_DAY;
  583. hours = (dwTimeWindow - (days * SECONDS_PER_DAY)) / SECONDS_PER_HOUR;
  584. minutes = (dwTimeWindow - (days * SECONDS_PER_DAY) - (hours * SECONDS_PER_HOUR)) / SECONDS_PER_MIN;
  585. seconds = dwTimeWindow -
  586. (days * SECONDS_PER_DAY) -
  587. (hours * SECONDS_PER_HOUR) -
  588. (minutes * SECONDS_PER_MIN);
  589. wsprintf (szTemp, TEXT("%d d : %d h : %d m : %d s"), days, hours, minutes, seconds);
  590. SetDlgItemText(hWndDlg, IDC_TIMEWINDOW_TIME, szTemp);
  591. }
  592. /**************************************************************************
  593. UpdateLanguageDisplay
  594. this function will update both the combo box for selecting/entering
  595. the Language ID value, and the language value if possible.
  596. If idx is >= 0, then it is a valid index into the array, otherwise
  597. the index is found by searching the entries in the list
  598. **************************************************************************/
  599. void UpdateLanguageDisplay
  600. (
  601. HWND hWndDlg,
  602. DWORD dwLanguageID,
  603. INT idx
  604. )
  605. {
  606. TCHAR szTemp[MAX_LCID_VALUE];
  607. LRESULT idxLangID;
  608. if (idx >= 0)
  609. {
  610. SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, g_szLanguageIDMap[idx].lpszLang);
  611. }
  612. else
  613. {
  614. wsprintf (szTemp, TEXT("%d"), dwLanguageID);
  615. // Search the Combo-Box to see if we have the proposed LCID in the list already
  616. if (CB_ERR !=
  617. (idxLangID = SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_FINDSTRINGEXACT, 0, (LPARAM)szTemp)))
  618. {
  619. // The Language ID is one that is in our pre-populated list, so we have a matching
  620. // language string as well
  621. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETCURSEL, idxLangID, 0l);
  622. SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, g_szLanguageIDMap[(int) idxLangID].lpszLang);
  623. }
  624. else
  625. {
  626. SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, g_szUnknown);
  627. }
  628. }
  629. }
  630. /**************************************************************************
  631. SetUndoButton
  632. Sets the state of the Undo button.
  633. **************************************************************************/
  634. void SetUndoButton
  635. (
  636. HWND hWndDlg,
  637. BOOL bUndoState
  638. )
  639. {
  640. g_bCanUndo = bUndoState;
  641. EnableWindow(GetDlgItem(hWndDlg, IDC_UNDO), bUndoState);
  642. }
  643. /**************************************************************************
  644. InitMainDlg
  645. **************************************************************************/
  646. BOOL InitMainDlg
  647. (
  648. HWND hWndDlg,
  649. LPPMSETTINGS lpPMConfig
  650. )
  651. {
  652. TCHAR szTemp[MAX_REGISTRY_STRING];
  653. LPTSTR lpszConfigSetNames, lpszCur;
  654. LRESULT dwCurSel;
  655. int nCmdShow;
  656. int nSelectedLanguage;
  657. #ifdef DO_KEYSTUFF
  658. HWND hWndListView;
  659. LVCOLUMN lvc;
  660. #endif
  661. // Remote Computer Name
  662. if (('\0' != g_szRemoteComputer[0]))
  663. {
  664. SetDlgItemText(hWndDlg, IDC_SERVERNAME, g_szRemoteComputer);
  665. }
  666. else
  667. {
  668. LoadString(g_hInst, IDS_LOCALHOST, szTemp, sizeof(szTemp));
  669. SetDlgItemText(hWndDlg, IDC_SERVERNAME, szTemp);
  670. }
  671. // Icon
  672. HICON hic = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_PMADMIN));
  673. SendMessage(hWndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hic);
  674. SendMessage(hWndDlg, WM_SETICON, ICON_BIG, (LPARAM)hic);
  675. // List of config sets
  676. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_RESETCONTENT, 0, 0L);
  677. LoadString(g_hInst, IDS_DEFAULT, szTemp, sizeof(szTemp));
  678. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_ADDSTRING, 0, (LPARAM)szTemp);
  679. if(ReadRegConfigSetNames(hWndDlg, g_szRemoteComputer, &lpszConfigSetNames) &&
  680. lpszConfigSetNames)
  681. {
  682. lpszCur = lpszConfigSetNames;
  683. while(*lpszCur)
  684. {
  685. SendDlgItemMessage(hWndDlg,
  686. IDC_CONFIGSETS,
  687. CB_ADDSTRING,
  688. 0,
  689. (LPARAM)lpszCur);
  690. lpszCur = _tcschr(lpszCur, TEXT('\0')) + 1;
  691. }
  692. free(lpszConfigSetNames);
  693. lpszConfigSetNames = NULL;
  694. }
  695. if(g_szConfigSet[0] != TEXT('\0'))
  696. {
  697. dwCurSel = SendDlgItemMessage(hWndDlg,
  698. IDC_CONFIGSETS,
  699. CB_FINDSTRINGEXACT,
  700. -1,
  701. (LPARAM)g_szConfigSet);
  702. }
  703. else
  704. {
  705. dwCurSel = 0;
  706. }
  707. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_SETCURSEL, dwCurSel, 0L);
  708. // If the current selection was the default, then hide the
  709. // host name and ip address controls.
  710. nCmdShow = (dwCurSel ? SW_SHOW : SW_HIDE);
  711. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTNAMETEXT), nCmdShow);
  712. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTNAMEEDIT), nCmdShow);
  713. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTIPTEXT), nCmdShow);
  714. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTIPEDIT), nCmdShow);
  715. EnableWindow(GetDlgItem(hWndDlg, IDC_REMOVECONFIG), (int) dwCurSel);
  716. //
  717. // HostName
  718. SetDlgItemText(hWndDlg, IDC_HOSTNAMEEDIT, lpPMConfig->szHostName);
  719. SendDlgItemMessage(hWndDlg, IDC_HOSTNAMEEDIT, EM_SETLIMITTEXT, INTERNET_MAX_HOST_NAME_LENGTH - 1, 0l);
  720. //
  721. // HostIP
  722. SetDlgItemText(hWndDlg, IDC_HOSTIPEDIT, lpPMConfig->szHostIP);
  723. SendDlgItemMessage(hWndDlg, IDC_HOSTIPEDIT, EM_SETLIMITTEXT, MAX_IPLEN - 1, 0l);
  724. //
  725. // Install Dir
  726. SetDlgItemText(hWndDlg, IDC_INSTALLDIR, g_szInstallPath);
  727. // Version
  728. SetDlgItemText(hWndDlg, IDC_VERSION, g_szPMVersion);
  729. // Time Window
  730. // Set the Range and position for the spinner
  731. SendDlgItemMessage(hWndDlg, IDC_TIMEWINDOW_SPIN, UDM_SETRANGE32, (int)0, (LPARAM)(int)MAX_TIME_WINDOW_SECONDS );
  732. SendDlgItemMessage(hWndDlg, IDC_TIMEWINDOW_SPIN, UDM_SETPOS, 0, MAKELONG(lpPMConfig->dwTimeWindow,0));
  733. wsprintf (szTemp, TEXT("%lu"), lpPMConfig->dwTimeWindow);
  734. SetDlgItemText(hWndDlg, IDC_TIMEWINDOW, szTemp);
  735. UpdateTimeWindowDisplay(hWndDlg, lpPMConfig->dwTimeWindow);
  736. // Initialize the force signing values
  737. CheckDlgButton(hWndDlg, IDC_FORCESIGNIN, lpPMConfig->dwForceSignIn ? BST_CHECKED : BST_UNCHECKED);
  738. // language ID
  739. // Initialize the LanguageID dropdown with the known LCIDs
  740. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_RESETCONTENT, 0, 0l);
  741. nSelectedLanguage = -1;
  742. for (int i = 0; i < sizeof(g_szLanguageIDMap)/sizeof(LANGIDMAP); i++)
  743. {
  744. LRESULT lCurrent = SendDlgItemMessage(hWndDlg,
  745. IDC_LANGUAGEID,
  746. CB_ADDSTRING,
  747. 0,
  748. (LPARAM)g_szLanguageIDMap[i].lpszLang);
  749. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETITEMDATA, lCurrent, (LPARAM)g_szLanguageIDMap[i].wLangID);
  750. if(lpPMConfig->dwLanguageID == g_szLanguageIDMap[i].wLangID)
  751. {
  752. nSelectedLanguage = i;
  753. }
  754. }
  755. // Now select the correct item in the list...
  756. if(nSelectedLanguage == -1)
  757. {
  758. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETCURSEL, 0, NULL);
  759. }
  760. else
  761. {
  762. LRESULT lLanguage = SendDlgItemMessage(hWndDlg,
  763. IDC_LANGUAGEID,
  764. CB_FINDSTRINGEXACT,
  765. -1,
  766. (LPARAM)g_szLanguageIDMap[nSelectedLanguage].lpszLang);
  767. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETCURSEL, lLanguage, NULL);
  768. }
  769. // Update the display of the combo box and the language value
  770. UpdateLanguageDisplay(hWndDlg, lpPMConfig->dwLanguageID, -1);
  771. // Co-branding template
  772. SetDlgItemText(hWndDlg, IDC_COBRANDING_TEMPLATE, lpPMConfig->szCoBrandTemplate);
  773. SendDlgItemMessage(hWndDlg, IDC_COBRANDING_TEMPLATE, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  774. // Site ID
  775. wsprintf (szTemp, TEXT("%d"), lpPMConfig->dwSiteID);
  776. SetDlgItemText(hWndDlg, IDC_SITEID, szTemp);
  777. // Return URL
  778. SetDlgItemText(hWndDlg, IDC_RETURNURL, lpPMConfig->szReturnURL);
  779. SendDlgItemMessage(hWndDlg, IDC_RETURNURL, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  780. // Cookie domain
  781. SetDlgItemText(hWndDlg, IDC_COOKIEDOMAIN, lpPMConfig->szTicketDomain);
  782. SendDlgItemMessage(hWndDlg, IDC_COOKIEDOMAIN, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  783. // Cookie path
  784. SetDlgItemText(hWndDlg, IDC_COOKIEPATH, lpPMConfig->szTicketPath);
  785. SendDlgItemMessage(hWndDlg, IDC_COOKIEPATH, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  786. // Cookie domain
  787. SetDlgItemText(hWndDlg, IDC_PROFILEDOMAIN, lpPMConfig->szProfileDomain);
  788. SendDlgItemMessage(hWndDlg, IDC_PROFILEDOMAIN, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  789. // Cookie path
  790. SetDlgItemText(hWndDlg, IDC_PROFILEPATH, lpPMConfig->szProfilePath);
  791. SendDlgItemMessage(hWndDlg, IDC_PROFILEPATH, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  792. // Secure Cookie domain
  793. SetDlgItemText(hWndDlg, IDC_SECUREDOMAIN, lpPMConfig->szSecureDomain);
  794. SendDlgItemMessage(hWndDlg, IDC_SECUREDOMAIN, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  795. // Secure Cookie path
  796. SetDlgItemText(hWndDlg, IDC_SECUREPATH, lpPMConfig->szSecurePath);
  797. SendDlgItemMessage(hWndDlg, IDC_SECUREPATH, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  798. // Disaster URL
  799. SetDlgItemText(hWndDlg, IDC_DISASTERURL, lpPMConfig->szDisasterURL);
  800. SendDlgItemMessage(hWndDlg, IDC_DISASTERURL, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  801. // Set the Standalone and Disable Cookies check boxes
  802. CheckDlgButton(hWndDlg, IDC_STANDALONE, lpPMConfig->dwStandAlone ? BST_CHECKED : BST_UNCHECKED);
  803. CheckDlgButton(hWndDlg, IDC_DISABLECOOKIES, lpPMConfig->dwDisableCookies ? BST_CHECKED : BST_UNCHECKED);
  804. SetUndoButton(hWndDlg, FALSE);
  805. #ifdef DO_KEYSTUFF
  806. // Current encryption key
  807. wsprintf (szTemp, TEXT("%d"), lpPMConfig->dwCurrentKey);
  808. SetDlgItemText(hWndDlg, IDC_CURRENTKEY, szTemp);
  809. // Initialize the Listview control for the Encryption Keys
  810. hWndListView = GetDlgItem(hWndDlg, IDC_KEYLIST);
  811. // Setup for full row select
  812. ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_FULLROWSELECT);
  813. // Setup the columns
  814. lvc.mask = LVCF_TEXT;
  815. lvc.pszText = TEXT("Key Number");
  816. lvc.iSubItem = 0;
  817. ListView_InsertColumn(hWndListView, 0, &lvc);
  818. lvc.mask = LVCF_TEXT;
  819. lvc.pszText = TEXT("Expires");
  820. lvc.iSubItem = 1;
  821. ListView_InsertColumn(hWndListView, 1, &lvc);
  822. lvc.mask = LVCF_TEXT;
  823. lvc.pszText = TEXT("Current");
  824. lvc.iSubItem = 2;
  825. ListView_InsertColumn(hWndListView, 2, &lvc);
  826. // Initially size the columns
  827. ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER);
  828. ListView_SetColumnWidth(hWndListView, 1, LVSCW_AUTOSIZE_USEHEADER);
  829. ListView_SetColumnWidth(hWndListView, 2, LVSCW_AUTOSIZE_USEHEADER);
  830. // Enumerate the KeyData sub-key to fill in the list
  831. DWORD dwRet;
  832. DWORD dwIndex = 0;
  833. TCHAR szValue[MAX_REGISTRY_STRING];
  834. DWORD dwcbValue;
  835. LVITEM lvi;
  836. dwType = REG_SZ;
  837. do {
  838. dwcbValue = sizeof(szValue);
  839. dwcbTemp = sizeof(szTemp);
  840. szTemp[0] = '\0';
  841. szValue[0] = '\0';
  842. if (ERROR_SUCCESS == (dwRet = RegEnumValue(hkeyEncryptionKeyData,
  843. dwIndex,
  844. szValue,
  845. &dwcbValue,
  846. NULL,
  847. &dwType,
  848. (LPBYTE)szTemp,
  849. &dwcbTemp)))
  850. {
  851. // Insert the Column
  852. lvi.mask = LVIF_TEXT;
  853. lvi.iItem = dwIndex;
  854. lvi.iSubItem = 0;
  855. lvi.pszText = szValue;
  856. lvi.cchTextMax = lstrlen(szValue);
  857. ListView_InsertItem(hWndListView, &lvi);
  858. ListView_SetItemText(hWndListView, dwIndex, 1, szTemp);
  859. // See if this is the current key
  860. if (g_OriginalSettings.dwCurrentKey == (DWORD)atoi((LPSTR)szValue))
  861. {
  862. ListView_SetItemText(hWndListView, dwIndex, 2, g_szYes);
  863. }
  864. else
  865. {
  866. ListView_SetItemText(hWndListView, dwIndex, 2, g_szNo);
  867. }
  868. }
  869. ++dwIndex;
  870. } while (dwRet == ERROR_SUCCESS);
  871. #endif
  872. return TRUE;
  873. }
  874. /**************************************************************************
  875. Update the computer MRU list based on contents of g_aszComputerMRU
  876. **************************************************************************/
  877. BOOL
  878. UpdateComputerMRU
  879. (
  880. HWND hWndDlg
  881. )
  882. {
  883. BOOL bReturn;
  884. HMENU hMenu;
  885. HMENU hComputerMenu;
  886. int nIndex;
  887. MENUITEMINFO mii;
  888. TCHAR achMenuBuf[MAX_PATH];
  889. DWORD dwError;
  890. hMenu = GetMenu(hWndDlg);
  891. if(hMenu == NULL)
  892. {
  893. bReturn = FALSE;
  894. goto Cleanup;
  895. }
  896. hComputerMenu = GetSubMenu(hMenu, 1);
  897. if(hComputerMenu == NULL)
  898. {
  899. bReturn = FALSE;
  900. goto Cleanup;
  901. }
  902. while(GetMenuItemID(hComputerMenu, 1) != -1)
  903. DeleteMenu(hComputerMenu, 1, MF_BYPOSITION);
  904. for(nIndex = 0; nIndex < COMPUTER_MRU_SIZE; nIndex++)
  905. {
  906. if(g_ComputerMRU[nIndex] != NULL)
  907. break;
  908. }
  909. if(nIndex == COMPUTER_MRU_SIZE)
  910. {
  911. bReturn = TRUE;
  912. goto Cleanup;
  913. }
  914. // Add the separator.
  915. ZeroMemory(&mii, sizeof(MENUITEMINFO));
  916. mii.cbSize = sizeof(MENUITEMINFO);
  917. mii.fMask = MIIM_TYPE;
  918. mii.fType = MFT_SEPARATOR;
  919. if(!InsertMenuItem(hComputerMenu, 1, TRUE, &mii))
  920. {
  921. dwError = GetLastError();
  922. bReturn = FALSE;
  923. goto Cleanup;
  924. }
  925. // Now add each item in the MRU list.
  926. for(nIndex = 0; nIndex < COMPUTER_MRU_SIZE && g_ComputerMRU[nIndex]; nIndex++)
  927. {
  928. ZeroMemory(&mii, sizeof(MENUITEMINFO));
  929. mii.cbSize = sizeof(MENUITEMINFO);
  930. mii.fMask = MIIM_TYPE | MIIM_ID;
  931. mii.fType = MFT_STRING;
  932. mii.wID = IDM_COMPUTERMRUBASE + nIndex;
  933. wsprintf(achMenuBuf, TEXT("&%d %s"), nIndex + 1, g_ComputerMRU[nIndex]);
  934. mii.dwTypeData = achMenuBuf;
  935. mii.cch = lstrlen(achMenuBuf) + 1;
  936. InsertMenuItem(hComputerMenu, nIndex + 2, TRUE, &mii);
  937. }
  938. bReturn = TRUE;
  939. Cleanup:
  940. return bReturn;
  941. }
  942. /**************************************************************************
  943. Leaving this config set, prompt for save.
  944. **************************************************************************/
  945. int
  946. SavePrompt
  947. (
  948. HWND hWndDlg
  949. )
  950. {
  951. TCHAR szPrompt[MAX_RESOURCE];
  952. TCHAR szTitle[MAX_RESOURCE];
  953. LoadString(g_hInst, IDS_SAVE_PROMPT, szPrompt, sizeof(szPrompt));
  954. LoadString(g_hInst, IDS_APP_TITLE, szTitle, sizeof(szTitle));
  955. return MessageBox(hWndDlg, szPrompt, szTitle, MB_YESNOCANCEL | MB_ICONEXCLAMATION);
  956. }
  957. /**************************************************************************
  958. Switching configurations, check for unsaved changes.
  959. **************************************************************************/
  960. BOOL
  961. DoConfigSwitch
  962. (
  963. HWND hWndDlg,
  964. LPTSTR szNewComputer,
  965. LPTSTR szNewConfigSet
  966. )
  967. {
  968. BOOL bReturn;
  969. int nOption;
  970. PMSETTINGS newSettings;
  971. //
  972. // If switching to current config, do nothing.
  973. //
  974. if(lstrcmp(szNewComputer, g_szRemoteComputer) == 0 &&
  975. lstrcmp(szNewConfigSet, g_szConfigSet) == 0)
  976. {
  977. bReturn = TRUE;
  978. goto Cleanup;
  979. }
  980. //
  981. // If no changes then return.
  982. //
  983. if(0 == memcmp(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS)))
  984. nOption = IDNO;
  985. else
  986. nOption = SavePrompt(hWndDlg);
  987. switch(nOption)
  988. {
  989. case IDYES:
  990. if(!WriteRegConfigSet(hWndDlg, &g_CurrentSettings, g_szRemoteComputer, g_szConfigSet))
  991. {
  992. bReturn = FALSE;
  993. break;
  994. }
  995. case IDNO:
  996. InitializePMConfigStruct(&newSettings);
  997. if (ReadRegConfigSet(hWndDlg,
  998. &newSettings,
  999. szNewComputer,
  1000. szNewConfigSet))
  1001. {
  1002. memcpy(g_szRemoteComputer, szNewComputer, sizeof(g_szRemoteComputer));
  1003. memcpy(g_szConfigSet, szNewConfigSet, sizeof(g_szConfigSet));
  1004. memcpy(&g_CurrentSettings, &newSettings, sizeof(PMSETTINGS));
  1005. memcpy(&g_OriginalSettings, &newSettings, sizeof(PMSETTINGS));
  1006. bReturn = TRUE;
  1007. }
  1008. else
  1009. {
  1010. bReturn = FALSE;
  1011. }
  1012. InitMainDlg(hWndDlg, &g_CurrentSettings);
  1013. break;
  1014. case IDCANCEL:
  1015. {
  1016. LRESULT lSel;
  1017. if(g_szConfigSet[0] == TEXT('\0'))
  1018. {
  1019. lSel = 0;
  1020. }
  1021. else
  1022. {
  1023. lSel = SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_FINDSTRINGEXACT, 0, (LPARAM)g_szConfigSet);
  1024. }
  1025. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_SETCURSEL, lSel, 0L);
  1026. bReturn = FALSE;
  1027. }
  1028. break;
  1029. }
  1030. Cleanup:
  1031. return bReturn;
  1032. }
  1033. /**************************************************************************
  1034. Switching servers, check for unsaved changes.
  1035. **************************************************************************/
  1036. BOOL
  1037. DoServerSwitch
  1038. (
  1039. HWND hWndDlg,
  1040. LPTSTR szNewComputer
  1041. )
  1042. {
  1043. BOOL bReturn;
  1044. if(DoConfigSwitch(hWndDlg, szNewComputer, TEXT("")))
  1045. {
  1046. // Put computer name on MRU list.
  1047. if(lstrlen(szNewComputer))
  1048. g_ComputerMRU.insert(szNewComputer);
  1049. else
  1050. {
  1051. TCHAR achTemp[MAX_REGISTRY_STRING];
  1052. LoadString(g_hInst, IDS_LOCALHOST, achTemp, sizeof(achTemp));
  1053. g_ComputerMRU.insert(achTemp);
  1054. }
  1055. // Update MRU menu.
  1056. UpdateComputerMRU(hWndDlg);
  1057. bReturn = TRUE;
  1058. }
  1059. else
  1060. bReturn = FALSE;
  1061. return bReturn;
  1062. }
  1063. /**************************************************************************
  1064. Closing app, check for unsaved changes.
  1065. **************************************************************************/
  1066. void
  1067. DoExit
  1068. (
  1069. HWND hWndDlg
  1070. )
  1071. {
  1072. if(0 != memcmp(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS)))
  1073. {
  1074. int nOption;
  1075. nOption = SavePrompt(hWndDlg);
  1076. switch(nOption)
  1077. {
  1078. case IDYES:
  1079. if(WriteRegConfigSet(hWndDlg, &g_CurrentSettings, g_szRemoteComputer, g_szConfigSet))
  1080. EndDialog(hWndDlg, TRUE);
  1081. break;
  1082. case IDNO:
  1083. EndDialog(hWndDlg, TRUE);
  1084. break;
  1085. case IDCANCEL:
  1086. break;
  1087. }
  1088. }
  1089. else
  1090. EndDialog( hWndDlg, TRUE );
  1091. }
  1092. /**************************************************************************
  1093. Dialog proc for the main dialog
  1094. **************************************************************************/
  1095. LRESULT CALLBACK DlgMain
  1096. (
  1097. HWND hWndDlg,
  1098. UINT uMsg,
  1099. WPARAM wParam,
  1100. LPARAM lParam
  1101. )
  1102. {
  1103. static BOOL bOkToClose;
  1104. switch ( uMsg )
  1105. {
  1106. case WM_INITDIALOG:
  1107. InitializePMConfigStruct(&g_OriginalSettings);
  1108. if (ReadRegConfigSet(hWndDlg,
  1109. &g_OriginalSettings,
  1110. g_szRemoteComputer,
  1111. g_szConfigSet))
  1112. {
  1113. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1114. UpdateComputerMRU(hWndDlg);
  1115. // Make a copy of the original setting for editing purposes
  1116. memcpy(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS));
  1117. }
  1118. return TRUE;
  1119. case WM_HELP:
  1120. {
  1121. WinHelp( (HWND)((LPHELPINFO) lParam)->hItemHandle, g_szHelpFileName,
  1122. HELP_WM_HELP, (ULONG_PTR) s_PMAdminHelpIDs);
  1123. break;
  1124. }
  1125. case WM_CONTEXTMENU:
  1126. {
  1127. WinHelp((HWND) wParam, g_szHelpFileName, HELP_CONTEXTMENU,
  1128. (ULONG_PTR) s_PMAdminHelpIDs);
  1129. break;
  1130. }
  1131. case WM_COMMAND:
  1132. {
  1133. WORD wCmd = LOWORD(wParam);
  1134. LPTSTR lpszStrToUpdate;
  1135. DWORD cbStrToUpdate;
  1136. switch (wCmd)
  1137. {
  1138. // Handle the Menu Cases
  1139. case IDM_OPEN:
  1140. {
  1141. if (PMAdmin_GetFileName(hWndDlg,
  1142. TRUE,
  1143. g_szConfigFile,
  1144. sizeof(g_szConfigFile)/sizeof(TCHAR)))
  1145. {
  1146. if (ReadFileConfigSet(&g_CurrentSettings, g_szConfigFile))
  1147. {
  1148. InitMainDlg(hWndDlg, &g_CurrentSettings);
  1149. }
  1150. }
  1151. break;
  1152. }
  1153. case IDM_SAVE:
  1154. {
  1155. // Have we alread opened or saved a config file, and have a file name
  1156. // yet?
  1157. if ('\0' != g_szConfigFile[0])
  1158. {
  1159. // Write out to the current file, and then break
  1160. WriteFileConfigSet(&g_CurrentSettings, g_szConfigFile);
  1161. break;
  1162. }
  1163. // No file name yet, so fall thru to the Save AS case
  1164. }
  1165. case IDM_SAVEAS:
  1166. {
  1167. if (PMAdmin_GetFileName(hWndDlg,
  1168. FALSE,
  1169. g_szConfigFile,
  1170. sizeof(g_szConfigFile)/sizeof(TCHAR)))
  1171. {
  1172. WriteFileConfigSet(&g_CurrentSettings, g_szConfigFile);
  1173. }
  1174. break;
  1175. }
  1176. case IDM_EXIT:
  1177. {
  1178. DoExit(hWndDlg);
  1179. break;
  1180. }
  1181. case IDM_ABOUT:
  1182. {
  1183. DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT_DIALOG), hWndDlg, (DLGPROC)About);
  1184. break;
  1185. }
  1186. case IDM_SELECT:
  1187. {
  1188. if(!PMAdmin_OnCommandConnect(hWndDlg, g_szNewRemoteComputer)) break;
  1189. if(!DoServerSwitch(hWndDlg, g_szNewRemoteComputer))
  1190. DoConfigSwitch(hWndDlg, g_szRemoteComputer, g_szConfigSet);
  1191. break;
  1192. }
  1193. case IDM_REFRESH:
  1194. {
  1195. DoConfigSwitch(hWndDlg, g_szRemoteComputer, g_szConfigSet);
  1196. break;
  1197. }
  1198. case IDM_HELP:
  1199. {
  1200. TCHAR szPMHelpFile[MAX_PATH];
  1201. lstrcpy(szPMHelpFile, g_szInstallPath);
  1202. PathAppend(szPMHelpFile, g_szPMOpsHelpFileRelativePath);
  1203. HtmlHelp(hWndDlg, szPMHelpFile, HH_DISPLAY_TOPIC, (ULONG_PTR)(LPTSTR)g_szPMAdminBookmark);
  1204. break;
  1205. }
  1206. // Handle the Dialog Control Cases
  1207. case IDC_COMMIT:
  1208. {
  1209. TCHAR szTitle[MAX_TITLE];
  1210. TCHAR szMessage[MAX_MESSAGE];
  1211. if(0 != memcmp(&g_OriginalSettings, &g_CurrentSettings, sizeof(PMSETTINGS)))
  1212. {
  1213. if (IDOK == CommitOKWarning(hWndDlg))
  1214. {
  1215. // It is OK to commit, and the registry is consistent, or it is OK to
  1216. // proceed, so write out the current settings
  1217. if (WriteRegConfigSet(hWndDlg,
  1218. &g_CurrentSettings,
  1219. g_szRemoteComputer,
  1220. g_szConfigSet))
  1221. {
  1222. // The changes where committed, so current becomes original
  1223. memcpy(&g_OriginalSettings, &g_CurrentSettings, sizeof(PMSETTINGS));
  1224. SetUndoButton(hWndDlg, FALSE);
  1225. }
  1226. else
  1227. {
  1228. ReportError(hWndDlg,IDS_COMMITERROR);
  1229. }
  1230. }
  1231. }
  1232. else
  1233. {
  1234. LoadString(g_hInst, IDS_APP_TITLE, szTitle, sizeof(szTitle));
  1235. LoadString(g_hInst, IDS_NOTHINGTOCOMMIT, szMessage, sizeof(szMessage));
  1236. MessageBox(hWndDlg, szMessage, szTitle, MB_OK);
  1237. }
  1238. break;
  1239. }
  1240. case IDC_UNDO:
  1241. {
  1242. // Restore the original settings, and re-init the current settings
  1243. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1244. memcpy(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS));
  1245. break;
  1246. }
  1247. case IDC_CONFIGSETS:
  1248. {
  1249. TCHAR szDefault[MAX_RESOURCE];
  1250. TCHAR szConfigSet[MAX_CONFIGSETNAME];
  1251. if(CBN_SELCHANGE == HIWORD(wParam))
  1252. {
  1253. GetDlgItemText(hWndDlg,
  1254. IDC_CONFIGSETS,
  1255. szConfigSet,
  1256. sizeof(szConfigSet));
  1257. //
  1258. // Convert <Default> to empty string.
  1259. //
  1260. LoadString(g_hInst, IDS_DEFAULT, szDefault, sizeof(szDefault));
  1261. if(lstrcmp(szConfigSet, szDefault) == 0)
  1262. szConfigSet[0] = TEXT('\0');
  1263. //
  1264. // If it's the current set, do nothing.
  1265. //
  1266. if(lstrcmp(szConfigSet, g_szConfigSet) != 0)
  1267. {
  1268. DoConfigSwitch(hWndDlg, g_szRemoteComputer, szConfigSet);
  1269. }
  1270. break;
  1271. }
  1272. break;
  1273. }
  1274. case IDC_NEWCONFIG:
  1275. {
  1276. DWORD dwCurSel;
  1277. TCHAR szConfigSet[MAX_CONFIGSETNAME];
  1278. PMSETTINGS newConfig;
  1279. GetDefaultSettings(&newConfig);
  1280. if(!NewConfigSet(hWndDlg,
  1281. szConfigSet,
  1282. sizeof(szConfigSet),
  1283. newConfig.szHostName,
  1284. newConfig.cbHostName,
  1285. newConfig.szHostIP,
  1286. newConfig.cbHostIP))
  1287. {
  1288. break;
  1289. }
  1290. if(WriteRegConfigSet(hWndDlg, &newConfig, g_szRemoteComputer, szConfigSet))
  1291. {
  1292. if(DoConfigSwitch(hWndDlg, g_szRemoteComputer, szConfigSet))
  1293. {
  1294. memcpy(g_szConfigSet, szConfigSet, sizeof(g_szConfigSet));
  1295. memcpy(&g_OriginalSettings, &newConfig, sizeof(PMSETTINGS));
  1296. memcpy(&g_CurrentSettings, &newConfig, sizeof(PMSETTINGS));
  1297. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1298. }
  1299. else
  1300. {
  1301. RemoveRegConfigSet(hWndDlg, g_szRemoteComputer, szConfigSet);
  1302. }
  1303. }
  1304. else
  1305. {
  1306. ReportError(hWndDlg, IDS_WRITENEW_ERROR);
  1307. }
  1308. break;
  1309. }
  1310. case IDC_REMOVECONFIG:
  1311. {
  1312. LRESULT dwCurSel;
  1313. LRESULT dwNumItems;
  1314. TCHAR szDefault[MAX_RESOURCE];
  1315. dwCurSel = SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_GETCURSEL, 0, 0L);
  1316. if(dwCurSel == 0 || dwCurSel == CB_ERR)
  1317. break;
  1318. if(!RemoveConfigSetWarning(hWndDlg))
  1319. break;
  1320. if(!RemoveRegConfigSet(hWndDlg, g_szRemoteComputer, g_szConfigSet))
  1321. {
  1322. //MessageBox(
  1323. break;
  1324. }
  1325. dwNumItems = SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_GETCOUNT, 0, 0L);
  1326. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_DELETESTRING, dwCurSel, 0L);
  1327. // Was this the last item in the list?
  1328. if(dwCurSel + 1 == dwNumItems)
  1329. dwCurSel--;
  1330. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_SETCURSEL, dwCurSel, 0L);
  1331. GetDlgItemText(hWndDlg, IDC_CONFIGSETS, g_szConfigSet, sizeof(g_szConfigSet));
  1332. LoadString(g_hInst, IDS_DEFAULT, szDefault, sizeof(szDefault));
  1333. if(lstrcmp(g_szConfigSet, szDefault) == 0)
  1334. g_szConfigSet[0] = TEXT('\0');
  1335. // [CR] Should warn if changes have not been committed!
  1336. InitializePMConfigStruct(&g_OriginalSettings);
  1337. if (ReadRegConfigSet(hWndDlg,
  1338. &g_OriginalSettings,
  1339. g_szRemoteComputer,
  1340. g_szConfigSet))
  1341. {
  1342. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1343. // Make a copy of the original setting for editing purposes
  1344. memcpy(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS));
  1345. }
  1346. break;
  1347. }
  1348. case IDC_TIMEWINDOW:
  1349. {
  1350. BOOL bValid = TRUE;
  1351. DWORD dwEditValue = GetDlgItemInt(hWndDlg, wCmd, &bValid, FALSE);
  1352. // Look at the notification code
  1353. if (EN_KILLFOCUS == HIWORD(wParam))
  1354. {
  1355. if (bValid && (dwEditValue >= 100) && (dwEditValue <= MAX_TIME_WINDOW_SECONDS))
  1356. {
  1357. g_CurrentSettings.dwTimeWindow = dwEditValue;
  1358. SetUndoButton(hWndDlg, TRUE);
  1359. UpdateTimeWindowDisplay(hWndDlg, dwEditValue);
  1360. }
  1361. else
  1362. {
  1363. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1364. SetFocus(GetDlgItem(hWndDlg, wCmd));
  1365. bOkToClose = FALSE;
  1366. }
  1367. }
  1368. break;
  1369. }
  1370. case IDC_LANGUAGEID:
  1371. {
  1372. // Look at the notification code
  1373. switch (HIWORD(wParam))
  1374. {
  1375. // The user selected a different value in the LangID combo
  1376. case CBN_SELCHANGE:
  1377. {
  1378. // Get the index of the new item selected and update with the approparite
  1379. // language ID string
  1380. LRESULT idx = SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_GETCURSEL, 0, 0);
  1381. // Update the current Settings
  1382. g_CurrentSettings.dwLanguageID =
  1383. (DWORD) SendDlgItemMessage(hWndDlg,
  1384. IDC_LANGUAGEID,
  1385. CB_GETITEMDATA,
  1386. idx,
  1387. 0);
  1388. SetUndoButton(hWndDlg, TRUE);
  1389. break;
  1390. }
  1391. }
  1392. break;
  1393. }
  1394. case IDC_COBRANDING_TEMPLATE:
  1395. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szCoBrandTemplate;
  1396. cbStrToUpdate = g_CurrentSettings.cbCoBrandTemplate;
  1397. goto HANDLE_EN_FOR_STRING_CTRLS;
  1398. case IDC_RETURNURL:
  1399. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szReturnURL;
  1400. cbStrToUpdate = g_CurrentSettings.cbReturnURL;
  1401. goto HANDLE_EN_FOR_STRING_CTRLS;
  1402. case IDC_COOKIEDOMAIN:
  1403. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szTicketDomain;
  1404. cbStrToUpdate = g_CurrentSettings.cbTicketDomain;
  1405. goto HANDLE_EN_FOR_STRING_CTRLS;
  1406. case IDC_COOKIEPATH:
  1407. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szTicketPath;
  1408. cbStrToUpdate = g_CurrentSettings.cbTicketPath;
  1409. goto HANDLE_EN_FOR_STRING_CTRLS;
  1410. case IDC_PROFILEDOMAIN:
  1411. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szProfileDomain;
  1412. cbStrToUpdate = g_CurrentSettings.cbProfileDomain;
  1413. goto HANDLE_EN_FOR_STRING_CTRLS;
  1414. case IDC_PROFILEPATH:
  1415. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szProfilePath;
  1416. cbStrToUpdate = g_CurrentSettings.cbProfilePath;
  1417. goto HANDLE_EN_FOR_STRING_CTRLS;
  1418. case IDC_SECUREDOMAIN:
  1419. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szSecureDomain;
  1420. cbStrToUpdate = g_CurrentSettings.cbSecureDomain;
  1421. goto HANDLE_EN_FOR_STRING_CTRLS;
  1422. case IDC_SECUREPATH:
  1423. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szSecurePath;
  1424. cbStrToUpdate = g_CurrentSettings.cbSecurePath;
  1425. goto HANDLE_EN_FOR_STRING_CTRLS;
  1426. case IDC_DISASTERURL:
  1427. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szDisasterURL;
  1428. cbStrToUpdate = g_CurrentSettings.cbDisasterURL;
  1429. goto HANDLE_EN_FOR_STRING_CTRLS;
  1430. {
  1431. HANDLE_EN_FOR_STRING_CTRLS:
  1432. switch (HIWORD(wParam))
  1433. {
  1434. case EN_CHANGE:
  1435. if (!g_bCanUndo)
  1436. SetUndoButton(hWndDlg, TRUE);
  1437. // Get the updated Value
  1438. GetDlgItemText(hWndDlg,
  1439. wCmd,
  1440. lpszStrToUpdate,
  1441. cbStrToUpdate);
  1442. break;
  1443. case EN_MAXTEXT:
  1444. {
  1445. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1446. break;
  1447. }
  1448. }
  1449. break;
  1450. }
  1451. case IDC_HOSTNAMEEDIT:
  1452. switch (HIWORD(wParam))
  1453. {
  1454. case EN_CHANGE:
  1455. {
  1456. TCHAR szHostName[INTERNET_MAX_HOST_NAME_LENGTH];
  1457. if (!g_bCanUndo)
  1458. SetUndoButton(hWndDlg, TRUE);
  1459. // Get the updated Value
  1460. GetDlgItemText(hWndDlg,
  1461. wCmd,
  1462. szHostName,
  1463. sizeof(szHostName));
  1464. if(lstrlen(szHostName) == 0 && g_szConfigSet[0])
  1465. {
  1466. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1467. SetDlgItemText(hWndDlg, IDC_HOSTNAMEEDIT, g_CurrentSettings.szHostName);
  1468. SetFocus(GetDlgItem(hWndDlg, IDC_HOSTNAMEEDIT));
  1469. }
  1470. else
  1471. {
  1472. lstrcpy(g_CurrentSettings.szHostName, szHostName);
  1473. }
  1474. }
  1475. break;
  1476. case EN_MAXTEXT:
  1477. {
  1478. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1479. break;
  1480. }
  1481. }
  1482. break;
  1483. case IDC_HOSTIPEDIT:
  1484. switch (HIWORD(wParam))
  1485. {
  1486. case EN_KILLFOCUS:
  1487. {
  1488. TCHAR szHostIP[MAX_IPLEN];
  1489. // Get the updated Value
  1490. GetDlgItemText(hWndDlg,
  1491. wCmd,
  1492. szHostIP,
  1493. sizeof(szHostIP));
  1494. if(lstrlen(szHostIP) > 0 && g_szConfigSet[0] == 0 && !IsValidIP(szHostIP))
  1495. {
  1496. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1497. SetDlgItemText(hWndDlg, IDC_HOSTIPEDIT, g_CurrentSettings.szHostIP);
  1498. SetFocus(GetDlgItem(hWndDlg, IDC_HOSTIPEDIT));
  1499. }
  1500. }
  1501. break;
  1502. case EN_CHANGE:
  1503. {
  1504. TCHAR szHostIP[MAX_IPLEN];
  1505. if (!g_bCanUndo)
  1506. SetUndoButton(hWndDlg, TRUE);
  1507. // Get the updated Value
  1508. GetDlgItemText(hWndDlg,
  1509. wCmd,
  1510. szHostIP,
  1511. sizeof(szHostIP));
  1512. if(lstrlen(szHostIP) == 0 && g_szConfigSet[0])
  1513. {
  1514. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1515. SetDlgItemText(hWndDlg, IDC_HOSTIPEDIT, g_CurrentSettings.szHostIP);
  1516. SetFocus(GetDlgItem(hWndDlg, IDC_HOSTIPEDIT));
  1517. }
  1518. else
  1519. {
  1520. lstrcpy(g_CurrentSettings.szHostIP, szHostIP);
  1521. }
  1522. }
  1523. break;
  1524. case EN_MAXTEXT:
  1525. {
  1526. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1527. break;
  1528. }
  1529. }
  1530. break;
  1531. case IDC_SITEID:
  1532. {
  1533. BOOL bValid = TRUE;
  1534. DWORD dwEditValue = GetDlgItemInt(hWndDlg, wCmd, &bValid, FALSE);
  1535. // Look at the notification code
  1536. if (EN_CHANGE == HIWORD(wParam))
  1537. {
  1538. if (bValid && (dwEditValue >= 1) && (dwEditValue <= MAX_SITEID))
  1539. {
  1540. g_CurrentSettings.dwSiteID = dwEditValue;
  1541. SetUndoButton(hWndDlg, TRUE);
  1542. }
  1543. else
  1544. {
  1545. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1546. SetDlgItemInt(hWndDlg, wCmd, g_CurrentSettings.dwSiteID, FALSE);
  1547. SetFocus(GetDlgItem(hWndDlg, wCmd));
  1548. }
  1549. }
  1550. break;
  1551. }
  1552. case IDC_STANDALONE:
  1553. {
  1554. if (BN_CLICKED == HIWORD(wParam))
  1555. {
  1556. SetUndoButton(hWndDlg, TRUE);
  1557. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  1558. g_CurrentSettings.dwStandAlone = 1l;
  1559. else
  1560. g_CurrentSettings.dwStandAlone = 0l;
  1561. }
  1562. break;
  1563. }
  1564. case IDC_DISABLECOOKIES:
  1565. {
  1566. if (BN_CLICKED == HIWORD(wParam))
  1567. {
  1568. SetUndoButton(hWndDlg, TRUE);
  1569. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  1570. g_CurrentSettings.dwDisableCookies = 1l;
  1571. else
  1572. g_CurrentSettings.dwDisableCookies = 0l;
  1573. }
  1574. break;
  1575. }
  1576. case IDC_FORCESIGNIN:
  1577. {
  1578. if (BN_CLICKED == HIWORD(wParam))
  1579. {
  1580. SetUndoButton(hWndDlg, TRUE);
  1581. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  1582. g_CurrentSettings.dwForceSignIn = 1l;
  1583. else
  1584. g_CurrentSettings.dwForceSignIn = 0l;
  1585. }
  1586. break;
  1587. }
  1588. default:
  1589. {
  1590. if(wCmd >= IDM_COMPUTERMRUBASE && wCmd < IDM_COMPUTERMRUBASE + COMPUTER_MRU_SIZE)
  1591. {
  1592. TCHAR achBuf[MAX_PATH];
  1593. TCHAR achTemp[MAX_REGISTRY_STRING];
  1594. LPTSTR szNewRemoteComputer;
  1595. //
  1596. // Get the selected computer.
  1597. //
  1598. if(GetMenuString(GetMenu(hWndDlg),
  1599. wCmd,
  1600. achBuf,
  1601. MAX_PATH,
  1602. MF_BYCOMMAND) == 0)
  1603. break;
  1604. //
  1605. // Get past the shortcut chars.
  1606. //
  1607. szNewRemoteComputer = _tcschr(achBuf, TEXT(' '));
  1608. if(szNewRemoteComputer == NULL)
  1609. break;
  1610. szNewRemoteComputer++;
  1611. //
  1612. // Is it local host?
  1613. //
  1614. LoadString(g_hInst, IDS_LOCALHOST, achTemp, sizeof(achTemp));
  1615. if(lstrcmp(szNewRemoteComputer, achTemp) == 0)
  1616. {
  1617. achBuf[0] = TEXT('\0');
  1618. szNewRemoteComputer = achBuf;
  1619. }
  1620. //
  1621. // Now try to connect and read.
  1622. //
  1623. if(!DoServerSwitch(hWndDlg, szNewRemoteComputer))
  1624. DoConfigSwitch(hWndDlg, g_szRemoteComputer, g_szConfigSet);
  1625. break;
  1626. }
  1627. break;
  1628. }
  1629. }
  1630. break;
  1631. }
  1632. case WM_CLOSE:
  1633. {
  1634. HWND hwndFocus = GetFocus();
  1635. bOkToClose = TRUE;
  1636. SetFocus(NULL);
  1637. if(bOkToClose)
  1638. DoExit(hWndDlg);
  1639. else
  1640. SetFocus(hwndFocus);
  1641. }
  1642. break;
  1643. }
  1644. return FALSE;
  1645. }