Module: wine Branch: master Commit: cfdce43de93bf66a126a297f85721a4e42b24755 URL: http://source.winehq.org/git/wine.git/?a=commit;h=cfdce43de93bf66a126a297f85...
Author: Juan Lang juan.lang@gmail.com Date: Thu Jul 21 13:17:21 2011 -0700
wininet: Implement setting proxy options globally for a process.
---
dlls/wininet/internet.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 90dd27e..c949f5d 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -498,10 +498,24 @@ static void FreeProxyInfo( proxyinfo_t *lpwpi ) heap_free(lpwpi->proxyBypass); }
+static proxyinfo_t *global_proxy; + +static void free_global_proxy( void ) +{ + EnterCriticalSection( &WININET_cs ); + if (global_proxy) + { + FreeProxyInfo( global_proxy ); + heap_free( global_proxy ); + } + LeaveCriticalSection( &WININET_cs ); +} + /*********************************************************************** * INTERNET_LoadProxySettings * - * Loads proxy information from the registry or environment into lpwpi. + * Loads proxy information from process-wide global settings, the registry, + * or the environment into lpwpi. * * The caller should call FreeProxyInfo when done with lpwpi. * @@ -516,6 +530,15 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) LPCSTR envproxy; LONG ret;
+ EnterCriticalSection( &WININET_cs ); + if (global_proxy) + { + lpwpi->proxyEnabled = global_proxy->proxyEnabled; + lpwpi->proxy = heap_strdupW( global_proxy->proxy ); + lpwpi->proxyBypass = heap_strdupW( global_proxy->proxyBypass ); + } + LeaveCriticalSection( &WININET_cs ); + if ((ret = RegOpenKeyW( HKEY_CURRENT_USER, szInternetSettings, &key ))) return ret;
@@ -2538,6 +2561,48 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, lpwhh->ErrorMask = *(ULONG*)lpBuffer; } break; + case INTERNET_OPTION_PROXY: + { + INTERNET_PROXY_INFOW *info = lpBuffer; + + if (!lpBuffer || dwBufferLength < sizeof(INTERNET_PROXY_INFOW)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if (!hInternet) + { + EnterCriticalSection( &WININET_cs ); + free_global_proxy(); + global_proxy = heap_alloc( sizeof(proxyinfo_t) ); + if (global_proxy) + { + if (info->dwAccessType == INTERNET_OPEN_TYPE_PROXY) + { + global_proxy->proxyEnabled = 1; + global_proxy->proxy = heap_strdupW( info->lpszProxy ); + global_proxy->proxyBypass = heap_strdupW( info->lpszProxyBypass ); + } + else + { + global_proxy->proxyEnabled = 0; + global_proxy->proxy = global_proxy->proxyBypass = NULL; + } + } + LeaveCriticalSection( &WININET_cs ); + } + else + { + /* In general, each type of object should handle + * INTERNET_OPTION_PROXY directly. This FIXME ensures it doesn't + * get silently dropped. + */ + FIXME("INTERNET_OPTION_PROXY unimplemented\n"); + SetLastError(ERROR_INTERNET_INVALID_OPTION); + ret = FALSE; + } + break; + } case INTERNET_OPTION_CODEPAGE: { ULONG codepage = *(ULONG *)lpBuffer;