Prepare for libtorrent v1.1 support

This commit is contained in:
Vladimir Golovnev (Glassez)
2016-01-20 09:57:02 +03:00
parent 31be920ba4
commit c93ada1e7b
6 changed files with 48 additions and 34 deletions

View File

@@ -43,8 +43,8 @@
namespace libt = libtorrent;
using namespace BitTorrent;
TorrentInfo::TorrentInfo(boost::intrusive_ptr<const libt::torrent_info> nativeInfo)
: m_nativeInfo(const_cast<libt::torrent_info *>(nativeInfo.get()))
TorrentInfo::TorrentInfo(NativeConstPtr nativeInfo)
: m_nativeInfo(nativeInfo)
{
}
@@ -63,7 +63,7 @@ TorrentInfo TorrentInfo::loadFromFile(const QString &path, QString &error)
{
error.clear();
libt::error_code ec;
TorrentInfo info(new libt::torrent_info(Utils::String::toStdString(Utils::Fs::toNativePath(path)), ec));
TorrentInfo info(NativePtr(new libt::torrent_info(Utils::String::toStdString(Utils::Fs::toNativePath(path)), ec)));
if (ec) {
error = QString::fromUtf8(ec.message().c_str());
qDebug("Cannot load .torrent file: %s", qPrintable(error));
@@ -214,10 +214,10 @@ QByteArray TorrentInfo::metadata() const
void TorrentInfo::renameFile(uint index, const QString &newPath)
{
if (!isValid()) return;
m_nativeInfo->rename_file(index, Utils::String::toStdString(newPath));
nativeInfo()->rename_file(index, Utils::String::toStdString(newPath));
}
boost::intrusive_ptr<libtorrent::torrent_info> TorrentInfo::nativeInfo() const
TorrentInfo::NativePtr TorrentInfo::nativeInfo() const
{
return m_nativeInfo;
return *reinterpret_cast<const NativePtr *>(&m_nativeInfo);
}