From f4a9597ae85efcbce01cd3b1ec0937fc96347328 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sat, 10 May 2014 00:13:20 +0300 Subject: [PATCH] Fix libtorrent 1.0.0 compilation. Closes #1659 Conflicts: src/properties/peerlistwidget.cpp --- src/properties/peerlistwidget.cpp | 23 ++++++++++++++++------- src/properties/peerlistwidget.h | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/properties/peerlistwidget.cpp b/src/properties/peerlistwidget.cpp index b6c55fcae..4f7a185fd 100644 --- a/src/properties/peerlistwidget.cpp +++ b/src/properties/peerlistwidget.cpp @@ -382,7 +382,7 @@ QStandardItem* PeerListWidget::addPeer(const QString& ip, const peer_info& peer) m_missingFlags.insert(ip); } } - m_listModel->setData(m_listModel->index(row, PeerListDelegate::CONNECTION), getConnectionString(peer.connection_type)); + m_listModel->setData(m_listModel->index(row, PeerListDelegate::CONNECTION), getConnectionString(peer)); QString flags, tooltip; getFlags(peer, flags, tooltip); m_listModel->setData(m_listModel->index(row, PeerListDelegate::FLAGS), flags); @@ -408,7 +408,7 @@ void PeerListWidget::updatePeer(const QString& ip, const peer_info& peer) { m_missingFlags.remove(ip); } } - m_listModel->setData(m_listModel->index(row, PeerListDelegate::CONNECTION), getConnectionString(peer.connection_type)); + m_listModel->setData(m_listModel->index(row, PeerListDelegate::CONNECTION), getConnectionString(peer)); QString flags, tooltip; getFlags(peer, flags, tooltip); m_listModel->setData(m_listModel->index(row, PeerListDelegate::FLAGS), flags); @@ -439,14 +439,19 @@ void PeerListWidget::handleSortColumnChanged(int col) } } -QString PeerListWidget::getConnectionString(int connection_type) +QString PeerListWidget::getConnectionString(const peer_info& peer) { +#if LIBTORRENT_VERSION_NUM < 10000 + if (peer.connection_type & peer_info::bittorrent_utp) { +#else + if (peer.flags & peer_info::utp_socket) { +#endif + return QString::fromUtf8("μTP"); + } + QString connection; - switch(connection_type) { + switch(peer.connection_type) { #if LIBTORRENT_VERSION_NUM >= 1600 - case peer_info::bittorrent_utp: - connection = "uTP"; - break; case peer_info::http_seed: #endif case peer_info::web_seed: @@ -555,7 +560,11 @@ void PeerListWidget::getFlags(const peer_info& peer, QString& flags, QString& to } #if LIBTORRENT_VERSION_NUM > 1500 //P = Peer is using uTorrent uTP +#if LIBTORRENT_VERSION_NUM < 10000 if (peer.connection_type & peer_info::bittorrent_utp) { +#else + if (peer.flags & peer_info::utp_socket) { +#endif flags += "P "; tooltip += QString::fromUtf8("μTP"); tooltip += ", "; diff --git a/src/properties/peerlistwidget.h b/src/properties/peerlistwidget.h index c85f8fda2..f372d2a0c 100644 --- a/src/properties/peerlistwidget.h +++ b/src/properties/peerlistwidget.h @@ -83,7 +83,7 @@ protected slots: void handleSortColumnChanged(int col); private: - static QString getConnectionString(int connection_type); + static QString getConnectionString(const libtorrent::peer_info &peer); static void getFlags(const libtorrent::peer_info& peer, QString& flags, QString& tooltip); private: