From c03c95fc856bb0b00e2fdba2fbc577d11ca79f59 Mon Sep 17 00:00:00 2001 From: bluebrother Date: Sun, 29 Jul 2007 18:41:15 +0000 Subject: [PATCH] linux: respect http_proxy value for "system" proxy settings. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14062 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/configure.cpp | 58 +++++++++++++++++++++++++++++++++++-------- rbutil/rbutilqt/configure.h | 2 ++ rbutil/rbutilqt/install.h | 2 +- rbutil/rbutilqt/rbutilqt.cpp | 54 +++++++++++++++++++++++++++++----------- 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 37983e3fb..63a78a795 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp @@ -22,6 +22,10 @@ #include "configure.h" #include "ui_configurefrm.h" +#ifdef __linux +#include +#endif + #define DEFAULT_LANG "English (builtin)" Config::Config(QWidget *parent) : QDialog(parent) @@ -33,9 +37,9 @@ Config::Config(QWidget *parent) : QDialog(parent) QRegExp validate("[0-9]*"); proxyValidator->setRegExp(validate); ui.proxyPort->setValidator(proxyValidator); - - ui.radioSystemProxy->setEnabled(false); // not implemented yet - +#ifndef __linux + ui.radioSystemProxy->setEnabled(false); // only on linux for now +#endif // build language list and sort alphabetically QStringList langs = findLanguageFiles(); for(int i = 0; i < langs.size(); ++i) @@ -52,6 +56,7 @@ Config::Config(QWidget *parent) : QDialog(parent) connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(abort())); connect(ui.radioNoProxy, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool))); + connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool))); } @@ -59,13 +64,13 @@ void Config::accept() { qDebug() << "Config::accept()"; // proxy: save entered proxy values, not displayed. - QUrl proxy; - proxy.setScheme("http"); - proxy.setUserName(ui.proxyUser->text()); - proxy.setPassword(ui.proxyPass->text()); - proxy.setHost(ui.proxyHost->text()); - proxy.setPort(ui.proxyPort->text().toInt()); - + if(ui.radioManualProxy->isChecked()) { + proxy.setScheme("http"); + proxy.setUserName(ui.proxyUser->text()); + proxy.setPassword(ui.proxyPass->text()); + proxy.setHost(ui.proxyHost->text()); + proxy.setPort(ui.proxyPort->text().toInt()); + } userSettings->setValue("defaults/proxy", proxy.toString()); qDebug() << "new proxy:" << proxy; // proxy type @@ -141,6 +146,39 @@ void Config::setNoProxy(bool checked) } +void Config::setSystemProxy(bool checked) +{ + bool i = !checked; + ui.proxyPort->setEnabled(i); + ui.proxyHost->setEnabled(i); + ui.proxyUser->setEnabled(i); + ui.proxyPass->setEnabled(i); + if(checked) { + // save values in input box + proxy.setScheme("http"); + proxy.setUserName(ui.proxyUser->text()); + proxy.setPassword(ui.proxyPass->text()); + proxy.setHost(ui.proxyHost->text()); + proxy.setPort(ui.proxyPort->text().toInt()); + // show system values in input box +#ifdef __linux + QUrl envproxy = QUrl(getenv("http_proxy")); + ui.proxyHost->setText(envproxy.host()); + ui.proxyPort->setText(QString("%1").arg(envproxy.port())); + ui.proxyUser->setText(envproxy.userName()); + ui.proxyPass->setText(envproxy.password()); +#endif + } + else { + ui.proxyHost->setText(proxy.host()); + ui.proxyPort->setText(QString("%1").arg(proxy.port())); + ui.proxyUser->setText(proxy.userName()); + ui.proxyPass->setText(proxy.password()); + } + +} + + QStringList Config::findLanguageFiles() { QDir dir(programPath + "/"); diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h index a37f88b5e..20ae4092b 100644 --- a/rbutil/rbutilqt/configure.h +++ b/rbutil/rbutilqt/configure.h @@ -45,9 +45,11 @@ class Config : public QDialog QMap lang; QString language; QString programPath; + QUrl proxy; private slots: void setNoProxy(bool); + void setSystemProxy(bool); void updateLanguage(void); }; diff --git a/rbutil/rbutilqt/install.h b/rbutil/rbutilqt/install.h index 90afb068b..002963f75 100644 --- a/rbutil/rbutilqt/install.h +++ b/rbutil/rbutilqt/install.h @@ -65,7 +65,7 @@ class Install : public QDialog void setDetailsStable(bool); void setDetailsArchived(bool); void done(bool); - + }; diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index d5c6680c2..848d087bf 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -30,6 +30,10 @@ #include "installbootloader.h" #include "installzipwindow.h" +#ifdef __linux +#include +#endif + RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) { QString programPath = qApp->arguments().at(0); @@ -86,7 +90,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) ui.buttonComplete->setEnabled(false); ui.buttonDetect->setEnabled(false); - initIpodpatcher(); + initIpodpatcher(); downloadInfo(); } @@ -100,6 +104,10 @@ void RbUtilQt::downloadInfo() connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); if(userSettings->value("defaults/proxytype") == "manual") daily->setProxy(QUrl(userSettings->value("defaults/proxy").toString())); +#ifdef __linux + else if(userSettings->value("defaults/proxytype") == "system") + daily->setProxy(QUrl(getenv("http_proxy"))); +#endif qDebug() << "downloading build info"; daily->setFile(&buildInfo); @@ -218,6 +226,10 @@ void RbUtilQt::install() installWindow->setDeviceSettings(devices); if(userSettings->value("defaults/proxytype") == "manual") installWindow->setProxy(QUrl(userSettings->value("defaults/proxy").toString())); +#ifdef __linux + else if(userSettings->value("defaults/proxytype") == "system") + installWindow->setProxy(QUrl(getenv("http_proxy"))); +#endif installWindow->setMountPoint(userSettings->value("defaults/mountpoint").toString()); buildInfo.open(); @@ -243,6 +255,10 @@ void RbUtilQt::installBl() installWindow->setDeviceSettings(devices); if(userSettings->value("defaults/proxytype") == "manual") installWindow->setProxy(QUrl(userSettings->value("defaults/proxy").toString())); +#ifdef __linux + else if(userSettings->value("defaults/proxytype") == "system") + installWindow->setProxy(QUrl(getenv("http_proxy"))); +#endif installWindow->setMountPoint(userSettings->value("defaults/mountpoint").toString()); installWindow->show(); @@ -250,30 +266,38 @@ void RbUtilQt::installBl() void RbUtilQt::installFonts() { - InstallZipWindow* installWindow = new InstallZipWindow(this); - installWindow->setUserSettings(userSettings); + InstallZipWindow* installWindow = new InstallZipWindow(this); + installWindow->setUserSettings(userSettings); installWindow->setDeviceSettings(devices); if(userSettings->value("defaults/proxytype") == "manual") installWindow->setProxy(QUrl(userSettings->value("defaults/proxy").toString())); +#ifdef __linux + else if(userSettings->value("defaults/proxytype") == "system") + installWindow->setProxy(QUrl(getenv("http_proxy"))); +#endif installWindow->setMountPoint(userSettings->value("defaults/mountpoint").toString()); - installWindow->setLogSection("Fonts"); - installWindow->setUrl(devices->value("font_url").toString()); - installWindow->setWindowTitle("Font Installation"); - installWindow->show(); - + installWindow->setLogSection("Fonts"); + installWindow->setUrl(devices->value("font_url").toString()); + installWindow->setWindowTitle("Font Installation"); + installWindow->show(); + } void RbUtilQt::installDoom() { - InstallZipWindow* installWindow = new InstallZipWindow(this); - installWindow->setUserSettings(userSettings); + InstallZipWindow* installWindow = new InstallZipWindow(this); + installWindow->setUserSettings(userSettings); installWindow->setDeviceSettings(devices); if(userSettings->value("defaults/proxytype") == "manual") installWindow->setProxy(QUrl(userSettings->value("defaults/proxy").toString())); +#ifdef __linux + else if(userSettings->value("defaults/proxytype") == "system") + installWindow->setProxy(QUrl(getenv("http_proxy"))); +#endif installWindow->setMountPoint(userSettings->value("defaults/mountpoint").toString()); - installWindow->setLogSection("Doom"); - installWindow->setUrl(devices->value("doom_url").toString()); - installWindow->setWindowTitle("Doom Installation"); - installWindow->show(); - + installWindow->setLogSection("Doom"); + installWindow->setUrl(devices->value("doom_url").toString()); + installWindow->setWindowTitle("Doom Installation"); + installWindow->show(); + } -- 2.11.4.GIT