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.

2567 lines
89 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. #include <passport.h>
  15. #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
  16. const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
  17. MIDL_DEFINE_GUID(CLSID,IID_IPassportAdmin,0xA0082CF5,0xAFF5,0x11D2,0x95,0xE3,0x00,0xC0,0x4F,0x8E,0x7A,0x70);
  18. MIDL_DEFINE_GUID(CLSID,CLSID_Admin,0xA0082CF6,0xAFF5,0x11D2,0x95,0xE3,0x00,0xC0,0x4F,0x8E,0x7A,0x70);
  19. /**************************************************************************
  20. Local Function Prototypes
  21. **************************************************************************/
  22. int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
  23. INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  24. INT_PTR CALLBACK DlgMain(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  25. /**************************************************************************
  26. Global Variables
  27. **************************************************************************/
  28. // Globals
  29. HINSTANCE g_hInst;
  30. HWND g_hwndMain = 0;
  31. HWND g_hwndMainDlg = 0;
  32. PMSETTINGS g_OriginalSettings;
  33. PMSETTINGS g_CurrentSettings;
  34. TCHAR g_szDlgClassName[] = TEXT("PassportManagerAdminClass");
  35. TCHAR g_szClassName[] = TEXT("PassportManagerMainWindowClass");
  36. BOOL g_bCanUndo;
  37. DWORD g_dwRefreshNetMap = 0;
  38. TCHAR g_szInstallPath[MAX_PATH];
  39. TCHAR g_szPMVersion[MAX_REGISTRY_STRING];
  40. TCHAR g_szPMOpsHelpFileRelativePath[] = TEXT("sdk\\Passport_SDK.chm");
  41. TCHAR g_szPMAdminBookmark[] = TEXT("/Reference/operations/Passport_Admin.htm");
  42. TCHAR g_szRemoteComputer[MAX_PATH] = {L'\0'};
  43. TCHAR g_szNewRemoteComputer[MAX_PATH];
  44. TCHAR g_szConfigFile[MAX_PATH];
  45. TCHAR g_szConfigSet[MAX_CONFIGSETNAME] = {L'\0'};
  46. TCHAR g_szHelpFileName[MAX_PATH];
  47. PpMRU g_ComputerMRU(COMPUTER_MRU_SIZE);
  48. // unfortunately the registry stores the environment as a string in the registry and
  49. // this string is not localized. So in the registry we use english strings and in
  50. // UI we use localized versions of these strings.
  51. extern WCHAR g_szEnglishProduction[];
  52. extern WCHAR g_szEnglishPreProduction[];
  53. extern WCHAR g_szEnglishBetaPreProduction[];
  54. extern WCHAR g_szEnglishOther[];
  55. // Global constant strings
  56. TCHAR g_szYes[] = TEXT("Yes");
  57. TCHAR g_szNo[] = TEXT("No");
  58. TCHAR g_szUnknown[] = TEXT("Unknown");
  59. BOOL g_fFromFile = FALSE;
  60. #define MAX_LCID_VALUE 40
  61. // NOTE: 667507: The language strings below are no longer used! The function szLanguageName
  62. // derives these from common system data.
  63. LANGIDMAP g_szLanguageIDMap[] =
  64. {
  65. // 667507: remove duplicate locales - description strings now looked up using GetLocaleInfo, so
  66. // these duplicates do not have different string descriptions
  67. #if 0
  68. {0x0409, TEXT("English")}, // This item will be the default selection below...
  69. {0x0407, TEXT("German")},
  70. {0x0411, TEXT("Japanese")},
  71. {0x0412, TEXT("Korean")},
  72. {0x0404, TEXT("Traditional Chinese")},
  73. {0x0804, TEXT("Simplified Chinese")},
  74. {0x040c, TEXT("French")},
  75. {0x0c0a, TEXT("Spanish")},
  76. {0x0416, TEXT("Brazilian")},
  77. {0x0410, TEXT("Italian")},
  78. {0x0413, TEXT("Dutch")},
  79. {0x041d, TEXT("Swedish")},
  80. {0x0406, TEXT("Danish")},
  81. {0x040b, TEXT("Finnish")},
  82. {0x040e, TEXT("Hungarian")},
  83. {0x0414, TEXT("Norwegian")},
  84. {0x0408, TEXT("Greek")},
  85. {0x0415, TEXT("Polish")},
  86. {0x0419, TEXT("Russian")},
  87. {0x0405, TEXT("Czech")},
  88. {0x0816, TEXT("Portuguese")},
  89. {0x041f, TEXT("Turkish")},
  90. {0x041b, TEXT("Slovak")},
  91. {0x0424, TEXT("Slovenian")},
  92. {0x0401, TEXT("Arabic")},
  93. {0x040d, TEXT("Hebrew")},
  94. #endif
  95. {0x0401, TEXT("Arabic - Saudi Arabia")},
  96. {0x0801, TEXT("Arabic - Iraq")},
  97. {0x0c01, TEXT("Arabic - Egypt")},
  98. {0x1001, TEXT("Arabic - Libya")},
  99. {0x1401, TEXT("Arabic - Algeria")},
  100. {0x1801, TEXT("Arabic - Morocco")},
  101. {0x1c01, TEXT("Arabic - Tunisia")},
  102. {0x2001, TEXT("Arabic - Oman")},
  103. {0x2401, TEXT("Arabic - Yemen")},
  104. {0x2801, TEXT("Arabic - Syria")},
  105. {0x2c01, TEXT("Arabic - Jordan")},
  106. {0x3001, TEXT("Arabic - Lebanon")},
  107. {0x3401, TEXT("Arabic - Kuwait")},
  108. {0x3801, TEXT("Arabic - United Arab Emirates")},
  109. {0x3c01, TEXT("Arabic - Bahrain")},
  110. {0x4001, TEXT("Arabic - Qatar")},
  111. {0x0402, TEXT("Bulgarian - Bulgaria")},
  112. {0x0403, TEXT("Catalan - Spain")},
  113. {0x0404, TEXT("Chinese � Taiwan")},
  114. {0x0804, TEXT("Chinese - PRC")},
  115. {0x0c04, TEXT("Chinese - Hong Kong SAR, PRC")},
  116. {0x1004, TEXT("Chinese - Singapore")},
  117. {0x1404, TEXT("Chinese - Macao SAR")},
  118. {0x0405, TEXT("Czech - Czech Republic")},
  119. {0x0406, TEXT("Danish - Denmark")},
  120. {0x0407, TEXT("German - Germany")},
  121. {0x0807, TEXT("German - Switzerland")},
  122. {0x0c07, TEXT("German - Austria")},
  123. {0x1007, TEXT("German - Luxembourg")},
  124. {0x1407, TEXT("German - Liechtenstein")},
  125. {0x0408, TEXT("Greek - Greece")},
  126. {0x0409, TEXT("English - United States")},
  127. {0x0809, TEXT("English - United Kingdom")},
  128. {0x0c09, TEXT("English - Australia")},
  129. {0x1009, TEXT("English - Canada")},
  130. {0x1409, TEXT("English - New Zealand")},
  131. {0x1809, TEXT("English - Ireland")},
  132. {0x1c09, TEXT("English - South Africa")},
  133. {0x2009, TEXT("English - Jamaica")},
  134. {0x2409, TEXT("English - Caribbean")},
  135. {0x2809, TEXT("English - Belize")},
  136. {0x2c09, TEXT("English - Trinidad")},
  137. {0x3009, TEXT("English - Zimbabwe")},
  138. {0x3409, TEXT("English - Philippines")},
  139. {0x040a, TEXT("Spanish - Spain (Traditional Sort)")},
  140. {0x080a, TEXT("Spanish - Mexico")},
  141. {0x0c0a, TEXT("Spanish - Spain (Modern Sort)")},
  142. {0x100a, TEXT("Spanish - Guatemala")},
  143. {0x140a, TEXT("Spanish - Costa Rica")},
  144. {0x180a, TEXT("Spanish - Panama")},
  145. {0x1c0a, TEXT("Spanish - Dominican Republic")},
  146. {0x200a, TEXT("Spanish - Venezuela")},
  147. {0x240a, TEXT("Spanish - Colombia")},
  148. {0x280a, TEXT("Spanish - Peru")},
  149. {0x2c0a, TEXT("Spanish - Argentina")},
  150. {0x300a, TEXT("Spanish - Ecuador")},
  151. {0x340a, TEXT("Spanish - Chile")},
  152. {0x380a, TEXT("Spanish - Uruguay")},
  153. {0x3c0a, TEXT("Spanish - Paraguay")},
  154. {0x400a, TEXT("Spanish - Bolivia")},
  155. {0x440a, TEXT("Spanish - El Salvador")},
  156. {0x480a, TEXT("Spanish - Honduras")},
  157. {0x4c0a, TEXT("Spanish - Nicaragua")},
  158. {0x500a, TEXT("Spanish - Puerto Rico")},
  159. {0x040b, TEXT("Finnish - Finland")},
  160. {0x040c, TEXT("French - France")},
  161. {0x080c, TEXT("French - Belgium")},
  162. {0x0c0c, TEXT("French - Canada")},
  163. {0x100c, TEXT("French - Switzerland")},
  164. {0x140c, TEXT("French - Luxembourg")},
  165. {0x180c, TEXT("French - Monaco")},
  166. {0x040d, TEXT("Hebrew - Israel")},
  167. {0x040e, TEXT("Hungarian - Hungary")},
  168. {0x040f, TEXT("Icelandic - Iceland")},
  169. {0x0410, TEXT("Italian - Italy")},
  170. {0x0810, TEXT("Italian - Switzerland")},
  171. {0x0411, TEXT("Japanese - Japan")},
  172. {0x0412, TEXT("Korean (Extended Wansung) - Korea")},
  173. {0x0812, TEXT("Korean (Johab) - Korea")},
  174. {0x0413, TEXT("Dutch - Netherlands")},
  175. {0x0813, TEXT("Dutch - Belgium")},
  176. {0x0414, TEXT("Norwegian - Norway (Bokmal)")},
  177. {0x0814, TEXT("Norwegian - Norway (Nynorsk)")},
  178. {0x0415, TEXT("Polish - Poland")},
  179. {0x0416, TEXT("Portuguese - Brazil")},
  180. {0x0816, TEXT("Portuguese - Portugal")},
  181. {0x0417, TEXT("Rhaeto-Romanic - Rhaeto-Romanic")},
  182. {0x0418, TEXT("Romanian - Romania")},
  183. {0x0818, TEXT("Romanian - Moldavia")},
  184. {0x0419, TEXT("Russian - Russia")},
  185. {0x0819, TEXT("Russian - Moldavia")},
  186. {0x041a, TEXT("Croatian - Croatia")},
  187. {0x081a, TEXT("Serbian - Serbia (Latin)")},
  188. {0x0c1a, TEXT("Serbian - Serbia (Cyrillic)")},
  189. {0x041b, TEXT("Slovak - Slovakia")},
  190. {0x041c, TEXT("Albanian - Albania")},
  191. {0x041d, TEXT("Swedish - Sweden")},
  192. {0x081d, TEXT("Swedish - Finland")},
  193. {0x041e, TEXT("Thai - Thailand")},
  194. {0x041f, TEXT("Turkish - Turkey")},
  195. {0x0420, TEXT("Urdu - Urdu")},
  196. {0x0421, TEXT("Indonesian - Indonesia")},
  197. {0x0422, TEXT("Ukrainian - Ukraine")},
  198. {0x0423, TEXT("Belarussian - Belarus")},
  199. {0x0424, TEXT("Slovene - Slovenia")},
  200. {0x0425, TEXT("Estonian - Estonia")},
  201. {0x0426, TEXT("Latvian - Latvia")},
  202. {0x0427, TEXT("Lithuanian - Lithuania")},
  203. {0x0429, TEXT("Farsi - Iran")},
  204. {0x042a, TEXT("Vietnamese - Vietnam")},
  205. {0x042d, TEXT("Basque - Spain")},
  206. {0x042e, TEXT("Sorbian - Sorbian")},
  207. {0x042f, TEXT("FYRO Macedonian - Macedonian (Fyrom)")},
  208. {0x0430, TEXT("Sutu - Sutu")},
  209. {0x0431, TEXT("Tsonga - Tsonga")},
  210. {0x0432, TEXT("Tswana - Tswana")},
  211. {0x0433, TEXT("Venda - Venda")},
  212. {0x0434, TEXT("Xhosa - Xhosa")},
  213. {0x0435, TEXT("Zulu - Zulu")},
  214. {0x0436, TEXT("Afrikaans - South Africa")},
  215. {0x0438, TEXT("Faeroese - Faeroe Islands")},
  216. {0x0439, TEXT("Hindi - Hindi")},
  217. {0x043a, TEXT("Maltese - Maltese")},
  218. {0x043b, TEXT("Saami - Saami (Lappish)")},
  219. {0x043c, TEXT("Gaelic - Scots")},
  220. {0x083c, TEXT("Gaelic - Irish")},
  221. {0x043d, TEXT("Yiddish - Yiddish")},
  222. {0x043e, TEXT("Malay - Malaysian")},
  223. {0x083e, TEXT("Malay - Brunei")},
  224. {0x0441, TEXT("Swahili - Kenya")}
  225. };
  226. const DWORD s_PMAdminHelpIDs[] =
  227. {
  228. IDC_SERVERNAME, IDH_SERVERNAME,
  229. IDC_INSTALLDIR, IDH_INSTALLDIR,
  230. IDC_TIMEWINDOW, IDH_TIMEWINDOW,
  231. IDC_TIMEWINDOW_TIME, NO_HELP,
  232. IDC_FORCESIGNIN, IDH_FORCESIGNIN,
  233. IDC_LANGUAGEID, IDH_LANGUAGEID,
  234. IDC_COBRANDING_TEMPLATE, IDH_COBRANDING_TEMPLATE,
  235. IDC_SITEID, IDH_SITEID,
  236. IDC_RETURNURL, IDH_RETURNURL,
  237. IDC_COOKIEDOMAIN, IDH_COOKIEDOMAIN,
  238. IDC_COOKIEPATH, IDH_COOKIEPATH,
  239. IDC_PROFILEDOMAIN, IDH_PROFILEDOMAIN,
  240. IDC_PROFILEPATH, IDH_PROFILEPATH,
  241. IDC_SECUREDOMAIN, IDH_SECUREDOMAIN,
  242. IDC_SECUREPATH, IDH_SECUREPATH,
  243. IDC_STANDALONE, IDH_STANDALONE,
  244. IDC_DISABLECOOKIES, IDH_DISABLECOOKIES,
  245. IDC_DISASTERURL, IDH_DISASTERURL,
  246. IDC_COMMIT, IDH_COMMIT,
  247. IDC_UNDO, IDH_UNDO,
  248. IDC_CONFIGSETS, IDH_CONFIGSETS,
  249. IDC_NEWCONFIG, IDH_NEWCONFIG,
  250. IDC_REMOVECONFIG, IDH_REMOVECONFIG,
  251. IDC_CONFIGSETEDIT, IDH_CONFIGSETEDIT,
  252. IDC_HOSTNAMEEDIT, IDH_HOSTNAMEEDIT,
  253. IDC_HOSTIPEDIT, IDH_HOSTIPEDIT,
  254. IDC_VERBOSE_MODE, IDH_VERBOSE_MODE,
  255. IDC_ENVCHANGE, IDH_ENVCHANGE,
  256. IDC_ENVIRONMENT, IDH_ENVIRONMENT,
  257. IDC_ENABLE_MANREFRESH, IDH_ENABLEMREFRESH,
  258. IDC_REFRESH_NET, IDH_NSREFRESH,
  259. IDC_PRODUCTION, NO_HELP,
  260. IDC_PREPRODUCTION, NO_HELP,
  261. IDC_BETA_PREPRODUCTION, NO_HELP,
  262. IDC_OTHER, NO_HELP,
  263. IDC_REMOTEFILE, IDH_REMOTEFILE,
  264. IDC_MOREINFO, IDH_MOREINFO,
  265. 0, 0
  266. };
  267. #define SERVERNAME_CMD TEXT("/Server")
  268. #define CONFIGFILE_CMD TEXT("/Config")
  269. #define CONFIGSET_CMD TEXT("/Name")
  270. #define HELP_CMD TEXT("/?")
  271. #define IS_DOT_NET_SERVER() (LOWORD(GetVersion()) >= 0x0105)
  272. // 667507 - Look up locale description string from locale ID from the table
  273. TCHAR g_szTemp[200]; // buffer for locale names fetched by GetLocaleInfo()
  274. // 667507: Accept locale ID as input, fetch locale description string from system via GetLocaleInfo, and
  275. // return a pointer to it. This function is intended as a drop-in replacement for references to
  276. // the string value: g_szLanguageIDMap[idx].lpszLang
  277. TCHAR *szLanguageName(WORD lc)
  278. {
  279. if (0 == GetLocaleInfo(lc,LOCALE_SLANGUAGE,g_szTemp,200))
  280. g_szTemp[0] = 0;
  281. return g_szTemp;
  282. }
  283. // Process the incomming command line
  284. void Usage()
  285. {
  286. ReportError(NULL, IDS_USAGE);
  287. exit(0);
  288. }
  289. // ----------------------------------------------------------------------------
  290. // Re-written to use CommandLineToArgvW instead of a custom parser, for bug #9049.
  291. //
  292. // We do a lot of W -> A and A -> W conversion in here (the implementation
  293. // would be trivial if it weren't for the conversions). Since we're only going
  294. // to run on NT platforms, it would be better to just compile with UNICODE and
  295. // go from there.
  296. // ----------------------------------------------------------------------------
  297. void
  298. ProcessCommandLineArgs (
  299. LPSTR szCmdLine
  300. )
  301. {
  302. TCHAR szOut[MAX_PATH];
  303. int nArgCount = 0, nArgPos;
  304. LPWSTR *awszArgs = NULL;
  305. LPTSTR szArg = NULL;
  306. LPTSTR szArgValue = NULL;
  307. awszArgs = CommandLineToArgvW(GetCommandLineW(), &nArgCount);
  308. if (awszArgs == NULL) Usage();
  309. // Iterate over the arguments. Check for the command-line switches. Currently,
  310. // all switches have a parameter that comes after them (in the next command-line argument).
  311. //
  312. nArgPos = 0;
  313. while (nArgPos < nArgCount)
  314. {
  315. szArg = NULL;
  316. szArgValue = NULL;
  317. #ifndef UNICODE
  318. // Convert the parameter in the array from wide ot ansi, so we can compare
  319. //
  320. int nLen = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, NULL, 0, NULL, NULL);
  321. szArg = new char[nLen];
  322. if (szArg == NULL)
  323. {
  324. return;
  325. }
  326. nLen = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, szArg, nLen, NULL, NULL);
  327. #else
  328. szArg = awszArgs[nArgPos];
  329. #endif
  330. if (lstrcmpi(szArg, SERVERNAME_CMD) == 0)
  331. {
  332. if (++nArgPos >= nArgCount) Usage();
  333. #ifndef UNICODE
  334. int nLenValue = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, NULL, 0, NULL, NULL);
  335. szArgValue = new char[nLenValue];
  336. nLenValue = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, szArgValue, nLenValue, NULL, NULL);
  337. #else
  338. szArgValue = awszArgs[nArgPos];
  339. #endif
  340. if (lstrlen(szArgValue) >= MAX_PATH) {
  341. //
  342. // As we are running .Net above. We should always have UNICODE. Just return. No memory free required here.
  343. //
  344. return;
  345. }
  346. lstrcpy(g_szRemoteComputer, szArgValue);
  347. }
  348. if (lstrcmpi(szArg, CONFIGFILE_CMD) == 0)
  349. {
  350. if (++nArgPos >= nArgCount) Usage();
  351. #ifndef UNICODE
  352. int nLenValue = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, NULL, 0, NULL, NULL);
  353. szArgValue = new char[nLenValue];
  354. nLenValue = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, szArgValue, nLenValue, NULL, NULL);
  355. #else
  356. szArgValue = awszArgs[nArgPos];
  357. #endif
  358. if (lstrlen(szArgValue) >= MAX_PATH) {
  359. //
  360. // As we are running .Net above. We should always have UNICODE. Just return. No memory free required here.
  361. //
  362. return;
  363. }
  364. lstrcpy(g_szConfigFile, szArgValue);
  365. }
  366. if (lstrcmpi(szArg, CONFIGSET_CMD) == 0)
  367. {
  368. if (++nArgPos >= nArgCount) Usage();
  369. #ifndef UNICODE
  370. int nLenValue = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, NULL, 0, NULL, NULL);
  371. szArgValue = new char[nLenValue];
  372. nLenValue = WideCharToMultiByte(CP_ACP, 0, awszArgs[nArgPos], -1, szArgValue, nLenValue, NULL, NULL);
  373. #else
  374. szArgValue = awszArgs[nArgPos];
  375. #endif
  376. if (lstrlen(szArgValue) >= MAX_CONFIGSETNAME) {
  377. //
  378. // As we are running .Net above. We should always have UNICODE. Just return. No memory free required here.
  379. //
  380. return;
  381. }
  382. lstrcpy(g_szConfigSet, szArgValue);
  383. }
  384. nArgPos++;
  385. #ifndef UNICODE
  386. szArg = NULL;
  387. szArgValue = NULL;
  388. #endif
  389. } // while
  390. HeapFree(GetProcessHeap(), 0, (PVOID) awszArgs);
  391. }
  392. BOOL RegisterAndSetIcon
  393. (
  394. HINSTANCE hInstance
  395. )
  396. {
  397. //
  398. // Fetch the default dialog class information.
  399. //
  400. WNDCLASS wndClass;
  401. if (!GetClassInfo (0, MAKEINTRESOURCE (32770), &wndClass))
  402. {
  403. return FALSE;
  404. }
  405. //
  406. // Assign the Icon.
  407. //
  408. wndClass.hInstance = hInstance;
  409. wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  410. wndClass.lpszClassName = (LPTSTR)g_szDlgClassName;
  411. wndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN_MENU);
  412. //
  413. // Register the window class.
  414. //
  415. return RegisterClass( &wndClass );
  416. }
  417. void InitializeComputerMRU(void)
  418. {
  419. g_ComputerMRU.load(TEXT("Computer MRU"), TEXT("msppcnfg.ini"));
  420. }
  421. void SaveComputerMRU(void)
  422. {
  423. g_ComputerMRU.save(TEXT("Computer MRU"), TEXT("msppcnfg.ini"));
  424. }
  425. void InsertComputerMRU
  426. (
  427. LPCTSTR szComputer
  428. )
  429. {
  430. g_ComputerMRU.insert(szComputer);
  431. }
  432. void InitializePMConfigStruct
  433. (
  434. LPPMSETTINGS lpPMConfig
  435. )
  436. {
  437. // Zero Init the structure
  438. ZeroMemory(lpPMConfig, sizeof(PMSETTINGS));
  439. // Setup the buffer sizes
  440. lpPMConfig->cbCoBrandTemplate = sizeof(lpPMConfig->szCoBrandTemplate);
  441. lpPMConfig->cbReturnURL = sizeof(lpPMConfig->szReturnURL);
  442. lpPMConfig->cbTicketDomain = sizeof(lpPMConfig->szTicketDomain);
  443. lpPMConfig->cbTicketPath = sizeof(lpPMConfig->szTicketPath);
  444. lpPMConfig->cbProfileDomain = sizeof(lpPMConfig->szProfileDomain);
  445. lpPMConfig->cbProfilePath = sizeof(lpPMConfig->szProfilePath);
  446. lpPMConfig->cbSecureDomain = sizeof(lpPMConfig->szSecureDomain);
  447. lpPMConfig->cbSecurePath = sizeof(lpPMConfig->szSecurePath);
  448. lpPMConfig->cbDisasterURL = sizeof(lpPMConfig->szDisasterURL);
  449. lpPMConfig->cbHostName = sizeof(lpPMConfig->szHostName);
  450. lpPMConfig->cbHostIP = sizeof(lpPMConfig->szHostIP);
  451. lpPMConfig->cbEnvName = sizeof(lpPMConfig->szEnvName);
  452. lpPMConfig->cbRemoteFile = sizeof(lpPMConfig->szRemoteFile);
  453. }
  454. void GetDefaultSettings
  455. (
  456. LPPMSETTINGS lpPMConfig
  457. )
  458. {
  459. InitializePMConfigStruct(lpPMConfig);
  460. lpPMConfig->dwSiteID = 1;
  461. lpPMConfig->dwLanguageID = 1033;
  462. lpPMConfig->dwTimeWindow = DEFAULT_TIME_WINDOW;
  463. #ifdef DO_KEYSTUFF
  464. lpPMConfig->dwCurrentKey = 1;
  465. #endif
  466. // set the default secure level so that HTTPS is used
  467. lpPMConfig->dwSecureLevel = 10;
  468. }
  469. void InitInstance
  470. (
  471. HINSTANCE hInstance
  472. )
  473. {
  474. InitializeComputerMRU();
  475. InitializePMConfigStruct(&g_OriginalSettings);
  476. g_bCanUndo = FALSE;
  477. g_szInstallPath[0] = TEXT('\0');
  478. ZeroMemory(g_szPMVersion, sizeof(g_szPMVersion));
  479. ZeroMemory(g_szRemoteComputer, sizeof(g_szRemoteComputer));
  480. ZeroMemory(g_szNewRemoteComputer, sizeof(g_szNewRemoteComputer));
  481. ZeroMemory(g_szConfigFile, sizeof(g_szConfigFile));
  482. ZeroMemory(g_szHelpFileName, sizeof(g_szHelpFileName));
  483. // Load the Help File Name
  484. LoadString(hInstance, IDS_PMHELPFILE, g_szHelpFileName, DIMENSION(g_szHelpFileName));
  485. }
  486. INT WINAPI WinMain
  487. (
  488. HINSTANCE hInstance,
  489. HINSTANCE hPrevInstance,
  490. LPSTR lpszCmdLine,
  491. INT nCmdShow
  492. )
  493. {
  494. MSG msg;
  495. HACCEL hAccel;
  496. TCHAR szTitle[MAX_TITLE];
  497. TCHAR szMessage[MAX_MESSAGE];
  498. g_hInst = hInstance;
  499. //don't forget this
  500. InitCommonControls();
  501. if(!hPrevInstance)
  502. {
  503. //
  504. // Register this app's window and set the icon only 1 time for all instances
  505. //
  506. if (!RegisterAndSetIcon(hInstance))
  507. return FALSE;
  508. }
  509. if (!g_ComputerMRU.init())
  510. {
  511. return FALSE;
  512. }
  513. // Initialize the necessary Instance Variables and settings;
  514. InitInstance(hInstance);
  515. // If there was a command line, then process it, otherwise show the GUI
  516. if (lpszCmdLine && (*lpszCmdLine != TEXT('\0')))
  517. {
  518. TCHAR szFile[MAX_PATH];
  519. ProcessCommandLineArgs(lpszCmdLine);
  520. if(g_szConfigFile[0] == TEXT('\0')) Usage();
  521. // Check to see if we got a fully qualified path name for the config file
  522. if (PathIsFileSpec(g_szConfigFile))
  523. {
  524. // Not qualified, so assume it exists in our CWD
  525. lstrcpy(szFile, g_szConfigFile);
  526. GetCurrentDirectory(DIMENSION(g_szConfigFile), g_szConfigFile);
  527. if (!PathAppend(g_szConfigFile, szFile)){
  528. //
  529. // We could have do better than just return error. The original code uses too many global vars.
  530. // It would be real pain to make this app support path longer than MAX_PATH. Let's behave not too
  531. // bad if path is really longer than MAX_PATH. If support for longer than MAX_PATH is needed, we
  532. // can change more later. This is just a quick fix.
  533. //
  534. return FALSE;
  535. }
  536. }
  537. // Load the Config set specified
  538. if (ReadFileConfigSet(&g_OriginalSettings, g_szConfigFile))
  539. {
  540. if ((g_szRemoteComputer[0] != TEXT('\0')) || (g_szConfigSet[0] != TEXT('\0')))
  541. {
  542. // Commit the ConfigSet Read
  543. WriteRegConfigSet(NULL,
  544. &g_OriginalSettings,
  545. g_szRemoteComputer,
  546. g_szConfigSet);
  547. }
  548. else
  549. {
  550. g_fFromFile = TRUE;
  551. //
  552. // Create the dialog for this instance
  553. //
  554. DialogBox( hInstance,
  555. MAKEINTRESOURCE (IDD_MAIN),
  556. NULL,
  557. DlgMain );
  558. }
  559. }
  560. }
  561. else
  562. {
  563. //
  564. // Create the dialog for this instance
  565. //
  566. DialogBox( hInstance,
  567. MAKEINTRESOURCE (IDD_MAIN),
  568. NULL,
  569. DlgMain );
  570. }
  571. SaveComputerMRU();
  572. return TRUE;
  573. }
  574. /**************************************************************************
  575. Utility functions for the dialogs
  576. **************************************************************************/
  577. /**************************************************************************
  578. About()
  579. **************************************************************************/
  580. INT_PTR CALLBACK About
  581. (
  582. HWND hWnd,
  583. UINT uMessage,
  584. WPARAM wParam,
  585. LPARAM lParam
  586. )
  587. {
  588. switch (uMessage)
  589. {
  590. case WM_INITDIALOG:
  591. {
  592. TCHAR achProductVersionBuf[64];
  593. TCHAR achProductIDBuf[64 + PRODUCTID_LEN];
  594. HKEY hkeyPassport;
  595. DWORD dwcbTemp;
  596. DWORD dwType;
  597. if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  598. g_szPassportReg,
  599. 0,
  600. KEY_READ,
  601. &hkeyPassport))
  602. {
  603. ReportError(hWnd, IDS_CONFIGREAD_ERROR);
  604. return TRUE;
  605. }
  606. // Load the Help File Name
  607. LoadString(g_hInst,
  608. IDS_PRODUCTID,
  609. achProductIDBuf,
  610. DIMENSION(achProductIDBuf) - PRODUCTID_LEN);
  611. LoadString(g_hInst,
  612. IDS_PRODUCTVERSION,
  613. achProductVersionBuf,
  614. DIMENSION(achProductVersionBuf));
  615. // Display product version
  616. if (IS_DOT_NET_SERVER())
  617. {
  618. DWORD dwLen = lstrlen(achProductVersionBuf);
  619. dwcbTemp = DIMENSION(achProductVersionBuf) - dwLen;
  620. dwType = REG_SZ;
  621. RegQueryValueEx(hkeyPassport,
  622. TEXT("Version"),
  623. NULL,
  624. &dwType,
  625. (LPBYTE) (achProductVersionBuf + dwLen),
  626. &dwcbTemp);
  627. }
  628. else
  629. {
  630. #ifdef UNICODE
  631. lstrcat(achProductVersionBuf, LVER_PRODUCTVERSION_STR);
  632. #else
  633. lstrcat(achProductVersionBuf, VER_PRODUCTVERSION_STR);
  634. #endif
  635. }
  636. SetDlgItemText(hWnd, IDC_PRODUCTVERSION, achProductVersionBuf);
  637. // Display product id
  638. dwcbTemp = PRODUCTID_LEN;
  639. dwType = REG_SZ;
  640. RegQueryValueEx(hkeyPassport,
  641. TEXT("ProductID"),
  642. NULL,
  643. &dwType,
  644. (LPBYTE)&(achProductIDBuf[lstrlen(achProductIDBuf)]),
  645. &dwcbTemp);
  646. RegCloseKey(hkeyPassport);
  647. SetDlgItemText(hWnd, IDC_PRODUCTID, achProductIDBuf);
  648. return TRUE;
  649. }
  650. case WM_COMMAND:
  651. switch(wParam)
  652. {
  653. case IDOK:
  654. case IDCANCEL:
  655. EndDialog(hWnd, wParam);
  656. return TRUE;
  657. }
  658. break;
  659. }
  660. return FALSE;
  661. }
  662. /**************************************************************************
  663. UpdateTimeWindowDisplay
  664. this function will update the "human" readable display of the time
  665. window setting.
  666. **************************************************************************/
  667. void UpdateTimeWindowDisplay
  668. (
  669. HWND hWndDlg,
  670. DWORD dwTimeWindow
  671. )
  672. {
  673. int days, hours, minutes, seconds;
  674. TCHAR szTemp[MAX_REGISTRY_STRING];
  675. // Format the Time display
  676. days = dwTimeWindow / SECONDS_PER_DAY;
  677. hours = (dwTimeWindow - (days * SECONDS_PER_DAY)) / SECONDS_PER_HOUR;
  678. minutes = (dwTimeWindow - (days * SECONDS_PER_DAY) - (hours * SECONDS_PER_HOUR)) / SECONDS_PER_MIN;
  679. seconds = dwTimeWindow -
  680. (days * SECONDS_PER_DAY) -
  681. (hours * SECONDS_PER_HOUR) -
  682. (minutes * SECONDS_PER_MIN);
  683. wsprintf (szTemp, TEXT("%d d : %d h : %d m : %d s"), days, hours, minutes, seconds);
  684. SetDlgItemText(hWndDlg, IDC_TIMEWINDOW_TIME, szTemp);
  685. }
  686. /**************************************************************************
  687. UpdateLanguageDisplay
  688. this function will update both the combo box for selecting/entering
  689. the Language ID value, and the language value if possible.
  690. If idx is >= 0, then it is a valid index into the array, otherwise
  691. the index is found by searching the entries in the list
  692. **************************************************************************/
  693. void UpdateLanguageDisplay
  694. (
  695. HWND hWndDlg,
  696. DWORD dwLanguageID,
  697. INT idx
  698. )
  699. {
  700. TCHAR szTemp[MAX_LCID_VALUE];
  701. LRESULT idxLangID;
  702. if (idx >= 0)
  703. {
  704. TCHAR *psz = szLanguageName(g_szLanguageIDMap[idx].wLangID);
  705. if (psz[0] != 0)
  706. // 667507: use lookup fn to get locale description. Use unknown if the system doesn't recognize it
  707. //SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, g_szLanguageIDMap[idx].lpszLang);
  708. SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, psz);
  709. else
  710. SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, g_szUnknown);
  711. }
  712. else
  713. {
  714. wsprintf (szTemp, TEXT("%lu"), dwLanguageID);
  715. // Search the Combo-Box to see if we have the proposed LCID in the list already
  716. if (CB_ERR !=
  717. (idxLangID = SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_FINDSTRINGEXACT, 0, (LPARAM)szTemp)))
  718. {
  719. // The Language ID is one that is in our pre-populated list, so we have a matching
  720. // language string as well
  721. // 667507: use lookup fn to get description string
  722. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETCURSEL, idxLangID, 0l);
  723. SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, szLanguageName(g_szLanguageIDMap[(int) idxLangID].wLangID));
  724. }
  725. else
  726. {
  727. SetDlgItemText(hWndDlg, IDC_LANGUAGEID_LANG, g_szUnknown);
  728. }
  729. }
  730. }
  731. /**************************************************************************
  732. SetUndoButton
  733. Sets the state of the Undo button.
  734. **************************************************************************/
  735. void SetUndoButton
  736. (
  737. HWND hWndDlg,
  738. BOOL bUndoState
  739. )
  740. {
  741. g_bCanUndo = bUndoState;
  742. EnableWindow(GetDlgItem(hWndDlg, IDC_UNDO), bUndoState);
  743. }
  744. /**************************************************************************
  745. InitMainDlg
  746. **************************************************************************/
  747. BOOL InitMainDlg
  748. (
  749. HWND hWndDlg,
  750. LPPMSETTINGS lpPMConfig
  751. )
  752. {
  753. TCHAR szTemp[MAX_REGISTRY_STRING];
  754. LPTSTR lpszConfigSetNames, lpszCur;
  755. LRESULT dwCurSel;
  756. int nCmdShow;
  757. int nSelectedLanguage;
  758. #ifdef DO_KEYSTUFF
  759. HWND hWndListView;
  760. LVCOLUMN lvc;
  761. #endif
  762. // Remote Computer Name
  763. if ((TEXT('\0') != g_szRemoteComputer[0]))
  764. {
  765. SetDlgItemText(hWndDlg, IDC_SERVERNAME, g_szRemoteComputer);
  766. }
  767. else
  768. {
  769. LoadString(g_hInst, IDS_LOCALHOST, szTemp, DIMENSION(szTemp));
  770. SetDlgItemText(hWndDlg, IDC_SERVERNAME, szTemp);
  771. }
  772. // Icon
  773. HICON hic = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_PMADMIN));
  774. SendMessage(hWndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hic);
  775. SendMessage(hWndDlg, WM_SETICON, ICON_BIG, (LPARAM)hic);
  776. // List of config sets
  777. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_RESETCONTENT, 0, 0L);
  778. LoadString(g_hInst, IDS_DEFAULT, szTemp, DIMENSION(szTemp));
  779. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_ADDSTRING, 0, (LPARAM)szTemp);
  780. if(ReadRegConfigSetNames(hWndDlg, g_szRemoteComputer, &lpszConfigSetNames) &&
  781. lpszConfigSetNames)
  782. {
  783. lpszCur = lpszConfigSetNames;
  784. while(*lpszCur)
  785. {
  786. SendDlgItemMessage(hWndDlg,
  787. IDC_CONFIGSETS,
  788. CB_ADDSTRING,
  789. 0,
  790. (LPARAM)lpszCur);
  791. lpszCur = _tcschr(lpszCur, TEXT('\0')) + 1;
  792. }
  793. free(lpszConfigSetNames);
  794. lpszConfigSetNames = NULL;
  795. }
  796. if(g_szConfigSet[0] != TEXT('\0'))
  797. {
  798. dwCurSel = SendDlgItemMessage(hWndDlg,
  799. IDC_CONFIGSETS,
  800. CB_FINDSTRINGEXACT,
  801. -1,
  802. (LPARAM)g_szConfigSet);
  803. }
  804. else
  805. {
  806. dwCurSel = 0;
  807. }
  808. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_SETCURSEL, dwCurSel, 0L);
  809. // If the current selection was the default, then hide the
  810. // host name and ip address controls.
  811. nCmdShow = (dwCurSel ? SW_SHOW : SW_HIDE);
  812. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTNAMETEXT), nCmdShow);
  813. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTNAMEEDIT), nCmdShow);
  814. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTIPTEXT), nCmdShow);
  815. ShowWindow(GetDlgItem(hWndDlg, IDC_HOSTIPEDIT), nCmdShow);
  816. EnableWindow(GetDlgItem(hWndDlg, IDC_REMOVECONFIG), (int) dwCurSel);
  817. // Check registry to decide if Enable Manual Refresh checkbox should be checked
  818. TCHAR szBuffer[MAX_REGISTRY_STRING];
  819. DWORD dwBufferSize = MAX_REGISTRY_STRING;
  820. HKEY hKey;
  821. DWORD dwValType;
  822. //
  823. // EnvName
  824. // Warning: if version number > 1.10, this algorithm needs to be changed
  825. if (lstrcmp(g_szPMVersion, g_szVersion14) < 0) // hide this for previous verison
  826. {
  827. EnableWindow(GetDlgItem(hWndDlg, IDC_ENVCHANGE), FALSE);
  828. EnableWindow(GetDlgItem(hWndDlg, IDC_ENABLE_MANREFRESH), FALSE);
  829. EnableWindow(GetDlgItem(hWndDlg, IDC_REFRESH_NET), FALSE);
  830. }
  831. else
  832. {
  833. EnableWindow(GetDlgItem(hWndDlg, IDC_ENVCHANGE), TRUE);
  834. EnableWindow(GetDlgItem(hWndDlg, IDC_ENABLE_MANREFRESH), TRUE);
  835. EnableWindow(GetDlgItem(hWndDlg, IDC_REFRESH_NET), lpPMConfig->dwEnableManualRefresh ? TRUE : FALSE);
  836. }
  837. CheckDlgButton(hWndDlg, IDC_ENABLE_MANREFRESH, lpPMConfig->dwEnableManualRefresh ? BST_CHECKED : BST_UNCHECKED);
  838. {
  839. TCHAR pszEnvName[MAX_RESOURCE];
  840. if(lstrcmp(lpPMConfig->szEnvName, g_szEnglishPreProduction) == 0)
  841. {
  842. LoadString(g_hInst, IDS_PREPRODUCTION, pszEnvName, DIMENSION(pszEnvName));
  843. }
  844. else if(lstrcmp(lpPMConfig->szEnvName, g_szEnglishBetaPreProduction) == 0)
  845. {
  846. LoadString(g_hInst, IDS_BETAPREPRODUCTION, pszEnvName, DIMENSION(pszEnvName));
  847. }
  848. else if(lstrcmp(lpPMConfig->szEnvName, g_szEnglishOther) == 0)
  849. {
  850. LoadString(g_hInst, IDS_OTHER, pszEnvName, DIMENSION(pszEnvName));
  851. }
  852. else // must be Production
  853. {
  854. LoadString(g_hInst, IDS_PRODUCTION, pszEnvName, DIMENSION(pszEnvName));
  855. }
  856. SetDlgItemText(hWndDlg, IDC_ENVIRONMENT, pszEnvName);
  857. }
  858. //
  859. // HostName
  860. SetDlgItemText(hWndDlg, IDC_HOSTNAMEEDIT, lpPMConfig->szHostName);
  861. SendDlgItemMessage(hWndDlg, IDC_HOSTNAMEEDIT, EM_SETLIMITTEXT, INTERNET_MAX_HOST_NAME_LENGTH - 1, 0l);
  862. //
  863. // HostIP
  864. SetDlgItemText(hWndDlg, IDC_HOSTIPEDIT, lpPMConfig->szHostIP);
  865. SendDlgItemMessage(hWndDlg, IDC_HOSTIPEDIT, EM_SETLIMITTEXT, MAX_IPLEN - 1, 0l);
  866. //
  867. // Install Dir
  868. SetDlgItemText(hWndDlg, IDC_INSTALLDIR, g_szInstallPath);
  869. // Version
  870. // SetDlgItemText(hWndDlg, IDC_VERSION, g_szPMVersion);
  871. // Time Window
  872. wsprintf (szTemp, TEXT("%lu"), lpPMConfig->dwTimeWindow);
  873. SetDlgItemText(hWndDlg, IDC_TIMEWINDOW, szTemp);
  874. UpdateTimeWindowDisplay(hWndDlg, lpPMConfig->dwTimeWindow);
  875. // Initialize the force signing values
  876. CheckDlgButton(hWndDlg, IDC_FORCESIGNIN, lpPMConfig->dwForceSignIn ? BST_CHECKED : BST_UNCHECKED);
  877. // language ID
  878. // Initialize the LanguageID dropdown with the known LCIDs
  879. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_RESETCONTENT, 0, 0l);
  880. nSelectedLanguage = -1;
  881. for (int i = 0; i < sizeof(g_szLanguageIDMap)/sizeof(LANGIDMAP); i++)
  882. {
  883. // 667507 - If there is no description string for a locale ID numeric value, don't add it
  884. // to the combo box, because we can't display it.
  885. TCHAR *psz = szLanguageName(g_szLanguageIDMap[i].wLangID);
  886. if (psz[0] == 0) continue;
  887. // this locale ID value has a UI string to identify it. Put it into the combobox droplist
  888. LRESULT lCurrent = SendDlgItemMessage(hWndDlg,
  889. IDC_LANGUAGEID,
  890. CB_ADDSTRING,
  891. 0,
  892. (LPARAM) psz);
  893. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETITEMDATA, lCurrent, (LPARAM)g_szLanguageIDMap[i].wLangID);
  894. if(lpPMConfig->dwLanguageID == g_szLanguageIDMap[i].wLangID)
  895. {
  896. nSelectedLanguage = i;
  897. }
  898. }
  899. // Now select the correct item in the list...
  900. if(nSelectedLanguage == -1)
  901. {
  902. // 667507 "English" is no longer item 0.
  903. //SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETCURSEL, 0, NULL);
  904. TCHAR *psz = szLanguageName(LOWORD(GetSystemDefaultLCID()));
  905. if (psz[0] == 0)
  906. {
  907. // copy the "Unknown" string to the locale description if unable to convert
  908. // This should be impossible.
  909. _tcscpy(psz,g_szUnknown);
  910. }
  911. // Locate a match for that language name in the combo box, get the index
  912. LRESULT lLanguage = SendDlgItemMessage(hWndDlg,
  913. IDC_LANGUAGEID,
  914. CB_FINDSTRINGEXACT,
  915. -1,
  916. (LPARAM)psz);
  917. // Select that indexed item in the list
  918. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETCURSEL, lLanguage, NULL);
  919. }
  920. else
  921. {
  922. // 667507: use lookup fn for locale description
  923. LRESULT lLanguage = SendDlgItemMessage(hWndDlg,
  924. IDC_LANGUAGEID,
  925. CB_FINDSTRINGEXACT,
  926. -1,
  927. (LPARAM)szLanguageName(g_szLanguageIDMap[nSelectedLanguage].wLangID));
  928. SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_SETCURSEL, lLanguage, NULL);
  929. }
  930. // Update the display of the combo box and the language value
  931. UpdateLanguageDisplay(hWndDlg, lpPMConfig->dwLanguageID, -1);
  932. // Co-branding template
  933. SetDlgItemText(hWndDlg, IDC_COBRANDING_TEMPLATE, lpPMConfig->szCoBrandTemplate);
  934. SendDlgItemMessage(hWndDlg, IDC_COBRANDING_TEMPLATE, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  935. // Site ID
  936. // bug 8257
  937. if ((lpPMConfig->dwSiteID < 1) || (lpPMConfig->dwSiteID > MAX_SITEID))
  938. {
  939. wsprintf (szTemp, TEXT("1"));
  940. }
  941. else
  942. wsprintf (szTemp, TEXT("%lu"), lpPMConfig->dwSiteID); // bug 8832
  943. SetDlgItemText(hWndDlg, IDC_SITEID, szTemp);
  944. // Return URL
  945. SetDlgItemText(hWndDlg, IDC_RETURNURL, lpPMConfig->szReturnURL);
  946. SendDlgItemMessage(hWndDlg, IDC_RETURNURL, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  947. // Cookie domain
  948. SetDlgItemText(hWndDlg, IDC_COOKIEDOMAIN, lpPMConfig->szTicketDomain);
  949. SendDlgItemMessage(hWndDlg, IDC_COOKIEDOMAIN, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  950. // Cookie path
  951. SetDlgItemText(hWndDlg, IDC_COOKIEPATH, lpPMConfig->szTicketPath);
  952. SendDlgItemMessage(hWndDlg, IDC_COOKIEPATH, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  953. // Cookie domain
  954. SetDlgItemText(hWndDlg, IDC_PROFILEDOMAIN, lpPMConfig->szProfileDomain);
  955. SendDlgItemMessage(hWndDlg, IDC_PROFILEDOMAIN, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  956. // Cookie path
  957. SetDlgItemText(hWndDlg, IDC_PROFILEPATH, lpPMConfig->szProfilePath);
  958. SendDlgItemMessage(hWndDlg, IDC_PROFILEPATH, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  959. // Secure Cookie domain
  960. SetDlgItemText(hWndDlg, IDC_SECUREDOMAIN, lpPMConfig->szSecureDomain);
  961. SendDlgItemMessage(hWndDlg, IDC_SECUREDOMAIN, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  962. // Secure Cookie path
  963. SetDlgItemText(hWndDlg, IDC_SECUREPATH, lpPMConfig->szSecurePath);
  964. SendDlgItemMessage(hWndDlg, IDC_SECUREPATH, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  965. // Disaster URL
  966. SetDlgItemText(hWndDlg, IDC_DISASTERURL, lpPMConfig->szDisasterURL);
  967. SendDlgItemMessage(hWndDlg, IDC_DISASTERURL, EM_SETLIMITTEXT, INTERNET_MAX_URL_LENGTH -1, 0l);
  968. // Set the Standalone and Disable Cookies check boxes
  969. CheckDlgButton(hWndDlg, IDC_STANDALONE, lpPMConfig->dwStandAlone ? BST_CHECKED : BST_UNCHECKED);
  970. CheckDlgButton(hWndDlg, IDC_DISABLECOOKIES, lpPMConfig->dwDisableCookies ? BST_CHECKED : BST_UNCHECKED);
  971. CheckDlgButton(hWndDlg, IDC_VERBOSE_MODE, lpPMConfig->dwVerboseMode ? BST_CHECKED : BST_UNCHECKED);
  972. SetUndoButton(hWndDlg, FALSE);
  973. #ifdef DO_KEYSTUFF
  974. // Current encryption key
  975. wsprintf (szTemp, TEXT("%lu"), lpPMConfig->dwCurrentKey);
  976. SetDlgItemText(hWndDlg, IDC_CURRENTKEY, szTemp);
  977. // Initialize the Listview control for the Encryption Keys
  978. hWndListView = GetDlgItem(hWndDlg, IDC_KEYLIST);
  979. // Setup for full row select
  980. ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_FULLROWSELECT);
  981. // Setup the columns
  982. lvc.mask = LVCF_TEXT;
  983. lvc.pszText = TEXT("Key Number");
  984. lvc.iSubItem = 0;
  985. ListView_InsertColumn(hWndListView, 0, &lvc);
  986. lvc.mask = LVCF_TEXT;
  987. lvc.pszText = TEXT("Expires");
  988. lvc.iSubItem = 1;
  989. ListView_InsertColumn(hWndListView, 1, &lvc);
  990. lvc.mask = LVCF_TEXT;
  991. lvc.pszText = TEXT("Current");
  992. lvc.iSubItem = 2;
  993. ListView_InsertColumn(hWndListView, 2, &lvc);
  994. // Initially size the columns
  995. ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER);
  996. ListView_SetColumnWidth(hWndListView, 1, LVSCW_AUTOSIZE_USEHEADER);
  997. ListView_SetColumnWidth(hWndListView, 2, LVSCW_AUTOSIZE_USEHEADER);
  998. // Enumerate the KeyData sub-key to fill in the list
  999. DWORD dwRet;
  1000. DWORD dwIndex = 0;
  1001. TCHAR szValue[MAX_REGISTRY_STRING];
  1002. DWORD dwcbValue;
  1003. LVITEM lvi;
  1004. dwType = REG_SZ;
  1005. do {
  1006. dwcbValue = sizeof(szValue);
  1007. dwcbTemp = sizeof(szTemp);
  1008. szTemp[0] = TEXT('\0');
  1009. szValue[0] = TEXT('\0');
  1010. if (ERROR_SUCCESS == (dwRet = RegEnumValue(hkeyEncryptionKeyData,
  1011. dwIndex,
  1012. szValue,
  1013. &dwcbValue,
  1014. NULL,
  1015. &dwType,
  1016. (LPBYTE)szTemp,
  1017. &dwcbTemp)))
  1018. {
  1019. // Insert the Column
  1020. lvi.mask = LVIF_TEXT;
  1021. lvi.iItem = dwIndex;
  1022. lvi.iSubItem = 0;
  1023. lvi.pszText = szValue;
  1024. lvi.cchTextMax = lstrlen(szValue);
  1025. ListView_InsertItem(hWndListView, &lvi);
  1026. ListView_SetItemText(hWndListView, dwIndex, 1, szTemp);
  1027. // See if this is the current key
  1028. if (g_OriginalSettings.dwCurrentKey == (DWORD)atoi((LPSTR)szValue))
  1029. {
  1030. ListView_SetItemText(hWndListView, dwIndex, 2, g_szYes);
  1031. }
  1032. else
  1033. {
  1034. ListView_SetItemText(hWndListView, dwIndex, 2, g_szNo);
  1035. }
  1036. }
  1037. ++dwIndex;
  1038. } while (dwRet == ERROR_SUCCESS);
  1039. #endif
  1040. return TRUE;
  1041. }
  1042. /**************************************************************************
  1043. Update the computer MRU list based on contents of g_aszComputerMRU
  1044. **************************************************************************/
  1045. BOOL
  1046. UpdateComputerMRU
  1047. (
  1048. HWND hWndDlg
  1049. )
  1050. {
  1051. BOOL bReturn;
  1052. HMENU hMenu;
  1053. HMENU hComputerMenu;
  1054. int nIndex;
  1055. MENUITEMINFO mii;
  1056. TCHAR achMenuBuf[MAX_PATH];
  1057. DWORD dwError;
  1058. hMenu = GetMenu(hWndDlg);
  1059. if(hMenu == NULL)
  1060. {
  1061. bReturn = FALSE;
  1062. goto Cleanup;
  1063. }
  1064. hComputerMenu = GetSubMenu(hMenu, 1);
  1065. if(hComputerMenu == NULL)
  1066. {
  1067. bReturn = FALSE;
  1068. goto Cleanup;
  1069. }
  1070. while(GetMenuItemID(hComputerMenu, 1) != -1)
  1071. DeleteMenu(hComputerMenu, 1, MF_BYPOSITION);
  1072. for(nIndex = 0; nIndex < COMPUTER_MRU_SIZE; nIndex++)
  1073. {
  1074. if(g_ComputerMRU[nIndex] != NULL)
  1075. break;
  1076. }
  1077. if(nIndex == COMPUTER_MRU_SIZE)
  1078. {
  1079. bReturn = TRUE;
  1080. goto Cleanup;
  1081. }
  1082. // Add the separator.
  1083. ZeroMemory(&mii, sizeof(MENUITEMINFO));
  1084. mii.cbSize = sizeof(MENUITEMINFO);
  1085. mii.fMask = MIIM_TYPE;
  1086. mii.fType = MFT_SEPARATOR;
  1087. if(!InsertMenuItem(hComputerMenu, 1, TRUE, &mii))
  1088. {
  1089. dwError = GetLastError();
  1090. bReturn = FALSE;
  1091. goto Cleanup;
  1092. }
  1093. // Now add each item in the MRU list.
  1094. for(nIndex = 0; nIndex < COMPUTER_MRU_SIZE && g_ComputerMRU[nIndex]; nIndex++)
  1095. {
  1096. ZeroMemory(&mii, sizeof(MENUITEMINFO));
  1097. mii.cbSize = sizeof(MENUITEMINFO);
  1098. mii.fMask = MIIM_TYPE | MIIM_ID;
  1099. mii.fType = MFT_STRING;
  1100. mii.wID = IDM_COMPUTERMRUBASE + nIndex;
  1101. //
  1102. // It is very unlikely, but is possible to that lstrlen(g_ComputerMRU[nIndex]) > MAX_PATH - 4.
  1103. // If it is, achMenuBuf would be too small. 4 is one digit for nIndex (MAX is COMPUTER_MRU_SIZE) and the
  1104. // rest for & space and ending 0.
  1105. // If g_ComputerMRU[nIndex] is just a WIndows comupter server name, then no buffer overrun would be possible.
  1106. // Let's leave this for the moment.
  1107. //
  1108. wsprintf(achMenuBuf, TEXT("&%d %s"), nIndex + 1, g_ComputerMRU[nIndex]);
  1109. mii.dwTypeData = achMenuBuf;
  1110. mii.cch = lstrlen(achMenuBuf) + 1;
  1111. InsertMenuItem(hComputerMenu, nIndex + 2, TRUE, &mii);
  1112. }
  1113. bReturn = TRUE;
  1114. Cleanup:
  1115. return bReturn;
  1116. }
  1117. /**************************************************************************
  1118. Leaving this config set, prompt for save.
  1119. **************************************************************************/
  1120. int
  1121. SavePrompt
  1122. (
  1123. HWND hWndDlg
  1124. )
  1125. {
  1126. TCHAR szPrompt[MAX_RESOURCE];
  1127. TCHAR szTitle[MAX_RESOURCE];
  1128. LoadString(g_hInst, IDS_SAVE_PROMPT, szPrompt, DIMENSION(szPrompt));
  1129. LoadString(g_hInst, IDS_APP_TITLE, szTitle, DIMENSION(szTitle));
  1130. return MessageBox(hWndDlg, szPrompt, szTitle, MB_YESNOCANCEL | MB_ICONEXCLAMATION);
  1131. }
  1132. /**************************************************************************
  1133. Switching configurations, check for unsaved changes.
  1134. **************************************************************************/
  1135. BOOL
  1136. DoConfigSwitch
  1137. (
  1138. HWND hWndDlg,
  1139. LPTSTR szNewComputer,
  1140. LPTSTR szNewConfigSet
  1141. )
  1142. {
  1143. BOOL bReturn;
  1144. int nOption;
  1145. PMSETTINGS *pNewSettings = NULL;
  1146. pNewSettings = (PMSETTINGS*)LocalAlloc(LMEM_FIXED, sizeof(PMSETTINGS));
  1147. if (NULL == pNewSettings)
  1148. {
  1149. bReturn = FALSE;
  1150. goto Cleanup;
  1151. }
  1152. //
  1153. // If switching to current config, do nothing.
  1154. //
  1155. if(lstrcmp(szNewComputer, g_szRemoteComputer) == 0 &&
  1156. lstrcmp(szNewConfigSet, g_szConfigSet) == 0)
  1157. {
  1158. bReturn = TRUE;
  1159. goto Cleanup;
  1160. }
  1161. //
  1162. // If no changes then return.
  1163. //
  1164. if(0 == memcmp(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS)))
  1165. nOption = IDNO;
  1166. else
  1167. nOption = SavePrompt(hWndDlg);
  1168. switch(nOption)
  1169. {
  1170. case IDYES:
  1171. if(!WriteRegConfigSet(hWndDlg, &g_CurrentSettings, g_szRemoteComputer, g_szConfigSet))
  1172. {
  1173. bReturn = FALSE;
  1174. break;
  1175. }
  1176. case IDNO:
  1177. InitializePMConfigStruct(pNewSettings);
  1178. if (ReadRegConfigSet(hWndDlg,
  1179. pNewSettings,
  1180. szNewComputer,
  1181. szNewConfigSet))
  1182. {
  1183. memcpy(g_szRemoteComputer, szNewComputer, sizeof(g_szRemoteComputer));
  1184. memcpy(g_szConfigSet, szNewConfigSet, sizeof(g_szConfigSet));
  1185. memcpy(&g_CurrentSettings, pNewSettings, sizeof(PMSETTINGS));
  1186. memcpy(&g_OriginalSettings, pNewSettings, sizeof(PMSETTINGS));
  1187. bReturn = TRUE;
  1188. }
  1189. else
  1190. {
  1191. bReturn = FALSE;
  1192. }
  1193. InitMainDlg(hWndDlg, &g_CurrentSettings);
  1194. break;
  1195. case IDCANCEL:
  1196. {
  1197. LRESULT lSel;
  1198. if(g_szConfigSet[0] == TEXT('\0'))
  1199. {
  1200. lSel = 0;
  1201. }
  1202. else
  1203. {
  1204. lSel = SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_FINDSTRINGEXACT, 0, (LPARAM)g_szConfigSet);
  1205. }
  1206. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_SETCURSEL, lSel, 0L);
  1207. bReturn = FALSE;
  1208. }
  1209. break;
  1210. }
  1211. Cleanup:
  1212. if (pNewSettings)
  1213. {
  1214. LocalFree(pNewSettings);
  1215. }
  1216. return bReturn;
  1217. }
  1218. /**************************************************************************
  1219. Switching servers, check for unsaved changes.
  1220. **************************************************************************/
  1221. BOOL
  1222. DoServerSwitch
  1223. (
  1224. HWND hWndDlg,
  1225. LPTSTR szNewComputer
  1226. )
  1227. {
  1228. BOOL bReturn;
  1229. if(DoConfigSwitch(hWndDlg, szNewComputer, TEXT("")))
  1230. {
  1231. // Put computer name on MRU list.
  1232. if(lstrlen(szNewComputer))
  1233. g_ComputerMRU.insert(szNewComputer);
  1234. else
  1235. {
  1236. TCHAR achTemp[MAX_REGISTRY_STRING];
  1237. LoadString(g_hInst, IDS_LOCALHOST, achTemp, DIMENSION(achTemp));
  1238. g_ComputerMRU.insert(achTemp);
  1239. }
  1240. // Update MRU menu.
  1241. UpdateComputerMRU(hWndDlg);
  1242. bReturn = TRUE;
  1243. }
  1244. else
  1245. bReturn = FALSE;
  1246. return bReturn;
  1247. }
  1248. /**************************************************************************
  1249. Closing app, check for unsaved changes.
  1250. **************************************************************************/
  1251. void
  1252. DoExit
  1253. (
  1254. HWND hWndDlg
  1255. )
  1256. {
  1257. if(0 != memcmp(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS)))
  1258. {
  1259. int nOption;
  1260. nOption = SavePrompt(hWndDlg);
  1261. switch(nOption)
  1262. {
  1263. case IDYES:
  1264. if(WriteRegConfigSet(hWndDlg, &g_CurrentSettings, g_szRemoteComputer, g_szConfigSet))
  1265. EndDialog(hWndDlg, TRUE);
  1266. break;
  1267. case IDNO:
  1268. EndDialog(hWndDlg, TRUE);
  1269. break;
  1270. case IDCANCEL:
  1271. break;
  1272. }
  1273. }
  1274. else
  1275. EndDialog( hWndDlg, TRUE );
  1276. }
  1277. HRESULT
  1278. LocalRefreshOfNetworkMapping(
  1279. HWND hWndDlg
  1280. )
  1281. {
  1282. IPassportAdmin * pPassportAdmin = NULL;
  1283. VARIANT_BOOL vbRefreshed;
  1284. VARIANT_BOOL vbWait; // not used for anything
  1285. TCHAR szTitle[MAX_TITLE];
  1286. TCHAR szMessage[MAX_RESOURCE * 2];
  1287. HRESULT hr;
  1288. vbRefreshed = VARIANT_FALSE;
  1289. vbWait = VARIANT_FALSE;
  1290. hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
  1291. if( FAILED( hr ) )
  1292. {
  1293. goto Cleanup;
  1294. }
  1295. hr = CoCreateInstance( CLSID_Admin,
  1296. NULL,
  1297. CLSCTX_INPROC_SERVER,
  1298. IID_IPassportAdmin,
  1299. (void**)&pPassportAdmin );
  1300. CoUninitialize();
  1301. if ( FAILED( hr ) )
  1302. {
  1303. goto Cleanup;
  1304. }
  1305. hr = pPassportAdmin->Refresh(vbWait, &vbRefreshed);
  1306. if ( FAILED( hr ) )
  1307. {
  1308. goto Cleanup;
  1309. }
  1310. if ( vbRefreshed == VARIANT_FALSE )
  1311. {
  1312. // put up a dialog box indicating that refresh failed
  1313. LoadString(g_hInst, IDS_OPEN_TITLE, szTitle, DIMENSION(szTitle));
  1314. LoadString(g_hInst, IDS_OPEN_ERROR, szMessage, DIMENSION(szMessage));
  1315. int Choice = IDRETRY;
  1316. while (Choice == IDRETRY)
  1317. {
  1318. hr = pPassportAdmin->Refresh(vbWait, &vbRefreshed);
  1319. if ( FAILED( hr ) )
  1320. {
  1321. goto Cleanup;
  1322. }
  1323. if ( vbRefreshed == VARIANT_FALSE )
  1324. {
  1325. Choice = MessageBox(hWndDlg, szMessage, szTitle, MB_RETRYCANCEL);
  1326. }
  1327. else
  1328. {
  1329. Choice = IDCANCEL;
  1330. }
  1331. }
  1332. }
  1333. Cleanup:
  1334. if (NULL != pPassportAdmin)
  1335. {
  1336. pPassportAdmin->Release();
  1337. }
  1338. return hr;
  1339. }
  1340. /**************************************************************************
  1341. Dialog proc for the main dialog
  1342. **************************************************************************/
  1343. INT_PTR CALLBACK DlgMain
  1344. (
  1345. HWND hWndDlg,
  1346. UINT uMsg,
  1347. WPARAM wParam,
  1348. LPARAM lParam
  1349. )
  1350. {
  1351. static BOOL bOkToClose;
  1352. BOOL fResult;
  1353. switch ( uMsg )
  1354. {
  1355. case WM_INITDIALOG:
  1356. if (g_fFromFile)
  1357. {
  1358. // Make a copy of the original setting for editing purposes
  1359. memcpy(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS));
  1360. }
  1361. else
  1362. {
  1363. InitializePMConfigStruct(&g_OriginalSettings);
  1364. }
  1365. if (!ReadRegConfigSet(hWndDlg,
  1366. &g_OriginalSettings,
  1367. g_szRemoteComputer,
  1368. g_szConfigSet))
  1369. {
  1370. EndDialog( hWndDlg, TRUE );
  1371. }
  1372. if (g_fFromFile)
  1373. {
  1374. InitMainDlg(hWndDlg, &g_CurrentSettings);
  1375. UpdateComputerMRU(hWndDlg);
  1376. }
  1377. else
  1378. {
  1379. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1380. UpdateComputerMRU(hWndDlg);
  1381. // Make a copy of the original setting for editing purposes
  1382. memcpy(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS));
  1383. }
  1384. // Change invalid SiteID to 1 so it will be save when exiting
  1385. // bug 8257
  1386. if ((g_CurrentSettings.dwSiteID < 1) || (g_CurrentSettings.dwSiteID > MAX_SITEID))
  1387. g_CurrentSettings.dwSiteID = 1;
  1388. return TRUE;
  1389. case WM_HELP:
  1390. {
  1391. if (((LPHELPINFO) lParam)->iCtrlId == -1) break;
  1392. WinHelp( (HWND)((LPHELPINFO) lParam)->hItemHandle, g_szHelpFileName,
  1393. HELP_WM_HELP, (ULONG_PTR) s_PMAdminHelpIDs);
  1394. break;
  1395. }
  1396. case WM_CONTEXTMENU:
  1397. {
  1398. WinHelp((HWND) wParam, g_szHelpFileName, HELP_CONTEXTMENU,
  1399. (ULONG_PTR) s_PMAdminHelpIDs);
  1400. break;
  1401. }
  1402. case WM_COMMAND:
  1403. {
  1404. WORD wCmd = LOWORD(wParam);
  1405. LPTSTR lpszStrToUpdate;
  1406. DWORD cbStrToUpdate;
  1407. switch (wCmd)
  1408. {
  1409. // Handle the Menu Cases
  1410. case IDM_OPEN:
  1411. {
  1412. if (PMAdmin_GetFileName(hWndDlg,
  1413. TRUE,
  1414. g_szConfigFile,
  1415. DIMENSION(g_szConfigFile)))
  1416. {
  1417. if (ReadFileConfigSet(&g_CurrentSettings, g_szConfigFile))
  1418. {
  1419. InitMainDlg(hWndDlg, &g_CurrentSettings);
  1420. }
  1421. }
  1422. break;
  1423. }
  1424. case IDM_SAVE:
  1425. {
  1426. // Have we alread opened or saved a config file, and have a file name
  1427. // yet?
  1428. if (TEXT('\0') != g_szConfigFile[0])
  1429. {
  1430. // Write out to the current file, and then break
  1431. WriteFileConfigSet(&g_CurrentSettings, g_szConfigFile);
  1432. break;
  1433. }
  1434. // No file name yet, so fall thru to the Save AS case
  1435. }
  1436. case IDM_SAVEAS:
  1437. {
  1438. if (PMAdmin_GetFileName(hWndDlg,
  1439. FALSE,
  1440. g_szConfigFile,
  1441. DIMENSION(g_szConfigFile)))
  1442. {
  1443. WriteFileConfigSet(&g_CurrentSettings, g_szConfigFile);
  1444. }
  1445. break;
  1446. }
  1447. case IDM_EXIT:
  1448. {
  1449. DoExit(hWndDlg);
  1450. break;
  1451. }
  1452. case IDM_ABOUT:
  1453. {
  1454. DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT_DIALOG), hWndDlg, About);
  1455. break;
  1456. }
  1457. case IDM_SELECT:
  1458. {
  1459. if(!PMAdmin_OnCommandConnect(hWndDlg, g_szNewRemoteComputer)) break;
  1460. if(!DoServerSwitch(hWndDlg, g_szNewRemoteComputer))
  1461. DoConfigSwitch(hWndDlg, g_szRemoteComputer, g_szConfigSet);
  1462. break;
  1463. }
  1464. /*
  1465. case IDM_REFRESH:
  1466. {
  1467. DoConfigSwitch(hWndDlg, g_szRemoteComputer, g_szConfigSet);
  1468. break;
  1469. }
  1470. */
  1471. case IDM_HELP:
  1472. {
  1473. /*
  1474. TCHAR szPMHelpFile[MAX_PATH];
  1475. lstrcpy(szPMHelpFile, g_szInstallPath);
  1476. PathAppend(szPMHelpFile, g_szPMOpsHelpFileRelativePath);
  1477. HtmlHelp(hWndDlg, szPMHelpFile, HH_DISPLAY_TOPIC, (ULONG_PTR)(LPTSTR)g_szPMAdminBookmark);
  1478. */
  1479. TCHAR szURL[MAX_PATH];
  1480. lstrcpy(szURL, _T("http://www.passport.com/SDKDocuments/SDK21/default.htm?Reference%2Foperations%2FPassport%5FAdmin%2Ehtm"));
  1481. ShellExecute(hWndDlg, _T("open"), szURL, NULL, NULL, 0);
  1482. break;
  1483. }
  1484. // Handle the Dialog Control Cases
  1485. case IDC_COMMIT:
  1486. {
  1487. TCHAR szTitle[MAX_TITLE];
  1488. TCHAR szMessage[MAX_MESSAGE];
  1489. TCHAR szTemp1[MAX_RESOURCE * 2];
  1490. TCHAR szTemp2[MAX_RESOURCE];
  1491. BOOL bLaunchSite = FALSE, bCancel = FALSE, bToFromProd = FALSE;
  1492. TCHAR szURL[MAX_MESSAGE];
  1493. HINSTANCE ret;
  1494. if(0 != memcmp(&g_OriginalSettings, &g_CurrentSettings, sizeof(PMSETTINGS)))
  1495. {
  1496. LRESULT dwCurrentConfigSel;
  1497. dwCurrentConfigSel = SendDlgItemMessage(hWndDlg,
  1498. IDC_CONFIGSETS,
  1499. CB_FINDSTRINGEXACT,
  1500. -1,
  1501. (LPARAM)g_szConfigSet);
  1502. // If the Hostname or IP address is blank for a non-default config, then pop up
  1503. // an error and refuse to save. (Bug #9080) KENI
  1504. //
  1505. if ((dwCurrentConfigSel != 0 && _tcslen(g_szConfigSet) != 0) && _tcslen(g_CurrentSettings.szHostName) == 0)
  1506. {
  1507. ReportControlMessage(hWndDlg, IDC_HOSTNAMEEDIT, VALIDATION_ERROR);
  1508. return FALSE;
  1509. }
  1510. if ((dwCurrentConfigSel != 0 && _tcslen(g_szConfigSet) != 0) && _tcslen(g_CurrentSettings.szHostIP) == 0)
  1511. {
  1512. ReportControlMessage(hWndDlg, IDC_HOSTIPEDIT, VALIDATION_ERROR);
  1513. return FALSE;
  1514. }
  1515. if (IDOK == CommitOKWarning(hWndDlg))
  1516. {
  1517. if(lstrcmp(g_OriginalSettings.szEnvName, g_szEnglishProduction) == 0 ||
  1518. lstrcmp(g_CurrentSettings.szEnvName, g_szEnglishProduction) == 0)
  1519. bToFromProd = TRUE;
  1520. // It is OK to commit, and the registry is consistent, or it is OK to
  1521. // proceed, so write out the current settings
  1522. if (WriteRegConfigSet(hWndDlg,
  1523. &g_CurrentSettings,
  1524. g_szRemoteComputer,
  1525. g_szConfigSet))
  1526. {
  1527. int Choice;
  1528. LoadString(g_hInst, IDS_CONFIG_COMPLETE_TITLE, szTitle, DIMENSION(szTitle));
  1529. if ( (lstrcmp(g_OriginalSettings.szEnvName, g_CurrentSettings.szEnvName) ||
  1530. lstrcmp(g_OriginalSettings.szRemoteFile, g_CurrentSettings.szRemoteFile) ))
  1531. {
  1532. TCHAR *pTempStr;
  1533. LoadString(g_hInst, IDS_CONFIG_COMPLETE, szTemp1, DIMENSION(szTemp1));
  1534. //
  1535. // 2 stands for %s in the string IDS_CONFIG_COMPLETE
  1536. //
  1537. {
  1538. TCHAR pszEnvName[MAX_RESOURCE];
  1539. if(lstrcmp(g_CurrentSettings.szEnvName, g_szEnglishPreProduction) == 0)
  1540. {
  1541. LoadString(g_hInst, IDS_PREPRODUCTION, pszEnvName, DIMENSION(pszEnvName));
  1542. }
  1543. else if(lstrcmp(g_CurrentSettings.szEnvName, g_szEnglishBetaPreProduction) == 0)
  1544. {
  1545. LoadString(g_hInst, IDS_BETAPREPRODUCTION, pszEnvName, DIMENSION(pszEnvName));
  1546. }
  1547. else if(lstrcmp(g_CurrentSettings.szEnvName, g_szEnglishOther) == 0)
  1548. {
  1549. LoadString(g_hInst, IDS_OTHER, pszEnvName, DIMENSION(pszEnvName));
  1550. }
  1551. else // must be Production
  1552. {
  1553. LoadString(g_hInst, IDS_PRODUCTION, pszEnvName, DIMENSION(pszEnvName));
  1554. }
  1555. if ((lstrlen(szTemp1) + lstrlen(pszEnvName)) >= MAX_RESOURCE - 2) {
  1556. //
  1557. // -1 == chars (%s - NULL)
  1558. //
  1559. pTempStr = new TCHAR[lstrlen(szTemp1) + lstrlen(pszEnvName) - 1];
  1560. } else {
  1561. pTempStr = szTemp2;
  1562. }
  1563. //
  1564. // IDS_CONFIG_COMPLETE has only one parameter in it.
  1565. //
  1566. //wsprintf (szTemp2, szTemp1, g_CurrentSettings.szEnvName, g_CurrentSettings.szEnvName);
  1567. wsprintf (pTempStr, szTemp1, pszEnvName);
  1568. }
  1569. if(MessageBox(hWndDlg, pTempStr, szTitle, MB_OKCANCEL) == IDOK)
  1570. bLaunchSite = TRUE;
  1571. else
  1572. bCancel = TRUE;
  1573. if (pTempStr != szTemp2) {
  1574. delete [] pTempStr;
  1575. }
  1576. }
  1577. // The changes where committed, so current becomes original
  1578. memcpy(&g_OriginalSettings, &g_CurrentSettings, sizeof(PMSETTINGS));
  1579. SetUndoButton(hWndDlg, FALSE);
  1580. }
  1581. else
  1582. {
  1583. ReportError(hWndDlg,IDS_COMMITERROR);
  1584. }
  1585. }
  1586. }
  1587. else if(g_dwRefreshNetMap == 0l)
  1588. {
  1589. LoadString(g_hInst, IDS_APP_TITLE, szTitle, DIMENSION(szTitle));
  1590. LoadString(g_hInst, IDS_NOTHINGTOCOMMIT, szMessage, DIMENSION(szMessage));
  1591. MessageBox(hWndDlg, szMessage, szTitle, MB_OK);
  1592. }
  1593. if(g_dwRefreshNetMap && !bLaunchSite && !bCancel)
  1594. {
  1595. LoadString(g_hInst, IDS_CONFIG_COMPLETE_TITLE, szTitle, DIMENSION(szTitle));
  1596. LoadString(g_hInst, IDS_MANUAL_REFRESH, szTemp1, DIMENSION(szTemp1));
  1597. if(MessageBox(hWndDlg, szTemp1, szTitle, MB_OKCANCEL) == IDOK)
  1598. bLaunchSite = TRUE;
  1599. }
  1600. if(bLaunchSite)
  1601. {
  1602. if (g_szRemoteComputer[0] == TEXT('\0'))
  1603. {
  1604. HRESULT hr;
  1605. hr = LocalRefreshOfNetworkMapping(hWndDlg);
  1606. if ( FAILED( hr ) )
  1607. {
  1608. // put up dialog indicating failure
  1609. }
  1610. }
  1611. else
  1612. {
  1613. // launch Validation Site
  1614. //
  1615. // Looks like the following lstrcat are OK. The only var is g_szRemoteComputer.
  1616. // And szURL has 8K space for the result string.
  1617. //
  1618. if ((TEXT('\0') != g_szRemoteComputer[0]))
  1619. {
  1620. lstrcpy(szURL, _T("http://"));
  1621. lstrcat(szURL, g_szRemoteComputer);
  1622. lstrcat(szURL, _T("/passporttest/default.asp?Refresh=True&Env="));
  1623. }
  1624. else
  1625. lstrcpy(szURL, _T("http://localhost/passporttest/default.asp?Refresh=True&Env="));
  1626. // get env
  1627. if(lstrcmp(g_CurrentSettings.szEnvName, g_szEnglishPreProduction) == 0)
  1628. lstrcat(szURL, _T("Prep"));
  1629. else if(lstrcmp(g_CurrentSettings.szEnvName, g_szEnglishBetaPreProduction) == 0)
  1630. lstrcat(szURL, _T("Beta"));
  1631. else if(lstrcmp(g_CurrentSettings.szEnvName, g_szEnglishOther) == 0)
  1632. lstrcat(szURL, _T("Other"));
  1633. else // must be Production
  1634. lstrcat(szURL, _T("Prod"));
  1635. // NewID=True when switching to or from Prod.
  1636. if(bToFromProd)
  1637. lstrcat(szURL, _T("&NewID=True"));
  1638. else
  1639. lstrcat(szURL, _T("&NewID=False"));
  1640. ret = ShellExecute(hWndDlg, _T("open"), szURL, NULL, NULL, 0);
  1641. if (ret <= (HINSTANCE) 32)
  1642. {
  1643. LoadString(g_hInst, IDS_OPEN_TITLE, szTitle, DIMENSION(szTitle));
  1644. LoadString(g_hInst, IDS_OPEN_ERROR, szTemp1, DIMENSION(szTemp1));
  1645. int Choice = IDRETRY;
  1646. while (Choice == IDRETRY)
  1647. {
  1648. ret = ShellExecute(hWndDlg, _T("open"), szURL, NULL, NULL, 0);
  1649. if (ret <= (HINSTANCE) 32)
  1650. Choice = MessageBox(hWndDlg, szTemp1, szTitle, MB_RETRYCANCEL);
  1651. else
  1652. Choice = IDCANCEL;
  1653. }
  1654. }
  1655. }
  1656. }
  1657. if(g_dwRefreshNetMap == 1l)
  1658. {
  1659. g_dwRefreshNetMap = 0l;
  1660. CheckDlgButton(hWndDlg, IDC_REFRESH_NET, BST_UNCHECKED);
  1661. }
  1662. break;
  1663. }
  1664. case IDC_UNDO:
  1665. {
  1666. // Restore the original settings, and re-init the current settings
  1667. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1668. memcpy(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS));
  1669. break;
  1670. }
  1671. case IDC_CONFIGSETS:
  1672. {
  1673. TCHAR szDefault[MAX_RESOURCE];
  1674. TCHAR szConfigSet[MAX_CONFIGSETNAME];
  1675. if(CBN_SELCHANGE == HIWORD(wParam))
  1676. {
  1677. GetDlgItemText(hWndDlg,
  1678. IDC_CONFIGSETS,
  1679. szConfigSet,
  1680. DIMENSION(szConfigSet));
  1681. //
  1682. // Convert <Default> to empty string.
  1683. //
  1684. LoadString(g_hInst, IDS_DEFAULT, szDefault, DIMENSION(szDefault));
  1685. if(lstrcmp(szConfigSet, szDefault) == 0)
  1686. szConfigSet[0] = TEXT('\0');
  1687. //
  1688. // If it's the current set, do nothing.
  1689. //
  1690. if(lstrcmp(szConfigSet, g_szConfigSet) != 0)
  1691. {
  1692. DoConfigSwitch(hWndDlg, g_szRemoteComputer, szConfigSet);
  1693. }
  1694. break;
  1695. }
  1696. break;
  1697. }
  1698. case IDC_ENABLE_MANREFRESH:
  1699. {
  1700. if (BN_CLICKED == HIWORD(wParam))
  1701. {
  1702. SetUndoButton(hWndDlg, TRUE);
  1703. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  1704. {
  1705. g_CurrentSettings.dwEnableManualRefresh = 1l;
  1706. EnableWindow(GetDlgItem(hWndDlg, IDC_REFRESH_NET), TRUE);
  1707. }
  1708. else
  1709. {
  1710. g_CurrentSettings.dwEnableManualRefresh = 0l;
  1711. g_dwRefreshNetMap = 0l;
  1712. EnableWindow(GetDlgItem(hWndDlg, IDC_REFRESH_NET), FALSE);
  1713. CheckDlgButton(hWndDlg, IDC_REFRESH_NET, BST_UNCHECKED);
  1714. }
  1715. }
  1716. break;
  1717. }
  1718. case IDC_REFRESH_NET:
  1719. {
  1720. if (BN_CLICKED == HIWORD(wParam))
  1721. {
  1722. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  1723. {
  1724. g_dwRefreshNetMap = 1l;
  1725. }
  1726. else
  1727. {
  1728. g_dwRefreshNetMap = 0l;
  1729. }
  1730. }
  1731. break;
  1732. }
  1733. case IDC_ENVCHANGE:
  1734. {
  1735. if(EnvChange(hWndDlg,
  1736. g_CurrentSettings.szEnvName,
  1737. g_CurrentSettings.cbEnvName) == TRUE)
  1738. {
  1739. InitMainDlg(hWndDlg, &g_CurrentSettings);
  1740. }
  1741. break;
  1742. }
  1743. case IDC_NEWCONFIG:
  1744. {
  1745. DWORD dwCurSel;
  1746. TCHAR szConfigSet[MAX_CONFIGSETNAME];
  1747. PMSETTINGS *pNewConfig;
  1748. pNewConfig = (PMSETTINGS*)LocalAlloc(LMEM_FIXED, sizeof(PMSETTINGS));
  1749. if (NULL == pNewConfig)
  1750. {
  1751. break;
  1752. }
  1753. GetDefaultSettings(pNewConfig);
  1754. _tcscpy(pNewConfig->szRemoteFile, g_CurrentSettings.szRemoteFile);
  1755. _tcscpy(pNewConfig->szEnvName, g_CurrentSettings.szEnvName);
  1756. pNewConfig->dwEnableManualRefresh = g_CurrentSettings.dwEnableManualRefresh;
  1757. if(!NewConfigSet(hWndDlg,
  1758. szConfigSet,
  1759. DIMENSION(szConfigSet),
  1760. pNewConfig->szHostName,
  1761. pNewConfig->cbHostName,
  1762. pNewConfig->szHostIP,
  1763. pNewConfig->cbHostIP))
  1764. {
  1765. LocalFree(pNewConfig);
  1766. break;
  1767. }
  1768. if(WriteRegConfigSet(hWndDlg, pNewConfig, g_szRemoteComputer, szConfigSet))
  1769. {
  1770. if(DoConfigSwitch(hWndDlg, g_szRemoteComputer, szConfigSet))
  1771. {
  1772. memcpy(g_szConfigSet, szConfigSet, sizeof(g_szConfigSet));
  1773. memcpy(&g_OriginalSettings, pNewConfig, sizeof(PMSETTINGS));
  1774. memcpy(&g_CurrentSettings, pNewConfig, sizeof(PMSETTINGS));
  1775. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1776. }
  1777. else
  1778. {
  1779. RemoveRegConfigSet(hWndDlg, g_szRemoteComputer, szConfigSet);
  1780. }
  1781. }
  1782. else
  1783. {
  1784. ReportError(hWndDlg, IDS_WRITENEW_ERROR);
  1785. }
  1786. LocalFree(pNewConfig);
  1787. break;
  1788. }
  1789. case IDC_REMOVECONFIG:
  1790. {
  1791. LRESULT dwCurSel;
  1792. LRESULT dwNumItems;
  1793. TCHAR szDefault[MAX_RESOURCE];
  1794. dwCurSel = SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_GETCURSEL, 0, 0L);
  1795. if(dwCurSel == 0 || dwCurSel == CB_ERR)
  1796. break;
  1797. if(!RemoveConfigSetWarning(hWndDlg))
  1798. break;
  1799. if(!RemoveRegConfigSet(hWndDlg, g_szRemoteComputer, g_szConfigSet))
  1800. {
  1801. //MessageBox(
  1802. break;
  1803. }
  1804. dwNumItems = SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_GETCOUNT, 0, 0L);
  1805. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_DELETESTRING, dwCurSel, 0L);
  1806. // Was this the last item in the list?
  1807. if(dwCurSel + 1 == dwNumItems)
  1808. dwCurSel--;
  1809. SendDlgItemMessage(hWndDlg, IDC_CONFIGSETS, CB_SETCURSEL, dwCurSel, 0L);
  1810. GetDlgItemText(hWndDlg, IDC_CONFIGSETS, g_szConfigSet, DIMENSION(g_szConfigSet));
  1811. LoadString(g_hInst, IDS_DEFAULT, szDefault, DIMENSION(szDefault));
  1812. if(lstrcmp(g_szConfigSet, szDefault) == 0)
  1813. g_szConfigSet[0] = TEXT('\0');
  1814. // [CR] Should warn if changes have not been committed!
  1815. InitializePMConfigStruct(&g_OriginalSettings);
  1816. if (ReadRegConfigSet(hWndDlg,
  1817. &g_OriginalSettings,
  1818. g_szRemoteComputer,
  1819. g_szConfigSet))
  1820. {
  1821. InitMainDlg(hWndDlg, &g_OriginalSettings);
  1822. // Make a copy of the original setting for editing purposes
  1823. memcpy(&g_CurrentSettings, &g_OriginalSettings, sizeof(PMSETTINGS));
  1824. }
  1825. break;
  1826. }
  1827. case IDC_TIMEWINDOW:
  1828. {
  1829. BOOL bValid = TRUE;
  1830. DWORD dwEditValue = GetDlgItemInt(hWndDlg, wCmd, &bValid, FALSE);
  1831. // Look at the notification code
  1832. if (EN_KILLFOCUS == HIWORD(wParam))
  1833. {
  1834. if (bValid && (dwEditValue >= 100) && (dwEditValue <= MAX_TIME_WINDOW_SECONDS))
  1835. {
  1836. g_CurrentSettings.dwTimeWindow = dwEditValue;
  1837. SetUndoButton(hWndDlg, TRUE);
  1838. UpdateTimeWindowDisplay(hWndDlg, dwEditValue);
  1839. }
  1840. else
  1841. {
  1842. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1843. SetFocus(GetDlgItem(hWndDlg, wCmd));
  1844. bOkToClose = FALSE;
  1845. }
  1846. }
  1847. break;
  1848. }
  1849. case IDC_LANGUAGEID:
  1850. {
  1851. // Look at the notification code
  1852. switch (HIWORD(wParam))
  1853. {
  1854. // The user selected a different value in the LangID combo
  1855. case CBN_SELCHANGE:
  1856. {
  1857. // Get the index of the new item selected and update with the approparite
  1858. // language ID string
  1859. LRESULT idx = SendDlgItemMessage(hWndDlg, IDC_LANGUAGEID, CB_GETCURSEL, 0, 0);
  1860. // Update the current Settings
  1861. g_CurrentSettings.dwLanguageID =
  1862. (DWORD) SendDlgItemMessage(hWndDlg,
  1863. IDC_LANGUAGEID,
  1864. CB_GETITEMDATA,
  1865. idx,
  1866. 0);
  1867. SetUndoButton(hWndDlg, TRUE);
  1868. break;
  1869. }
  1870. }
  1871. break;
  1872. }
  1873. case IDC_COBRANDING_TEMPLATE:
  1874. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szCoBrandTemplate;
  1875. cbStrToUpdate = g_CurrentSettings.cbCoBrandTemplate;
  1876. goto HANDLE_EN_FOR_STRING_CTRLS;
  1877. case IDC_RETURNURL:
  1878. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szReturnURL;
  1879. cbStrToUpdate = g_CurrentSettings.cbReturnURL;
  1880. goto HANDLE_EN_FOR_STRING_CTRLS;
  1881. case IDC_COOKIEDOMAIN:
  1882. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szTicketDomain;
  1883. cbStrToUpdate = g_CurrentSettings.cbTicketDomain;
  1884. goto HANDLE_EN_FOR_STRING_CTRLS;
  1885. case IDC_COOKIEPATH:
  1886. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szTicketPath;
  1887. cbStrToUpdate = g_CurrentSettings.cbTicketPath;
  1888. goto HANDLE_EN_FOR_STRING_CTRLS;
  1889. case IDC_PROFILEDOMAIN:
  1890. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szProfileDomain;
  1891. cbStrToUpdate = g_CurrentSettings.cbProfileDomain;
  1892. goto HANDLE_EN_FOR_STRING_CTRLS;
  1893. case IDC_PROFILEPATH:
  1894. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szProfilePath;
  1895. cbStrToUpdate = g_CurrentSettings.cbProfilePath;
  1896. goto HANDLE_EN_FOR_STRING_CTRLS;
  1897. case IDC_SECUREDOMAIN:
  1898. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szSecureDomain;
  1899. cbStrToUpdate = g_CurrentSettings.cbSecureDomain;
  1900. goto HANDLE_EN_FOR_STRING_CTRLS;
  1901. case IDC_SECUREPATH:
  1902. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szSecurePath;
  1903. cbStrToUpdate = g_CurrentSettings.cbSecurePath;
  1904. goto HANDLE_EN_FOR_STRING_CTRLS;
  1905. case IDC_DISASTERURL:
  1906. lpszStrToUpdate = (LPTSTR)&g_CurrentSettings.szDisasterURL;
  1907. cbStrToUpdate = g_CurrentSettings.cbDisasterURL;
  1908. goto HANDLE_EN_FOR_STRING_CTRLS;
  1909. {
  1910. HANDLE_EN_FOR_STRING_CTRLS:
  1911. switch (HIWORD(wParam))
  1912. {
  1913. case EN_CHANGE:
  1914. if (!g_bCanUndo)
  1915. SetUndoButton(hWndDlg, TRUE);
  1916. // Get the updated Value
  1917. // cbStrToUpdate is BYTE count
  1918. //
  1919. GetDlgItemText(hWndDlg,
  1920. wCmd,
  1921. lpszStrToUpdate,
  1922. cbStrToUpdate/sizeof(TCHAR));
  1923. break;
  1924. case EN_MAXTEXT:
  1925. {
  1926. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1927. break;
  1928. }
  1929. }
  1930. break;
  1931. }
  1932. case IDC_HOSTNAMEEDIT:
  1933. switch (HIWORD(wParam))
  1934. {
  1935. case EN_CHANGE:
  1936. {
  1937. TCHAR szHostName[INTERNET_MAX_HOST_NAME_LENGTH];
  1938. if (!g_bCanUndo)
  1939. SetUndoButton(hWndDlg, TRUE);
  1940. // Get the updated Value
  1941. GetDlgItemText(hWndDlg,
  1942. wCmd,
  1943. szHostName,
  1944. DIMENSION(szHostName));
  1945. if(lstrlen(szHostName) == 0 && g_szConfigSet[0])
  1946. {
  1947. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1948. //SetDlgItemText(hWndDlg, IDC_HOSTNAMEEDIT, g_CurrentSettings.szHostName); (commented, bug #9080)
  1949. SetFocus(GetDlgItem(hWndDlg, IDC_HOSTNAMEEDIT));
  1950. }
  1951. else
  1952. {
  1953. lstrcpy(g_CurrentSettings.szHostName, szHostName);
  1954. }
  1955. }
  1956. break;
  1957. case EN_MAXTEXT:
  1958. {
  1959. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1960. break;
  1961. }
  1962. }
  1963. break;
  1964. case IDC_HOSTIPEDIT:
  1965. switch (HIWORD(wParam))
  1966. {
  1967. case EN_KILLFOCUS:
  1968. {
  1969. TCHAR szHostIP[MAX_IPLEN];
  1970. // Get the updated Value
  1971. GetDlgItemText(hWndDlg,
  1972. wCmd,
  1973. szHostIP,
  1974. DIMENSION(szHostIP));
  1975. if((lstrlen(szHostIP) > 0 && g_szConfigSet[0] == 0) || !IsValidIP(szHostIP)) //bug 8834
  1976. {
  1977. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1978. SetDlgItemText(hWndDlg, IDC_HOSTIPEDIT, g_CurrentSettings.szHostIP);
  1979. SetFocus(GetDlgItem(hWndDlg, IDC_HOSTIPEDIT));
  1980. }
  1981. }
  1982. break;
  1983. case EN_CHANGE:
  1984. {
  1985. TCHAR szHostIP[MAX_IPLEN];
  1986. if (!g_bCanUndo)
  1987. SetUndoButton(hWndDlg, TRUE);
  1988. // Get the updated Value
  1989. GetDlgItemText(hWndDlg,
  1990. wCmd,
  1991. szHostIP,
  1992. DIMENSION(szHostIP));
  1993. if(lstrlen(szHostIP) == 0 && g_szConfigSet[0])
  1994. {
  1995. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  1996. // SetDlgItemText(hWndDlg, IDC_HOSTIPEDIT, g_CurrentSettings.szHostIP); (commented, bug #9080)
  1997. SetFocus(GetDlgItem(hWndDlg, IDC_HOSTIPEDIT));
  1998. }
  1999. else
  2000. {
  2001. lstrcpy(g_CurrentSettings.szHostIP, szHostIP);
  2002. }
  2003. }
  2004. break;
  2005. case EN_MAXTEXT:
  2006. {
  2007. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  2008. break;
  2009. }
  2010. }
  2011. break;
  2012. case IDC_SITEID:
  2013. {
  2014. BOOL bValid = TRUE;
  2015. DWORD dwEditValue = GetDlgItemInt(hWndDlg, wCmd, &bValid, FALSE);
  2016. // Look at the notification code
  2017. if (EN_CHANGE == HIWORD(wParam))
  2018. {
  2019. if (bValid && (dwEditValue >= 1) && (dwEditValue <= MAX_SITEID))
  2020. {
  2021. g_CurrentSettings.dwSiteID = dwEditValue;
  2022. SetUndoButton(hWndDlg, TRUE);
  2023. }
  2024. else
  2025. {
  2026. ReportControlMessage(hWndDlg, wCmd, VALIDATION_ERROR);
  2027. SetDlgItemInt(hWndDlg, wCmd, g_CurrentSettings.dwSiteID, FALSE);
  2028. SetFocus(GetDlgItem(hWndDlg, wCmd));
  2029. }
  2030. }
  2031. break;
  2032. }
  2033. case IDC_STANDALONE:
  2034. {
  2035. if (BN_CLICKED == HIWORD(wParam))
  2036. {
  2037. SetUndoButton(hWndDlg, TRUE);
  2038. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  2039. g_CurrentSettings.dwStandAlone = 1l;
  2040. else
  2041. g_CurrentSettings.dwStandAlone = 0l;
  2042. }
  2043. break;
  2044. }
  2045. /////////////////////////////////////////////////////////////
  2046. //JVP 3/2/2000
  2047. /////////////////////////////////////////////////////////////
  2048. case IDC_VERBOSE_MODE:
  2049. {
  2050. if (BN_CLICKED == HIWORD(wParam))
  2051. {
  2052. SetUndoButton(hWndDlg, TRUE);
  2053. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  2054. g_CurrentSettings.dwVerboseMode = 1l;
  2055. else
  2056. g_CurrentSettings.dwVerboseMode = 0l;
  2057. }
  2058. break;
  2059. }
  2060. case IDC_DISABLECOOKIES:
  2061. {
  2062. if (BN_CLICKED == HIWORD(wParam))
  2063. {
  2064. SetUndoButton(hWndDlg, TRUE);
  2065. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  2066. g_CurrentSettings.dwDisableCookies = 1l;
  2067. else
  2068. g_CurrentSettings.dwDisableCookies = 0l;
  2069. }
  2070. break;
  2071. }
  2072. case IDC_FORCESIGNIN:
  2073. {
  2074. if (BN_CLICKED == HIWORD(wParam))
  2075. {
  2076. SetUndoButton(hWndDlg, TRUE);
  2077. if (BST_CHECKED == IsDlgButtonChecked(hWndDlg, wCmd))
  2078. g_CurrentSettings.dwForceSignIn = 1l;
  2079. else
  2080. g_CurrentSettings.dwForceSignIn = 0l;
  2081. }
  2082. break;
  2083. }
  2084. default:
  2085. {
  2086. if(wCmd >= IDM_COMPUTERMRUBASE && wCmd < IDM_COMPUTERMRUBASE + COMPUTER_MRU_SIZE)
  2087. {
  2088. HMENU hMenu = NULL;
  2089. TCHAR achBuf[MAX_PATH];
  2090. TCHAR achTemp[MAX_REGISTRY_STRING];
  2091. LPTSTR szNewRemoteComputer;
  2092. //
  2093. // Get the selected computer.
  2094. //
  2095. if (NULL == (hMenu = GetMenu(hWndDlg)))
  2096. {
  2097. break;
  2098. }
  2099. if(GetMenuString(hMenu,
  2100. wCmd,
  2101. achBuf,
  2102. MAX_PATH,
  2103. MF_BYCOMMAND) == 0)
  2104. break;
  2105. //
  2106. // Get past the shortcut chars.
  2107. //
  2108. szNewRemoteComputer = _tcschr(achBuf, TEXT(' '));
  2109. if(szNewRemoteComputer == NULL)
  2110. break;
  2111. szNewRemoteComputer++;
  2112. //
  2113. // Is it local host?
  2114. //
  2115. LoadString(g_hInst, IDS_LOCALHOST, achTemp, DIMENSION(achTemp));
  2116. if(lstrcmp(szNewRemoteComputer, achTemp) == 0)
  2117. {
  2118. achBuf[0] = TEXT('\0');
  2119. szNewRemoteComputer = achBuf;
  2120. }
  2121. //
  2122. // Now try to connect and read.
  2123. //
  2124. if(!DoServerSwitch(hWndDlg, szNewRemoteComputer))
  2125. DoConfigSwitch(hWndDlg, g_szRemoteComputer, g_szConfigSet);
  2126. break;
  2127. }
  2128. break;
  2129. }
  2130. }
  2131. break;
  2132. }
  2133. case WM_CLOSE:
  2134. {
  2135. HWND hwndFocus = GetFocus();
  2136. bOkToClose = TRUE;
  2137. SetFocus(NULL);
  2138. if(bOkToClose)
  2139. DoExit(hWndDlg);
  2140. else
  2141. SetFocus(hwndFocus);
  2142. }
  2143. break;
  2144. }
  2145. return FALSE;
  2146. }