mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 13:58:51 +03:00
- Added DHT to trackers list
This commit is contained in:
parent
e2b8aeafa6
commit
e36e500045
6 changed files with 66 additions and 6 deletions
|
@ -15,7 +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: Display the number of peers returned by each tracker & DHT
|
||||||
- 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)
|
||||||
|
|
|
@ -170,7 +170,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void TransferListWidget::setRowColor(int row, QColor color) {
|
/*void TransferListWidget::setRowColor(int row, QColor color) {
|
||||||
unsigned int nbColumns = listModel->columnCount()-2;
|
unsigned int nbColumns = listModel->columnCount()-1;
|
||||||
for(unsigned int i=0; i<nbColumns; ++i) {
|
for(unsigned int i=0; i<nbColumns; ++i) {
|
||||||
listModel->setData(listModel->index(row, i), QVariant(color), Qt::ForegroundRole);
|
listModel->setData(listModel->index(row, i), QVariant(color), Qt::ForegroundRole);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1633,6 +1633,16 @@ void bittorrent::readAlerts() {
|
||||||
trackersInfos[h.hash()] = trackers_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());
|
||||||
}
|
}
|
||||||
|
} else if (dht_reply_alert* p = dynamic_cast<dht_reply_alert*>(a.get())) {
|
||||||
|
QTorrentHandle h(p->handle);
|
||||||
|
if(h.is_valid()){
|
||||||
|
// Connection was successful now but there is a warning message
|
||||||
|
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
|
||||||
|
TrackerInfos data = trackers_data.value("dht", TrackerInfos("dht"));
|
||||||
|
data.num_peers = p->num_peers;
|
||||||
|
trackers_data.insert("dht", data);
|
||||||
|
trackersInfos[h.hash()] = trackers_data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) {
|
else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) {
|
||||||
addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString(p->message().c_str())), QColor("red"));
|
addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString(p->message().c_str())), QColor("red"));
|
||||||
|
|
|
@ -386,6 +386,11 @@ bool QTorrentHandle::resolve_countries() const {
|
||||||
return h.resolve_countries();
|
return h.resolve_countries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QTorrentHandle::priv() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
|
return h.get_torrent_info().priv();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setters
|
// Setters
|
||||||
//
|
//
|
||||||
|
|
|
@ -121,6 +121,7 @@ class QTorrentHandle {
|
||||||
QString creation_date() const;
|
QString creation_date() const;
|
||||||
void get_peer_info(std::vector<peer_info>&) const;
|
void get_peer_info(std::vector<peer_info>&) const;
|
||||||
bool resolve_countries() const;
|
bool resolve_countries() const;
|
||||||
|
bool priv() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setters
|
// Setters
|
||||||
|
|
|
@ -38,12 +38,14 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QColor>
|
||||||
#include "propertieswidget.h"
|
#include "propertieswidget.h"
|
||||||
#include "trackersadditiondlg.h"
|
#include "trackersadditiondlg.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "bittorrent.h"
|
#include "bittorrent.h"
|
||||||
|
|
||||||
enum TrackerListColumn {COL_URL, COL_STATUS, COL_PEERS, COL_MSG};
|
enum TrackerListColumn {COL_URL, COL_STATUS, COL_PEERS, COL_MSG};
|
||||||
|
#define NB_STICKY_ITEM 1
|
||||||
|
|
||||||
class TrackerList: public QTreeWidget {
|
class TrackerList: public QTreeWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -51,6 +53,7 @@ class TrackerList: public QTreeWidget {
|
||||||
private:
|
private:
|
||||||
PropertiesWidget *properties;
|
PropertiesWidget *properties;
|
||||||
QHash<QString, QTreeWidgetItem*> tracker_items;
|
QHash<QString, QTreeWidgetItem*> tracker_items;
|
||||||
|
QTreeWidgetItem* dht_item;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
|
TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
|
||||||
|
@ -69,6 +72,9 @@ public:
|
||||||
header << tr("Peers");
|
header << tr("Peers");
|
||||||
header << tr("Message");
|
header << tr("Message");
|
||||||
setHeaderItem(new QTreeWidgetItem(header));
|
setHeaderItem(new QTreeWidgetItem(header));
|
||||||
|
dht_item = new QTreeWidgetItem(QStringList(tr("[DHT]")));
|
||||||
|
insertTopLevelItem(0, dht_item);
|
||||||
|
setRowColor(0, QColor("grey"));
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,19 +82,57 @@ public:
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QList<QTreeWidgetItem*> getSelectedTrackerItems() const {
|
||||||
|
QList<QTreeWidgetItem*> selected_items = selectedItems();
|
||||||
|
QList<QTreeWidgetItem*> selected_trackers;
|
||||||
|
foreach(QTreeWidgetItem *item, selectedItems()) {
|
||||||
|
if(indexOfTopLevelItem(item) >= NB_STICKY_ITEM) { // Ignore STICKY ITEMS
|
||||||
|
selected_trackers << item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selected_trackers;
|
||||||
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
void setRowColor(int row, QColor color) {
|
||||||
|
unsigned int nbColumns = columnCount();
|
||||||
|
QTreeWidgetItem *item = topLevelItem(row);
|
||||||
|
for(unsigned int i=0; i<nbColumns; ++i) {
|
||||||
|
item->setData(i, Qt::ForegroundRole, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
qDeleteAll(tracker_items.values());
|
qDeleteAll(tracker_items.values());
|
||||||
tracker_items.clear();
|
tracker_items.clear();
|
||||||
|
dht_item->setText(COL_PEERS, "");
|
||||||
|
dht_item->setText(COL_STATUS, "");
|
||||||
|
dht_item->setText(COL_MSG, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadStickyItems(const QTorrentHandle &h, QHash<QString, TrackerInfos> trackers_data) {
|
||||||
|
// load DHT information
|
||||||
|
if(properties->getBTSession()->isDHTEnabled() && !h.priv()) {
|
||||||
|
dht_item->setText(COL_STATUS, tr("Working"));
|
||||||
|
} else {
|
||||||
|
dht_item->setText(COL_STATUS, tr("Disabled"));
|
||||||
|
}
|
||||||
|
dht_item->setText(COL_PEERS, QString::number(trackers_data.value("dht", TrackerInfos("dht")).num_peers));
|
||||||
|
if(h.priv()) {
|
||||||
|
dht_item->setText(COL_MSG, tr("This torrent is private"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadTrackers() {
|
void loadTrackers() {
|
||||||
QStringList old_trackers_urls = tracker_items.keys();
|
|
||||||
// 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, TrackerInfos> trackers_data = properties->getBTSession()->getTrackersInfo(h.hash());
|
QHash<QString, TrackerInfos> trackers_data = properties->getBTSession()->getTrackersInfo(h.hash());
|
||||||
|
loadStickyItems(h, trackers_data);
|
||||||
|
// Load actual trackers information
|
||||||
|
QStringList old_trackers_urls = tracker_items.keys();
|
||||||
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++) {
|
||||||
|
@ -151,7 +195,7 @@ public slots:
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<QTreeWidgetItem *> selected_items = selectedItems();
|
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
|
||||||
if(selected_items.isEmpty()) return;
|
if(selected_items.isEmpty()) return;
|
||||||
QStringList urls_to_remove;
|
QStringList urls_to_remove;
|
||||||
foreach(QTreeWidgetItem *item, selected_items){
|
foreach(QTreeWidgetItem *item, selected_items){
|
||||||
|
@ -181,12 +225,12 @@ public slots:
|
||||||
}
|
}
|
||||||
|
|
||||||
void showTrackerListMenu(QPoint) {
|
void showTrackerListMenu(QPoint) {
|
||||||
QList<QTreeWidgetItem*> selected_items = selectedItems();
|
QList<QTreeWidgetItem*> selected_items = getSelectedTrackerItems();
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
// Add actions
|
// Add actions
|
||||||
QAction *addAct = menu.addAction(QIcon(":/Icons/oxygen/list-add.png"), tr("Add a new tracker"));
|
QAction *addAct = menu.addAction(QIcon(":/Icons/oxygen/list-add.png"), tr("Add a new tracker"));
|
||||||
QAction *delAct = 0;
|
QAction *delAct = 0;
|
||||||
if(!selectedItems().isEmpty()) {
|
if(!getSelectedTrackerItems().isEmpty()) {
|
||||||
delAct = menu.addAction(QIcon(":/Icons/oxygen/list-remove.png"), "Remove tracker");
|
delAct = menu.addAction(QIcon(":/Icons/oxygen/list-remove.png"), "Remove tracker");
|
||||||
}
|
}
|
||||||
QAction *act = menu.exec(QCursor::pos());
|
QAction *act = menu.exec(QCursor::pos());
|
||||||
|
|
Loading…
Reference in a new issue