mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
- FEATURE: Display the number of peers returned by each tracker
This commit is contained in:
parent
484a75ad64
commit
e2b8aeafa6
@ -15,6 +15,7 @@
|
|||||||
- FEATURE: Display total amounts transferred in status bar
|
- FEATURE: Display total amounts transferred in status bar
|
||||||
- FEATURE: Announce to all trackers specified for a torrent (µTorrent behavior)
|
- FEATURE: Announce to all trackers specified for a torrent (µTorrent behavior)
|
||||||
- FEATURE: Display trackers status as well as error/warning messages
|
- FEATURE: Display trackers status as well as error/warning messages
|
||||||
|
- FEATURE: Display the number of peers returned by each tracker
|
||||||
- FEATURE: Global upload/download speeds can be capped from status bar (µTorrent behavior)
|
- FEATURE: Global upload/download speeds can be capped from status bar (µTorrent behavior)
|
||||||
- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is now required)
|
- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is now required)
|
||||||
- FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only)
|
- FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only)
|
||||||
|
@ -578,7 +578,7 @@ void bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
|
|||||||
}
|
}
|
||||||
TorrentPersistentData::deletePersistentData(hash);
|
TorrentPersistentData::deletePersistentData(hash);
|
||||||
// Remove tracker errors
|
// Remove tracker errors
|
||||||
trackersErrors.remove(hash);
|
trackersInfos.remove(hash);
|
||||||
if(delete_local_files)
|
if(delete_local_files)
|
||||||
addConsoleMessage(tr("'%1' was removed from transfer list and hard disk.", "'xxx.avi' was removed...").arg(fileName));
|
addConsoleMessage(tr("'%1' was removed from transfer list and hard disk.", "'xxx.avi' was removed...").arg(fileName));
|
||||||
else
|
else
|
||||||
@ -1597,7 +1597,12 @@ void bittorrent::readAlerts() {
|
|||||||
// Authentication
|
// Authentication
|
||||||
if(p->status_code != 401) {
|
if(p->status_code != 401) {
|
||||||
qDebug("Received a tracker error for %s: %s", p->url.c_str(), p->msg.c_str());
|
qDebug("Received a tracker error for %s: %s", p->url.c_str(), p->msg.c_str());
|
||||||
trackersErrors[h.hash()][misc::toQString(p->url)] = misc::toQString(p->message());
|
QString tracker_url = misc::toQString(p->url);
|
||||||
|
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
||||||
|
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
|
||||||
|
data.last_message = misc::toQString(p->msg);
|
||||||
|
trackers_data.insert(tracker_url, data);
|
||||||
|
trackersInfos[h.hash()] = trackers_data;
|
||||||
} else {
|
} else {
|
||||||
emit trackerAuthenticationRequired(h);
|
emit trackerAuthenticationRequired(h);
|
||||||
}
|
}
|
||||||
@ -1608,17 +1613,24 @@ void bittorrent::readAlerts() {
|
|||||||
if(h.is_valid()){
|
if(h.is_valid()){
|
||||||
qDebug("Received a tracker reply from %s", p->url.c_str());
|
qDebug("Received a tracker reply from %s", p->url.c_str());
|
||||||
// Connection was successful now. Remove possible old errors
|
// Connection was successful now. Remove possible old errors
|
||||||
QHash<QString, QString> errors = trackersErrors.value(h.hash(), QHash<QString, QString>());
|
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
||||||
errors.remove(misc::toQString(p->url));
|
QString tracker_url = misc::toQString(p->url);
|
||||||
trackersErrors[h.hash()] = errors;
|
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
|
||||||
|
data.last_message = ""; // Reset error/warning message
|
||||||
|
data.num_peers = p->num_peers;
|
||||||
|
trackers_data.insert(tracker_url, data);
|
||||||
|
trackersInfos[h.hash()] = trackers_data;
|
||||||
}
|
}
|
||||||
} else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get())) {
|
} else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get())) {
|
||||||
QTorrentHandle h(p->handle);
|
QTorrentHandle h(p->handle);
|
||||||
if(h.is_valid()){
|
if(h.is_valid()){
|
||||||
// Connection was successful now. Remove possible old errors
|
// Connection was successful now but there is a warning message
|
||||||
QHash<QString, QString> errors = trackersErrors.value(h.hash(), QHash<QString, QString>());
|
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
||||||
errors[misc::toQString(p->url)] = misc::toQString(p->msg);
|
QString tracker_url = misc::toQString(p->url);
|
||||||
trackersErrors[h.hash()] = errors;
|
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
|
||||||
|
data.last_message = misc::toQString(p->msg); // Store warning message
|
||||||
|
trackers_data.insert(tracker_url, data);
|
||||||
|
trackersInfos[h.hash()] = trackers_data;
|
||||||
qDebug("Received a tracker warning from %s: %s", p->url.c_str(), p->msg.c_str());
|
qDebug("Received a tracker warning from %s: %s", p->url.c_str(), p->msg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1673,8 +1685,8 @@ void bittorrent::readAlerts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, QString> bittorrent::getTrackersErrors(QString hash) const{
|
QHash<QString, TrackerInfos> bittorrent::getTrackersInfo(QString hash) const{
|
||||||
return trackersErrors.value(hash, QHash<QString, QString>());
|
return trackersInfos.value(hash, QHash<QString, TrackerInfos>());
|
||||||
}
|
}
|
||||||
|
|
||||||
int bittorrent::getListenPort() const{
|
int bittorrent::getListenPort() const{
|
||||||
|
@ -50,6 +50,25 @@ class FileSystemWatcher;
|
|||||||
class FilterParserThread;
|
class FilterParserThread;
|
||||||
class HttpServer;
|
class HttpServer;
|
||||||
|
|
||||||
|
class TrackerInfos {
|
||||||
|
public:
|
||||||
|
QString name_or_url;
|
||||||
|
QString last_message;
|
||||||
|
unsigned long num_peers;
|
||||||
|
|
||||||
|
//TrackerInfos() {}
|
||||||
|
TrackerInfos(const TrackerInfos &b) {
|
||||||
|
qDebug("TrackerInfos copy contructor called");
|
||||||
|
name_or_url = b.name_or_url;
|
||||||
|
Q_ASSERT(!name_or_url.isEmpty());
|
||||||
|
last_message = b.last_message;
|
||||||
|
qDebug("Copied message: %s", last_message.toLocal8Bit().data());
|
||||||
|
num_peers = b.num_peers;
|
||||||
|
}
|
||||||
|
TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class bittorrent : public QObject {
|
class bittorrent : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -58,7 +77,7 @@ private:
|
|||||||
session *s;
|
session *s;
|
||||||
QPointer<QTimer> timerAlerts;
|
QPointer<QTimer> timerAlerts;
|
||||||
QHash<QString, QString> savepath_fromurl;
|
QHash<QString, QString> savepath_fromurl;
|
||||||
QHash<QString, QHash<QString, QString> > trackersErrors;
|
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
||||||
// Ratio
|
// Ratio
|
||||||
QPointer<QTimer> BigRatioTimer;
|
QPointer<QTimer> BigRatioTimer;
|
||||||
// HTTP
|
// HTTP
|
||||||
@ -110,7 +129,7 @@ public:
|
|||||||
int getListenPort() const;
|
int getListenPort() const;
|
||||||
float getRealRatio(QString hash) const;
|
float getRealRatio(QString hash) const;
|
||||||
session* getSession() const;
|
session* getSession() const;
|
||||||
QHash<QString, QString> getTrackersErrors(QString hash) const;
|
QHash<QString, TrackerInfos> getTrackersInfo(QString hash) const;
|
||||||
bool has_filtered_files(QString hash) const;
|
bool has_filtered_files(QString hash) const;
|
||||||
bool hasActiveTorrents() const;
|
bool hasActiveTorrents() const;
|
||||||
bool isQueueingEnabled() const;
|
bool isQueueingEnabled() const;
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "bittorrent.h"
|
#include "bittorrent.h"
|
||||||
|
|
||||||
enum TrackerListColumn {COL_URL, COL_STATUS, COL_MSG};
|
enum TrackerListColumn {COL_URL, COL_STATUS, COL_PEERS, COL_MSG};
|
||||||
|
|
||||||
class TrackerList: public QTreeWidget {
|
class TrackerList: public QTreeWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -66,6 +66,7 @@ public:
|
|||||||
QStringList header;
|
QStringList header;
|
||||||
header << tr("URL");
|
header << tr("URL");
|
||||||
header << tr("Status");
|
header << tr("Status");
|
||||||
|
header << tr("Peers");
|
||||||
header << tr("Message");
|
header << tr("Message");
|
||||||
setHeaderItem(new QTreeWidgetItem(header));
|
setHeaderItem(new QTreeWidgetItem(header));
|
||||||
loadSettings();
|
loadSettings();
|
||||||
@ -87,7 +88,7 @@ public slots:
|
|||||||
// Load trackers from torrent handle
|
// Load trackers from torrent handle
|
||||||
QTorrentHandle h = properties->getCurrentTorrent();
|
QTorrentHandle h = properties->getCurrentTorrent();
|
||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
QHash<QString, QString> errors = properties->getBTSession()->getTrackersErrors(h.hash());
|
QHash<QString, TrackerInfos> trackers_data = properties->getBTSession()->getTrackersInfo(h.hash());
|
||||||
std::vector<announce_entry> trackers = h.trackers();
|
std::vector<announce_entry> trackers = h.trackers();
|
||||||
std::vector<announce_entry>::iterator it;
|
std::vector<announce_entry>::iterator it;
|
||||||
for(it = trackers.begin(); it != trackers.end(); it++) {
|
for(it = trackers.begin(); it != trackers.end(); it++) {
|
||||||
@ -105,7 +106,7 @@ public slots:
|
|||||||
if((*it).verified) {
|
if((*it).verified) {
|
||||||
item->setText(COL_STATUS, tr("Working"));
|
item->setText(COL_STATUS, tr("Working"));
|
||||||
} else {
|
} else {
|
||||||
if((*it).updating) {
|
if((*it).updating && (*it).fails == 0) {
|
||||||
item->setText(COL_STATUS, tr("Updating..."));
|
item->setText(COL_STATUS, tr("Updating..."));
|
||||||
} else {
|
} else {
|
||||||
if((*it).fails > 0) {
|
if((*it).fails > 0) {
|
||||||
@ -115,7 +116,8 @@ public slots:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item->setText(COL_MSG, errors.value(tracker_url, ""));
|
item->setText(COL_PEERS, QString::number(trackers_data.value(tracker_url, TrackerInfos(tracker_url)).num_peers));
|
||||||
|
item->setText(COL_MSG, trackers_data.value(tracker_url, TrackerInfos(tracker_url)).last_message);
|
||||||
}
|
}
|
||||||
// Remove old trackers
|
// Remove old trackers
|
||||||
foreach(const QString &tracker, old_trackers_urls) {
|
foreach(const QString &tracker, old_trackers_urls) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user