forked from len0rd/rockbox
Implement system proxy values retrieval on OS X.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25439 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7a994c84c3
commit
b470303311
3 changed files with 41 additions and 4 deletions
|
|
@ -60,6 +60,9 @@
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/ucred.h>
|
#include <sys/ucred.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <SystemConfiguration/SystemConfiguration.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
@ -390,6 +393,42 @@ QUrl System::systemProxy(void)
|
||||||
return QUrl("http://" + QString::fromWCharArray(proxyval));
|
return QUrl("http://" + QString::fromWCharArray(proxyval));
|
||||||
else
|
else
|
||||||
return QUrl("");
|
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
|
#else
|
||||||
return QUrl("");
|
return QUrl("");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,7 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
|
||||||
QRegExp validate("[0-9]*");
|
QRegExp validate("[0-9]*");
|
||||||
proxyValidator->setRegExp(validate);
|
proxyValidator->setRegExp(validate);
|
||||||
ui.proxyPort->setValidator(proxyValidator);
|
ui.proxyPort->setValidator(proxyValidator);
|
||||||
#if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32)
|
|
||||||
ui.radioSystemProxy->setEnabled(false); // not on OS X for now
|
|
||||||
#endif
|
|
||||||
// build language list and sort alphabetically
|
// build language list and sort alphabetically
|
||||||
QStringList langs = findLanguageFiles();
|
QStringList langs = findLanguageFiles();
|
||||||
for(int i = 0; i < langs.size(); ++i)
|
for(int i = 0; i < langs.size(); ++i)
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ macx {
|
||||||
QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc
|
QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc
|
||||||
QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386
|
QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386
|
||||||
CONFIG+=x86 ppc
|
CONFIG+=x86 ppc
|
||||||
LIBS += -L/usr/local/lib -framework IOKit -framework CoreFoundation -framework Carbon -lz
|
LIBS += -L/usr/local/lib -framework IOKit -framework CoreFoundation -framework Carbon -framework SystemConfiguration -lz
|
||||||
INCLUDEPATH += /usr/local/include
|
INCLUDEPATH += /usr/local/include
|
||||||
|
|
||||||
# rule for creating a dmg file
|
# rule for creating a dmg file
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue