Browse Source

Simplified proxy settings

Fix deprecation warnings with libtorrent v0.15.4+
adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
a3db4790a7
  1. 1
      Changelog
  2. 27
      src/downloadthread.cpp
  3. 157
      src/options_imp.cpp
  4. 27
      src/options_imp.h
  5. 78
      src/preferences.h
  6. 61
      src/qtlibtorrent/qbtsession.cpp
  7. 3
      src/qtlibtorrent/qbtsession.h
  8. 721
      src/ui/options.ui
  9. 42
      src/webui/eventmanager.cpp
  10. 98
      src/webui/html/preferences_content.html

1
Changelog

@ -10,6 +10,7 @@
- FEATURE: Bring up the connection settings when clicking on the connection status icon - FEATURE: Bring up the connection settings when clicking on the connection status icon
- FEATURE: Major code refactoring and optimization - FEATURE: Major code refactoring and optimization
- FEATURE: Added "Amount downloaded/left" columns to transfer list - FEATURE: Added "Amount downloaded/left" columns to transfer list
- FEATURE: Simplified proxy settings
- COSMETIC: Replaced message box by on-screen notification for download errors - COSMETIC: Replaced message box by on-screen notification for download errors
- COSMETIC: Improved the torrent creation tool appearance - COSMETIC: Improved the torrent creation tool appearance
- OTHERS: Dropped support for Qt <= 4.4 - OTHERS: Dropped support for Qt <= 4.4

27
src/downloadthread.cpp

@ -177,31 +177,26 @@ void downloadThread::checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal)
void downloadThread::applyProxySettings() { void downloadThread::applyProxySettings() {
QNetworkProxy proxy; QNetworkProxy proxy;
QIniSettings settings("qBittorrent", "qBittorrent"); const Preferences pref;
int intValue = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), 0).toInt(); if(pref.isProxyEnabled()) {
if(intValue > 0) {
// Proxy enabled // Proxy enabled
QString IP = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString(); proxy.setHostName(pref.getProxyIp());
proxy.setHostName(IP); proxy.setPort(pref.getProxyPort());
QString port = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toString();
qDebug("Using proxy: %s", qPrintable(IP));
proxy.setPort(port.toUShort());
// Default proxy type is HTTP, we must change if it is SOCKS5 // Default proxy type is HTTP, we must change if it is SOCKS5
if(intValue == Proxy::SOCKS5 || intValue == Proxy::SOCKS5_PW) { const int proxy_type = pref.getProxyType();
qDebug("Proxy is SOCKS5, not HTTP"); if(proxy_type == Proxy::SOCKS5 || proxy_type == Proxy::SOCKS5_PW) {
qDebug() << Q_FUNC_INFO << "using SOCKS proxy";
proxy.setType(QNetworkProxy::Socks5Proxy); proxy.setType(QNetworkProxy::Socks5Proxy);
} else { } else {
qDebug() << Q_FUNC_INFO << "using HTTP proxy";
proxy.setType(QNetworkProxy::HttpProxy); proxy.setType(QNetworkProxy::HttpProxy);
} }
// Authentication? // Authentication?
if(intValue > 2) { if(pref.isProxyAuthEnabled()) {
qDebug("Proxy requires authentication, authenticating"); qDebug("Proxy requires authentication, authenticating");
QString username = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Username"), QString()).toString(); proxy.setUser(pref.getProxyUsername());
proxy.setUser(username); proxy.setPassword(pref.getProxyPassword());
QString password = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Password"), QString()).toString();
proxy.setPassword(password);
} }
} else { } else {
proxy.setType(QNetworkProxy::NoProxy); proxy.setType(QNetworkProxy::NoProxy);
} }

157
src/options_imp.cpp

