summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/configure.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-23 13:12:34 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-23 13:12:34 +0000
commit74154436a5fff8a8dd27115395c83c6d41ebf4e9 (patch)
treeaf3aecb7938ab3c0a5d55b5bdad70ad3794fade5 /rbutil/rbutilqt/configure.cpp
parenta1a45757405449563dbed163a2185b2a7af80d21 (diff)
downloadrockbox-74154436a5fff8a8dd27115395c83c6d41ebf4e9.tar.gz
rockbox-74154436a5fff8a8dd27115395c83c6d41ebf4e9.zip
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
Diffstat (limited to 'rbutil/rbutilqt/configure.cpp')
-rw-r--r--rbutil/rbutilqt/configure.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index eaa68a2a1c..967e0111e9 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -25,6 +25,13 @@
25#include "browsedirtree.h" 25#include "browsedirtree.h"
26 26
27#include <stdio.h> 27#include <stdio.h>
28#if defined(Q_OS_WIN32)
29#if defined(UNICODE)
30#define _UNICODE
31#endif
32#include <tchar.h>
33#include <windows.h>
34#endif
28 35
29#define DEFAULT_LANG "English (C)" 36#define DEFAULT_LANG "English (C)"
30 37
@@ -37,8 +44,8 @@ Config::Config(QWidget *parent) : QDialog(parent)
37 QRegExp validate("[0-9]*"); 44 QRegExp validate("[0-9]*");
38 proxyValidator->setRegExp(validate); 45 proxyValidator->setRegExp(validate);
39 ui.proxyPort->setValidator(proxyValidator); 46 ui.proxyPort->setValidator(proxyValidator);
40#ifndef __linux 47#if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32)
41 ui.radioSystemProxy->setEnabled(false); // only on linux for now 48 ui.radioSystemProxy->setEnabled(false); // not on macox for now
42#endif 49#endif
43 // build language list and sort alphabetically 50 // build language list and sort alphabetically
44 QStringList langs = findLanguageFiles(); 51 QStringList langs = findLanguageFiles();
@@ -160,7 +167,7 @@ void Config::setUserSettings(QSettings *user)
160 ui.proxyUser->setText(proxy.userName()); 167 ui.proxyUser->setText(proxy.userName());
161 ui.proxyPass->setText(proxy.password()); 168 ui.proxyPass->setText(proxy.password());
162 169
163 QString proxyType = userSettings->value("proxytype").toString(); 170 QString proxyType = userSettings->value("proxytype", "system").toString();
164 if(proxyType == "manual") ui.radioManualProxy->setChecked(true); 171 if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
165 else if(proxyType == "system") ui.radioSystemProxy->setChecked(true); 172 else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
166 else ui.radioNoProxy->setChecked(true); 173 else ui.radioNoProxy->setChecked(true);
@@ -419,13 +426,36 @@ void Config::setSystemProxy(bool checked)
419 proxy.setHost(ui.proxyHost->text()); 426 proxy.setHost(ui.proxyHost->text());
420 proxy.setPort(ui.proxyPort->text().toInt()); 427 proxy.setPort(ui.proxyPort->text().toInt());
421 // show system values in input box 428 // show system values in input box
422#ifdef __linux 429 QUrl envproxy;
423 QUrl envproxy = QUrl(getenv("http_proxy")); 430#if defined(Q_OS_LINUX)
431 envproxy = QUrl(getenv("http_proxy"));
432#endif
433#if defined(Q_OS_WIN32)
434 HKEY hk;
435 wchar_t proxyval[80];
436 DWORD buflen = 80;
437 long ret;
438
439 ret = RegOpenKeyEx(HKEY_CURRENT_USER, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
440 0, KEY_QUERY_VALUE, &hk);
441 if(ret != ERROR_SUCCESS) return;
442
443 ret = RegQueryValueEx(hk, _TEXT("ProxyServer"), NULL, NULL, (LPBYTE)proxyval, &buflen);
444 if(ret != ERROR_SUCCESS) return;
445
446 RegCloseKey(hk);
447 envproxy = QUrl("http://" + QString::fromWCharArray(proxyval));
448 qDebug() << envproxy;
424 ui.proxyHost->setText(envproxy.host()); 449 ui.proxyHost->setText(envproxy.host());
425 ui.proxyPort->setText(QString("%1").arg(envproxy.port())); 450 ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
426 ui.proxyUser->setText(envproxy.userName()); 451 ui.proxyUser->setText(envproxy.userName());
427 ui.proxyPass->setText(envproxy.password()); 452 ui.proxyPass->setText(envproxy.password());
428#endif 453#endif
454 ui.proxyHost->setText(envproxy.host());
455 ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
456 ui.proxyUser->setText(envproxy.userName());
457 ui.proxyPass->setText(envproxy.password());
458
429 } 459 }
430 else { 460 else {
431 ui.proxyHost->setText(proxy.host()); 461 ui.proxyHost->setText(proxy.host());