Mercurial > pidgin.yaz
changeset 11193:e865bdbbf91d
[gaim-migrate @ 13316]
Default Environmental proxy to the IE http proxy.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sat, 06 Aug 2005 04:05:09 +0000 |
parents | fd6232f9a418 |
children | 4c1f45ac00e9 |
files | src/win_gaim.c |
diffstat | 1 files changed, 48 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/win_gaim.c Fri Aug 05 01:24:55 2005 +0000 +++ b/src/win_gaim.c Sat Aug 06 04:05:09 2005 +0000 @@ -39,6 +39,8 @@ # define ATTACH_PARENT_PROCESS -1 #endif +#define WIN32_PROXY_REGKEY "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" + typedef int (CALLBACK* LPFNGAIMMAIN)(HINSTANCE, int, char**); typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCTSTR); typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); @@ -73,7 +75,7 @@ "???"), sub_key, val_name, retv, szBuf); } - RegCloseKey(key); + RegCloseKey(hkey); } else { TCHAR szBuf[80]; @@ -283,6 +285,46 @@ return TRUE; } +static void wgaim_set_proxy() { + DWORD regval = 1; + DWORD reglen = sizeof(DWORD); + + /* If the proxy server environment variables are already set, + * we shouldn't override them */ + if (getenv("HTTP_PROXY") || getenv("http_proxy") || getenv("HTTPPROXY")) + return; + + if (read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY, "ProxyEnable", + (LPBYTE) ®val, ®len) && (regval & 1)) { + char proxy_server[2048]; + char *c = NULL; + reglen = sizeof(proxy_server); + + if (!read_reg_string(HKEY_CURRENT_USER, WIN32_PROXY_REGKEY , "ProxyServer", + (LPBYTE) &proxy_server, ®len)) + return; + + if ((reglen > strlen("http=")) && (c = strstr(proxy_server, "http="))) { + char *d; + c += strlen("http="); + d = strchr(c, ';'); + if (d) { + *d = '\0'; + } + /* c now points the proxy server (and port) */ + } + + if (c) { + const char envstr_prefix[] = "HTTP_PROXY=http://"; + char envstr[sizeof(envstr_prefix) + strlen(c) + 1]; + snprintf(envstr, sizeof(envstr), "%s%s", envstr_prefix, c); + printf("Setting HTTP Proxy: %s\n", envstr); + putenv(envstr); + } + } + +} + #ifdef __GNUC__ # ifndef _stdcall # define _stdcall __attribute__((stdcall)) @@ -336,9 +378,11 @@ if(!getenv("GAIM_NO_DLL_CHECK")) dll_prep(); - wgaim_set_locale(); - if(!getenv("GAIM_MULTI_INST") && !wgaim_set_running()) - return 0; + wgaim_set_locale(); + if(!getenv("GAIM_MULTI_INST") && !wgaim_set_running()) + return 0; + + wgaim_set_proxy(); /* Now we are ready for Gaim .. */ if((hmod=LoadLibrary("gaim.dll"))) {