Commit adb1e78b authored by Kuang Rufan's avatar Kuang Rufan Committed by Felix Paul Kühne

fix error in getting proxy setting on darwin.

1. fix build error for ios.
2. fix vlc_getProxyUrl always return NULL on osx.
Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 5b5ccda8
...@@ -28,8 +28,13 @@ ...@@ -28,8 +28,13 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_network.h> #include <vlc_network.h>
#import <TargetConditionals.h>
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#if TARGET_OS_IPHONE
#include <CFNetwork/CFProxySupport.h>
#else
#include <SystemConfiguration/SystemConfiguration.h> #include <SystemConfiguration/SystemConfiguration.h>
#endif
/** /**
* Determines the network proxy server to use (if any). * Determines the network proxy server to use (if any).
...@@ -39,6 +44,37 @@ ...@@ -39,6 +44,37 @@
char *vlc_getProxyUrl(const char *url) char *vlc_getProxyUrl(const char *url)
{ {
VLC_UNUSED(url); VLC_UNUSED(url);
#if TARGET_OS_IPHONE
char *proxy_url = NULL;
CFDictionaryRef dicRef = CFNetworkCopySystemProxySettings();
if (NULL != dicRef) {
const CFStringRef proxyCFstr = (const CFStringRef)CFDictionaryGetValue(
dicRef, (const void*)kCFNetworkProxiesHTTPProxy);
const CFNumberRef portCFnum = (const CFNumberRef)CFDictionaryGetValue(
dicRef, (const void*)kCFNetworkProxiesHTTPPort);
if (NULL != proxyCFstr && NULL != portCFnum) {
int port = 0;
if (!CFNumberGetValue(portCFnum, kCFNumberIntType, &port)) {
CFRelease(dicRef);
return NULL;
}
char host_buffer[4096];
memset(host_buffer, 0, sizeof(host_buffer));
if (CFStringGetCString(proxyCFstr, host_buffer, sizeof(host_buffer)
- 1, kCFStringEncodingUTF8)) {
char buffer[4096];
memset(host_buffer, 0, sizeof(host_buffer));
sprintf(buffer, "%s:%d", host_buffer, port);
proxy_url = strdup(buffer);
}
}
CFRelease(dicRef);
}
return proxy_url;
#else
CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL); CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL);
char *proxy_url = NULL; char *proxy_url = NULL;
...@@ -77,10 +113,11 @@ char *vlc_getProxyUrl(const char *url) ...@@ -77,10 +113,11 @@ char *vlc_getProxyUrl(const char *url)
CFSTR(":%i"), CFSTR(":%i"),
i_httpProxyPort); i_httpProxyPort);
CFStringGetCString(outputURL, char buffer[4096];
proxy_url, if (CFStringGetCString(outputURL, buffer, sizeof(buffer),
sizeof(proxy_url), kCFStringEncodingUTF8))
kCFStringEncodingASCII); proxy_url = strdup(buffer);
CFRelease(outputURL); CFRelease(outputURL);
} }
CFRelease(httpProxy); CFRelease(httpProxy);
...@@ -90,4 +127,5 @@ char *vlc_getProxyUrl(const char *url) ...@@ -90,4 +127,5 @@ char *vlc_getProxyUrl(const char *url)
} }
return proxy_url; return proxy_url;
#endif
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment