mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 05:35:20 -05:00
w32: implement "system proxy" settings. This uses the IE setting by reading its values from the registry. Make system proxy the default value if no configuration file is found.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14827 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a1a4575740
commit
74154436a5
2 changed files with 64 additions and 8 deletions
|
|
@ -25,6 +25,13 @@
|
||||||
#include "browsedirtree.h"
|
#include "browsedirtree.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
#if defined(UNICODE)
|
||||||
|
#define _UNICODE
|
||||||
|
#endif
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_LANG "English (C)"
|
#define DEFAULT_LANG "English (C)"
|
||||||
|
|
||||||
|
|
@ -37,8 +44,8 @@ Config::Config(QWidget *parent) : QDialog(parent)
|
||||||
QRegExp validate("[0-9]*");
|
QRegExp validate("[0-9]*");
|
||||||
proxyValidator->setRegExp(validate);
|
proxyValidator->setRegExp(validate);
|
||||||
ui.proxyPort->setValidator(proxyValidator);
|
ui.proxyPort->setValidator(proxyValidator);
|
||||||
#ifndef __linux
|
#if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32)
|
||||||
ui.radioSystemProxy->setEnabled(false); // only on linux for now
|
ui.radioSystemProxy->setEnabled(false); // not on macox for now
|
||||||
#endif
|
#endif
|
||||||
// build language list and sort alphabetically
|
// build language list and sort alphabetically
|
||||||
QStringList langs = findLanguageFiles();
|
QStringList langs = findLanguageFiles();
|
||||||
|
|
@ -160,7 +167,7 @@ void Config::setUserSettings(QSettings *user)
|
||||||
ui.proxyUser->setText(proxy.userName());
|
ui.proxyUser->setText(proxy.userName());
|
||||||
ui.proxyPass->setText(proxy.password());
|
ui.proxyPass->setText(proxy.password());
|
||||||
|
|
||||||
QString proxyType = userSettings->value("proxytype").toString();
|
QString proxyType = userSettings->value("proxytype", "system").toString();
|
||||||
if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
|
if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
|
||||||
else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
|
else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
|
||||||
else ui.radioNoProxy->setChecked(true);
|
else ui.radioNoProxy->setChecked(true);
|
||||||
|
|
@ -419,13 +426,36 @@ void Config::setSystemProxy(bool checked)
|
||||||
proxy.setHost(ui.proxyHost->text());
|
proxy.setHost(ui.proxyHost->text());
|
||||||
proxy.setPort(ui.proxyPort->text().toInt());
|
proxy.setPort(ui.proxyPort->text().toInt());
|
||||||
// show system values in input box
|
// show system values in input box
|
||||||
#ifdef __linux
|
QUrl envproxy;
|
||||||
QUrl envproxy = QUrl(getenv("http_proxy"));
|
#if defined(Q_OS_LINUX)
|
||||||
|
envproxy = QUrl(getenv("http_proxy"));
|
||||||
|
#endif
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
HKEY hk;
|
||||||
|
wchar_t proxyval[80];
|
||||||
|
DWORD buflen = 80;
|
||||||
|
long ret;
|
||||||
|
|
||||||
|
ret = RegOpenKeyEx(HKEY_CURRENT_USER, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
|
||||||
|
0, KEY_QUERY_VALUE, &hk);
|
||||||
|
if(ret != ERROR_SUCCESS) return;
|
||||||
|
|
||||||
|
ret = RegQueryValueEx(hk, _TEXT("ProxyServer"), NULL, NULL, (LPBYTE)proxyval, &buflen);
|
||||||
|
if(ret != ERROR_SUCCESS) return;
|
||||||
|
|
||||||
|
RegCloseKey(hk);
|
||||||
|
envproxy = QUrl("http://" + QString::fromWCharArray(proxyval));
|
||||||
|
qDebug() << envproxy;
|
||||||
ui.proxyHost->setText(envproxy.host());
|
ui.proxyHost->setText(envproxy.host());
|
||||||
ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
|
ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
|
||||||
ui.proxyUser->setText(envproxy.userName());
|
ui.proxyUser->setText(envproxy.userName());
|
||||||
ui.proxyPass->setText(envproxy.password());
|
ui.proxyPass->setText(envproxy.password());
|
||||||
#endif
|
#endif
|
||||||
|
ui.proxyHost->setText(envproxy.host());
|
||||||
|
ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
|
||||||
|
ui.proxyUser->setText(envproxy.userName());
|
||||||
|
ui.proxyPass->setText(envproxy.password());
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui.proxyHost->setText(proxy.host());
|
ui.proxyHost->setText(proxy.host());
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,17 @@
|
||||||
#include "uninstallwindow.h"
|
#include "uninstallwindow.h"
|
||||||
#include "browseof.h"
|
#include "browseof.h"
|
||||||
|
|
||||||
#ifdef __linux
|
#if defined(Q_OS_LINUX)
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
#if defined(UNICODE)
|
||||||
|
#define _UNICODE
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
|
RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
|
||||||
{
|
{
|
||||||
|
|
@ -935,11 +943,29 @@ void RbUtilQt::updateInfo()
|
||||||
|
|
||||||
QUrl RbUtilQt::proxy()
|
QUrl RbUtilQt::proxy()
|
||||||
{
|
{
|
||||||
if(userSettings->value("proxytype") == "manual")
|
if(userSettings->value("proxytype", "system").toString() == "manual")
|
||||||
return QUrl(userSettings->value("proxy").toString());
|
return QUrl(userSettings->value("proxy").toString());
|
||||||
#ifdef __linux
|
#if defined(Q_OS_LINUX)
|
||||||
else if(userSettings->value("proxytype") == "system")
|
else if(userSettings->value("proxytype") == "system")
|
||||||
return QUrl(getenv("http_proxy"));
|
return QUrl(getenv("http_proxy"));
|
||||||
|
#endif
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
HKEY hk;
|
||||||
|
wchar_t proxyval[80];
|
||||||
|
DWORD buflen = 80;
|
||||||
|
long ret;
|
||||||
|
|
||||||
|
ret = RegOpenKeyEx(HKEY_CURRENT_USER, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
|
||||||
|
0, KEY_QUERY_VALUE, &hk);
|
||||||
|
if(ret != ERROR_SUCCESS) return QUrl("");
|
||||||
|
|
||||||
|
ret = RegQueryValueEx(hk, _TEXT("ProxyServer"), NULL, NULL, (LPBYTE)proxyval, &buflen);
|
||||||
|
if(ret != ERROR_SUCCESS) return QUrl("");
|
||||||
|
|
||||||
|
RegCloseKey(hk);
|
||||||
|
qDebug() << QString::fromWCharArray(proxyval);
|
||||||
|
return QUrl("http://" + QString::fromWCharArray(proxyval));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return QUrl("");
|
return QUrl("");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue