Browse Source

Automatically add trackers to new downloads.

adaptive-webui-19844
ngosang 10 years ago
parent
commit
9c7bb08a03
  1. 14
      src/core/bittorrent/session.cpp
  2. 1
      src/core/bittorrent/session.h
  3. 20
      src/core/preferences.cpp
  4. 4
      src/core/preferences.h
  5. 31
      src/gui/options.ui
  6. 6
      src/gui/options_imp.cpp

14
src/core/bittorrent/session.cpp

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
@ -620,6 +621,16 @@ void Session::configure() @@ -620,6 +621,16 @@ void Session::configure()
qDebug("Applying encryption settings");
m_nativeSession->set_pe_settings(encryptionSettings);
// * Add trackers
m_additionalTrackers.empty();
if (pref->isAddTrackersEnabled()) {
foreach (QString tracker, pref->getTrackersList().split("\n")) {
tracker = tracker.trimmed();
if (!tracker.isEmpty())
m_additionalTrackers << tracker;
}
}
// * Maximum ratio
m_highRatioAction = pref->getMaxRatioAction();
setGlobalMaxRatio(pref->getGlobalMaxRatio());
@ -2111,6 +2122,9 @@ void Session::handleAddTorrentAlert(libtorrent::add_torrent_alert *p) @@ -2111,6 +2122,9 @@ void Session::handleAddTorrentAlert(libtorrent::add_torrent_alert *p)
}
}
if (pref->isAddTrackersEnabled() && !torrent->isPrivate())
torrent->addTrackers(m_additionalTrackers);
bool addPaused = data.addPaused;
if (data.addPaused == TriStateBool::Undefined)
addPaused = pref->addTorrentsInPause();

1
src/core/bittorrent/session.h

@ -330,6 +330,7 @@ namespace BitTorrent @@ -330,6 +330,7 @@ namespace BitTorrent
bool m_appendExtension;
uint m_refreshInterval;
MaxRatioAction m_highRatioAction;
QList<BitTorrent::TrackerEntry> m_additionalTrackers;
QString m_defaultSavePath;
QString m_tempPath;
QString m_filterPath;

20
src/core/preferences.cpp

@ -962,6 +962,26 @@ void Preferences::setEncryptionSetting(int val) @@ -962,6 +962,26 @@ void Preferences::setEncryptionSetting(int val)
setValue("Preferences/Bittorrent/Encryption", val);
}
bool Preferences::isAddTrackersEnabled() const
{
return value("Preferences/Bittorrent/AddTrackers", false).toBool();
}
void Preferences::setAddTrackersEnabled(bool enabled)
{
setValue("Preferences/Bittorrent/AddTrackers", enabled);
}
QString Preferences::getTrackersList() const
{
return value("Preferences/Bittorrent/TrackersList").toString();
}
void Preferences::setTrackersList(const QString &val)
{
setValue("Preferences/Bittorrent/TrackersList", val);
}
qreal Preferences::getGlobalMaxRatio() const
{
return value("Preferences/Bittorrent/MaxRatio", -1).toDouble();

4
src/core/preferences.h

@ -270,6 +270,10 @@ public: @@ -270,6 +270,10 @@ public:
void setLSDEnabled(bool enabled);
int getEncryptionSetting() const;
void setEncryptionSetting(int val);
bool isAddTrackersEnabled() const;
void setAddTrackersEnabled(bool enabled);
QString getTrackersList() const;
void setTrackersList(const QString &val);
qreal getGlobalMaxRatio() const;
void setGlobalMaxRatio(qreal ratio);
MaxRatioAction getMaxRatioAction() const;

31
src/gui/options.ui

@ -2273,6 +2273,37 @@ @@ -2273,6 +2273,37 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="checkEnableAddTrackers">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Automatically add these trackers to new downloads:</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_16">
<item row="0" column="0">
<widget class="QPlainTextEdit" name="textTrackers">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_8">
<property name="orientation">

6
src/gui/options_imp.cpp

@ -249,6 +249,8 @@ options_imp::options_imp(QWidget *parent) @@ -249,6 +249,8 @@ options_imp::options_imp(QWidget *parent)
connect(spinMaxActiveUploads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxActiveTorrents, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkIgnoreSlowTorrentsForQueueing, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkEnableAddTrackers, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(textTrackers, SIGNAL(textChanged()), this, SLOT(enableApplyButton()));
#ifndef DISABLE_WEBUI
// Web UI tab
connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -468,6 +470,8 @@ void options_imp::saveOptions() @@ -468,6 +470,8 @@ void options_imp::saveOptions()
pref->setLSDEnabled(isLSDEnabled());
pref->setEncryptionSetting(getEncryptionSetting());
pref->enableAnonymousMode(checkAnonymousMode->isChecked());
pref->setAddTrackersEnabled(checkEnableAddTrackers->isChecked());
pref->setTrackersList(textTrackers->toPlainText());
pref->setGlobalMaxRatio(getMaxRatio());
pref->setMaxRatioAction(comboRatioLimitAct->currentIndex());
// End Bittorrent preferences
@ -783,6 +787,8 @@ void options_imp::loadOptions() @@ -783,6 +787,8 @@ void options_imp::loadOptions()
checkLSD->setChecked(pref->isLSDEnabled());
comboEncryption->setCurrentIndex(pref->getEncryptionSetting());
checkAnonymousMode->setChecked(pref->isAnonymousModeEnabled());
checkEnableAddTrackers->setChecked(pref->isAddTrackersEnabled());
textTrackers->setPlainText(pref->getTrackersList());
checkEnableQueueing->setChecked(pref->isQueueingSystemEnabled());
spinMaxActiveDownloads->setValue(pref->getMaxActiveDownloads());

Loading…
Cancel
Save