@ -166,10 +166,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(checkMaxUploadsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxUploadsLimitPerTorrent(bool))); connect(checkMaxUploadsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxUploadsLimitPerTorrent(bool)));
connect(checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableMaxRatio(bool))); connect(checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableMaxRatio(bool)));
// Proxy tab // Proxy tab
connect(comboProxyType_http, SIGNAL(currentIndexChanged(int)),this, SLOT(enableHTTPProxy(int))); connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int)));
connect(checkProxyAuth_http, SIGNAL(toggled(bool)), this, SLOT(enableHTTPProxyAuth(bool))); connect(checkProxyAuth, SIGNAL(toggled(bool)), this, SLOT(enableProxyAuth(bool)));
connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enablePeerProxy(int)));
connect(checkProxyAuth, SIGNAL(toggled(bool)), this, SLOT(enablePeerProxyAuth(bool)));
// Apply button is activated when a value is changed // Apply button is activated when a value is changed
// General tab // General tab
@ -232,12 +230,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(spinMaxRatio, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxRatio, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(comboRatioLimitAct, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(comboRatioLimitAct, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
// Proxy tab // Proxy tab
connect(comboProxyType_http, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(textProxyIP_http, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinProxyPort_http, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkProxyAuth_http, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(textProxyUsername_http, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(textProxyPassword_http, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(comboProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(comboProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(textProxyIP, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(textProxyIP, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinProxyPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinProxyPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
@ -418,18 +410,12 @@ void options_imp::saveOptions(){
pref.setSchedulerStartTime(schedule_from->time()); pref.setSchedulerStartTime(schedule_from->time());
pref.setSchedulerEndTime(schedule_to->time()); pref.setSchedulerEndTime(schedule_to->time());
pref.setSchedulerDays((scheduler_days)schedule_days->currentIndex()); pref.setSchedulerDays((scheduler_days)schedule_days->currentIndex());
pref.setPeerProxyType(getPeerProxyType()); pref.setProxyType(getProxyType());
pref.setPeerProxyIp(getPeerProxyIp()); pref.setProxyIp(getProxyIp());
pref.setPeerProxyPort(getPeerProxyPort()); pref.setProxyPort(getProxyPort());
pref.setPeerProxyAuthEnabled(isPeerProxyAuthEnabled()); pref.setProxyAuthEnabled(isProxyAuthEnabled());
pref.setPeerProxyUsername(getPeerProxyUsername()); pref.setProxyUsername(getProxyUsername());
pref.setPeerProxyPassword(getPeerProxyPassword()); pref.setProxyPassword(getProxyPassword());
pref.setHTTPProxyType(getHTTPProxyType());
pref.setHTTPProxyIp(getHTTPProxyIp());
pref.setHTTPProxyPort(getHTTPProxyPort());
pref.setHTTPProxyAuthEnabled(isHTTPProxyAuthEnabled());
pref.setHTTPProxyUsername(getHTTPProxyUsername());
pref.setHTTPProxyPassword(getHTTPProxyPassword());
// End Connection preferences // End Connection preferences
// Bittorrent preferences // Bittorrent preferences
pref.setMaxConnecs(getMaxConnecs()); pref.setMaxConnecs(getMaxConnecs());
@ -480,18 +466,18 @@ bool options_imp::isFilteringEnabled() const{
return checkIPFilter->isChecked(); return checkIPFilter->isChecked();
} }
int options_imp::getPeerProxyType() const{ int options_imp::getProxyType() const{
switch(comboProxyType->currentIndex()) { switch(comboProxyType->currentIndex()) {
case 1: case 1:
return Proxy::SOCKS4; return Proxy::SOCKS4;
break; break;
case 2: case 2:
if(isPeerProxyAuthEnabled()){ if(isProxyAuthEnabled()){
return Proxy::SOCKS5_PW; return Proxy::SOCKS5_PW;
} }
return Proxy::SOCKS5; return Proxy::SOCKS5;
case 3: case 3:
if(isPeerProxyAuthEnabled()){ if(isProxyAuthEnabled()){
return Proxy::HTTP_PW; return Proxy::HTTP_PW;
} }
return Proxy::HTTP; return Proxy::HTTP;
@ -500,25 +486,6 @@ int options_imp::getPeerProxyType() const{
} }
} }
int options_imp::getHTTPProxyType() const {
switch(comboProxyType_http->currentIndex()) {
case 1: {
if(isHTTPProxyAuthEnabled()){
return Proxy::HTTP_PW;
}
return Proxy::HTTP;
}
case 2: {
if(isHTTPProxyAuthEnabled()) {
return Proxy::SOCKS5_PW;
}
return Proxy::SOCKS5;
}
default:
return -1; // Disabled
}
}
QString options_imp::getStyle() const{ QString options_imp::getStyle() const{
return comboStyle->itemText(comboStyle->currentIndex()); return comboStyle->itemText(comboStyle->currentIndex());
} }
@ -529,10 +496,6 @@ void options_imp::setStyle(QString style) {
comboStyle->setCurrentIndex(index); comboStyle->setCurrentIndex(index);
} }
bool options_imp::isHTTPProxyAuthEnabled() const{
return checkProxyAuth_http->isChecked();
}
void options_imp::loadOptions(){ void options_imp::loadOptions(){
int intValue; int intValue;
float floatValue; float floatValue;
@ -638,7 +601,7 @@ void options_imp::loadOptions(){
schedule_to->setTime(pref.getSchedulerEndTime()); schedule_to->setTime(pref.getSchedulerEndTime());
schedule_days->setCurrentIndex((int)pref.getSchedulerDays()); schedule_days->setCurrentIndex((int)pref.getSchedulerDays());
intValue = pref.getPeerProxyType(); intValue = pref.getProxyType();
switch(intValue) { switch(intValue) {
case Proxy::SOCKS4: case Proxy::SOCKS4:
comboProxyType->setCurrentIndex(1); comboProxyType->setCurrentIndex(1);
@ -654,37 +617,16 @@ void options_imp::loadOptions(){
default: default:
comboProxyType->setCurrentIndex(0); comboProxyType->setCurrentIndex(0);
} }
enablePeerProxy(comboProxyType->currentIndex()); enableProxy(comboProxyType->currentIndex());
//if(isProxyEnabled()) { //if(isProxyEnabled()) {
// Proxy is enabled, save settings // Proxy is enabled, save settings
textProxyIP->setText(pref.getPeerProxyIp()); textProxyIP->setText(pref.getProxyIp());
spinProxyPort->setValue(pref.getPeerProxyPort()); spinProxyPort->setValue(pref.getProxyPort());
checkProxyAuth->setChecked(pref.isPeerProxyAuthEnabled()); checkProxyAuth->setChecked(pref.isProxyAuthEnabled());
textProxyUsername->setText(pref.getPeerProxyUsername()); textProxyUsername->setText(pref.getProxyUsername());
textProxyPassword->setText(pref.getPeerProxyPassword()); textProxyPassword->setText(pref.getProxyPassword());
enablePeerProxyAuth(checkProxyAuth->isChecked()); enableProxyAuth(checkProxyAuth->isChecked());
//} //}
intValue = pref.getHTTPProxyType();
switch(intValue) {
case Proxy::HTTP:
case Proxy::HTTP_PW:
comboProxyType_http->setCurrentIndex(1);
break;
case Proxy::SOCKS5:
case Proxy::SOCKS5_PW:
comboProxyType_http->setCurrentIndex(2);
break;
default:
comboProxyType_http->setCurrentIndex(0);
}
enableHTTPProxy(comboProxyType_http->currentIndex());
textProxyUsername_http->setText(pref.getHTTPProxyUsername());
textProxyPassword_http->setText(pref.getHTTPProxyPassword());
textProxyIP_http->setText(pref.getHTTPProxyIp());
spinProxyPort_http->setValue(pref.getHTTPProxyPort());
checkProxyAuth_http->setChecked(pref.isHTTPProxyAuthEnabled());
enableHTTPProxyAuth(checkProxyAuth_http->isChecked());
// End HTTPProxy
// End Connection preferences // End Connection preferences
// Bittorrent preferences // Bittorrent preferences
intValue = pref.getMaxConnecs(); intValue = pref.getMaxConnecs();
@ -987,7 +929,7 @@ void options_imp::enableMaxRatio(bool checked){
comboRatioLimitAct->setEnabled(checked); comboRatioLimitAct->setEnabled(checked);
} }
void options_imp::enablePeerProxy(int index){ void options_imp::enableProxy(int index){
if(index){ if(index){
//enable //enable
lblProxyIP->setEnabled(true); lblProxyIP->setEnabled(true);
@ -1011,32 +953,13 @@ void options_imp::enablePeerProxy(int index){
} }
} }
void options_imp::enableHTTPProxy(int index){ void options_imp::enableProxyAuth(bool checked){
bool enable = (index > 0);
lblProxyIP_http->setEnabled(enable);
textProxyIP_http->setEnabled(enable);
lblProxyPort_http->setEnabled(enable);
spinProxyPort_http->setEnabled(enable);
checkProxyAuth_http->setEnabled(enable);
if(!enable)
checkProxyAuth_http->setChecked(false);
}
void options_imp::enablePeerProxyAuth(bool checked){
lblProxyUsername->setEnabled(checked); lblProxyUsername->setEnabled(checked);
lblProxyPassword->setEnabled(checked); lblProxyPassword->setEnabled(checked);
textProxyUsername->setEnabled(checked); textProxyUsername->setEnabled(checked);
textProxyPassword->setEnabled(checked); textProxyPassword->setEnabled(checked);
} }
void options_imp::enableHTTPProxyAuth(bool checked){
lblProxyUsername_http->setEnabled(checked);
lblProxyPassword_http->setEnabled(checked);
textProxyUsername_http->setEnabled(checked);
textProxyPassword_http->setEnabled(checked);
}
bool options_imp::isSlashScreenDisabled() const { bool options_imp::isSlashScreenDisabled() const {
return !checkShowSplash->isChecked(); return !checkShowSplash->isChecked();
} }
@ -1054,62 +977,36 @@ bool options_imp::isDHTPortSameAsBT() const {
} }
// Proxy settings // Proxy settings
bool options_imp::isPeerProxyEnabled() const{ bool options_imp::isProxyEnabled() const{
return comboProxyType->currentIndex(); return comboProxyType->currentIndex();
} }
bool options_imp::isHTTPProxyEnabled() const { bool options_imp::isProxyAuthEnabled() const{
return comboProxyType_http->currentIndex();
}
bool options_imp::isPeerProxyAuthEnabled() const{
return checkProxyAuth->isChecked(); return checkProxyAuth->isChecked();
} }
QString options_imp::getPeerProxyIp() const{ QString options_imp::getProxyIp() const{
QString ip = textProxyIP->text(); QString ip = textProxyIP->text();
ip = ip.trimmed(); ip = ip.trimmed();
return ip; return ip;
} }
QString options_imp::getHTTPProxyIp() const{ unsigned short options_imp::getProxyPort() const{
QString ip = textProxyIP_http->text();
ip = ip.trimmed();
return ip;
}
unsigned short options_imp::getPeerProxyPort() const{
return spinProxyPort->value(); return spinProxyPort->value();
} }
unsigned short options_imp::getHTTPProxyPort() const{ QString options_imp::getProxyUsername() const{
return spinProxyPort_http->value();
}
QString options_imp::getPeerProxyUsername() const{
QString username = textProxyUsername->text(); QString username = textProxyUsername->text();
username = username.trimmed(); username = username.trimmed();
return username; return username;
} }
QString options_imp::getHTTPProxyUsername() const{ QString options_imp::getProxyPassword() const{
QString username = textProxyUsername_http->text();
username = username.trimmed();
return username;
}
QString options_imp::getPeerProxyPassword() const{
QString password = textProxyPassword->text(); QString password = textProxyPassword->text();
password = password.trimmed(); password = password.trimmed();
return password; return password;
} }
QString options_imp::getHTTPProxyPassword() const{
QString password = textProxyPassword_http->text();
password = password.trimmed();
return password;
}
// Locale Settings // Locale Settings
QString options_imp::getLocale() const{ QString options_imp::getLocale() const{
return locales.at(comboI18n->currentIndex()); return locales.at(comboI18n->currentIndex());

27
src/options_imp.h

@ -96,20 +96,13 @@ protected:
int getEncryptionSetting() const; int getEncryptionSetting() const;
float getMaxRatio() const; float getMaxRatio() const;
// Proxy options // Proxy options
QString getHTTPProxyIp() const; bool isProxyEnabled() const;
unsigned short getHTTPProxyPort() const; bool isProxyAuthEnabled() const;
QString getHTTPProxyUsername() const; QString getProxyIp() const;
QString getHTTPProxyPassword() const; unsigned short getProxyPort() const;
int getHTTPProxyType() const; QString getProxyUsername() const;
bool isPeerProxyEnabled() const; QString getProxyPassword() const;
bool isHTTPProxyEnabled() const; int getProxyType() const;
bool isPeerProxyAuthEnabled() const;
bool isHTTPProxyAuthEnabled() const;
QString getPeerProxyIp() const;
unsigned short getPeerProxyPort() const;
QString getPeerProxyUsername() const;
QString getPeerProxyPassword() const;
int getPeerProxyType() const;
// IP Filter // IP Filter
bool isFilteringEnabled() const; bool isFilteringEnabled() const;
QString getFilter() const; QString getFilter() const;
@ -126,10 +119,8 @@ protected:
protected slots: protected slots:
void enableUploadLimit(bool checked); void enableUploadLimit(bool checked);
void enableDownloadLimit(bool checked); void enableDownloadLimit(bool checked);
void enablePeerProxy(int comboIndex); void enableProxy(int comboIndex);
void enablePeerProxyAuth(bool checked); void enableProxyAuth(bool checked);
void enableHTTPProxy(int comboIndex);
void enableHTTPProxyAuth(bool checked);
void enableMaxConnecsLimit(bool checked); void enableMaxConnecsLimit(bool checked);
void enableMaxConnecsLimitPerTorrent(bool checked); void enableMaxConnecsLimitPerTorrent(bool checked);
void enableMaxUploadsLimitPerTorrent(bool checked); void enableMaxUploadsLimitPerTorrent(bool checked);

78
src/preferences.h

@ -423,107 +423,55 @@ public:
} }
// Proxy options // Proxy options
bool isHTTPProxyEnabled() const { bool isProxyEnabled() const {
return value(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), 0).toInt() > 0;
}
bool isHTTPProxyAuthEnabled() const {
return value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Authentication"), false).toBool();
}
void setHTTPProxyAuthEnabled(bool enabled) {
setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Authentication"), enabled);
}
QString getHTTPProxyIp() const {
return value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString();
}
void setHTTPProxyIp(const QString &ip) {
setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), ip);
}
unsigned short getHTTPProxyPort() const {
return value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toInt();
}
void setHTTPProxyPort(unsigned short port) {
setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), port);
}
QString getHTTPProxyUsername() const {
return value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Username"), QString()).toString();
}
void setHTTPProxyUsername(const QString &username) {
setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Username"), username);
}
QString getHTTPProxyPassword() const {
return value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Password"), QString()).toString();
}
void setHTTPProxyPassword(const QString &password) {
setValue(QString::fromUtf8("Preferences/Connection/HTTPProxy/Password"), password);
}
int getHTTPProxyType() const {
return value(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), 0).toInt();
}
void setHTTPProxyType(int type) {
setValue(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), type);
}
bool isPeerProxyEnabled() const {
return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt() > 0; return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt() > 0;
} }
bool isPeerProxyAuthEnabled() const { bool isProxyAuthEnabled() const {
return value(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), false).toBool(); return value(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), false).toBool();
} }
void setPeerProxyAuthEnabled(bool enabled) { void setProxyAuthEnabled(bool enabled) {
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), enabled); setValue(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), enabled);
} }
QString getPeerProxyIp() const { QString getProxyIp() const {
return value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString(); return value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString();
} }
void setPeerProxyIp(const QString &ip) { void setProxyIp(const QString &ip) {
setValue(QString::fromUtf8("Preferences/Connection/Proxy/IP"), ip); setValue(QString::fromUtf8("Preferences/Connection/Proxy/IP"), ip);
} }
unsigned short getPeerProxyPort() const { unsigned short getProxyPort() const {
return value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toInt(); return value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toInt();
} }
void setPeerProxyPort(unsigned short port) { void setProxyPort(unsigned short port) {
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Port"), port); setValue(QString::fromUtf8("Preferences/Connection/Proxy/Port"), port);
} }
QString getPeerProxyUsername() const { QString getProxyUsername() const {
return value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString(); return value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString();
} }
void setPeerProxyUsername(const QString &username) { void setProxyUsername(const QString &username) {
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Username"), username); setValue(QString::fromUtf8("Preferences/Connection/Proxy/Username"), username);
} }
QString getPeerProxyPassword() const { QString getProxyPassword() const {
return value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString(); return value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString();
} }
void setPeerProxyPassword(const QString &password) { void setProxyPassword(const QString &password) {
setValue(QString::fromUtf8("Preferences/Connection/Proxy/Password"), password); setValue(QString::fromUtf8("Preferences/Connection/Proxy/Password"), password);
} }
int getPeerProxyType() const { int getProxyType() const {
return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt(); return value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
} }
void setPeerProxyType(int type) { void setProxyType(int type) {
setValue(QString::fromUtf8("Preferences/Connection/ProxyType"), type); setValue(QString::fromUtf8("Preferences/Connection/ProxyType"), type);
} }

61
src/qtlibtorrent/qbtsession.cpp

@ -517,20 +517,20 @@ void QBtSession::configureSession() {
} }
// * Proxy settings // * Proxy settings
proxy_settings proxySettings; proxy_settings proxySettings;
if(pref.isPeerProxyEnabled()) { if(pref.isProxyEnabled()) {
qDebug("Enabling P2P proxy"); qDebug("Enabling P2P proxy");
proxySettings.hostname = pref.getPeerProxyIp().toStdString(); proxySettings.hostname = pref.getProxyIp().toStdString();
qDebug("hostname is %s", proxySettings.hostname.c_str()); qDebug("hostname is %s", proxySettings.hostname.c_str());
proxySettings.port = pref.getPeerProxyPort(); proxySettings.port = pref.getProxyPort();
qDebug("port is %d", proxySettings.port); qDebug("port is %d", proxySettings.port);
if(pref.isPeerProxyAuthEnabled()) { if(pref.isProxyAuthEnabled()) {
proxySettings.username = pref.getPeerProxyUsername().toStdString(); proxySettings.username = pref.getProxyUsername().toStdString();
proxySettings.password = pref.getPeerProxyPassword().toStdString(); proxySettings.password = pref.getProxyPassword().toStdString();
qDebug("username is %s", proxySettings.username.c_str()); qDebug("username is %s", proxySettings.username.c_str());
qDebug("password is %s", proxySettings.password.c_str()); qDebug("password is %s", proxySettings.password.c_str());
} }
} }
switch(pref.getPeerProxyType()) { switch(pref.getProxyType()) {
case Proxy::HTTP: case Proxy::HTTP:
qDebug("type: http"); qDebug("type: http");
proxySettings.type = proxy_settings::http; proxySettings.type = proxy_settings::http;
@ -552,39 +552,7 @@ void QBtSession::configureSession() {
default: default:
proxySettings.type = proxy_settings::none; proxySettings.type = proxy_settings::none;
} }
setPeerProxySettings(proxySettings); setProxySettings(proxySettings);
// HTTP Proxy
proxy_settings http_proxySettings;
qDebug("HTTP Communications proxy type: %d", pref.getHTTPProxyType());
switch(pref.getHTTPProxyType()) {
case Proxy::HTTP_PW:
http_proxySettings.type = proxy_settings::http_pw;
http_proxySettings.username = pref.getHTTPProxyUsername().toStdString();
http_proxySettings.password = pref.getHTTPProxyPassword().toStdString();
http_proxySettings.hostname = pref.getHTTPProxyIp().toStdString();
http_proxySettings.port = pref.getHTTPProxyPort();
break;
case Proxy::HTTP:
http_proxySettings.type = proxy_settings::http;
http_proxySettings.hostname = pref.getHTTPProxyIp().toStdString();
http_proxySettings.port = pref.getHTTPProxyPort();
break;
case Proxy::SOCKS5:
http_proxySettings.type = proxy_settings::socks5;
http_proxySettings.hostname = pref.getHTTPProxyIp().toStdString();
http_proxySettings.port = pref.getHTTPProxyPort();
break;
case Proxy::SOCKS5_PW:
http_proxySettings.type = proxy_settings::socks5_pw;
http_proxySettings.username = pref.getHTTPProxyUsername().toStdString();
http_proxySettings.password = pref.getHTTPProxyPassword().toStdString();
http_proxySettings.hostname = pref.getHTTPProxyIp().toStdString();
http_proxySettings.port = pref.getHTTPProxyPort();
break;
default:
http_proxySettings.type = proxy_settings::none;
}
setHTTPProxySettings(http_proxySettings);
// Tracker // Tracker
if(pref.isTrackerEnabled()) { if(pref.isTrackerEnabled()) {
if(!m_tracker) { if(!m_tracker) {
@ -1890,15 +1858,10 @@ void QBtSession::setSessionSettings(const session_settings &sessionSettings) {
} }
// Set Proxy // Set Proxy
void QBtSession::setPeerProxySettings(const proxy_settings &proxySettings) { void QBtSession::setProxySettings(const proxy_settings &proxySettings) {
qDebug("Set Peer Proxy settings"); qDebug() << Q_FUNC_INFO;
s->set_peer_proxy(proxySettings); s->set_proxy(proxySettings);
s->set_dht_proxy(proxySettings); // Define environment variable
}
void QBtSession::setHTTPProxySettings(const proxy_settings &proxySettings) {
s->set_tracker_proxy(proxySettings);
s->set_web_seed_proxy(proxySettings);
QString proxy_str; QString proxy_str;
switch(proxySettings.type) { switch(proxySettings.type) {
case proxy_settings::http_pw: case proxy_settings::http_pw:

3
src/qtlibtorrent/qbtsession.h

@ -133,8 +133,7 @@ public slots:
void setUploadRateLimit(long rate); void setUploadRateLimit(long rate);
void setMaxRatio(float ratio); void setMaxRatio(float ratio);
void setDHTPort(int dht_port); void setDHTPort(int dht_port);
void setPeerProxySettings(const proxy_settings &proxySettings); void setProxySettings(const proxy_settings &proxySettings);
void setHTTPProxySettings(const proxy_settings &proxySettings);
void setSessionSettings(const session_settings &sessionSettings); void setSessionSettings(const session_settings &sessionSettings);
void startTorrentsInPause(bool b); void startTorrentsInPause(bool b);
void setDefaultTempPath(QString temppath); void setDefaultTempPath(QString temppath);

721
src/ui/options.ui

@ -155,15 +155,6 @@
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Proxy</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/proxy.png</normaloff>:/Icons/oxygen/proxy.png</iconset>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Web UI</string> <string>Web UI</string>
@ -210,9 +201,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-40</y> <y>0</y>
<width>503</width> <width>507</width>
<height>446</height> <height>430</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="verticalLayout_9">
@ -514,8 +505,8 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-269</y> <y>0</y>
<width>503</width> <width>507</width>
<height>698</height> <height>698</height>
</rect> </rect>
</property> </property>
@ -949,11 +940,11 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>519</width> <width>507</width>
<height>398</height> <height>485</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_28"> <layout class="QVBoxLayout" name="verticalLayout_20">
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
@ -1163,6 +1154,201 @@ QGroupBox {
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupProxy">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Proxy server</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
<item>
<layout class="QHBoxLayout" name="_2">
<item>
<widget class="QLabel" name="ProxyType_lbl">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboProxyType">
<item>
<property name="text">
<string>(None)</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS4</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS5</string>
</property>
</item>
<item>
<property name="text">
<string>HTTP</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="lblProxyIP">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Host:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="textProxyIP">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>75</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblProxyPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinProxyPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>29</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_13">
<item row="0" column="0">
<widget class="QCheckBox" name="checkProxyAuth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Authentication</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QLabel" name="lblProxyUsername">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="textProxyUsername">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>1000</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblProxyPassword">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="textProxyPassword">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>1000</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="checkIPFilter"> <widget class="QGroupBox" name="checkIPFilter">
<property name="title"> <property name="title">
@ -1202,19 +1388,6 @@ QGroupBox {
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@ -1236,7 +1409,7 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>519</width> <width>524</width>
<height>406</height> <height>406</height>
</rect> </rect>
</property> </property>
@ -1488,12 +1661,6 @@ QGroupBox {
</item> </item>
<item> <item>
<widget class="QTimeEdit" name="schedule_from"> <widget class="QTimeEdit" name="schedule_from">
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
<property name="time"> <property name="time">
<time> <time>
<hour>8</hour> <hour>8</hour>
@ -1501,6 +1668,12 @@ QGroupBox {
<second>0</second> <second>0</second>
</time> </time>
</property> </property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -1515,9 +1688,6 @@ QGroupBox {
</item> </item>
<item> <item>
<widget class="QTimeEdit" name="schedule_to"> <widget class="QTimeEdit" name="schedule_to">
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="time"> <property name="time">
<time> <time>
<hour>20</hour> <hour>20</hour>
@ -1525,6 +1695,9 @@ QGroupBox {
<second>0</second> <second>0</second>
</time> </time>
</property> </property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -1625,8 +1798,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>552</width> <width>570</width>
<height>430</height> <height>422</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
@ -1996,463 +2169,45 @@ QGroupBox {
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabOptionPage5"> <widget class="QWidget" name="tabOptionPage7">
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<item> <item>
<widget class="QScrollArea" name="scrollArea_5"> <widget class="QScrollArea" name="scrollArea_7">
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents_5"> <widget class="QWidget" name="scrollAreaWidgetContents_7">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>484</width> <width>524</width>
<height>308</height> <height>406</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_23">
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="checkWebUi">
<property name="title"> <property name="title">
<string>HTTP Communications (trackers, Web seeds, search engine)</string> <string>Enable Web User Interface (Remote control)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_27"> <property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QGroupBox" name="groupWebUiServer">
<property name="title">
<string>HTTP Server</string>
</property>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
<widget class="QLabel" name="ProxyType_lbl_2"> <widget class="QLabel" name="lblWebUiPort">
<property name="text"> <property name="text">
<string>Type:</string> <string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboProxyType_http">
<item>
<property name="text">
<string>(None)</string>
</property>
</item>
<item>
<property name="text">
<string>HTTP</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS5</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="lblProxyIP_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Host:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="textProxyIP_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>75</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblProxyPort_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinProxyPort_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>29</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QCheckBox" name="checkProxyAuth_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Authentication</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QLabel" name="lblProxyUsername_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="textProxyUsername_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>1000</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblProxyPassword_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="textProxyPassword_http">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>1000</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupProxy">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Peer Communications</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="ProxyType_lbl">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboProxyType">
<item>
<property name="text">
<string>(None)</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS4</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS5</string>
</property>
</item>
<item>
<property name="text">
<string>HTTP</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="lblProxyIP">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Host:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="textProxyIP">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>75</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblProxyPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinProxyPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>29</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_13">
<item row="0" column="0">
<widget class="QCheckBox" name="checkProxyAuth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Authentication</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QLabel" name="lblProxyUsername">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="textProxyUsername">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>1000</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblProxyPassword">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="textProxyPassword">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>1000</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>180</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabOptionPage7">
<layout class="QVBoxLayout">
<item>
<widget class="QScrollArea" name="scrollArea_7">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_7">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>386</width>
<height>229</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
<item>
<widget class="QGroupBox" name="checkWebUi">
<property name="title">
<string>Enable Web User Interface (Remote control)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupWebUiServer">
<property name="title">
<string>HTTP Server</string>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lblWebUiPort">
<property name="text">
<string>Port:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -2589,8 +2344,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>524</width>
<height>28</height> <height>406</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_36"/> <layout class="QVBoxLayout" name="verticalLayout_36"/>

42
src/webui/eventmanager.cpp

@ -234,29 +234,17 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
pref.setEncryptionSetting(m["encryption"].toInt()); pref.setEncryptionSetting(m["encryption"].toInt());
// Proxy // Proxy
if(m.contains("proxy_type")) if(m.contains("proxy_type"))
pref.setPeerProxyType(m["proxy_type"].toInt()); pref.setProxyType(m["proxy_type"].toInt());
if(m.contains("proxy_ip")) if(m.contains("proxy_ip"))
pref.setPeerProxyIp(m["proxy_ip"].toString()); pref.setProxyIp(m["proxy_ip"].toString());
if(m.contains("proxy_port")) if(m.contains("proxy_port"))
pref.setPeerProxyPort(m["proxy_port"].toUInt()); pref.setProxyPort(m["proxy_port"].toUInt());
if(m.contains("proxy_auth_enabled")) if(m.contains("proxy_auth_enabled"))
pref.setPeerProxyAuthEnabled(m["proxy_auth_enabled"].toBool()); pref.setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
if(m.contains("proxy_username")) if(m.contains("proxy_username"))
pref.setPeerProxyUsername(m["proxy_username"].toString()); pref.setProxyUsername(m["proxy_username"].toString());
if(m.contains("proxy_password")) if(m.contains("proxy_password"))
pref.setPeerProxyPassword(m["proxy_password"].toString()); pref.setProxyPassword(m["proxy_password"].toString());
if(m.contains("http_proxy_type"))
pref.setHTTPProxyType(m["http_proxy_type"].toInt());
if(m.contains("http_proxy_ip"))
pref.setHTTPProxyIp(m["http_proxy_ip"].toString());
if(m.contains("http_proxy_port"))
pref.setHTTPProxyPort(m["http_proxy_port"].toUInt());
if(m.contains("http_proxy_auth_enabled"))
pref.setHTTPProxyAuthEnabled(m["http_proxy_auth_enabled"].toBool());
if(m.contains("http_proxy_username"))
pref.setHTTPProxyUsername(m["http_proxy_username"].toString());
if(m.contains("http_proxy_password"))
pref.setHTTPProxyPassword(m["http_proxy_password"].toString());
// IP Filter // IP Filter
if(m.contains("ip_filter_enabled")) if(m.contains("ip_filter_enabled"))
pref.setFilteringEnabled(m["ip_filter_enabled"].toBool()); pref.setFilteringEnabled(m["ip_filter_enabled"].toBool());
@ -320,18 +308,12 @@ QVariantMap EventManager::getGlobalPreferences() const {
data["lsd"] = pref.isLSDEnabled(); data["lsd"] = pref.isLSDEnabled();
data["encryption"] = pref.getEncryptionSetting(); data["encryption"] = pref.getEncryptionSetting();
// Proxy // Proxy
data["proxy_type"] = pref.getPeerProxyType(); data["proxy_type"] = pref.getProxyType();
data["proxy_ip"] = pref.getPeerProxyIp(); data["proxy_ip"] = pref.getProxyIp();
data["proxy_port"] = pref.getPeerProxyPort(); data["proxy_port"] = pref.getProxyPort();
data["proxy_auth_enabled"] = pref.isPeerProxyAuthEnabled(); data["proxy_auth_enabled"] = pref.isProxyAuthEnabled();
data["proxy_username"] = pref.getPeerProxyUsername(); data["proxy_username"] = pref.getProxyUsername();
data["proxy_password"] = pref.getPeerProxyPassword(); data["proxy_password"] = pref.getProxyPassword();
data["http_proxy_type"] = pref.getHTTPProxyType();
data["http_proxy_ip"] = pref.getHTTPProxyIp();
data["http_proxy_port"] = pref.getHTTPProxyPort();
data["http_proxy_auth_enabled"] = pref.isHTTPProxyAuthEnabled();
data["http_proxy_username"] = pref.getHTTPProxyUsername();
data["http_proxy_password"] = pref.getHTTPProxyPassword();
// IP Filter // IP Filter
data["ip_filter_enabled"] = pref.isFilteringEnabled(); data["ip_filter_enabled"] = pref.isFilteringEnabled();
data["ip_filter_path"] = pref.getFilter(); data["ip_filter_path"] = pref.getFilter();

98
src/webui/html/preferences_content.html

@ -172,25 +172,7 @@
</div> </div>
<div id="ProxyTab" class="PrefTab invisible"> <div id="ProxyTab" class="PrefTab invisible">
<fieldset> <legend><b>_(Proxy server)</b></legend>
<legend><b>_(HTTP Communications (trackers, Web seeds, search engine))</b></legend>
<div style="padding-left: 30px;">
_(Type:) <select id ="http_proxy_type_select" onchange="updateHTTPProxySettings();">
<option value="none">_((None))</option>
<option value="http">_(HTTP)</option>
<option value="socks5">_(SOCKS5)</option>
</select>&nbsp;&nbsp;&nbsp;&nbsp;
_(Host:) <input type="text" id="http_proxy_host_text" />&nbsp;&nbsp;&nbsp;&nbsp;
_(Port:) <input type="text" id="http_proxy_port_value" style="width: 4em;"/><br/><br/>
<input type="checkbox" id="http_proxy_auth_checkbox" onclick="updateHTTPProxyAuthSettings();" />&nbsp;&nbsp;_(Authentication)<br/>
<table>
<tr><td style="padding-left: 10px;">_(Username:)</td><td><input type="text" id="http_proxy_username_text" /></td></tr>
<tr><td style="padding-left: 10px;">_(Password:)</td><td><input type="password" id="http_proxy_password_text" /></td></tr>
</table>
</div>
</fieldset>
<fieldset>
<legend><b>_(Peer Communications)</b></legend>
<div style="padding-left: 30px;"> <div style="padding-left: 30px;">
_(Type:) <select id ="peer_proxy_type_select" onchange="updatePeerProxySettings();"> _(Type:) <select id ="peer_proxy_type_select" onchange="updatePeerProxySettings();">
<option value="none">_((None))</option> <option value="none">_((None))</option>
@ -394,31 +376,6 @@
if($defined($('ipfilter_enabled_checkbox').get('checked')) && $('ipfilter_enabled_checkbox').get('checked')) if($defined($('ipfilter_enabled_checkbox').get('checked')) && $('ipfilter_enabled_checkbox').get('checked'))
ip_filter_enabled = 1; ip_filter_enabled = 1;
var ip_filter_path = $('ipfilter_text').get('value'); var ip_filter_path = $('ipfilter_text').get('value');
// HTTP Proxy
var http_proxy_type_str = $('http_proxy_type_select').get('value');
var http_proxy_type = -1;
var http_proxy_auth_enabled = 0;
if(http_proxy_type_str == "http") {
if($defined($('http_proxy_auth_checkbox').get('checked')) && $('http_proxy_auth_checkbox').get('checked')) {
http_proxy_type = 3;
http_proxy_auth_enabled = 1;
} else {
http_proxy_type = 1;
}
} else {
if(http_proxy_type_str == "socks5") {
if($defined($('http_proxy_auth_checkbox').get('checked')) && $('http_proxy_auth_checkbox').get('checked')) {
http_proxy_type = 4;
http_proxy_auth_enabled = 1;
} else {
http_proxy_type = 2;
}
}
}
var http_proxy_ip = $('http_proxy_host_text').get('value');
var http_proxy_port = $('http_proxy_port_value').get('value');
var http_proxy_username = $('http_proxy_username_text').get('value');
var http_proxy_password = $('http_proxy_password_text').get('value');
// Peer Proxy // Peer Proxy
var proxy_type_str = $('peer_proxy_type_select').get('value'); var proxy_type_str = $('peer_proxy_type_select').get('value');
var proxy_type = -1; var proxy_type = -1;
@ -515,12 +472,6 @@
dict.set('proxy_auth_enabled', proxy_auth_enabled); dict.set('proxy_auth_enabled', proxy_auth_enabled);
dict.set('proxy_username', proxy_username); dict.set('proxy_username', proxy_username);
dict.set('proxy_password', proxy_password); dict.set('proxy_password', proxy_password);
dict.set('http_proxy_type', http_proxy_type);
dict.set('http_proxy_ip', http_proxy_ip);
dict.set('http_proxy_port', http_proxy_port);
dict.set('http_proxy_auth_enabled', http_proxy_auth_enabled);
dict.set('http_proxy_username', http_proxy_username);
dict.set('http_proxy_password', http_proxy_password);
// Web UI // Web UI
dict.set('web_ui_port', webui_port); dict.set('web_ui_port', webui_port);
dict.set('web_ui_username', webui_username); dict.set('web_ui_username', webui_username);
@ -655,29 +606,6 @@ updateDHTPortSettings = function() {
} }
} }
updateHTTPProxySettings = function() {
if($('http_proxy_type_select').get('value') != "none") {
$('http_proxy_host_text').removeProperty('disabled');
$('http_proxy_port_value').removeProperty('disabled');
$('http_proxy_auth_checkbox').removeProperty('disabled');
} else {
$('http_proxy_host_text').set('disabled', 'true');
$('http_proxy_port_value').set('disabled', 'true');
$('http_proxy_auth_checkbox').set('disabled', 'true');
$('http_proxy_auth_checkbox').removeProperty('checked');
}
}
updateHTTPProxyAuthSettings = function() {
if($defined($('http_proxy_auth_checkbox').get('checked')) && $('http_proxy_auth_checkbox').get('checked')) {
$('http_proxy_username_text').removeProperty('disabled');
$('http_proxy_password_text').removeProperty('disabled');
} else {
$('http_proxy_username_text').set('disabled', 'true');
$('http_proxy_password_text').set('disabled', 'true');
}
}
updatePeerProxySettings = function() { updatePeerProxySettings = function() {
if($('peer_proxy_type_select').get('value') != "none") { if($('peer_proxy_type_select').get('value') != "none") {
$('peer_proxy_host_text').removeProperty('disabled'); $('peer_proxy_host_text').removeProperty('disabled');
@ -962,30 +890,6 @@ loadPreferences = function() {
updatePeerProxyAuthSettings(); updatePeerProxyAuthSettings();
$('peer_proxy_username_text').set('value', pref.proxy_username); $('peer_proxy_username_text').set('value', pref.proxy_username);
$('peer_proxy_password_text').set('value', pref.proxy_password); $('peer_proxy_password_text').set('value', pref.proxy_password);
// HTTP PROXY
switch(pref.http_proxy_type.toInt()) {
case 1: //HTTP
case 3: // HTTP_PW
$('http_proxy_type_select').set('value', 'http');
break;
case 2: // SOCKS5
case 4: // SOCKS5_PW
$('http_proxy_type_select').set('value', 'socks5');
break;
default: // NONE
$('http_proxy_type_select').set('value', 'none');
}
updateHTTPProxySettings();
$('http_proxy_host_text').set('value', pref.http_proxy_ip);
$('http_proxy_port_value').set('value', pref.http_proxy_port);
if(pref.http_proxy_auth_enabled) {
$('http_proxy_auth_checkbox').set('checked', 'checked');
} else {
$('http_proxy_auth_checkbox').removeProperty('checked');
}
updateHTTPProxyAuthSettings();
$('http_proxy_username_text').set('value', pref.http_proxy_username);
$('http_proxy_password_text').set('value', pref.http_proxy_password);
// Web UI // Web UI
$('webui_port_value').set('value', pref.web_ui_port); $('webui_port_value').set('value', pref.web_ui_port);
$('webui_username_text').set('value', pref.web_ui_username); $('webui_username_text').set('value', pref.web_ui_username);

Loading…
Cancel
Save