From b59dded2a42c1b0ded541d0051ecabd2f445f94b Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 1 May 2011 12:00:23 +0000 Subject: [PATCH] Update proxy settings in Web UI --- src/qtlibtorrent/qbtsession.cpp | 2 ++ src/webui/eventmanager.cpp | 3 +++ src/webui/html/preferences_content.html | 12 +++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index ad2f52db2..2de2fcd0a 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -282,6 +282,7 @@ void QBtSession::configureSession() { const unsigned short old_listenPort = getListenPort(); const unsigned short new_listenPort = pref.getSessionPort(); if(old_listenPort != new_listenPort) { + qDebug("Session port changes in program preferences: %d -> %d", old_listenPort, new_listenPort); setListeningPort(new_listenPort); addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg(QString::number(new_listenPort))); } @@ -1849,6 +1850,7 @@ void QBtSession::setAppendqBExtension(bool append) { // Set the ports range in which is chosen the port the Bittorrent // session will listen to void QBtSession::setListeningPort(int port) { + qDebug() << Q_FUNC_INFO << port; Preferences pref; std::pair ports(port, port); #if LIBTORRENT_VERSION_MINOR > 15 diff --git a/src/webui/eventmanager.cpp b/src/webui/eventmanager.cpp index f06caa7c6..d6b2afc4a 100644 --- a/src/webui/eventmanager.cpp +++ b/src/webui/eventmanager.cpp @@ -234,6 +234,8 @@ void EventManager::setGlobalPreferences(QVariantMap m) const { pref.setProxyIp(m["proxy_ip"].toString()); if(m.contains("proxy_port")) pref.setProxyPort(m["proxy_port"].toUInt()); + if(m.contains("proxy_peer_connections")) + pref.setProxyPeerConnections(m["proxy_peer_connections"].toBool()); if(m.contains("proxy_auth_enabled")) pref.setProxyAuthEnabled(m["proxy_auth_enabled"].toBool()); if(m.contains("proxy_username")) @@ -305,6 +307,7 @@ QVariantMap EventManager::getGlobalPreferences() const { data["proxy_type"] = pref.getProxyType(); data["proxy_ip"] = pref.getProxyIp(); data["proxy_port"] = pref.getProxyPort(); + data["proxy_peer_connections"] = pref.proxyPeerConnections(); data["proxy_auth_enabled"] = pref.isProxyAuthEnabled(); data["proxy_username"] = pref.getProxyUsername(); data["proxy_password"] = pref.getProxyPassword(); diff --git a/src/webui/html/preferences_content.html b/src/webui/html/preferences_content.html index d8c80347c..f33c5c509 100644 --- a/src/webui/html/preferences_content.html +++ b/src/webui/html/preferences_content.html @@ -182,7 +182,8 @@      _(Host:)      - _(Port:)

+ _(Port:)
+   _(Use proxy for peer connections)

  _(Authentication)
@@ -404,6 +405,7 @@ } var proxy_ip = $('peer_proxy_host_text').get('value'); var proxy_port = $('peer_proxy_port_value').get('value'); + var proxy_peer_connections = $defined($('use_peer_proxy_checkbox').get('checked')) && $('use_peer_proxy_checkbox').get('checked'); var proxy_username = $('peer_proxy_username_text').get('value'); var proxy_password = $('peer_proxy_password_text').get('value'); // Web UI @@ -469,6 +471,7 @@ dict.set('proxy_type', proxy_type); dict.set('proxy_ip', proxy_ip); dict.set('proxy_port', proxy_port); + dict.set('proxy_peer_connections', proxy_peer_connections); dict.set('proxy_auth_enabled', proxy_auth_enabled); dict.set('proxy_username', proxy_username); dict.set('proxy_password', proxy_password); @@ -610,6 +613,7 @@ updatePeerProxySettings = function() { if($('peer_proxy_type_select').get('value') != "none") { $('peer_proxy_host_text').removeProperty('disabled'); $('peer_proxy_port_value').removeProperty('disabled'); + $('use_peer_proxy_checkbox').removeProperty('disabled'); if($('peer_proxy_type_select').get('value') != "socks5") { $('peer_proxy_auth_checkbox').removeProperty('checked'); $('peer_proxy_auth_checkbox').set('disabled', 'true'); @@ -620,6 +624,7 @@ updatePeerProxySettings = function() { } else { $('peer_proxy_host_text').set('disabled', 'true'); $('peer_proxy_port_value').set('disabled', 'true'); + $('use_peer_proxy_checkbox').set('disabled', 'true'); $('peer_proxy_auth_checkbox').set('disabled', 'true'); $('peer_proxy_auth_checkbox').removeProperty('checked'); updatePeerProxyAuthSettings(); @@ -876,6 +881,11 @@ loadPreferences = function() { updatePeerProxySettings(); $('peer_proxy_host_text').set('value', pref.proxy_ip); $('peer_proxy_port_value').set('value', pref.proxy_port); + if(pref.proxy_peer_connections) { + $('use_peer_proxy_checkbox').set('checked', 'checked'); + } else { + $('use_peer_proxy_checkbox').removeProperty('checked'); + } if(pref.proxy_auth_enabled) { $('peer_proxy_auth_checkbox').set('checked', 'checked'); } else {
_(Username:)