Hans Leidekker : winhttp: Add support for retrieving the proxy automatic configuration URL on Mac OS X.

Alexandre Julliard julliard at winehq.org
Thu May 15 15:14:30 CDT 2014


Module: wine
Branch: master
Commit: 50c710bd914ee7197f234472523f86cd6c651a2a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=50c710bd914ee7197f234472523f86cd6c651a2a

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu May 15 14:06:02 2014 +0200

winhttp: Add support for retrieving the proxy automatic configuration URL on Mac OS X.

---

 dlls/winhttp/Makefile.in |    2 +-
 dlls/winhttp/session.c   |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/dlls/winhttp/Makefile.in b/dlls/winhttp/Makefile.in
index 948e0ed..7fbe2a7 100644
--- a/dlls/winhttp/Makefile.in
+++ b/dlls/winhttp/Makefile.in
@@ -2,7 +2,7 @@ MODULE    = winhttp.dll
 IMPORTLIB = winhttp
 IMPORTS   = uuid jsproxy user32 advapi32
 DELAYIMPORTS = oleaut32 ole32 crypt32 secur32
-EXTRALIBS = $(SOCKET_LIBS)
+EXTRALIBS = $(CORESERVICES_LIBS) $(SOCKET_LIBS)
 
 C_SRCS = \
 	cookie.c \
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index e773f05..f2ed72b 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -23,6 +23,15 @@
 #include <stdarg.h>
 #include <stdlib.h>
 
+#ifdef HAVE_CORESERVICES_CORESERVICES_H
+#define GetCurrentThread MacGetCurrentThread
+#define LoadResource MacLoadResource
+#include <CoreServices/CoreServices.h>
+#undef GetCurrentThread
+#undef LoadResource
+#undef DPRINTF
+#endif
+
 #include "windef.h"
 #include "winbase.h"
 #ifndef __MINGW32__
@@ -1286,12 +1295,42 @@ static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai )
     return ret;
 }
 
+static BOOL get_system_proxy_autoconfig_url( char *buf, DWORD buflen )
+{
+#ifdef HAVE_CORESERVICES_CORESERVICES_H
+    CFDictionaryRef settings = CFNetworkCopySystemProxySettings();
+    const void *ref;
+    BOOL ret = FALSE;
+
+    if (!settings) return FALSE;
+
+    if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString )))
+    {
+        CFRelease( settings );
+        return FALSE;
+    }
+    if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII ))
+    {
+        TRACE( "returning %s\n", debugstr_a(buf) );
+        ret = TRUE;
+    }
+    CFRelease( settings );
+    return ret;
+#else
+    FIXME( "no support on this platform\n" );
+    return FALSE;
+#endif
+}
+
+#define INTERNET_MAX_URL_LENGTH 2084
+
 /***********************************************************************
  *          WinHttpDetectAutoProxyConfigUrl (winhttp.@)
  */
 BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url )
 {
     BOOL ret = FALSE;
+    char system_url[INTERNET_MAX_URL_LENGTH + 1];
 
     TRACE("0x%08x, %p\n", flags, url);
 
@@ -1300,6 +1339,14 @@ BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url )
         set_last_error( ERROR_INVALID_PARAMETER );
         return FALSE;
     }
+    if (get_system_proxy_autoconfig_url( system_url, sizeof(system_url) ))
+    {
+        WCHAR *urlW;
+
+        if (!(urlW = strdupAW( system_url ))) return FALSE;
+        *url = urlW;
+        return TRUE;
+    }
     if (flags & WINHTTP_AUTO_DETECT_TYPE_DHCP)
     {
         static int fixme_shown;




More information about the wine-cvs mailing list