Browse Source

fix libtorrent 1.0 compatibility

adaptive-webui-19844
arvidn 11 years ago
parent
commit
3b4f9d2eeb
  1. 2
      src/misc.h
  2. 34
      src/qtlibtorrent/qbtsession.cpp
  3. 2
      src/qtlibtorrent/qbtsession.h

2
src/misc.h

@ -70,7 +70,7 @@ namespace misc @@ -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);
}

34
src/qtlibtorrent/qbtsession.cpp

@ -67,13 +67,16 @@ @@ -67,13 +67,16 @@
#include <libtorrent/identify_client.hpp>
#include <libtorrent/alert_types.hpp>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/upnp.hpp>
#include <libtorrent/natpmp.hpp>
#include <libtorrent/error_code.hpp>
#include <queue>
#include <string.h>
#include "dnsupdater.h"
#if LIBTORRENT_VERSION_MAJOR < 1
#include <libtorrent/upnp.hpp>
#include <libtorrent/natpmp.hpp>
#endif
//initialize static member variables
QHash<QString, TorrentTempData::TorrentData> TorrentTempData::data = QHash<QString, TorrentTempData::TorrentData>();
QHash<QString, bool> HiddenData::data = QHash<QString, bool>();
@ -106,8 +109,11 @@ QBtSession::QBtSession() @@ -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 @@ -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) { @@ -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");
#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();
#if LIBTORRENT_VERSION_MAJOR < 1
m_upnp = 0;
m_natpmp = 0;
}
#endif
}
}

2
src/qtlibtorrent/qbtsession.h

@ -279,8 +279,10 @@ private: @@ -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;
};

Loading…
Cancel
Save