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.

156 lines
6.5 KiB

  1. //
  2. // AUTOCNFG.CPP
  3. //
  4. #include "pch.h"
  5. INT_PTR CALLBACK QueryAutoConfigDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  6. {
  7. TCHAR szAutoConfigURL[MAX_URL],
  8. szAutoProxyURL[MAX_URL],
  9. szAutoConfigTime[7];
  10. BOOL fDetectConfig,
  11. fUseAutoConfig,
  12. fCheckDirtyOnly;
  13. switch (uMsg)
  14. {
  15. case WM_INITDIALOG:
  16. // warn the user that settings on this page will override imported connection settings
  17. if (InsGetBool(IS_CONNECTSET, IK_OPTION, FALSE, g_szInsFile))
  18. ErrorMessageBox(hDlg, IDS_CONNECTSET_WARN);
  19. DisableDBCSChars(hDlg, IDE_AUTOCONFIGTIME);
  20. EnableDBCSChars(hDlg, IDE_AUTOCONFIGURL);
  21. EnableDBCSChars(hDlg, IDE_AUTOPROXYURL);
  22. Edit_LimitText(GetDlgItem(hDlg, IDE_AUTOCONFIGTIME), countof(szAutoConfigTime) - 1);
  23. Edit_LimitText(GetDlgItem(hDlg, IDE_AUTOCONFIGURL), countof(szAutoConfigURL) - 1);
  24. Edit_LimitText(GetDlgItem(hDlg, IDE_AUTOPROXYURL), countof(szAutoProxyURL) - 1);
  25. fDetectConfig = FALSE;
  26. if (IsWindowEnabled(GetDlgItem(hDlg, IDC_AUTODETECT))) {
  27. fDetectConfig = InsGetBool(IS_URL, IK_DETECTCONFIG, TRUE, g_szInsFile);
  28. CheckDlgButton(hDlg, IDC_AUTODETECT, fDetectConfig ? BST_CHECKED : BST_UNCHECKED);
  29. }
  30. fUseAutoConfig = InsGetBool(IS_URL, IK_USEAUTOCONF, FALSE, g_szInsFile);
  31. CheckDlgButton(hDlg, IDC_YESAUTOCON, fUseAutoConfig ? BST_CHECKED : BST_UNCHECKED);
  32. GetPrivateProfileString(IS_URL, IK_AUTOCONFTIME, TEXT(""), szAutoConfigTime, countof(szAutoConfigTime), g_szInsFile);
  33. SetDlgItemText(hDlg, IDE_AUTOCONFIGTIME, szAutoConfigTime);
  34. EnableDlgItem2(hDlg, IDE_AUTOCONFIGTIME, fUseAutoConfig);
  35. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT2, fUseAutoConfig);
  36. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT3, fUseAutoConfig);
  37. GetPrivateProfileString(IS_URL, IK_AUTOCONFURL, TEXT(""), szAutoConfigURL, countof(szAutoConfigURL), g_szInsFile);
  38. SetDlgItemText(hDlg, IDE_AUTOCONFIGURL, szAutoConfigURL);
  39. EnableDlgItem2(hDlg, IDE_AUTOCONFIGURL, fUseAutoConfig);
  40. EnableDlgItem2(hDlg, IDC_AUTOCONFIGURL_TXT, fUseAutoConfig);
  41. GetPrivateProfileString(IS_URL, IK_AUTOCONFURLJS, TEXT(""), szAutoProxyURL, countof(szAutoProxyURL), g_szInsFile);
  42. SetDlgItemText(hDlg, IDE_AUTOPROXYURL, szAutoProxyURL);
  43. EnableDlgItem2(hDlg, IDE_AUTOPROXYURL, fUseAutoConfig);
  44. EnableDlgItem2(hDlg, IDC_AUTOPROXYURL_TXT, fUseAutoConfig);
  45. return TRUE;
  46. case UM_SAVE:
  47. fCheckDirtyOnly = (BOOL) lParam;
  48. fDetectConfig = (IsDlgButtonChecked(hDlg, IDC_AUTODETECT) == BST_CHECKED);
  49. fUseAutoConfig = (IsDlgButtonChecked(hDlg, IDC_YESAUTOCON) == BST_CHECKED);
  50. GetDlgItemText(hDlg, IDE_AUTOCONFIGTIME, szAutoConfigTime, countof(szAutoConfigTime));
  51. GetDlgItemText(hDlg, IDE_AUTOCONFIGURL, szAutoConfigURL, countof(szAutoConfigURL));
  52. GetDlgItemText(hDlg, IDE_AUTOPROXYURL, szAutoProxyURL, countof(szAutoProxyURL));
  53. if (fCheckDirtyOnly) {
  54. TCHAR szTmp[MAX_URL];
  55. BOOL fTemp;
  56. if (!g_fInsDirty) {
  57. fTemp = InsGetBool(IS_URL, IK_DETECTCONFIG, FALSE, g_szInsFile);
  58. g_fInsDirty = (fTemp != fDetectConfig);
  59. }
  60. if (!g_fInsDirty) {
  61. fTemp = InsGetBool(IS_URL, IK_USEAUTOCONF, FALSE, g_szInsFile);
  62. g_fInsDirty = (fTemp != fUseAutoConfig);
  63. }
  64. if (!g_fInsDirty) {
  65. GetPrivateProfileString(IS_URL, IK_AUTOCONFTIME, TEXT(""), szTmp, countof(szTmp), g_szInsFile);
  66. g_fInsDirty = (0 != StrCmpI(szTmp, szAutoConfigTime));
  67. }
  68. if (!g_fInsDirty) {
  69. GetPrivateProfileString(IS_URL, IK_AUTOCONFURL, TEXT(""), szTmp, countof(szTmp), g_szInsFile);
  70. g_fInsDirty = (0 != StrCmpI(szTmp, szAutoConfigURL));
  71. }
  72. if (!g_fInsDirty) {
  73. GetPrivateProfileString(IS_URL, IK_AUTOCONFURLJS, TEXT(""), szTmp, countof(szTmp), g_szInsFile);
  74. g_fInsDirty = (0 != StrCmpI(szTmp, szAutoProxyURL));
  75. }
  76. }
  77. else {
  78. // do error checking
  79. if (fUseAutoConfig) {
  80. if (IsWindowEnabled(GetDlgItem(hDlg, IDE_AUTOCONFIGTIME)) &&
  81. !CheckField(hDlg, IDE_AUTOCONFIGTIME, FC_NUMBER))
  82. return FALSE;
  83. if (*szAutoConfigURL == TEXT('\0') && *szAutoProxyURL == TEXT('\0')) {
  84. ErrorMessageBox(hDlg, IDS_AUTOCONFIG_NULL);
  85. SetFocus(GetDlgItem(hDlg, IDE_AUTOCONFIGURL));
  86. return FALSE;
  87. }
  88. if (!CheckField(hDlg, IDE_AUTOCONFIGURL, FC_URL) ||
  89. !CheckField(hDlg, IDE_AUTOPROXYURL, FC_URL))
  90. return FALSE;
  91. }
  92. // write the values to the INS file
  93. InsWriteBoolEx(IS_URL, IK_DETECTCONFIG, fDetectConfig, g_szInsFile);
  94. InsWriteBoolEx(IS_URL, IK_USEAUTOCONF, fUseAutoConfig, g_szInsFile);
  95. InsWriteString(IS_URL, IK_AUTOCONFTIME, szAutoConfigTime, g_szInsFile);
  96. InsWriteString(IS_URL, IK_AUTOCONFURL, szAutoConfigURL, g_szInsFile);
  97. InsWriteString(IS_URL, IK_AUTOCONFURLJS, szAutoProxyURL, g_szInsFile);
  98. }
  99. *((LPBOOL) wParam) = TRUE;
  100. return TRUE;
  101. case WM_COMMAND:
  102. switch (HIWORD(wParam))
  103. {
  104. case BN_CLICKED:
  105. switch(LOWORD(wParam))
  106. {
  107. case IDC_YESAUTOCON:
  108. fUseAutoConfig = (IsDlgButtonChecked(hDlg, IDC_YESAUTOCON) == BST_CHECKED);
  109. EnableDlgItem2(hDlg, IDE_AUTOCONFIGTIME, fUseAutoConfig);
  110. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT2, fUseAutoConfig);
  111. EnableDlgItem2(hDlg, IDC_AUTOCONFIGTEXT3, fUseAutoConfig);
  112. EnableDlgItem2(hDlg, IDE_AUTOCONFIGURL, fUseAutoConfig);
  113. EnableDlgItem2(hDlg, IDC_AUTOCONFIGURL_TXT, fUseAutoConfig);
  114. EnableDlgItem2(hDlg, IDE_AUTOPROXYURL, fUseAutoConfig);
  115. EnableDlgItem2(hDlg, IDC_AUTOPROXYURL_TXT, fUseAutoConfig);
  116. return TRUE;
  117. }
  118. break;
  119. }
  120. break;
  121. case WM_CLOSE:
  122. DestroyWindow(hDlg);
  123. break;
  124. }
  125. return FALSE;
  126. }