summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2010-04-02 19:22:32 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2010-04-02 19:22:32 +0000
commitb47030331197ff0fec8af069658c9dc2a5967847 (patch)
tree51fadb4e9307afca90ff615569f5c21fd528a106 /rbutil/rbutilqt/base
parent7a994c84c3abbfb2c18cfb5ebbd4ee8f6694e49d (diff)
Implement system proxy values retrieval on OS X.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25439 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/base')
-rw-r--r--rbutil/rbutilqt/base/system.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/system.cpp b/rbutil/rbutilqt/base/system.cpp
index 65acef5eea..7797157493 100644
--- a/rbutil/rbutilqt/base/system.cpp
+++ b/rbutil/rbutilqt/base/system.cpp
@@ -60,6 +60,9 @@
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
#endif
#include "utils.h"
@@ -390,6 +393,42 @@ QUrl System::systemProxy(void)
return QUrl("http://" + QString::fromWCharArray(proxyval));
else
return QUrl("");
+#elif defined(Q_OS_MACX)
+
+ CFDictionaryRef dictref;
+ CFStringRef stringref;
+ CFNumberRef numberref;
+ int enable;
+ int port;
+ unsigned int bufsize = 0;
+ char *buf;
+ QUrl proxy;
+
+ dictref = SCDynamicStoreCopyProxies(NULL);
+ stringref = (CFStringRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPProxy);
+ numberref = (CFNumberRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPEnable);
+ CFNumberGetValue(numberref, kCFNumberIntType, &enable);
+ if(enable == 1) {
+ // get number of characters. CFStringGetLength uses UTF-16 code pairs
+ bufsize = CFStringGetLength(stringref) * 2 + 1;
+ buf = (char*)malloc(sizeof(char) * bufsize);
+ if(buf == NULL) {
+ qDebug() << "[System] can't allocate memory for proxy string!";
+ CFRelease(dictref);
+ return QUrl("");
+ }
+ CFStringGetCString(stringref, buf, bufsize, kCFStringEncodingUTF16);
+ numberref = (CFNumberRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPPort);
+ CFNumberGetValue(numberref, kCFNumberIntType, &port);
+ proxy.setScheme("http");
+ proxy.setHost(QString::fromUtf16((unsigned short*)buf));
+ proxy.setPort(port);
+
+ free(buf);
+ }
+ CFRelease(dictref);
+
+ return proxy;
#else
return QUrl("");
#endif