# HG changeset patch # User Daniel Atallah # Date 1123301109 0 # Node ID e865bdbbf91d0b3f0e73031fed8cc1a41a354ee4 # Parent fd6232f9a41852eeab861f354b8f1553a4448d81 [gaim-migrate @ 13316] Default Environmental proxy to the IE http proxy. committer: Tailor Script diff -r fd6232f9a418 -r e865bdbbf91d src/win_gaim.c --- 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"))) {