Browse Source

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: Felix Paul Kühne <fkuehne@videolan.org>
pull/7/head
Kuang Rufan 14 years ago
committed by Felix Paul Kühne
parent
commit
adb1e78b73
  1. 46
      src/darwin/netconf.c

46
src/darwin/netconf.c

@ -28,8 +28,13 @@
#include <vlc_common.h>
#include <vlc_network.h>
#import <TargetConditionals.h>
#include <CoreFoundation/CoreFoundation.h>
#if TARGET_OS_IPHONE
#include <CFNetwork/CFProxySupport.h>
#else
#include <SystemConfiguration/SystemConfiguration.h>
#endif
/**
* Determines the network proxy server to use (if any).
@ -39,6 +44,37 @@
char *vlc_getProxyUrl(const char *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);
char *proxy_url = NULL;
@ -77,10 +113,11 @@ char *vlc_getProxyUrl(const char *url)
CFSTR(":%i"),
i_httpProxyPort);
CFStringGetCString(outputURL,
proxy_url,
sizeof(proxy_url),
kCFStringEncodingASCII);
char buffer[4096];
if (CFStringGetCString(outputURL, buffer, sizeof(buffer),
kCFStringEncodingUTF8))
proxy_url = strdup(buffer);
CFRelease(outputURL);
}
CFRelease(httpProxy);
@ -90,4 +127,5 @@ char *vlc_getProxyUrl(const char *url)
}
return proxy_url;
#endif
}

Loading…
Cancel
Save