Browse Source

- Improve tracker status detection when using libtorrent v0.14

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
c52e0cf841
  1. 10
      src/bittorrent.cpp
  2. 9
      src/bittorrent.h
  3. 5
      src/trackerlist.h

10
src/bittorrent.cpp

@ -1512,7 +1512,8 @@ void Bittorrent::readAlerts() { @@ -1512,7 +1512,8 @@ void Bittorrent::readAlerts() {
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
data.last_message = misc::toQString(p->msg);
#ifndef LIBTORRENT_0_15
data.simply_warning = false;
data.verified = false;
++data.fail_count;
#endif
trackers_data.insert(tracker_url, data);
trackersInfos[h.hash()] = trackers_data;
@ -1531,6 +1532,10 @@ void Bittorrent::readAlerts() { @@ -1531,6 +1532,10 @@ void Bittorrent::readAlerts() {
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
data.last_message = ""; // Reset error/warning message
data.num_peers = p->num_peers;
#ifndef LIBTORRENT_0_15
data.fail_count = 0;
data.verified = true;
#endif
trackers_data.insert(tracker_url, data);
trackersInfos[h.hash()] = trackers_data;
}
@ -1543,7 +1548,8 @@ void Bittorrent::readAlerts() { @@ -1543,7 +1548,8 @@ void Bittorrent::readAlerts() {
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
data.last_message = misc::toQString(p->msg); // Store warning message
#ifndef LIBTORRENT_0_15
data.simply_warning = true;
data.verified = true;
data.fail_count = 0;
#endif
trackers_data.insert(tracker_url, data);
trackersInfos[h.hash()] = trackers_data;

9
src/bittorrent.h

@ -56,7 +56,8 @@ public: @@ -56,7 +56,8 @@ public:
QString last_message;
unsigned long num_peers;
#ifndef LIBTORRENT_0_15
bool simply_warning;
bool verified;
uint fail_count;
#endif
//TrackerInfos() {}
@ -66,12 +67,14 @@ public: @@ -66,12 +67,14 @@ public:
last_message = b.last_message;
num_peers = b.num_peers;
#ifndef LIBTORRENT_0_15
simply_warning = b.simply_warning;
verified = b.verified;
fail_count = b.fail_count;
#endif
}
TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) {
#ifndef LIBTORRENT_0_15
simply_warning = false;
fail_count = 0;
verified = false;
#endif
}
};

5
src/trackerlist.h

@ -201,10 +201,13 @@ public slots: @@ -201,10 +201,13 @@ public slots:
}
}
#else
if(error_message.isEmpty() || data.simply_warning) {
if(data.verified) {
item->setText(COL_STATUS, tr("Working"));
} else {
if(data.fail_count > 0)
item->setText(COL_STATUS, tr("Not working"));
else
item->setText(COL_STATUS, tr("Not contacted yet"));
}
#endif
item->setText(COL_PEERS, QString::number(trackers_data.value(tracker_url, TrackerInfos(tracker_url)).num_peers));

Loading…
Cancel
Save