mshtml: Use wininet to get and parse the proxy
André Hentschel
nerv at dawncrow.de
Fri Aug 19 15:08:13 CDT 2011
---
dlls/mshtml/nsembed.c | 59 +++++++++++++++++++++---------------------------
1 files changed, 26 insertions(+), 33 deletions(-)
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index 2bebf8b..efc05df 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -27,6 +27,7 @@
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
+#include "wininet.h"
#include "ole2.h"
#include "shlobj.h"
@@ -488,51 +489,43 @@ static void set_lang(nsIPrefBranch *pref)
static void set_proxy(nsIPrefBranch *pref)
{
- char proxy[512];
- char * proxy_port;
- int proxy_port_num;
- DWORD enabled = 0, res, size, type;
- HKEY hkey;
+ CHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH];
+ URL_COMPONENTSA UrlComponents;
+ INTERNET_PROXY_INFOA *pi;
+ DWORD size;
- static const WCHAR proxy_keyW[] =
- {'S','o','f','t','w','a','r','e',
- '\\','M','i','c','r','o','s','o','f','t',
- '\\','W','i','n','d','o','w','s',
- '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',
- '\\','I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0};
+ InternetQueryOptionA(NULL, INTERNET_OPTION_PROXY, NULL, &size);
+ if (!size) return;
- res = RegOpenKeyW(HKEY_CURRENT_USER, proxy_keyW, &hkey);
- if(res != ERROR_SUCCESS)
- return;
+ pi = heap_alloc(size);
+ if (!pi) return;
- size = sizeof(enabled);
- res = RegQueryValueExA(hkey, "ProxyEnable", 0, &type, (LPBYTE)&enabled, &size);
- if(res != ERROR_SUCCESS || type != REG_DWORD || enabled == 0)
+ if(!InternetQueryOptionA(NULL, INTERNET_OPTION_PROXY, pi, &size))
{
- RegCloseKey(hkey);
+ heap_free(pi);
return;
}
- size = sizeof(proxy);
- res = RegQueryValueExA(hkey, "ProxyServer", 0, &type, (LPBYTE)proxy, &size);
- RegCloseKey(hkey);
- if(res != ERROR_SUCCESS || type != REG_SZ)
- return;
+ if (pi->dwAccessType != INTERNET_OPEN_TYPE_PROXY) return;
- proxy_port = strchr(proxy, ':');
- if (!proxy_port)
- return;
+ memset( &UrlComponents, 0, sizeof(UrlComponents));
+ UrlComponents.dwStructSize = sizeof(UrlComponents);
+ UrlComponents.lpszHostName = hostname;
+ UrlComponents.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
+ if(!InternetCrackUrlA(pi->lpszProxy, 0, 0, &UrlComponents)) return;
+ heap_free(pi);
+
+ if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
+ UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
- *proxy_port = 0;
- proxy_port_num = atoi(proxy_port + 1);
- TRACE("Setting proxy to %s, port %d\n", debugstr_a(proxy), proxy_port_num);
+ TRACE("Setting proxy to %s, port %d\n", UrlComponents.lpszHostName, UrlComponents.nPort);
- set_string_pref(pref, "network.proxy.http", proxy);
- set_string_pref(pref, "network.proxy.ssl", proxy);
+ set_string_pref(pref, "network.proxy.http", UrlComponents.lpszHostName);
+ set_string_pref(pref, "network.proxy.ssl", UrlComponents.lpszHostName);
set_int_pref(pref, "network.proxy.type", 1);
- set_int_pref(pref, "network.proxy.http_port", proxy_port_num);
- set_int_pref(pref, "network.proxy.ssl_port", proxy_port_num);
+ set_int_pref(pref, "network.proxy.http_port", UrlComponents.nPort);
+ set_int_pref(pref, "network.proxy.ssl_port", UrlComponents.nPort);
}
static void set_preferences(void)
--
Best Regards, André Hentschel
More information about the wine-patches
mailing list