Browse Source

Add support for anonymous mode

This mode was added in libtorrent v0.16 and should be used in
addition to a SOCKS5 proxy.
adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
5990615248
  1. 1
      Changelog
  2. 37
      src/preferences/options.ui
  3. 33
      src/preferences/options_imp.cpp
  4. 1
      src/preferences/options_imp.h
  5. 10
      src/preferences/preferences.h
  6. 8
      src/qtlibtorrent/qbtsession.cpp
  7. 7
      src/webui/eventmanager.cpp
  8. 26
      src/webui/html/preferences_content.html

1
Changelog

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
- FEATURE: Add file association settings to program preferences (Windows)
- FEATURE: Add setting to ignore slow torrents in queueing system
- FEATURE: Add advanced setting to announce to all trackers
- FEATURE: Add support for anonymous mode
- BUGFIX: Add tray menu entry for toggling window visibility
- COSMETIC: Display speed at the beginning of the Window title
- OTHER: Display libraries versions in about dialog (sledgehammer999)

37
src/preferences/options.ui

@ -1825,9 +1825,9 @@ @@ -1825,9 +1825,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-67</y>
<y>0</y>
<width>530</width>
<height>471</height>
<height>500</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -1976,6 +1976,37 @@ @@ -1976,6 +1976,37 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="checkAnonymousMode">
<property name="text">
<string>Enable anonymous mode</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string> (&lt;a href=&quot;http://sourceforge.net/apps/mediawiki/qbittorrent/index.php?title=Anonymous_mode&quot;&gt;More information&lt;/a&gt;)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_14">
<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>
@ -2206,7 +2237,7 @@ @@ -2206,7 +2237,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<width>485</width>
<height>535</height>
</rect>
</property>

33
src/preferences/options_imp.cpp

@ -124,10 +124,13 @@ options_imp::options_imp(QWidget *parent): @@ -124,10 +124,13 @@ options_imp::options_imp(QWidget *parent):
#ifndef Q_WS_WIN
groupFileAssociation->setVisible(false);
#endif
#if LIBTORRENT_VERSION_MINOR < 16
checkAnonymousMode->setVisible(false);
#endif
// Connect signals / slots
// Proxy tab
connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int)));
connect(checkAnonymousMode, SIGNAL(toggled(bool)), this, SLOT(toggleAnonymousMode(bool)));
// Apply button is activated when a value is changed
// General tab
@ -196,6 +199,9 @@ options_imp::options_imp(QWidget *parent): @@ -196,6 +199,9 @@ options_imp::options_imp(QWidget *parent):
connect(spinMaxConnecPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxUploadsPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkDHT, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#if LIBTORRENT_VERSION_MINOR > 15
connect(checkAnonymousMode, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#endif
connect(checkPeX, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkDifferentDHTPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinDHTPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
@ -443,6 +449,9 @@ void options_imp::saveOptions(){ @@ -443,6 +449,9 @@ void options_imp::saveOptions(){
pref.setDHTPort(getDHTPort());
pref.setLSDEnabled(isLSDEnabled());
pref.setEncryptionSetting(getEncryptionSetting());
#if LIBTORRENT_VERSION_MINOR > 15
pref.enableAnonymousMode(checkAnonymousMode->isChecked());
#endif
pref.setGlobalMaxRatio(getMaxRatio());
pref.setMaxRatioAction(comboRatioLimitAct->currentIndex());
// End Bittorrent preferences
@ -700,6 +709,9 @@ void options_imp::loadOptions(){ @@ -700,6 +709,9 @@ void options_imp::loadOptions(){
checkPeX->setChecked(pref.isPeXEnabled());
checkLSD->setChecked(pref.isLSDEnabled());
comboEncryption->setCurrentIndex(pref.getEncryptionSetting());
#if LIBTORRENT_VERSION_MINOR > 15
checkAnonymousMode->setChecked(pref.isAnonymousModeEnabled());
#endif
// Ratio limit
floatValue = pref.getGlobalMaxRatio();
if(floatValue >= 0.) {
@ -1301,3 +1313,22 @@ void options_imp::setSslCertificate(const QByteArray &cert, bool interactive) @@ -1301,3 +1313,22 @@ void options_imp::setSslCertificate(const QByteArray &cert, bool interactive)
}
#endif
}
void options_imp::toggleAnonymousMode(bool enabled)
{
if (enabled) {
// Disable DHT, LSD, UPnP / NAT-PMP
checkDHT->setEnabled(false);
checkDifferentDHTPort->setEnabled(false);
checkDHT->setChecked(false);
checkLSD->setEnabled(false);
checkLSD->setChecked(false);
checkUPnP->setEnabled(false);
checkUPnP->setChecked(false);
} else {
checkDHT->setEnabled(true);
checkDifferentDHTPort->setEnabled(true);
checkLSD->setEnabled(true);
checkUPnP->setEnabled(true);
}
}

1
src/preferences/options_imp.h

@ -84,6 +84,7 @@ private slots: @@ -84,6 +84,7 @@ private slots:
void on_btnWebUiKey_clicked();
void on_registerDNSBtn_clicked();
void setLocale(const QString &locale);
void toggleAnonymousMode(bool enabled);
private:
// Methods

10
src/preferences/preferences.h

@ -1013,6 +1013,16 @@ public: @@ -1013,6 +1013,16 @@ public:
return value(QString::fromUtf8("Preferences/Connection/InetAddress"), QString()).toString();
}
#if LIBTORRENT_VERSION_MINOR > 15
bool isAnonymousModeEnabled() const {
return value(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), false).toBool();
}
void enableAnonymousMode(bool enabled) {
setValue(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), enabled);
}
#endif
#if LIBTORRENT_VERSION_MINOR > 14
bool isSuperSeedingEnabled() const {
return value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool();

8
src/qtlibtorrent/qbtsession.cpp

@ -284,7 +284,7 @@ void QBtSession::configureSession() { @@ -284,7 +284,7 @@ void QBtSession::configureSession() {
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)));
addConsoleMessage(tr("qBittorrent is bound to port: TCP/%1", "e.g: qBittorrent is bound to port: 6881").arg(QString::number(getListenPort())));
}
// Downloads
@ -408,6 +408,12 @@ void QBtSession::configureSession() { @@ -408,6 +408,12 @@ void QBtSession::configureSession() {
sessionSettings.disk_io_write_mode = session_settings::disable_os_cache_for_aligned_files;
sessionSettings.disk_io_read_mode = session_settings::disable_os_cache_for_aligned_files;
#endif
#endif
#if LIBTORRENT_VERSION_MINOR > 15
sessionSettings.anonymous_mode = pref.isAnonymousModeEnabled();
if (sessionSettings.anonymous_mode) {
addConsoleMessage(tr("Anonymous mode [ON]"), "blue");
}
#endif
// Queueing System
if(pref.isQueueingSystemEnabled()) {

7
src/webui/eventmanager.cpp

@ -249,6 +249,10 @@ void EventManager::setGlobalPreferences(QVariantMap m) const { @@ -249,6 +249,10 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
pref.setLSDEnabled(m["lsd"].toBool());
if(m.contains("encryption"))
pref.setEncryptionSetting(m["encryption"].toInt());
#if LIBTORRENT_VERSION_MINOR >= 16
if(m.contains("anonymous_mode"))
pref.enableAnonymousMode(m["anonymous_mode"].toBool());
#endif
// Proxy
if(m.contains("proxy_type"))
pref.setProxyType(m["proxy_type"].toInt());
@ -362,6 +366,9 @@ QVariantMap EventManager::getGlobalPreferences() const { @@ -362,6 +366,9 @@ QVariantMap EventManager::getGlobalPreferences() const {
data["pex"] = pref.isPeXEnabled();
data["lsd"] = pref.isLSDEnabled();
data["encryption"] = pref.getEncryptionSetting();
#if LIBTORRENT_VERSION_MINOR >= 16
data["anonymous_mode"] = pref.isAnonymousModeEnabled();
#endif
// Proxy
data["proxy_type"] = pref.getProxyType();
data["proxy_ip"] = pref.getProxyIp();

26
src/webui/html/preferences_content.html

@ -76,6 +76,7 @@ @@ -76,6 +76,7 @@
<option value="1">_(Require encryption)</option>
<option value="2">_(Disable encryption)</option>
</select><br/>
<input type="checkbox" id="anonymous_mode_checkbox" onClick="toggleAnonymousMode()"/>&nbsp;&nbsp;_(Enable anonymous mode) (<a href="http://sourceforge.net/apps/mediawiki/qbittorrent/index.php?title=Anonymous_mode">More information</a>)<br/>
</div>
</fieldset>
</div>
@ -312,6 +313,23 @@ @@ -312,6 +313,23 @@
<script type="text/javascript">
var WatchedFoldersTable = new HtmlTable($("watched_folders_tab"));
toggleAnonymousMode = function() {
if($('anonymous_mode_checkbox').getProperty('checked')) {
$('dht_checkbox').setProperty('disabled', true);
$('DHTPortDiffThanBT_checkbox').setProperty('disabled', true);
$('dht_checkbox').setProperty('checked', false);
$('lsd_checkbox').setProperty('disabled', true);
$('lsd_checkbox').setProperty('checked', false);
$('upnp_checkbox').setProperty('disabled', true);
$('upnp_checkbox').setProperty('checked', false);
} else {
$('dht_checkbox').setProperty('disabled', false);
$('DHTPortDiffThanBT_checkbox').setProperty('disabled', false);
$('lsd_checkbox').setProperty('disabled', false);
$('upnp_checkbox').setProperty('disabled', false);
}
}
updateDlLimitEnabled = function() {
if($('dl_limit_checkbox').getProperty('checked')) {
$('dl_limit_value').setProperty('disabled', false);
@ -619,6 +637,11 @@ loadPreferences = function() { @@ -619,6 +637,11 @@ loadPreferences = function() {
$('lsd_checkbox').setProperty('checked', pref.lsd);
var encryption = pref.encryption.toInt();
$('encryption_select').getChildren('option')[encryption].setAttribute('selected', '');
if($defined(pref.anonymous_mode)) {
$('anonymous_mode_checkbox').setProperty('checked', pref.anonymous_mode);
} else {
$('enable_utp_checkbox').addClass('invisible');
}
// Downloads
$("savepath_text").setProperty('value', pref.save_path);
$('temppath_checkbox').setProperty('checked', pref.temp_path_enabled);
@ -797,6 +820,9 @@ applyPreferences = function() { @@ -797,6 +820,9 @@ applyPreferences = function() {
settings.set('pex', $('pex_checkbox').getProperty('checked'));
settings.set('lsd', $('lsd_checkbox').getProperty('checked'));
settings.set('encryption', $('encryption_select').getSelected()[0].getProperty('value'));
if(!$('anonymous_mode_checkbox').hasClass('invisible')) {
settings.set('anonymous_mode', $('anonymous_mode_checkbox').getProperty('checked'));
}
// Downloads
settings.set('save_path', $('savepath_text').getProperty('value'));

Loading…
Cancel
Save