Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

672 lines
19 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // ieproxy.c
  8. //
  9. // Description:
  10. // This file contains the dialog procedures for the IE proxy and advanced
  11. // proxy settings pop-ups.
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "pch.h"
  15. #include "resource.h"
  16. //----------------------------------------------------------------------------
  17. //
  18. // Function: OnUseSameProxyCheckBox
  19. //
  20. // Purpose:
  21. //
  22. // Arguments: IN HWND hwnd - handle to the dialog box
  23. //
  24. // Returns: VOID
  25. //
  26. //----------------------------------------------------------------------------
  27. static VOID
  28. OnUseSameProxyCheckBox( IN HWND hwnd )
  29. {
  30. TCHAR szAddressBuffer[MAX_PROXY_LEN + 1];
  31. TCHAR szPortBuffer[MAX_PROXY_PORT_LEN + 1];
  32. BOOL bUseSameProxy = IsDlgButtonChecked( hwnd, IDC_CB_USE_SAME_PROXY );
  33. EnableWindow( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY ), ! bUseSameProxy );
  34. EnableWindow( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY_PORT ), ! bUseSameProxy );
  35. EnableWindow( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY ), ! bUseSameProxy );
  36. EnableWindow( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY_PORT ), ! bUseSameProxy );
  37. EnableWindow( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY ), ! bUseSameProxy );
  38. EnableWindow( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY_PORT ), ! bUseSameProxy );
  39. EnableWindow( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY ), ! bUseSameProxy );
  40. EnableWindow( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY_PORT ), ! bUseSameProxy );
  41. //
  42. // Copy the HTTP proxy address to all the other proxy server edit boxes.
  43. //
  44. if( bUseSameProxy )
  45. {
  46. GetWindowText( GetDlgItem( hwnd, IDC_EDT_HTTP_PROXY ),
  47. szAddressBuffer,
  48. MAX_PROXY_LEN + 1 );
  49. GetWindowText( GetDlgItem( hwnd, IDC_EDT_HTTP_PROXY_PORT ),
  50. szPortBuffer,
  51. MAX_PROXY_PORT_LEN + 1 );
  52. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY ), szAddressBuffer );
  53. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY_PORT ), szPortBuffer );
  54. SetWindowText( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY ), szAddressBuffer );
  55. SetWindowText( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY_PORT ), szPortBuffer );
  56. SetWindowText( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY ), szAddressBuffer );
  57. SetWindowText( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY_PORT ), szPortBuffer );
  58. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY ), szAddressBuffer );
  59. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY_PORT ), szPortBuffer );
  60. }
  61. }
  62. //----------------------------------------------------------------------------
  63. //
  64. // Function: OnInitAdvancedProxySettingsDialog
  65. //
  66. // Purpose:
  67. //
  68. // Arguments: IN HWND hwnd - handle to the dialog box
  69. //
  70. // Returns: VOID
  71. //
  72. //----------------------------------------------------------------------------
  73. static VOID
  74. OnInitAdvancedProxySettingsDialog( IN HWND hwnd )
  75. {
  76. //
  77. // Set the text limit on the edit boxes
  78. //
  79. SendDlgItemMessage( hwnd,
  80. IDC_EDT_HTTP_PROXY,
  81. EM_LIMITTEXT,
  82. (WPARAM) MAX_PROXY_LEN,
  83. (LPARAM) 0 );
  84. SendDlgItemMessage( hwnd,
  85. IDC_EDT_HTTP_PROXY_PORT,
  86. EM_LIMITTEXT,
  87. (WPARAM) MAX_PROXY_PORT_LEN,
  88. (LPARAM) 0 );
  89. SendDlgItemMessage( hwnd,
  90. IDC_EDT_SECURE_PROXY,
  91. EM_LIMITTEXT,
  92. (WPARAM) MAX_PROXY_LEN,
  93. (LPARAM) 0 );
  94. SendDlgItemMessage( hwnd,
  95. IDC_EDT_SECURE_PROXY_PORT,
  96. EM_LIMITTEXT,
  97. (WPARAM) MAX_PROXY_PORT_LEN,
  98. (LPARAM) 0 );
  99. SendDlgItemMessage( hwnd,
  100. IDC_EDT_FTP_PROXY,
  101. EM_LIMITTEXT,
  102. (WPARAM) MAX_PROXY_LEN,
  103. (LPARAM) 0 );
  104. SendDlgItemMessage( hwnd,
  105. IDC_EDT_FTP_PROXY_PORT,
  106. EM_LIMITTEXT,
  107. (WPARAM) MAX_PROXY_PORT_LEN,
  108. (LPARAM) 0 );
  109. SendDlgItemMessage( hwnd,
  110. IDC_EDT_GOPHER_PROXY,
  111. EM_LIMITTEXT,
  112. (WPARAM) MAX_PROXY_LEN,
  113. (LPARAM) 0 );
  114. SendDlgItemMessage( hwnd,
  115. IDC_EDT_GOPHER_PROXY_PORT,
  116. EM_LIMITTEXT,
  117. (WPARAM) MAX_PROXY_PORT_LEN,
  118. (LPARAM) 0 );
  119. SendDlgItemMessage( hwnd,
  120. IDC_EDT_SOCKS_PROXY,
  121. EM_LIMITTEXT,
  122. (WPARAM) MAX_PROXY_LEN,
  123. (LPARAM) 0 );
  124. SendDlgItemMessage( hwnd,
  125. IDC_EDT_SOCKS_PROXY_PORT,
  126. EM_LIMITTEXT,
  127. (WPARAM) MAX_PROXY_PORT_LEN,
  128. (LPARAM) 0 );
  129. SendDlgItemMessage( hwnd,
  130. IDC_EB_EXCEPTIONS,
  131. EM_LIMITTEXT,
  132. (WPARAM) MAX_EXCEPTION_LEN,
  133. (LPARAM) 0 );
  134. //
  135. // Set the initial values
  136. //
  137. if( GenSettings.bUseSameProxyForAllProtocols )
  138. {
  139. CheckDlgButton( hwnd, IDC_CB_USE_SAME_PROXY, BST_CHECKED );
  140. }
  141. else
  142. {
  143. CheckDlgButton( hwnd, IDC_CB_USE_SAME_PROXY, BST_UNCHECKED );
  144. }
  145. SetWindowText( GetDlgItem( hwnd, IDC_EDT_HTTP_PROXY ),
  146. GenSettings.szHttpProxyAddress );
  147. SetWindowText( GetDlgItem( hwnd, IDC_EDT_HTTP_PROXY_PORT ),
  148. GenSettings.szHttpProxyPort );
  149. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY ),
  150. GenSettings.szSecureProxyAddress );
  151. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY_PORT ),
  152. GenSettings.szSecureProxyPort );
  153. SetWindowText( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY ),
  154. GenSettings.szFtpProxyAddress );
  155. SetWindowText( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY_PORT ),
  156. GenSettings.szFtpProxyPort );
  157. SetWindowText( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY ),
  158. GenSettings.szGopherProxyAddress );
  159. SetWindowText( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY_PORT ),
  160. GenSettings.szGopherProxyPort );
  161. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY ),
  162. GenSettings.szSocksProxyAddress );
  163. SetWindowText( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY_PORT ),
  164. GenSettings.szSocksProxyPort );
  165. SetWindowText( GetDlgItem( hwnd, IDC_EB_EXCEPTIONS ),
  166. GenSettings.szProxyExceptions );
  167. //
  168. // Grey/Ungrey the page appropriately
  169. //
  170. OnUseSameProxyCheckBox( hwnd );
  171. }
  172. //----------------------------------------------------------------------------
  173. //
  174. // Function: StoreAdvancedProxySettings
  175. //
  176. // Purpose:
  177. //
  178. // Arguments: IN HWND hwnd - handle to the dialog box
  179. //
  180. // Returns: VOID
  181. //
  182. //----------------------------------------------------------------------------
  183. static VOID
  184. StoreAdvancedProxySettings( IN HWND hwnd )
  185. {
  186. GenSettings.bUseSameProxyForAllProtocols = IsDlgButtonChecked( hwnd, IDC_CB_USE_SAME_PROXY );
  187. GetWindowText( GetDlgItem( hwnd, IDC_EDT_HTTP_PROXY ),
  188. GenSettings.szHttpProxyAddress,
  189. MAX_PROXY_LEN + 1 );
  190. GetWindowText( GetDlgItem( hwnd, IDC_EDT_HTTP_PROXY_PORT ),
  191. GenSettings.szHttpProxyPort,
  192. MAX_PROXY_PORT_LEN + 1 );
  193. GetWindowText( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY ),
  194. GenSettings.szSecureProxyAddress,
  195. MAX_PROXY_LEN + 1 );
  196. GetWindowText( GetDlgItem( hwnd, IDC_EDT_SECURE_PROXY_PORT ),
  197. GenSettings.szSecureProxyPort,
  198. MAX_PROXY_PORT_LEN + 1 );
  199. GetWindowText( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY ),
  200. GenSettings.szFtpProxyAddress,
  201. MAX_PROXY_LEN + 1 );
  202. GetWindowText( GetDlgItem( hwnd, IDC_EDT_FTP_PROXY_PORT ),
  203. GenSettings.szFtpProxyPort,
  204. MAX_PROXY_PORT_LEN + 1 );
  205. GetWindowText( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY ),
  206. GenSettings.szGopherProxyAddress,
  207. MAX_PROXY_LEN + 1 );
  208. GetWindowText( GetDlgItem( hwnd, IDC_EDT_GOPHER_PROXY_PORT ),
  209. GenSettings.szGopherProxyPort,
  210. MAX_PROXY_PORT_LEN + 1 );
  211. GetWindowText( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY ),
  212. GenSettings.szSocksProxyAddress,
  213. MAX_PROXY_LEN + 1 );
  214. GetWindowText( GetDlgItem( hwnd, IDC_EDT_SOCKS_PROXY_PORT ),
  215. GenSettings.szSocksProxyPort,
  216. MAX_PROXY_PORT_LEN + 1 );
  217. GetWindowText( GetDlgItem( hwnd, IDC_EB_EXCEPTIONS ),
  218. GenSettings.szProxyExceptions,
  219. MAX_EXCEPTION_LEN + 1 );
  220. }
  221. //----------------------------------------------------------------------------
  222. //
  223. // Function: AdvancedProxySettingsDlg
  224. //
  225. // Purpose:
  226. //
  227. // Arguments: standard Win32 dialog proc arguments
  228. //
  229. // Returns: standard Win32 dialog proc return value -- whether the message
  230. // was handled or not
  231. //
  232. //----------------------------------------------------------------------------
  233. INT_PTR CALLBACK AdvancedProxySettingsDlg(
  234. IN HWND hwnd,
  235. IN UINT uMsg,
  236. IN WPARAM wParam,
  237. IN LPARAM lParam )
  238. {
  239. BOOL bStatus = TRUE;
  240. switch( uMsg )
  241. {
  242. case WM_INITDIALOG:
  243. OnInitAdvancedProxySettingsDialog( hwnd );
  244. break;
  245. case WM_COMMAND:
  246. {
  247. int nButtonId;
  248. switch ( nButtonId = LOWORD(wParam) )
  249. {
  250. case IDOK:
  251. if( HIWORD( wParam ) == BN_CLICKED )
  252. {
  253. StoreAdvancedProxySettings( hwnd );
  254. EndDialog( hwnd, TRUE );
  255. }
  256. break;
  257. case IDCANCEL:
  258. if( HIWORD( wParam ) == BN_CLICKED )
  259. {
  260. EndDialog( hwnd, FALSE );
  261. }
  262. break;
  263. case IDC_CB_USE_SAME_PROXY:
  264. if( HIWORD( wParam ) == BN_CLICKED )
  265. {
  266. OnUseSameProxyCheckBox( hwnd );
  267. }
  268. break;
  269. default:
  270. bStatus = FALSE;
  271. break;
  272. }
  273. }
  274. break;
  275. default:
  276. bStatus = FALSE;
  277. break;
  278. }
  279. return( bStatus );
  280. }
  281. //----------------------------------------------------------------------------
  282. //
  283. // Function: GreyProxyPage
  284. //
  285. // Purpose:
  286. //
  287. // Arguments: IN HWND hwnd - handle to the dialog box
  288. //
  289. // Returns: VOID
  290. //
  291. //----------------------------------------------------------------------------
  292. static VOID
  293. GreyProxyPage( IN HWND hwnd )
  294. {
  295. BOOL bUseProxy = IsDlgButtonChecked( hwnd, IDC_CB_USE_PROXY );
  296. if( bUseProxy )
  297. {
  298. EnableWindow( GetDlgItem( hwnd, IDC_ADDRESS_TEXT ),
  299. GenSettings.bUseSameProxyForAllProtocols );
  300. EnableWindow( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  301. GenSettings.bUseSameProxyForAllProtocols );
  302. EnableWindow( GetDlgItem( hwnd, IDC_PORT_TEXT ),
  303. GenSettings.bUseSameProxyForAllProtocols );
  304. EnableWindow( GetDlgItem( hwnd, IDC_EB_PORT ),
  305. GenSettings.bUseSameProxyForAllProtocols );
  306. }
  307. else
  308. {
  309. EnableWindow( GetDlgItem( hwnd, IDC_ADDRESS_TEXT ),
  310. FALSE );
  311. EnableWindow( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  312. FALSE );
  313. EnableWindow( GetDlgItem( hwnd, IDC_PORT_TEXT ),
  314. FALSE );
  315. EnableWindow( GetDlgItem( hwnd, IDC_EB_PORT ),
  316. FALSE );
  317. }
  318. EnableWindow( GetDlgItem( hwnd, IDC_CB_LOCAL_BYPASS_PROXY ),
  319. bUseProxy );
  320. EnableWindow( GetDlgItem( hwnd, IDC_BUT_ADVANCED ),
  321. bUseProxy );
  322. }
  323. //----------------------------------------------------------------------------
  324. //
  325. // Function: GreyProxyPage
  326. //
  327. // Purpose:
  328. //
  329. // Arguments: IN HWND hwnd - handle to the dialog box
  330. //
  331. // Returns: VOID
  332. //
  333. //----------------------------------------------------------------------------
  334. static VOID
  335. FillProxyBoxes( IN HWND hwnd )
  336. {
  337. if( GenSettings.bUseSameProxyForAllProtocols )
  338. {
  339. SetWindowText( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  340. GenSettings.szHttpProxyAddress );
  341. SetWindowText( GetDlgItem( hwnd, IDC_EB_PORT ),
  342. GenSettings.szHttpProxyPort );
  343. }
  344. else
  345. {
  346. SetWindowText( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  347. _T("") );
  348. SetWindowText( GetDlgItem( hwnd, IDC_EB_PORT ),
  349. _T("") );
  350. }
  351. }
  352. //----------------------------------------------------------------------------
  353. //
  354. // Function: OnInitProxySettingsDialog
  355. //
  356. // Purpose:
  357. //
  358. // Arguments: IN HWND hwnd - handle to the dialog box
  359. //
  360. // Returns: VOID
  361. //
  362. //----------------------------------------------------------------------------
  363. static VOID
  364. OnInitProxySettingsDialog( IN HWND hwnd )
  365. {
  366. //
  367. // Set the text limit on the edit boxes
  368. //
  369. SendDlgItemMessage( hwnd,
  370. IDC_EB_ADDRESS,
  371. EM_LIMITTEXT,
  372. (WPARAM) MAX_PROXY_LEN,
  373. (LPARAM) 0 );
  374. SendDlgItemMessage( hwnd,
  375. IDC_EB_PORT,
  376. EM_LIMITTEXT,
  377. (WPARAM) MAX_PROXY_PORT_LEN,
  378. (LPARAM) 0 );
  379. //
  380. // Set the initial values
  381. //
  382. if( GenSettings.bUseProxyServer )
  383. {
  384. CheckDlgButton( hwnd, IDC_CB_USE_PROXY, BST_CHECKED );
  385. if( GenSettings.bUseSameProxyForAllProtocols )
  386. {
  387. SetWindowText( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  388. GenSettings.szHttpProxyAddress );
  389. SetWindowText( GetDlgItem( hwnd, IDC_EB_PORT ),
  390. GenSettings.szHttpProxyPort );
  391. }
  392. else
  393. {
  394. SetWindowText( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  395. _T("") );
  396. SetWindowText( GetDlgItem( hwnd, IDC_EB_PORT ),
  397. _T("") );
  398. }
  399. }
  400. else
  401. {
  402. CheckDlgButton( hwnd, IDC_CB_USE_PROXY, BST_UNCHECKED );
  403. }
  404. if( GenSettings.bBypassProxyForLocalAddresses )
  405. {
  406. CheckDlgButton( hwnd, IDC_CB_LOCAL_BYPASS_PROXY, BST_CHECKED );
  407. }
  408. else
  409. {
  410. CheckDlgButton( hwnd, IDC_CB_LOCAL_BYPASS_PROXY, BST_UNCHECKED );
  411. }
  412. GreyProxyPage( hwnd );
  413. }
  414. //----------------------------------------------------------------------------
  415. //
  416. // Function: StoreProxySettings
  417. //
  418. // Purpose:
  419. //
  420. // Arguments: IN HWND hwnd - handle to the dialog box
  421. //
  422. // Returns: VOID
  423. //
  424. //----------------------------------------------------------------------------
  425. static VOID
  426. StoreProxySettings( IN HWND hwnd )
  427. {
  428. GenSettings.bUseProxyServer = IsDlgButtonChecked( hwnd, IDC_CB_USE_PROXY );
  429. if( GenSettings.bUseSameProxyForAllProtocols )
  430. {
  431. GetWindowText( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  432. GenSettings.szHttpProxyAddress,
  433. MAX_PROXY_LEN + 1 );
  434. GetWindowText( GetDlgItem( hwnd, IDC_EB_PORT ),
  435. GenSettings.szHttpProxyPort,
  436. MAX_PROXY_PORT_LEN + 1 );
  437. }
  438. GenSettings.bBypassProxyForLocalAddresses = IsDlgButtonChecked( hwnd, IDC_CB_LOCAL_BYPASS_PROXY );
  439. }
  440. //----------------------------------------------------------------------------
  441. //
  442. // Function: OnAdvancedProxyClicked
  443. //
  444. // Purpose:
  445. //
  446. // Arguments: IN HWND hwnd - handle to the dialog box
  447. //
  448. // Returns: VOID
  449. //
  450. //----------------------------------------------------------------------------
  451. static VOID
  452. OnAdvancedProxyClicked( IN HWND hwnd )
  453. {
  454. if( GenSettings.bUseSameProxyForAllProtocols )
  455. {
  456. GetWindowText( GetDlgItem( hwnd, IDC_EB_ADDRESS ),
  457. GenSettings.szHttpProxyAddress,
  458. MAX_PROXY_LEN + 1 );
  459. GetWindowText( GetDlgItem( hwnd, IDC_EB_PORT ),
  460. GenSettings.szHttpProxyPort,
  461. MAX_PROXY_PORT_LEN + 1 );
  462. }
  463. DialogBox( FixedGlobals.hInstance,
  464. MAKEINTRESOURCE(IDD_IE_ADVANCED_PROXY),
  465. hwnd,
  466. AdvancedProxySettingsDlg );
  467. }
  468. //----------------------------------------------------------------------------
  469. //
  470. // Function: ProxySettingsDlg
  471. //
  472. // Purpose:
  473. //
  474. // Arguments: standard Win32 dialog proc arguments
  475. //
  476. // Returns: standard Win32 dialog proc return value -- whether the message
  477. // was handled or not
  478. //
  479. //----------------------------------------------------------------------------
  480. INT_PTR CALLBACK ProxySettingsDlg(
  481. IN HWND hwnd,
  482. IN UINT uMsg,
  483. IN WPARAM wParam,
  484. IN LPARAM lParam )
  485. {
  486. BOOL bStatus = TRUE;
  487. switch( uMsg )
  488. {
  489. case WM_INITDIALOG:
  490. OnInitProxySettingsDialog( hwnd );
  491. break;
  492. case WM_COMMAND:
  493. {
  494. int nButtonId;
  495. switch( nButtonId = LOWORD(wParam) )
  496. {
  497. case IDOK:
  498. if( HIWORD( wParam ) == BN_CLICKED )
  499. {
  500. StoreProxySettings( hwnd );
  501. EndDialog( hwnd, TRUE );
  502. }
  503. break;
  504. case IDCANCEL:
  505. if( HIWORD( wParam ) == BN_CLICKED )
  506. {
  507. EndDialog( hwnd, FALSE );
  508. }
  509. break;
  510. case IDC_BUT_ADVANCED:
  511. if( HIWORD(wParam) == BN_CLICKED )
  512. {
  513. OnAdvancedProxyClicked( hwnd );
  514. GreyProxyPage( hwnd );
  515. FillProxyBoxes( hwnd );
  516. }
  517. break;
  518. case IDC_CB_USE_PROXY:
  519. if( HIWORD(wParam) == BN_CLICKED )
  520. {
  521. GreyProxyPage( hwnd );
  522. }
  523. break;
  524. default:
  525. bStatus = FALSE;
  526. break;
  527. }
  528. }
  529. break;
  530. default:
  531. bStatus = FALSE;
  532. break;
  533. }
  534. return( bStatus );
  535. }