diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-04-02 19:22:32 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-04-02 19:22:32 +0000 |
commit | b47030331197ff0fec8af069658c9dc2a5967847 (patch) | |
tree | 51fadb4e9307afca90ff615569f5c21fd528a106 /rbutil/rbutilqt | |
parent | 7a994c84c3abbfb2c18cfb5ebbd4ee8f6694e49d (diff) | |
download | rockbox-b47030331197ff0fec8af069658c9dc2a5967847.tar.gz rockbox-b47030331197ff0fec8af069658c9dc2a5967847.zip |
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')
-rw-r--r-- | rbutil/rbutilqt/base/system.cpp | 39 | ||||
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.pro | 2 |
3 files changed, 41 insertions, 4 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 @@ | |||
60 | #include <sys/param.h> | 60 | #include <sys/param.h> |
61 | #include <sys/ucred.h> | 61 | #include <sys/ucred.h> |
62 | #include <sys/mount.h> | 62 | #include <sys/mount.h> |
63 | |||
64 | #include <CoreFoundation/CoreFoundation.h> | ||
65 | #include <SystemConfiguration/SystemConfiguration.h> | ||
63 | #endif | 66 | #endif |
64 | 67 | ||
65 | #include "utils.h" | 68 | #include "utils.h" |
@@ -390,6 +393,42 @@ QUrl System::systemProxy(void) | |||
390 | return QUrl("http://" + QString::fromWCharArray(proxyval)); | 393 | return QUrl("http://" + QString::fromWCharArray(proxyval)); |
391 | else | 394 | else |
392 | return QUrl(""); | 395 | return QUrl(""); |
396 | #elif defined(Q_OS_MACX) | ||
397 | |||
398 | CFDictionaryRef dictref; | ||
399 | CFStringRef stringref; | ||
400 | CFNumberRef numberref; | ||
401 | int enable; | ||
402 | int port; | ||
403 | unsigned int bufsize = 0; | ||
404 | char *buf; | ||
405 | QUrl proxy; | ||
406 | |||
407 | dictref = SCDynamicStoreCopyProxies(NULL); | ||
408 | stringref = (CFStringRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPProxy); | ||
409 | numberref = (CFNumberRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPEnable); | ||
410 | CFNumberGetValue(numberref, kCFNumberIntType, &enable); | ||
411 | if(enable == 1) { | ||
412 | // get number of characters. CFStringGetLength uses UTF-16 code pairs | ||
413 | bufsize = CFStringGetLength(stringref) * 2 + 1; | ||
414 | buf = (char*)malloc(sizeof(char) * bufsize); | ||
415 | if(buf == NULL) { | ||
416 | qDebug() << "[System] can't allocate memory for proxy string!"; | ||
417 | CFRelease(dictref); | ||
418 | return QUrl(""); | ||
419 | } | ||
420 | CFStringGetCString(stringref, buf, bufsize, kCFStringEncodingUTF16); | ||
421 | numberref = (CFNumberRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPPort); | ||
422 | CFNumberGetValue(numberref, kCFNumberIntType, &port); | ||
423 | proxy.setScheme("http"); | ||
424 | proxy.setHost(QString::fromUtf16((unsigned short*)buf)); | ||
425 | proxy.setPort(port); | ||
426 | |||
427 | free(buf); | ||
428 | } | ||
429 | CFRelease(dictref); | ||
430 | |||
431 | return proxy; | ||
393 | #else | 432 | #else |
394 | return QUrl(""); | 433 | return QUrl(""); |
395 | #endif | 434 | #endif |
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 0704f0a999..3411717398 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -54,9 +54,7 @@ Config::Config(QWidget *parent,int index) : QDialog(parent) | |||
54 | QRegExp validate("[0-9]*"); | 54 | QRegExp validate("[0-9]*"); |
55 | proxyValidator->setRegExp(validate); | 55 | proxyValidator->setRegExp(validate); |
56 | ui.proxyPort->setValidator(proxyValidator); | 56 | ui.proxyPort->setValidator(proxyValidator); |
57 | #if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32) | 57 | |
58 | ui.radioSystemProxy->setEnabled(false); // not on OS X for now | ||
59 | #endif | ||
60 | // build language list and sort alphabetically | 58 | // build language list and sort alphabetically |
61 | QStringList langs = findLanguageFiles(); | 59 | QStringList langs = findLanguageFiles(); |
62 | for(int i = 0; i < langs.size(); ++i) | 60 | for(int i = 0; i < langs.size(); ++i) |
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index 34b43e660e..d3fb9c4b84 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro | |||
@@ -139,7 +139,7 @@ macx { | |||
139 | QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc | 139 | QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc |
140 | QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386 | 140 | QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386 |
141 | CONFIG+=x86 ppc | 141 | CONFIG+=x86 ppc |
142 | LIBS += -L/usr/local/lib -framework IOKit -framework CoreFoundation -framework Carbon -lz | 142 | LIBS += -L/usr/local/lib -framework IOKit -framework CoreFoundation -framework Carbon -framework SystemConfiguration -lz |
143 | INCLUDEPATH += /usr/local/include | 143 | INCLUDEPATH += /usr/local/include |
144 | 144 | ||
145 | # rule for creating a dmg file | 145 | # rule for creating a dmg file |