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.

1240 lines
49 KiB

  1. #include "precomp.h"
  2. #include <inetcpl.h>
  3. #include "rsop.h"
  4. #include "resource.h"
  5. #include <tchar.h>
  6. // Private forward decalarations
  7. static void pxyEnableDlgItems(HWND hDlg, BOOL fSame, BOOL fUseProxy);
  8. static INT_PTR CALLBACK importConnSettingsRSoPProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  9. // defines for tree view image list
  10. #define BITMAP_WIDTH 16
  11. #define BITMAP_HEIGHT 16
  12. #define CONN_BITMAPS 2
  13. #define IMAGE_LAN 0
  14. #define IMAGE_MODEM 1
  15. /////////////////////////////////////////////////////////////////////
  16. void InitCSDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  17. {
  18. __try
  19. {
  20. BOOL bImport = FALSE;
  21. _bstr_t bstrClass = L"RSOP_IEConnectionSettings";
  22. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass, L"rsopPrecedence");
  23. if (SUCCEEDED(hr))
  24. {
  25. CPSObjData **paCSObj = pDRD->GetCSObjArray();
  26. long nCSObjects = pDRD->GetCSObjCount();
  27. BOOL bImportHandled = FALSE;
  28. BOOL bDeleteHandled = FALSE;
  29. for (long nObj = 0; nObj < nCSObjects; nObj++)
  30. {
  31. // importCurrentConnSettings field
  32. _variant_t vtValue;
  33. if (!bImportHandled)
  34. {
  35. hr = paCSObj[nObj]->pObj->Get(L"importCurrentConnSettings", 0, &vtValue, NULL, NULL);
  36. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  37. {
  38. bImport = (bool)vtValue ? TRUE : FALSE;
  39. CheckRadioButton(hDlg, IDC_CSNOIMPORT, IDC_CSIMPORT,
  40. (bool)vtValue ? IDC_CSIMPORT : IDC_CSNOIMPORT);
  41. bImportHandled = TRUE;
  42. DWORD dwCurGPOPrec = GetGPOPrecedence(paCSObj[nObj]->pObj, L"rsopPrecedence");
  43. pDRD->SetImportedConnSettPrec(dwCurGPOPrec);
  44. }
  45. }
  46. // deleteExistingConnSettings field
  47. if (!bDeleteHandled)
  48. {
  49. hr = paCSObj[nObj]->pObj->Get(L"deleteExistingConnSettings", 0, &vtValue, NULL, NULL);
  50. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  51. {
  52. CheckDlgButton(hDlg, IDC_DELCONNECT, BST_CHECKED);
  53. bDeleteHandled = TRUE;
  54. }
  55. }
  56. // no need to process other GPOs since enabled properties have been found
  57. if (bImportHandled && bDeleteHandled)
  58. break;
  59. }
  60. }
  61. EnableDlgItem2(hDlg, IDC_CSNOIMPORT, FALSE);
  62. EnableDlgItem2(hDlg, IDC_CSIMPORT, FALSE);
  63. EnableDlgItem2(hDlg, IDC_MODIFYCONNECT, bImport);
  64. EnableDlgItem2(hDlg, IDC_DELCONNECT, FALSE);
  65. }
  66. __except(TRUE)
  67. {
  68. }
  69. }
  70. /////////////////////////////////////////////////////////////////////
  71. HRESULT InitCSPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  72. {
  73. HRESULT hr = NOERROR;
  74. __try
  75. {
  76. _bstr_t bstrClass = L"RSOP_IEConnectionSettings";
  77. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  78. if (SUCCEEDED(hr))
  79. {
  80. CPSObjData **paCSObj = pDRD->GetCSObjArray();
  81. long nCSObjects = pDRD->GetCSObjCount();
  82. for (long nObj = 0; nObj < nCSObjects; nObj++)
  83. {
  84. _bstr_t bstrGPOName = pDRD->GetGPONameFromPSAssociation(paCSObj[nObj]->pObj,
  85. L"rsopPrecedence");
  86. // importCurrentConnSettings field
  87. BOOL bImport = FALSE;
  88. _variant_t vtValue;
  89. hr = paCSObj[nObj]->pObj->Get(L"importCurrentConnSettings", 0, &vtValue, NULL, NULL);
  90. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  91. bImport = (bool)vtValue ? TRUE : FALSE;
  92. // deleteExistingConnSettings field
  93. BOOL bDelete = FALSE;
  94. hr = paCSObj[nObj]->pObj->Get(L"deleteExistingConnSettings", 0, &vtValue, NULL, NULL);
  95. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  96. bDelete = (bool)vtValue ? TRUE : FALSE;
  97. _bstr_t bstrSetting;
  98. UINT iSettingString = 0;
  99. WCHAR wszTemp[128];
  100. if (bImport && bDelete)
  101. iSettingString = IDS_CS_IMP_DEL_SETTING;
  102. else if (bImport)
  103. iSettingString = IDS_CS_IMPORT_SETTING;
  104. else if (bDelete)
  105. iSettingString = IDS_CS_DELETE_SETTING;
  106. else
  107. bstrSetting = GetDisabledString();
  108. if (iSettingString > 0)
  109. {
  110. LoadString(g_hInstance, iSettingString, wszTemp, countof(wszTemp));
  111. bstrSetting = wszTemp;
  112. }
  113. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  114. }
  115. }
  116. }
  117. __except(TRUE)
  118. {
  119. }
  120. return hr;
  121. }
  122. /////////////////////////////////////////////////////////////////////
  123. void InitAutoConfigDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  124. {
  125. __try
  126. {
  127. _bstr_t bstrClass = L"RSOP_IEConnectionSettings";
  128. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass, L"rsopPrecedence");
  129. if (SUCCEEDED(hr))
  130. {
  131. CPSObjData **paCSObj = pDRD->GetCSObjArray();
  132. long nCSObjects = pDRD->GetCSObjCount();
  133. BOOL bDetectHandled = FALSE;
  134. BOOL bEnableHandled = FALSE;
  135. for (long nObj = 0; nObj < nCSObjects; nObj++)
  136. {
  137. // autoDetectConfigSettings field
  138. _variant_t vtValue;
  139. if (!bDetectHandled)
  140. {
  141. hr = paCSObj[nObj]->pObj->Get(L"autoDetectConfigSettings", 0, &vtValue, NULL, NULL);
  142. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  143. {
  144. CheckDlgButton(hDlg, IDC_AUTODETECT, BST_CHECKED);
  145. bDetectHandled = TRUE;
  146. }
  147. }
  148. // autoConfigEnable field
  149. if (!bEnableHandled)
  150. {
  151. hr = paCSObj[nObj]->pObj->Get(L"autoConfigEnable", 0, &vtValue, NULL, NULL);
  152. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  153. {
  154. CheckDlgButton(hDlg, IDC_YESAUTOCON, BST_CHECKED);
  155. bEnableHandled = TRUE;
  156. // autoConfigTime
  157. hr = paCSObj[nObj]->pObj->Get(L"autoConfigTime", 0, &vtValue, NULL, NULL);
  158. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  159. {
  160. TCHAR szTime[10] = _T("");
  161. wnsprintf(szTime, countof(szTime), _T("%ld"), (long)vtValue);
  162. SetDlgItemText(hDlg, IDE_AUTOCONFIGTIME, szTime);
  163. }
  164. // autoConfigURL
  165. _bstr_t bstrValue;
  166. hr = paCSObj[nObj]->pObj->Get(L"autoConfigURL", 0, &vtValue, NULL, NULL);
  167. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  168. {
  169. bstrValue = vtValue;
  170. SetDlgItemText(hDlg, IDE_AUTOCONFIGURL, (LPCTSTR)bstrValue);
  171. }
  172. // autoProxyURL
  173. hr = paCSObj[nObj]->pObj->Get(L"autoProxyURL", 0, &vtValue, NULL, NULL);
  174. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  175. {
  176. bstrValue = vtValue;
  177. SetDlgItemText(hDlg, IDE_AUTOPROXYURL, (LPCTSTR)bstrValue);
  178. }
  179. }
  180. }
  181. // no need to process other GPOs since enabled properties have been found
  182. if (bDetectHandled && bEnableHandled)
  183. break;
  184. }
  185. }
  186. EnableDlgItem2(hDlg, IDC_AUTODETECT, FALSE);
  187. EnableDlgItem2(hDlg, IDC_YESAUTOCON, FALSE);
  188. EnableDlgItem2(hDlg, IDE_AUTOCONFIGTIME, FALSE);
  189. EnableDlgItem2(hDlg, IDE_AUTOCONFIGURL, FALSE);
  190. EnableDlgItem2(hDlg, IDE_AUTOPROXYURL, FALSE);
  191. }
  192. __except(TRUE)
  193. {
  194. }
  195. }
  196. /////////////////////////////////////////////////////////////////////
  197. HRESULT InitAutoDetectCfgPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  198. {
  199. HRESULT hr = NOERROR;
  200. __try
  201. {
  202. _bstr_t bstrClass = L"RSOP_IEConnectionSettings";
  203. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  204. if (SUCCEEDED(hr))
  205. {
  206. CPSObjData **paCSObj = pDRD->GetCSObjArray();
  207. long nCSObjects = pDRD->GetCSObjCount();
  208. for (long nObj = 0; nObj < nCSObjects; nObj++)
  209. {
  210. _bstr_t bstrGPOName = pDRD->GetGPONameFromPSAssociation(paCSObj[nObj]->pObj,
  211. L"rsopPrecedence");
  212. // autoDetectConfigSettings field
  213. BOOL bDetect = FALSE;
  214. _variant_t vtValue;
  215. hr = paCSObj[nObj]->pObj->Get(L"autoDetectConfigSettings", 0, &vtValue, NULL, NULL);
  216. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  217. bDetect = (bool)vtValue ? TRUE : FALSE;
  218. _bstr_t bstrSetting;
  219. if (bDetect)
  220. bstrSetting = GetEnabledString();
  221. else
  222. bstrSetting = GetDisabledString();
  223. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  224. }
  225. }
  226. }
  227. __except(TRUE)
  228. {
  229. }
  230. return hr;
  231. }
  232. /////////////////////////////////////////////////////////////////////
  233. HRESULT InitAutoCfgEnablePrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  234. {
  235. HRESULT hr = NOERROR;
  236. __try
  237. {
  238. _bstr_t bstrClass = L"RSOP_IEConnectionSettings";
  239. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  240. if (SUCCEEDED(hr))
  241. {
  242. CPSObjData **paCSObj = pDRD->GetCSObjArray();
  243. long nCSObjects = pDRD->GetCSObjCount();
  244. for (long nObj = 0; nObj < nCSObjects; nObj++)
  245. {
  246. _bstr_t bstrGPOName = pDRD->GetGPONameFromPSAssociation(paCSObj[nObj]->pObj,
  247. L"rsopPrecedence");
  248. // autoConfigEnable field
  249. BOOL bEnable = FALSE;
  250. _variant_t vtValue;
  251. hr = paCSObj[nObj]->pObj->Get(L"autoConfigEnable", 0, &vtValue, NULL, NULL);
  252. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  253. bEnable = (bool)vtValue ? TRUE : FALSE;
  254. _bstr_t bstrSetting;
  255. if (bEnable)
  256. bstrSetting = GetEnabledString();
  257. else
  258. bstrSetting = GetDisabledString();
  259. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  260. }
  261. }
  262. }
  263. __except(TRUE)
  264. {
  265. }
  266. return hr;
  267. }
  268. /////////////////////////////////////////////////////////////////////
  269. void InitProxyDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  270. {
  271. __try
  272. {
  273. _bstr_t bstrClass = L"RSOP_IEConnectionSettings";
  274. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass, L"rsopPrecedence");
  275. if (SUCCEEDED(hr))
  276. {
  277. CPSObjData **paCSObj = pDRD->GetCSObjArray();
  278. long nCSObjects = pDRD->GetCSObjCount();
  279. for (long nObj = 0; nObj < nCSObjects; nObj++)
  280. {
  281. // enableProxy field
  282. _variant_t vtValue;
  283. hr = paCSObj[nObj]->pObj->Get(L"enableProxy", 0, &vtValue, NULL, NULL);
  284. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  285. {
  286. if ((bool)vtValue)
  287. CheckDlgButton(hDlg, IDC_YESPROXY, BST_CHECKED);
  288. // httpProxyServer
  289. _bstr_t bstrValue;
  290. hr = paCSObj[nObj]->pObj->Get(L"httpProxyServer", 0, &vtValue, NULL, NULL);
  291. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  292. {
  293. bstrValue = vtValue;
  294. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_HTTPPROXY, IDE_HTTPPORT, TRUE);
  295. }
  296. // useSameProxy
  297. hr = paCSObj[nObj]->pObj->Get(L"useSameProxy", 0, &vtValue, NULL, NULL);
  298. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  299. {
  300. if ((bool)vtValue)
  301. {
  302. CheckDlgButton(hDlg, IDC_SAMEFORALL, BST_CHECKED);
  303. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_FTPPROXY, IDE_FTPPORT, TRUE);
  304. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_GOPHERPROXY, IDE_GOPHERPORT, TRUE);
  305. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_SECPROXY, IDE_SECPORT, TRUE);
  306. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_SOCKSPROXY, IDE_SOCKSPORT, FALSE);
  307. }
  308. else
  309. {
  310. // ftpProxyServer
  311. hr = paCSObj[nObj]->pObj->Get(L"ftpProxyServer", 0, &vtValue, NULL, NULL);
  312. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  313. {
  314. bstrValue = vtValue;
  315. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_FTPPROXY, IDE_FTPPORT, TRUE);
  316. }
  317. // gopherProxyServer
  318. hr = paCSObj[nObj]->pObj->Get(L"gopherProxyServer", 0, &vtValue, NULL, NULL);
  319. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  320. {
  321. bstrValue = vtValue;
  322. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_GOPHERPROXY, IDE_GOPHERPORT, TRUE);
  323. }
  324. // secureProxyServer
  325. hr = paCSObj[nObj]->pObj->Get(L"secureProxyServer", 0, &vtValue, NULL, NULL);
  326. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  327. {
  328. bstrValue = vtValue;
  329. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_SECPROXY, IDE_SECPORT, TRUE);
  330. }
  331. // socksProxyServer
  332. hr = paCSObj[nObj]->pObj->Get(L"socksProxyServer", 0, &vtValue, NULL, NULL);
  333. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  334. {
  335. bstrValue = vtValue;
  336. SetProxyDlg(hDlg, (LPCTSTR)bstrValue, IDE_SOCKSPROXY, IDE_SOCKSPORT, FALSE);
  337. }
  338. }
  339. }
  340. // proxyOverride
  341. hr = paCSObj[nObj]->pObj->Get(L"proxyOverride", 0, &vtValue, NULL, NULL);
  342. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  343. {
  344. bstrValue = vtValue;
  345. TCHAR szProxy[MAX_PATH];
  346. StrCpy(szProxy, (LPCTSTR)bstrValue);
  347. if (TEXT('\0') == szProxy[0])
  348. StrCpy(szProxy, LOCALPROXY);
  349. LPTSTR pszLocal = StrStr(szProxy, LOCALPROXY);
  350. if (NULL != pszLocal)
  351. {
  352. if (pszLocal == szProxy)
  353. {
  354. LPTSTR pszSemicolon = pszLocal + countof(LOCALPROXY)-1;
  355. if (TEXT(';') == *pszSemicolon)
  356. pszSemicolon++;
  357. StrCpy(pszLocal, pszSemicolon);
  358. }
  359. else if (TEXT('\0') == *(pszLocal + countof(LOCALPROXY)-1))
  360. *(pszLocal - 1) = TEXT('\0');
  361. CheckDlgButton(hDlg, IDC_DISPROXYLOCAL, TRUE);
  362. }
  363. SetDlgItemText(hDlg, IDE_DISPROXYADR, szProxy);
  364. }
  365. break;
  366. }
  367. }
  368. }
  369. EnableDlgItem2(hDlg, IDC_YESPROXY, FALSE);
  370. EnableDlgItem2(hDlg, IDC_SAMEFORALL, FALSE);
  371. EnableDlgItem2(hDlg, IDE_HTTPPROXY, FALSE);
  372. EnableDlgItem2(hDlg, IDE_HTTPPORT, FALSE);
  373. EnableDlgItem2(hDlg, IDE_FTPPROXY, FALSE);
  374. EnableDlgItem2(hDlg, IDE_FTPPORT, FALSE);
  375. EnableDlgItem2(hDlg, IDE_GOPHERPROXY, FALSE);
  376. EnableDlgItem2(hDlg, IDE_GOPHERPORT, FALSE);
  377. EnableDlgItem2(hDlg, IDE_SECPROXY, FALSE);
  378. EnableDlgItem2(hDlg, IDE_SECPORT, FALSE);
  379. EnableDlgItem2(hDlg, IDE_SOCKSPROXY, FALSE);
  380. EnableDlgItem2(hDlg, IDE_SOCKSPORT, FALSE);
  381. EnableDlgItem2(hDlg, IDC_DISPROXYLOCAL, FALSE);
  382. EnableDlgItem2(hDlg, IDE_DISPROXYADR, FALSE);
  383. }
  384. __except(TRUE)
  385. {
  386. }
  387. }
  388. /////////////////////////////////////////////////////////////////////
  389. HRESULT InitProxyPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  390. {
  391. HRESULT hr = NOERROR;
  392. __try
  393. {
  394. _bstr_t bstrClass = L"RSOP_IEConnectionSettings";
  395. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  396. if (SUCCEEDED(hr))
  397. {
  398. CPSObjData **paCSObj = pDRD->GetCSObjArray();
  399. long nCSObjects = pDRD->GetCSObjCount();
  400. for (long nObj = 0; nObj < nCSObjects; nObj++)
  401. {
  402. _bstr_t bstrGPOName = pDRD->GetGPONameFromPSAssociation(paCSObj[nObj]->pObj,
  403. L"rsopPrecedence");
  404. // enableProxy field
  405. BOOL bEnable = FALSE;
  406. _variant_t vtValue;
  407. hr = paCSObj[nObj]->pObj->Get(L"enableProxy", 0, &vtValue, NULL, NULL);
  408. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  409. bEnable = (bool)vtValue ? TRUE : FALSE;
  410. _bstr_t bstrSetting;
  411. if (bEnable)
  412. bstrSetting = GetEnabledString();
  413. else
  414. bstrSetting = GetDisabledString();
  415. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  416. }
  417. }
  418. }
  419. __except(TRUE)
  420. {
  421. }
  422. return hr;
  423. }
  424. /////////////////////////////////////////////////////////////////////
  425. INT_PTR CALLBACK ConnectSetDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  426. {
  427. // Retrieve Property Sheet Page info for each call into dlg proc.
  428. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  429. TCHAR szWorkDir[MAX_PATH];
  430. BOOL fImport;
  431. switch (msg) {
  432. case WM_INITDIALOG:
  433. SetPropSheetCookie(hDlg, lParam);
  434. // find out if this dlg is in RSoP mode
  435. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  436. if (psCookie->pCS->IsRSoP())
  437. {
  438. TCHAR szViewSettings[128];
  439. LoadString(g_hInstance, IDS_VIEW_SETTINGS, szViewSettings, countof(szViewSettings));
  440. SetDlgItemText(hDlg, IDC_MODIFYCONNECT, szViewSettings);
  441. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  442. if (pDRD)
  443. InitCSDlgInRSoPMode(hDlg, pDRD);
  444. }
  445. break;
  446. case WM_DESTROY:
  447. if (psCookie->pCS->IsRSoP())
  448. DestroyDlgRSoPData(hDlg);
  449. break;
  450. case WM_COMMAND:
  451. if (BN_CLICKED != GET_WM_COMMAND_CMD(wParam, lParam))
  452. return FALSE;
  453. switch (GET_WM_COMMAND_ID(wParam, lParam)) {
  454. case IDC_CSNOIMPORT:
  455. DisableDlgItem(hDlg, IDC_MODIFYCONNECT);
  456. break;
  457. case IDC_CSIMPORT:
  458. EnableDlgItem(hDlg, IDC_MODIFYCONNECT);
  459. break;
  460. case IDC_MODIFYCONNECT:
  461. if (psCookie->pCS->IsRSoP())
  462. {
  463. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  464. if (NULL != pDRD)
  465. {
  466. CreateINetCplLookALikePage(hDlg, IDD_IMPORTEDCONNSETTINGS,
  467. importConnSettingsRSoPProc, (LPARAM)pDRD);
  468. }
  469. }
  470. else
  471. ShowInetcpl(hDlg, INET_PAGE_CONNECTION);
  472. break;
  473. default:
  474. return FALSE;
  475. }
  476. break;
  477. case WM_NOTIFY:
  478. switch (((LPNMHDR)lParam)->code) {
  479. case PSN_SETACTIVE:
  480. // don't do any of this stuff in RSoP mode
  481. if (!psCookie->pCS->IsRSoP())
  482. {
  483. fImport = InsGetBool(IS_CONNECTSET, IK_OPTION, FALSE, GetInsFile(hDlg));
  484. CheckRadioButton(hDlg, IDC_CSNOIMPORT, IDC_CSIMPORT, fImport ? IDC_CSIMPORT : IDC_CSNOIMPORT);
  485. EnableDlgItem2 (hDlg, IDC_MODIFYCONNECT, fImport);
  486. ReadBoolAndCheckButton(IS_CONNECTSET, IK_DELETECONN, FALSE, GetInsFile(hDlg), hDlg, IDC_DELCONNECT);
  487. }
  488. break;
  489. case PSN_HELP:
  490. ShowHelpTopic(hDlg);
  491. break;
  492. case PSN_APPLY:
  493. if (psCookie->pCS->IsRSoP())
  494. return FALSE;
  495. else
  496. {
  497. CNewCursor cur(IDC_WAIT);
  498. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\cs"), szWorkDir);
  499. fImport = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_CSIMPORT));
  500. if (!AcquireWriteCriticalSection(hDlg)) {
  501. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  502. break;
  503. }
  504. ImportConnectSet(GetInsFile(hDlg), szWorkDir, szWorkDir, fImport, IEM_GP);
  505. CheckButtonAndWriteBool(hDlg, IDC_DELCONNECT, IS_CONNECTSET, IK_DELETECONN, GetInsFile(hDlg));
  506. if (PathIsDirectoryEmpty(szWorkDir))
  507. PathRemovePath(szWorkDir);
  508. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  509. }
  510. break;
  511. default:
  512. return FALSE;
  513. }
  514. break;
  515. case WM_HELP:
  516. ShowHelpTopic(hDlg);
  517. break;
  518. default:
  519. return FALSE;
  520. }
  521. return TRUE;
  522. }
  523. /////////////////////////////////////////////////////////////////////
  524. INT_PTR CALLBACK AutoconfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  525. {
  526. // Retrieve Property Sheet Page info for each call into dlg proc.
  527. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  528. TCHAR szAutoConfigURL[INTERNET_MAX_URL_LENGTH],
  529. szAutoProxyURL[INTERNET_MAX_URL_LENGTH],
  530. szAutoConfigTime[7];
  531. BOOL fDetectConfig,
  532. fUseAutoConfig;
  533. switch (msg) {
  534. case WM_INITDIALOG:
  535. {
  536. SetPropSheetCookie(hDlg, lParam);
  537. // find out if this dlg is in RSoP mode
  538. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  539. BOOL bIsRSoP = psCookie->pCS->IsRSoP();
  540. if (bIsRSoP)
  541. {
  542. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  543. if (pDRD)
  544. InitAutoConfigDlgInRSoPMode(hDlg, pDRD);
  545. }
  546. else
  547. {
  548. // warn the user that settings on this page will override imported connection settings
  549. if (InsGetBool(IS_CONNECTSET, IK_OPTION, FALSE, GetInsFile(hDlg)))
  550. ErrorMessageBox(hDlg, IDS_CONNECTSET_WARN);
  551. DisableDBCSChars(hDlg, IDE_AUTOCONFIGTIME);
  552. }
  553. EnableDBCSChars(hDlg, IDE_AUTOCONFIGURL);
  554. EnableDBCSChars(hDlg, IDE_AUTOPROXYURL);
  555. if (!bIsRSoP)
  556. {
  557. Edit_LimitText(GetDlgItem(hDlg, IDE_AUTOCONFIGTIME), countof(szAutoConfigTime) - 1);
  558. Edit_LimitText(GetDlgItem(hDlg, IDE_AUTOCONFIGURL), countof(szAutoConfigURL) - 1);
  559. Edit_LimitText(GetDlgItem(hDlg, IDE_AUTOPROXYURL), countof(szAutoProxyURL) - 1);
  560. }
  561. break;
  562. }
  563. case WM_DESTROY:
  564. if (psCookie->pCS->IsRSoP())
  565. DestroyDlgRSoPData(hDlg);
  566. break;
  567. case WM_COMMAND:
  568. if (BN_CLICKED != GET_WM_COMMAND_CMD(wParam, lParam))
  569. return FALSE;
  570. switch(GET_WM_COMMAND_ID(wParam, lParam)) {
  571. case IDC_YESAUTOCON:
  572. fUseAutoConfig = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_YESAUTOCON));
  573. EnableDlgItem2(hDlg, IDE_AUTOCONFIGTIME, fUseAutoConfig);
  574. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT2, fUseAutoConfig);
  575. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT3, fUseAutoConfig);
  576. EnableDlgItem2(hDlg, IDE_AUTOCONFIGURL, fUseAutoConfig);
  577. EnableDlgItem2(hDlg, IDC_AUTOCONFIGURL_TXT, fUseAutoConfig);
  578. EnableDlgItem2(hDlg, IDE_AUTOPROXYURL, fUseAutoConfig);
  579. EnableDlgItem2(hDlg, IDC_AUTOPROXYURL_TXT, fUseAutoConfig);
  580. break;
  581. default:
  582. return FALSE;
  583. }
  584. break;
  585. case WM_NOTIFY:
  586. switch (((LPNMHDR)lParam)->code) {
  587. case PSN_SETACTIVE:
  588. // don't do any of this stuff in RSoP mode
  589. if (!psCookie->pCS->IsRSoP())
  590. {
  591. fDetectConfig = InsGetBool(IS_URL, IK_DETECTCONFIG, TRUE, GetInsFile(hDlg));
  592. CheckDlgButton(hDlg, IDC_AUTODETECT, fDetectConfig ? BST_CHECKED : BST_UNCHECKED);
  593. fUseAutoConfig = InsGetBool(IS_URL, IK_USEAUTOCONF, FALSE, GetInsFile(hDlg));
  594. CheckDlgButton(hDlg, IDC_YESAUTOCON, fUseAutoConfig ? BST_CHECKED : BST_UNCHECKED);
  595. InsGetString(IS_URL, IK_AUTOCONFTIME, szAutoConfigTime, countof(szAutoConfigTime), GetInsFile(hDlg));
  596. SetDlgItemText(hDlg, IDE_AUTOCONFIGTIME, szAutoConfigTime);
  597. EnableDlgItem2(hDlg, IDE_AUTOCONFIGTIME, fUseAutoConfig);
  598. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT2, fUseAutoConfig);
  599. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT3, fUseAutoConfig);
  600. InsGetString(IS_URL, IK_AUTOCONFURL, szAutoConfigURL, countof(szAutoConfigURL), GetInsFile(hDlg));
  601. SetDlgItemText(hDlg, IDE_AUTOCONFIGURL, szAutoConfigURL);
  602. EnableDlgItem2(hDlg, IDE_AUTOCONFIGURL, fUseAutoConfig);
  603. EnableDlgItem2(hDlg, IDC_AUTOCONFIGURL_TXT, fUseAutoConfig);
  604. InsGetString(IS_URL, IK_AUTOCONFURLJS, szAutoProxyURL, countof(szAutoProxyURL), GetInsFile(hDlg));
  605. SetDlgItemText(hDlg, IDE_AUTOPROXYURL, szAutoProxyURL);
  606. EnableDlgItem2(hDlg, IDE_AUTOPROXYURL, fUseAutoConfig);
  607. EnableDlgItem2(hDlg, IDC_AUTOPROXYURL_TXT, fUseAutoConfig);
  608. }
  609. break;
  610. case PSN_HELP:
  611. ShowHelpTopic(hDlg);
  612. break;
  613. case PSN_APPLY:
  614. if (psCookie->pCS->IsRSoP())
  615. return FALSE;
  616. else
  617. {
  618. fDetectConfig = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_AUTODETECT));
  619. fUseAutoConfig = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_YESAUTOCON));
  620. GetDlgItemText(hDlg, IDE_AUTOCONFIGTIME, szAutoConfigTime, countof(szAutoConfigTime));
  621. GetDlgItemText(hDlg, IDE_AUTOCONFIGURL, szAutoConfigURL, countof(szAutoConfigURL));
  622. GetDlgItemText(hDlg, IDE_AUTOPROXYURL, szAutoProxyURL, countof(szAutoProxyURL));
  623. // do error checking
  624. if (fUseAutoConfig) {
  625. if (IsWindowEnabled(GetDlgItem(hDlg, IDE_AUTOCONFIGTIME)) &&
  626. !CheckField(hDlg, IDE_AUTOCONFIGTIME, FC_NUMBER)) {
  627. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  628. return TRUE;
  629. }
  630. if (*szAutoConfigURL == TEXT('\0') && *szAutoProxyURL == TEXT('\0')) {
  631. ErrorMessageBox(hDlg, IDS_AUTOCONFIG_NULL);
  632. SetFocus(GetDlgItem(hDlg, IDE_AUTOCONFIGURL));
  633. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  634. return TRUE;
  635. }
  636. if (!CheckField(hDlg, IDE_AUTOCONFIGURL, FC_URL) ||
  637. !CheckField(hDlg, IDE_AUTOPROXYURL, FC_URL)) {
  638. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  639. return TRUE;
  640. }
  641. }
  642. // write the values to the ins file
  643. if (!AcquireWriteCriticalSection(hDlg)) {
  644. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  645. break;
  646. }
  647. InsWriteBoolEx(IS_URL, IK_DETECTCONFIG, fDetectConfig, GetInsFile(hDlg));
  648. InsWriteBoolEx(IS_URL, IK_USEAUTOCONF, fUseAutoConfig, GetInsFile(hDlg));
  649. InsWriteString(IS_URL, IK_AUTOCONFTIME, szAutoConfigTime, GetInsFile(hDlg));
  650. InsWriteString(IS_URL, IK_AUTOCONFURL, szAutoConfigURL, GetInsFile(hDlg));
  651. InsWriteString(IS_URL, IK_AUTOCONFURLJS, szAutoProxyURL, GetInsFile(hDlg));
  652. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  653. }
  654. break;
  655. default:
  656. return FALSE;
  657. }
  658. break;
  659. case WM_HELP:
  660. ShowHelpTopic(hDlg);
  661. break;
  662. default:
  663. return FALSE;
  664. }
  665. return TRUE;
  666. }
  667. /////////////////////////////////////////////////////////////////////
  668. INT_PTR CALLBACK ProxyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  669. {
  670. // Retrieve Property Sheet Page info for each call into dlg proc.
  671. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  672. TCHAR szProxy[MAX_PATH];
  673. PTSTR pszLocal;
  674. BOOL fSameProxy,
  675. fUseProxy,
  676. fLocal;
  677. switch (msg) {
  678. case WM_INITDIALOG:
  679. {
  680. SetPropSheetCookie(hDlg, lParam);
  681. // find out if this dlg is in RSoP mode
  682. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  683. BOOL bIsRSoP = psCookie->pCS->IsRSoP();
  684. if (bIsRSoP)
  685. {
  686. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  687. if (pDRD)
  688. InitProxyDlgInRSoPMode(hDlg, pDRD);
  689. }
  690. else
  691. {
  692. // warn the user that settings on this page will override imported connection settings
  693. if (InsGetBool(IS_CONNECTSET, IK_OPTION, FALSE, GetInsFile(hDlg)))
  694. ErrorMessageBox(hDlg, IDS_CONNECTSET_WARN);
  695. }
  696. EnableDBCSChars(hDlg, IDE_HTTPPROXY);
  697. EnableDBCSChars(hDlg, IDE_SECPROXY);
  698. EnableDBCSChars(hDlg, IDE_FTPPROXY);
  699. EnableDBCSChars(hDlg, IDE_GOPHERPROXY);
  700. EnableDBCSChars(hDlg, IDE_SOCKSPROXY);
  701. EnableDBCSChars(hDlg, IDE_DISPROXYADR);
  702. if (!bIsRSoP)
  703. {
  704. Edit_LimitText(GetDlgItem(hDlg, IDE_HTTPPORT), 5);
  705. Edit_LimitText(GetDlgItem(hDlg, IDE_FTPPORT), 5);
  706. Edit_LimitText(GetDlgItem(hDlg, IDE_GOPHERPORT), 5);
  707. Edit_LimitText(GetDlgItem(hDlg, IDE_SECPORT), 5);
  708. Edit_LimitText(GetDlgItem(hDlg, IDE_SOCKSPORT), 5);
  709. Edit_LimitText(GetDlgItem(hDlg, IDE_DISPROXYADR),(MAX_PATH - 11)); //size of <local>, etc
  710. }
  711. break;
  712. }
  713. case WM_DESTROY:
  714. if (psCookie->pCS->IsRSoP())
  715. DestroyDlgRSoPData(hDlg);
  716. break;
  717. case WM_COMMAND:
  718. fSameProxy = fUseProxy = fLocal = FALSE;
  719. if (BN_CLICKED == GET_WM_COMMAND_CMD(wParam, lParam)) {
  720. fSameProxy = IsDlgButtonChecked(hDlg, IDC_SAMEFORALL);
  721. fUseProxy = IsDlgButtonChecked(hDlg, IDC_YESPROXY);
  722. fLocal = IsDlgButtonChecked(hDlg, IDC_DISPROXYLOCAL);
  723. }
  724. switch (GET_WM_COMMAND_ID(wParam, lParam)) {
  725. case IDC_SAMEFORALL:
  726. if (BN_CLICKED != GET_WM_COMMAND_CMD(wParam, lParam))
  727. return FALSE;
  728. GetProxyDlg(hDlg, szProxy, IDE_HTTPPROXY, IDE_HTTPPORT);
  729. if (fSameProxy) {
  730. SetProxyDlg(hDlg, szProxy, IDE_HTTPPROXY, IDE_HTTPPORT, TRUE);
  731. SetProxyDlg(hDlg, szProxy, IDE_FTPPROXY, IDE_FTPPORT, TRUE);
  732. SetProxyDlg(hDlg, szProxy, IDE_GOPHERPROXY, IDE_GOPHERPORT, TRUE);
  733. SetProxyDlg(hDlg, szProxy, IDE_SECPROXY, IDE_SECPORT, TRUE);
  734. SetProxyDlg(hDlg, szProxy, IDE_SOCKSPROXY, IDE_SOCKSPORT, FALSE);
  735. }
  736. // fallthrough
  737. case IDC_YESPROXY:
  738. if (BN_CLICKED != GET_WM_COMMAND_CMD(wParam, lParam))
  739. return FALSE;
  740. pxyEnableDlgItems(hDlg, fSameProxy, fUseProxy);
  741. break;
  742. case IDE_HTTPPROXY:
  743. case IDE_HTTPPORT:
  744. if (EN_UPDATE != GET_WM_COMMAND_CMD(wParam, lParam))
  745. return FALSE;
  746. if (fSameProxy) {
  747. GetProxyDlg(hDlg, szProxy, IDE_HTTPPROXY, IDE_HTTPPORT);
  748. SetProxyDlg(hDlg, szProxy, IDE_FTPPROXY, IDE_FTPPORT, TRUE);
  749. SetProxyDlg(hDlg, szProxy, IDE_GOPHERPROXY, IDE_GOPHERPORT, TRUE);
  750. SetProxyDlg(hDlg, szProxy, IDE_SECPROXY, IDE_SECPORT, TRUE);
  751. SetProxyDlg(hDlg, szProxy, IDE_SOCKSPROXY, IDE_SOCKSPORT, FALSE);
  752. }
  753. break;
  754. default:
  755. return FALSE;
  756. }
  757. break;
  758. case WM_NOTIFY:
  759. switch (((LPNMHDR)lParam)->code) {
  760. case PSN_SETACTIVE:
  761. // don't do any of this stuff in RSoP mode
  762. if (!psCookie->pCS->IsRSoP())
  763. {
  764. fUseProxy = InsGetBool(IS_PROXY, IK_PROXYENABLE, FALSE, GetInsFile(hDlg));
  765. CheckDlgButton(hDlg, IDC_YESPROXY, fUseProxy);
  766. fSameProxy = InsGetBool(IS_PROXY, IK_SAMEPROXY, TRUE, GetInsFile(hDlg));
  767. CheckDlgButton(hDlg, IDC_SAMEFORALL, fSameProxy);
  768. InsGetString(IS_PROXY, IK_HTTPPROXY, szProxy, countof(szProxy), GetInsFile(hDlg));
  769. if (fSameProxy) {
  770. SetProxyDlg(hDlg, szProxy, IDE_HTTPPROXY, IDE_HTTPPORT, TRUE);
  771. SetProxyDlg(hDlg, szProxy, IDE_FTPPROXY, IDE_FTPPORT, TRUE);
  772. SetProxyDlg(hDlg, szProxy, IDE_GOPHERPROXY, IDE_GOPHERPORT, TRUE);
  773. SetProxyDlg(hDlg, szProxy, IDE_SECPROXY, IDE_SECPORT, TRUE);
  774. SetProxyDlg(hDlg, szProxy, IDE_SOCKSPROXY, IDE_SOCKSPORT, FALSE);
  775. }
  776. else {
  777. SetProxyDlg(hDlg, szProxy, IDE_HTTPPROXY, IDE_HTTPPORT, TRUE);
  778. InsGetString(IS_PROXY, IK_FTPPROXY, szProxy, countof(szProxy), GetInsFile(hDlg));
  779. SetProxyDlg(hDlg, szProxy, IDE_FTPPROXY, IDE_FTPPORT, TRUE);
  780. InsGetString(IS_PROXY, IK_GOPHERPROXY, szProxy, countof(szProxy), GetInsFile(hDlg));
  781. SetProxyDlg(hDlg, szProxy, IDE_GOPHERPROXY, IDE_GOPHERPORT, TRUE);
  782. InsGetString(IS_PROXY, IK_SECPROXY, szProxy, countof(szProxy), GetInsFile(hDlg));
  783. SetProxyDlg(hDlg, szProxy, IDE_SECPROXY, IDE_SECPORT, TRUE);
  784. InsGetString(IS_PROXY, IK_SOCKSPROXY, szProxy, countof(szProxy), GetInsFile(hDlg));
  785. if (TEXT('\0') != szProxy[0])
  786. SetProxyDlg(hDlg, szProxy, IDE_SOCKSPROXY, IDE_SOCKSPORT, FALSE);
  787. }
  788. InsGetString(IS_PROXY, IK_PROXYOVERRIDE, szProxy, countof(szProxy), GetInsFile(hDlg));
  789. if (TEXT('\0') == szProxy[0])
  790. StrCpy(szProxy, LOCALPROXY);
  791. pszLocal = StrStr(szProxy, LOCALPROXY);
  792. fLocal = FALSE;
  793. if (NULL != pszLocal) {
  794. if (pszLocal == szProxy) {
  795. PTSTR pszSemicolon;
  796. pszSemicolon = pszLocal + countof(LOCALPROXY)-1;
  797. if (TEXT(';') == *pszSemicolon)
  798. pszSemicolon++;
  799. StrCpy(pszLocal, pszSemicolon);
  800. }
  801. else if (TEXT('\0') == *(pszLocal + countof(LOCALPROXY)-1))
  802. *(pszLocal - 1) = TEXT('\0');
  803. fLocal = TRUE;
  804. }
  805. CheckDlgButton(hDlg, IDC_DISPROXYLOCAL, fLocal);
  806. SetDlgItemText(hDlg, IDE_DISPROXYADR, szProxy);
  807. pxyEnableDlgItems(hDlg, fSameProxy, fUseProxy);
  808. }
  809. break;
  810. case PSN_HELP:
  811. ShowHelpTopic(hDlg);
  812. break;
  813. case PSN_APPLY:
  814. if (psCookie->pCS->IsRSoP())
  815. return FALSE;
  816. else
  817. {
  818. if (!CheckField(hDlg, IDE_HTTPPORT, FC_NUMBER) ||
  819. !CheckField(hDlg, IDE_FTPPORT, FC_NUMBER) ||
  820. !CheckField(hDlg, IDE_GOPHERPORT, FC_NUMBER) ||
  821. !CheckField(hDlg, IDE_SECPORT, FC_NUMBER) ||
  822. !CheckField(hDlg, IDE_SOCKSPORT, FC_NUMBER))
  823. return TRUE;
  824. fUseProxy = IsDlgButtonChecked(hDlg, IDC_YESPROXY);
  825. fSameProxy = IsDlgButtonChecked(hDlg, IDC_SAMEFORALL);
  826. fLocal = IsDlgButtonChecked(hDlg, IDC_DISPROXYLOCAL);
  827. if (!AcquireWriteCriticalSection(hDlg)) {
  828. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  829. break;
  830. }
  831. InsWriteBoolEx(IS_PROXY, IK_PROXYENABLE, fUseProxy, GetInsFile(hDlg));
  832. GetProxyDlg(hDlg, szProxy, IDE_HTTPPROXY, IDE_HTTPPORT);
  833. InsWriteString(IS_PROXY, IK_HTTPPROXY, szProxy, GetInsFile(hDlg));
  834. GetProxyDlg(hDlg, szProxy, IDE_FTPPROXY, IDE_FTPPORT);
  835. InsWriteString(IS_PROXY, IK_FTPPROXY, szProxy, GetInsFile(hDlg));
  836. GetProxyDlg(hDlg, szProxy, IDE_GOPHERPROXY, IDE_GOPHERPORT);
  837. InsWriteString(IS_PROXY, IK_GOPHERPROXY, szProxy, GetInsFile(hDlg));
  838. GetProxyDlg(hDlg, szProxy, IDE_SECPROXY, IDE_SECPORT);
  839. InsWriteString(IS_PROXY, IK_SECPROXY, szProxy, GetInsFile(hDlg));
  840. GetProxyDlg(hDlg, szProxy, IDE_SOCKSPROXY, IDE_SOCKSPORT);
  841. InsWriteString(IS_PROXY, IK_SOCKSPROXY, szProxy, GetInsFile(hDlg));
  842. InsWriteBoolEx(IS_PROXY, IK_SAMEPROXY, fSameProxy, GetInsFile(hDlg));
  843. GetDlgItemText(hDlg, IDE_DISPROXYADR, szProxy, countof(szProxy));
  844. if (fLocal) {
  845. if (TEXT('\0') != szProxy[0]) {
  846. TCHAR szAux[MAX_PATH];
  847. StrRemoveAllWhiteSpace(szProxy);
  848. wnsprintf(szAux, countof(szAux), TEXT("%s;%s"), szProxy, LOCALPROXY);
  849. InsWriteQuotedString(IS_PROXY, IK_PROXYOVERRIDE, szAux, GetInsFile(hDlg));
  850. }
  851. else
  852. InsWriteString(IS_PROXY, IK_PROXYOVERRIDE, LOCALPROXY, GetInsFile(hDlg));
  853. }
  854. else
  855. InsWriteString(IS_PROXY, IK_PROXYOVERRIDE, szProxy, GetInsFile(hDlg));
  856. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  857. }
  858. break;
  859. default:
  860. return FALSE;
  861. }
  862. break;
  863. case WM_HELP:
  864. ShowHelpTopic(hDlg);
  865. break;
  866. default:
  867. return FALSE;
  868. }
  869. return TRUE;
  870. }
  871. /////////////////////////////////////////////////////////////////////////////
  872. // Implementation helper routines
  873. static void pxyEnableDlgItems(HWND hDlg, BOOL fSame, BOOL fUseProxy)
  874. {
  875. EnableDlgItem2(hDlg, IDC_FTPPROXY1, !fSame && fUseProxy);
  876. EnableDlgItem2(hDlg, IDE_FTPPROXY, !fSame && fUseProxy);
  877. EnableDlgItem2(hDlg, IDE_FTPPORT, !fSame && fUseProxy);
  878. EnableDlgItem2(hDlg, IDC_SECPROXY1, !fSame && fUseProxy);
  879. EnableDlgItem2(hDlg, IDE_SECPROXY, !fSame && fUseProxy);
  880. EnableDlgItem2(hDlg, IDE_SECPORT, !fSame && fUseProxy);
  881. EnableDlgItem2(hDlg, IDC_GOPHERPROXY1, !fSame && fUseProxy);
  882. EnableDlgItem2(hDlg, IDE_GOPHERPROXY, !fSame && fUseProxy);
  883. EnableDlgItem2(hDlg, IDE_GOPHERPORT, !fSame && fUseProxy);
  884. EnableDlgItem2(hDlg, IDC_SOCKSPROXY1, !fSame && fUseProxy);
  885. EnableDlgItem2(hDlg, IDE_SOCKSPROXY, !fSame && fUseProxy);
  886. EnableDlgItem2(hDlg, IDE_SOCKSPORT, !fSame && fUseProxy);
  887. EnableDlgItem2(hDlg, IDC_HTTPPROXY1, fUseProxy);
  888. EnableDlgItem2(hDlg, IDE_HTTPPROXY, fUseProxy);
  889. EnableDlgItem2(hDlg, IDE_HTTPPORT, fUseProxy);
  890. EnableDlgItem2(hDlg, IDC_DISPROXYADR1, fUseProxy);
  891. EnableDlgItem2(hDlg, IDE_DISPROXYADR, fUseProxy);
  892. EnableDlgItem2(hDlg, IDC_DISPROXYLOCAL, fUseProxy);
  893. EnableDlgItem2(hDlg, IDC_SAMEFORALL, fUseProxy);
  894. }
  895. //*******************************************************************
  896. // CODE FROM INETCPL
  897. //*******************************************************************
  898. /////////////////////////////////////////////////////////////////////
  899. void InitImportedConnSettingsDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  900. {
  901. __try
  902. {
  903. if (NULL != pDRD->ConnectToNamespace())
  904. {
  905. // get our stored precedence value
  906. DWORD dwCurGPOPrec = pDRD->GetImportedConnSettPrec();
  907. // create the object path of the program settings for this GPO
  908. WCHAR wszObjPath[128];
  909. wnsprintf(wszObjPath, countof(wszObjPath),
  910. L"RSOP_IEConnectionSettings.rsopID=\"IEAK\",rsopPrecedence=%ld", dwCurGPOPrec);
  911. _bstr_t bstrObjPath = wszObjPath;
  912. // get the RSOP_IEProgramSettings object and its properties
  913. ComPtr<IWbemServices> pWbemServices = pDRD->GetWbemServices();
  914. ComPtr<IWbemClassObject> pPSObj = NULL;
  915. HRESULT hr = pWbemServices->GetObject(bstrObjPath, 0L, NULL, (IWbemClassObject**)&pPSObj, NULL);
  916. if (SUCCEEDED(hr))
  917. {
  918. // defaultDialUpConnection field
  919. _variant_t vtValue;
  920. _bstr_t bstrDefault;
  921. hr = pPSObj->Get(L"defaultDialUpConnection", 0, &vtValue, NULL, NULL);
  922. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  923. {
  924. bstrDefault = vtValue;
  925. if (bstrDefault.length() > 0)
  926. SetDlgItemText(hDlg, IDC_DIAL_DEF_ISP, (LPCTSTR)bstrDefault);
  927. }
  928. // dialUpState field
  929. hr = pPSObj->Get(L"dialUpState", 0, &vtValue, NULL, NULL);
  930. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  931. {
  932. if (1 == (long)vtValue)
  933. CheckRadioButton(hDlg, IDC_DIALUP_NEVER, IDC_DIALUP, IDC_DIALUP_ON_NONET);
  934. else if (2 == (long)vtValue)
  935. CheckRadioButton(hDlg, IDC_DIALUP_NEVER, IDC_DIALUP, IDC_DIALUP);
  936. else
  937. CheckRadioButton(hDlg, IDC_DIALUP_NEVER, IDC_DIALUP, IDC_DIALUP_NEVER);
  938. }
  939. // dialUpConnections field
  940. hr = pPSObj->Get(L"dialUpConnections", 0, &vtValue, NULL, NULL);
  941. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  942. {
  943. HWND hwndTree = GetDlgItem(hDlg, IDC_CONN_LIST);
  944. ASSERT(hwndTree);
  945. // init tvi and tvins
  946. TVITEM tvi;
  947. TVINSERTSTRUCT tvins;
  948. tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
  949. tvi.lParam = 0;
  950. tvins.hInsertAfter = (HTREEITEM)TVI_SORT;
  951. tvins.hParent = TVI_ROOT;
  952. // clear list
  953. TreeView_DeleteAllItems(hwndTree);
  954. SAFEARRAY *psa = vtValue.parray;
  955. //-------------------------------
  956. // Get the upper and lower bounds of the Names array
  957. long lLower = 0;
  958. long lUpper = 0;
  959. hr = SafeArrayGetLBound(psa, 1, &lLower);
  960. if (SUCCEEDED(hr))
  961. hr = SafeArrayGetUBound(psa, 1, &lUpper);
  962. // check the case of no instances or a null array
  963. if (SUCCEEDED(hr) && lUpper >= lLower)
  964. {
  965. _bstr_t bstrName;
  966. HTREEITEM hFirst = NULL, hDefault = NULL;
  967. for (long lItem = lLower; lItem <= lUpper; lItem++)
  968. {
  969. BSTR bstrValue = NULL;
  970. hr = SafeArrayGetElement(psa, &lItem, (void*)&bstrValue);
  971. if (SUCCEEDED(hr))
  972. {
  973. bstrName = bstrValue;
  974. tvi.pszText = (LPTSTR)(LPCTSTR)bstrName;
  975. tvi.iImage = IMAGE_MODEM;
  976. tvi.iSelectedImage = IMAGE_MODEM;
  977. tvi.lParam = lItem;
  978. tvins.item = tvi;
  979. HTREEITEM hItem = TreeView_InsertItem(hwndTree, &tvins);
  980. if (0 == lItem)
  981. hFirst = hItem;
  982. if (NULL != hItem && bstrName == bstrDefault)
  983. hDefault = hItem;
  984. }
  985. }
  986. // select default or first entry if there is one
  987. if(NULL != hDefault)
  988. TreeView_Select(hwndTree, hDefault, TVGN_CARET);
  989. else if (NULL != hFirst)
  990. TreeView_Select(hwndTree, hFirst, TVGN_CARET);
  991. }
  992. }
  993. }
  994. }
  995. }
  996. __except(TRUE)
  997. {
  998. }
  999. }
  1000. /////////////////////////////////////////////////////////////////////
  1001. INT_PTR CALLBACK importConnSettingsRSoPProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1002. {
  1003. BOOL fResult = FALSE;
  1004. switch (uMsg) {
  1005. case WM_INITDIALOG:
  1006. {
  1007. // create image list for tree view
  1008. HIMAGELIST himl = ImageList_Create(BITMAP_WIDTH, BITMAP_HEIGHT, ILC_COLOR | ILC_MASK, CONN_BITMAPS, 4 );
  1009. HICON hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_LAN));
  1010. ImageList_AddIcon(himl, hIcon);
  1011. hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_PHONE));
  1012. ImageList_AddIcon(himl, hIcon);
  1013. TreeView_SetImageList(GetDlgItem(hDlg, IDC_CONN_LIST), himl, TVSIL_NORMAL);
  1014. // init the data
  1015. CDlgRSoPData *pDRD = (CDlgRSoPData*)((LPPROPSHEETPAGE)lParam)->lParam;
  1016. InitImportedConnSettingsDlgInRSoPMode(hDlg, pDRD);
  1017. // init other controls
  1018. CheckRadioButton(hDlg, IDC_DIALUP_NEVER, IDC_DIALUP, IDC_DIALUP_NEVER);
  1019. ShowWindow(GetDlgItem(hDlg, IDC_ENABLE_SECURITY), SW_HIDE); // only for 95 machines
  1020. // disable everything
  1021. EnableDlgItem2(hDlg, IDC_CONNECTION_WIZARD, FALSE);
  1022. EnableDlgItem2(hDlg, IDC_DIALUP_ADD, FALSE);
  1023. EnableDlgItem2(hDlg, IDC_DIALUP_REMOVE, FALSE);
  1024. EnableDlgItem2(hDlg, IDC_MODEM_SETTINGS, FALSE);
  1025. EnableDlgItem2(hDlg, IDC_DIALUP_NEVER, FALSE);
  1026. EnableDlgItem2(hDlg, IDC_DIALUP_ON_NONET, FALSE);
  1027. EnableDlgItem2(hDlg, IDC_DIALUP, FALSE);
  1028. EnableDlgItem2(hDlg, IDC_SET_DEFAULT, FALSE);
  1029. EnableDlgItem2(hDlg, IDC_ENABLE_SECURITY, FALSE);
  1030. EnableDlgItem2(hDlg, IDC_CON_SHARING, FALSE);
  1031. EnableDlgItem2(hDlg, IDC_LAN_SETTINGS, FALSE);
  1032. fResult = TRUE;
  1033. break;
  1034. }
  1035. case WM_COMMAND:
  1036. switch (LOWORD(wParam)) {
  1037. case IDOK:
  1038. EndDialog(hDlg, IDOK);
  1039. fResult = TRUE;
  1040. break;
  1041. case IDCANCEL:
  1042. EndDialog(hDlg, IDCANCEL);
  1043. fResult = TRUE;
  1044. break;
  1045. }
  1046. break;
  1047. }
  1048. return fResult;
  1049. }