Browse Source

Improve handling the case when torrent enters/leaves trackerless state

PR #19658.
adaptive-webui-19844
Vladimir Golovnev 1 year ago committed by GitHub
parent
commit
16111496ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/base/bittorrent/session.h
  2. 4
      src/base/bittorrent/sessionimpl.cpp
  3. 1
      src/gui/mainwindow.cpp
  4. 23
      src/gui/transferlistfilters/trackersfilterwidget.cpp
  5. 1
      src/gui/transferlistfilters/trackersfilterwidget.h
  6. 5
      src/gui/transferlistfilterswidget.cpp
  7. 1
      src/gui/transferlistfilterswidget.h

1
src/base/bittorrent/session.h

@ -484,7 +484,6 @@ namespace BitTorrent
void torrentTagAdded(Torrent *torrent, const QString &tag); void torrentTagAdded(Torrent *torrent, const QString &tag);
void torrentTagRemoved(Torrent *torrent, const QString &tag); void torrentTagRemoved(Torrent *torrent, const QString &tag);
void trackerError(Torrent *torrent, const QString &tracker); void trackerError(Torrent *torrent, const QString &tracker);
void trackerlessStateChanged(Torrent *torrent, bool trackerless);
void trackersAdded(Torrent *torrent, const QVector<TrackerEntry> &trackers); void trackersAdded(Torrent *torrent, const QVector<TrackerEntry> &trackers);
void trackersChanged(Torrent *torrent); void trackersChanged(Torrent *torrent);
void trackersRemoved(Torrent *torrent, const QStringList &trackers); void trackersRemoved(Torrent *torrent, const QStringList &trackers);

4
src/base/bittorrent/sessionimpl.cpp

@ -4815,8 +4815,6 @@ void SessionImpl::handleTorrentTrackersAdded(TorrentImpl *const torrent, const Q
for (const TrackerEntry &newTracker : newTrackers) for (const TrackerEntry &newTracker : newTrackers)
LogMsg(tr("Added tracker to torrent. Torrent: \"%1\". Tracker: \"%2\"").arg(torrent->name(), newTracker.url)); LogMsg(tr("Added tracker to torrent. Torrent: \"%1\". Tracker: \"%2\"").arg(torrent->name(), newTracker.url));
emit trackersAdded(torrent, newTrackers); emit trackersAdded(torrent, newTrackers);
if (torrent->trackers().size() == newTrackers.size())
emit trackerlessStateChanged(torrent, false);
emit trackersChanged(torrent); emit trackersChanged(torrent);
} }
@ -4825,8 +4823,6 @@ void SessionImpl::handleTorrentTrackersRemoved(TorrentImpl *const torrent, const
for (const QString &deletedTracker : deletedTrackers) for (const QString &deletedTracker : deletedTrackers)
LogMsg(tr("Removed tracker from torrent. Torrent: \"%1\". Tracker: \"%2\"").arg(torrent->name(), deletedTracker)); LogMsg(tr("Removed tracker from torrent. Torrent: \"%1\". Tracker: \"%2\"").arg(torrent->name(), deletedTracker));
emit trackersRemoved(torrent, deletedTrackers); emit trackersRemoved(torrent, deletedTrackers);
if (torrent->trackers().isEmpty())
emit trackerlessStateChanged(torrent, true);
emit trackersChanged(torrent); emit trackersChanged(torrent);
} }

1
src/gui/mainwindow.cpp

@ -1377,7 +1377,6 @@ void MainWindow::showFiltersSidebar(const bool show)
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersAdded, m_transferListFiltersWidget, &TransferListFiltersWidget::addTrackers); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersAdded, m_transferListFiltersWidget, &TransferListFiltersWidget::addTrackers);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::refreshTrackers); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::refreshTrackers);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerEntriesUpdated, m_transferListFiltersWidget, &TransferListFiltersWidget::trackerEntriesUpdated); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerEntriesUpdated, m_transferListFiltersWidget, &TransferListFiltersWidget::trackerEntriesUpdated);
m_splitter->insertWidget(0, m_transferListFiltersWidget); m_splitter->insertWidget(0, m_transferListFiltersWidget);

23
src/gui/transferlistfilters/trackersfilterwidget.cpp

