diff --git a/src/misc.h b/src/misc.h index 6aeb2db90..16a52a721 100644 --- a/src/misc.h +++ b/src/misc.h @@ -70,7 +70,7 @@ namespace misc inline QString toQString(const libtorrent::sha1_hash &hash) { char out[41]; - to_hex((char const*)&hash[0], libtorrent::sha1_hash::size, out); + libtorrent::to_hex((char const*)&hash[0], libtorrent::sha1_hash::size, out); return QString(out); } diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 7cdc916b7..38dcb90a8 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -67,13 +67,16 @@ #include #include #include -#include -#include #include #include #include #include "dnsupdater.h" +#if LIBTORRENT_VERSION_MAJOR < 1 +#include +#include +#endif + //initialize static member variables QHash TorrentTempData::data = QHash(); QHash HiddenData::data = QHash(); @@ -106,8 +109,11 @@ QBtSession::QBtSession() #ifndef DISABLE_GUI , geoipDBLoaded(false), resolve_countries(false) #endif - , m_tracker(0), m_shutdownAct(NO_SHUTDOWN), - m_upnp(0), m_natpmp(0), m_dynDNSUpdater(0) + , m_tracker(0), m_shutdownAct(NO_SHUTDOWN) + #if LIBTORRENT_VERSION_MAJOR < 1 + , m_upnp(0), m_natpmp(0) + #endif + , m_dynDNSUpdater(0) { BigRatioTimer = new QTimer(this); BigRatioTimer->setInterval(10000); @@ -1106,7 +1112,11 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr if (resumed) { if (loadFastResumeData(hash, buf)) { fastResume = true; +#if LIBTORRENT_VERSION_MAJOR < 1 p.resume_data = &buf; +#else + p.resume_data = buf; +#endif qDebug("Successfully loaded fast resume data"); } } @@ -1431,25 +1441,33 @@ void QBtSession::setMaxUploadsPerTorrent(int max) { void QBtSession::enableUPnP(bool b) { Preferences pref; if (b) { - if (!m_upnp) { - qDebug("Enabling UPnP / NAT-PMP"); - m_upnp = s->start_upnp(); - m_natpmp = s->start_natpmp(); - } + qDebug("Enabling UPnP / NAT-PMP"); +#if LIBTORRENT_VERSION_MAJOR < 1 + m_upnp = s->start_upnp(); + m_natpmp = s->start_natpmp(); +#else + s->start_upnp(); + s->start_natpmp(); +#endif // Use UPnP/NAT-PMP for Web UI too if (pref.isWebUiEnabled() && pref.useUPnPForWebUIPort()) { const qint16 port = pref.getWebUiPort(); +#if LIBTORRENT_VERSION_MAJOR < 1 m_upnp->add_mapping(upnp::tcp, port, port); m_natpmp->add_mapping(natpmp::tcp, port, port); +#else + s->add_port_mapping(session::tcp, port, port); +#endif } } else { - if (m_upnp) { - qDebug("Disabling UPnP / NAT-PMP"); - s->stop_upnp(); - s->stop_natpmp(); - m_upnp = 0; - m_natpmp = 0; - } + qDebug("Disabling UPnP / NAT-PMP"); + s->stop_upnp(); + s->stop_natpmp(); + +#if LIBTORRENT_VERSION_MAJOR < 1 + m_upnp = 0; + m_natpmp = 0; +#endif } } diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h index 749b836b3..ec71e83f2 100755 --- a/src/qtlibtorrent/qbtsession.h +++ b/src/qtlibtorrent/qbtsession.h @@ -279,8 +279,10 @@ private: TorrentSpeedMonitor *m_speedMonitor; shutDownAction m_shutdownAct; // Port forwarding +#if LIBTORRENT_VERSION_MAJOR < 1 libtorrent::upnp *m_upnp; libtorrent::natpmp *m_natpmp; +#endif // DynDNS DNSUpdater *m_dynDNSUpdater; };