From 4412476109ddb444caeec20586aa427155728225 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 16 Apr 2011 20:08:32 +0000 Subject: [PATCH] Started to fix compilation with libtorrent v0.16 --- src/qtlibtorrent/qbtsession.cpp | 21 ++++++++++++++++----- src/qtlibtorrent/qtorrenthandle.cpp | 19 +++++++++++++++++++ src/qtlibtorrent/qtorrenthandle.h | 1 + 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index c4bfbc9d3..ccb8cb1b9 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -54,6 +54,7 @@ #include "httpserver.h" #include "qinisettings.h" #include "bandwidthscheduler.h" +#include #include #include #if LIBTORRENT_VERSION_MINOR > 14 @@ -67,7 +68,6 @@ #include #include #include -#include #include #include #include @@ -427,24 +427,35 @@ void QBtSession::configureSession() { // IP address to announce to trackers QString announce_ip = pref.getNetworkAddress(); if(!announce_ip.isEmpty()) { +#if LIBTORRENT_VERSION_MINOR > 15 + sessionSettings.announce_ip = announce_ip.toStdString(); +#else boost::system::error_code ec; boost::asio::ip::address addr = boost::asio::ip::address::from_string(announce_ip.toStdString(), ec); if(!ec) { addConsoleMessage(tr("Reporting IP address %1 to trackers...").arg(announce_ip)); sessionSettings.announce_ip = addr; } +#endif } // Super seeding #if LIBTORRENT_VERSION_MINOR > 14 sessionSettings.strict_super_seeding = pref.isSuperSeedingEnabled(); #endif - qDebug() << "Settings SessionSettings"; - setSessionSettings(sessionSettings); - // Bittorrent +#if LIBTORRENT_VERSION_MINOR > 15 + // * Max Half-open connections + sessionSettings.half_open_limit = pref.getMaxHalfOpenConnections(); + // * Max connections limit + sessionSettings.connections_limit = pref.getMaxConnecs(); +#else // * Max Half-open connections s->set_max_half_open_connections(pref.getMaxHalfOpenConnections()); // * Max connections limit setMaxConnections(pref.getMaxConnecs()); +#endif + qDebug() << "Settings SessionSettings"; + setSessionSettings(sessionSettings); + // Bittorrent // * Max connections per torrent limit setMaxConnectionsPerTorrent(pref.getMaxConnecsPerTorrent()); // * Max uploads per torrent limit @@ -627,7 +638,7 @@ void QBtSession::initWebUi() { } } else { if(httpServer) - delete httpServer; + delete httpServer; if(m_dynDNSUpdater) { delete m_dynDNSUpdater; m_dynDNSUpdater = 0; diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index 775a893ad..1689b0472 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -107,11 +107,21 @@ QString QTorrentHandle::current_tracker() const { } bool QTorrentHandle::is_paused() const { +#if LIBTORRENT_VERSION_MINOR > 15 + torrent_status status = torrent_handle::status(0x0); + return status.paused && !status.auto_managed; +#else return torrent_handle::is_paused() && !torrent_handle::is_auto_managed(); +#endif } bool QTorrentHandle::is_queued() const { +#if LIBTORRENT_VERSION_MINOR > 15 + torrent_status status = torrent_handle::status(0x0); + return status.paused && status.auto_managed; +#else return torrent_handle::is_paused() && torrent_handle::is_auto_managed(); +#endif } size_type QTorrentHandle::total_size() const { @@ -422,6 +432,15 @@ void QTorrentHandle::downloading_pieces(bitfield &bf) const { return; } +bool QTorrentHandle::has_metadata() const { +#if LIBTORRENT_VERSION_MINOR > 15 + torrent_status st = torrent_handle::status(0x0); + return st.has_metadata; +#else + return torrent_handle::has_metadata(); +#endif +} + // // Setters // diff --git a/src/qtlibtorrent/qtorrenthandle.h b/src/qtlibtorrent/qtorrenthandle.h index 6fc1dced7..33bd79876 100644 --- a/src/qtlibtorrent/qtorrenthandle.h +++ b/src/qtlibtorrent/qtorrenthandle.h @@ -117,6 +117,7 @@ public: bool has_error() const; QString error() const; void downloading_pieces(libtorrent::bitfield &bf) const; + bool has_metadata() const; // // Setters