@ -117,15 +117,22 @@ TrackersFilterWidget::~TrackersFilterWidget()
void TrackersFilterWidget::addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers) void TrackersFilterWidget::addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers)
{ {
const BitTorrent::TorrentID torrentID = torrent->id(); const BitTorrent::TorrentID torrentID = torrent->id();
for (const BitTorrent::TrackerEntry &tracker : trackers) for (const BitTorrent::TrackerEntry &tracker : trackers)
addItems(tracker.url, {torrentID}); addItems(tracker.url, {torrentID});
removeItem(NULL_HOST, torrentID);
} }
void TrackersFilterWidget::removeTrackers(const BitTorrent::Torrent *torrent, const QStringList &trackers) void TrackersFilterWidget::removeTrackers(const BitTorrent::Torrent *torrent, const QStringList &trackers)
{ {
const BitTorrent::TorrentID torrentID = torrent->id(); const BitTorrent::TorrentID torrentID = torrent->id();
for (const QString &tracker : trackers) for (const QString &tracker : trackers)
removeItem(tracker, torrentID); removeItem(tracker, torrentID);
if (torrent->trackers().isEmpty())
addItems(NULL_HOST, {torrentID});
} }
void TrackersFilterWidget::refreshTrackers(const BitTorrent::Torrent *torrent) void TrackersFilterWidget::refreshTrackers(const BitTorrent::Torrent *torrent)
@ -167,15 +174,15 @@ void TrackersFilterWidget::refreshTrackers(const BitTorrent::Torrent *torrent)
addItems(trackerEntry.url, {torrentID}); addItems(trackerEntry.url, {torrentID});
} }
updateGeometry(); item(ERROR_ROW)->setText(tr("Error (%1)").arg(m_errors.size()));
} item(WARNING_ROW)->setText(tr("Warning (%1)").arg(m_warnings.size()));
void TrackersFilterWidget::changeTrackerless(const BitTorrent::Torrent *torrent, const bool trackerless) if (currentRow() == ERROR_ROW)
{ applyFilter(ERROR_ROW);
if (trackerless) else if (currentRow() == WARNING_ROW)
addItems(NULL_HOST, {torrent->id()}); applyFilter(WARNING_ROW);
else
removeItem(NULL_HOST, torrent->id()); updateGeometry();
} }
void TrackersFilterWidget::addItems(const QString &trackerURL, const QVector<BitTorrent::TorrentID> &torrents) void TrackersFilterWidget::addItems(const QString &trackerURL, const QVector<BitTorrent::TorrentID> &torrents)

1
src/gui/transferlistfilters/trackersfilterwidget.h

@ -55,7 +55,6 @@ public:
void addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers); void addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers);
void removeTrackers(const BitTorrent::Torrent *torrent, const QStringList &trackers); void removeTrackers(const BitTorrent::Torrent *torrent, const QStringList &trackers);
void refreshTrackers(const BitTorrent::Torrent *torrent); void refreshTrackers(const BitTorrent::Torrent *torrent);
void changeTrackerless(const BitTorrent::Torrent *torrent, bool trackerless);
void handleTrackerEntriesUpdated(const BitTorrent::Torrent *torrent void handleTrackerEntriesUpdated(const BitTorrent::Torrent *torrent
, const QHash<QString, BitTorrent::TrackerEntry> &updatedTrackerEntries); , const QHash<QString, BitTorrent::TrackerEntry> &updatedTrackerEntries);
void setDownloadTrackerFavicon(bool value); void setDownloadTrackerFavicon(bool value);

5
src/gui/transferlistfilterswidget.cpp

@ -191,11 +191,6 @@ void TransferListFiltersWidget::refreshTrackers(const BitTorrent::Torrent *torre
m_trackersFilterWidget->refreshTrackers(torrent); m_trackersFilterWidget->refreshTrackers(torrent);
} }
void TransferListFiltersWidget::changeTrackerless(const BitTorrent::Torrent *torrent, const bool trackerless)
{
m_trackersFilterWidget->changeTrackerless(torrent, trackerless);
}
void TransferListFiltersWidget::trackerEntriesUpdated(const BitTorrent::Torrent *torrent void TransferListFiltersWidget::trackerEntriesUpdated(const BitTorrent::Torrent *torrent
, const QHash<QString, BitTorrent::TrackerEntry> &updatedTrackerEntries) , const QHash<QString, BitTorrent::TrackerEntry> &updatedTrackerEntries)
{ {

1
src/gui/transferlistfilterswidget.h

@ -55,7 +55,6 @@ public slots:
void addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers); void addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers);
void removeTrackers(const BitTorrent::Torrent *torrent, const QStringList &trackers); void removeTrackers(const BitTorrent::Torrent *torrent, const QStringList &trackers);
void refreshTrackers(const BitTorrent::Torrent *torrent); void refreshTrackers(const BitTorrent::Torrent *torrent);
void changeTrackerless(const BitTorrent::Torrent *torrent, bool trackerless);
void trackerEntriesUpdated(const BitTorrent::Torrent *torrent void trackerEntriesUpdated(const BitTorrent::Torrent *torrent
, const QHash<QString, BitTorrent::TrackerEntry> &updatedTrackerEntries); , const QHash<QString, BitTorrent::TrackerEntry> &updatedTrackerEntries);

Loading…
Cancel
Save