mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-05 23:22:31 -06:00
Drop libtorrent 0.15.x support.
This commit is contained in:
@@ -69,14 +69,7 @@
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
#include <libtorrent/upnp.hpp>
|
||||
#include <libtorrent/natpmp.hpp>
|
||||
#if LIBTORRENT_VERSION_NUM < 001600
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#endif
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#endif
|
||||
#include <libtorrent/error_code.hpp>
|
||||
#include <queue>
|
||||
#include <string.h>
|
||||
#include "dnsupdater.h"
|
||||
@@ -120,10 +113,6 @@ QBtSession::QBtSession()
|
||||
BigRatioTimer->setInterval(10000);
|
||||
connect(BigRatioTimer, SIGNAL(timeout()), SLOT(processBigRatios()));
|
||||
Preferences pref;
|
||||
#if LIBTORRENT_VERSION_NUM < 001600
|
||||
// To avoid some exceptions
|
||||
boost::filesystem::path::default_name_check(boost::filesystem::no_check);
|
||||
#endif
|
||||
// Creating Bittorrent session
|
||||
QList<int> version;
|
||||
version << VERSION_MAJOR;
|
||||
@@ -398,10 +387,8 @@ void QBtSession::configureSession() {
|
||||
|
||||
sessionSettings.upnp_ignore_nonrouters = true;
|
||||
sessionSettings.use_dht_as_fallback = false;
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
// Disable support for SSL torrents for now
|
||||
sessionSettings.ssl_listen = 0;
|
||||
#endif
|
||||
// To prevent ISPs from blocking seeding
|
||||
sessionSettings.lazy_bitfields = true;
|
||||
// Speed up exit
|
||||
@@ -414,18 +401,14 @@ void QBtSession::configureSession() {
|
||||
sessionSettings.auto_scrape_min_interval = 900; // 15 minutes
|
||||
int cache_size = pref.diskCacheSize();
|
||||
sessionSettings.cache_size = cache_size ? cache_size * 64 : -1;
|
||||
#if LIBTORRENT_VERSION_NUM >= 001610
|
||||
sessionSettings.cache_expiry = pref.diskCacheTTL();
|
||||
#endif
|
||||
qDebug() << "Using a disk cache size of" << cache_size << "MiB";
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
sessionSettings.anonymous_mode = pref.isAnonymousModeEnabled();
|
||||
if (sessionSettings.anonymous_mode) {
|
||||
addConsoleMessage(tr("Anonymous mode [ON]"), "blue");
|
||||
} else {
|
||||
addConsoleMessage(tr("Anonymous mode [OFF]"), "blue");
|
||||
}
|
||||
#endif
|
||||
// Queueing System
|
||||
if (pref.isQueueingSystemEnabled()) {
|
||||
int max_downloading = pref.getMaxActiveDownloads();
|
||||
@@ -456,36 +439,16 @@ void QBtSession::configureSession() {
|
||||
sessionSettings.rate_limit_ip_overhead = pref.includeOverheadInLimits();
|
||||
// IP address to announce to trackers
|
||||
QString announce_ip = pref.getNetworkAddress();
|
||||
if (!announce_ip.isEmpty()) {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
if (!announce_ip.isEmpty())
|
||||
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
|
||||
sessionSettings.strict_super_seeding = pref.isSuperSeedingEnabled();
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
// * Max Half-open connections
|
||||
sessionSettings.half_open_limit = pref.getMaxHalfOpenConnections();
|
||||
// * Max connections limit
|
||||
sessionSettings.connections_limit = pref.getMaxConnecs();
|
||||
// * Global max upload slots
|
||||
sessionSettings.unchoke_slots_limit = pref.getMaxUploads();
|
||||
#else
|
||||
// * Max Half-open connections
|
||||
s->set_max_half_open_connections(pref.getMaxHalfOpenConnections());
|
||||
// * Max connections limit
|
||||
setMaxConnections(pref.getMaxConnecs());
|
||||
// * Global max upload slots
|
||||
s->set_max_uploads(pref.getMaxUploads());
|
||||
#endif
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
// uTP
|
||||
sessionSettings.enable_incoming_utp = pref.isuTPEnabled();
|
||||
sessionSettings.enable_outgoing_utp = pref.isuTPEnabled();
|
||||
@@ -493,7 +456,6 @@ void QBtSession::configureSession() {
|
||||
sessionSettings.rate_limit_utp = pref.isuTPRateLimited();
|
||||
sessionSettings.mixed_mode_algorithm = session_settings::peer_proportional;
|
||||
sessionSettings.connection_speed = 20; //default is 10
|
||||
#endif
|
||||
qDebug() << "Settings SessionSettings";
|
||||
setSessionSettings(sessionSettings);
|
||||
// Bittorrent
|
||||
@@ -1145,21 +1107,6 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
||||
qDebug("Successfully loaded fast resume data");
|
||||
}
|
||||
}
|
||||
#if LIBTORRENT_VERSION_NUM < 001600
|
||||
else {
|
||||
// Generate fake resume data to make sure unwanted files
|
||||
// are not allocated
|
||||
if (preAllocateAll) {
|
||||
vector<int> fp;
|
||||
TorrentTempData::getFilesPriority(hash, fp);
|
||||
if ((int)fp.size() == t->num_files()) {
|
||||
entry rd = generateFilePriorityResumeData(t, fp);
|
||||
bencode(std::back_inserter(buf), rd);
|
||||
p.resume_data = &buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
recoverPersistentData(hash, buf);
|
||||
QString savePath;
|
||||
@@ -1279,8 +1226,7 @@ void QBtSession::initializeAddTorrentParams(const QString &hash, add_torrent_par
|
||||
p.storage_mode = storage_mode_sparse;
|
||||
|
||||
// Priorities
|
||||
/*#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
if (TorrentTempData::hasTempData(hash)) {
|
||||
/*if (TorrentTempData::hasTempData(hash)) {
|
||||
std::vector<int> fp;
|
||||
TorrentTempData::getFilesPriority(hash, fp);
|
||||
if (!fp.empty()) {
|
||||
@@ -1290,8 +1236,7 @@ void QBtSession::initializeAddTorrentParams(const QString &hash, add_torrent_par
|
||||
}
|
||||
p.file_priorities = fp_conv;
|
||||
}
|
||||
}
|
||||
#endif*/
|
||||
}*/
|
||||
|
||||
// Start in pause
|
||||
p.paused = true;
|
||||
@@ -1394,7 +1339,6 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren
|
||||
|
||||
bool urlseeds_added = false;
|
||||
const QStringList old_urlseeds = h_ex.url_seeds();
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
std::vector<web_seed_entry> new_urlseeds = t->web_seeds();
|
||||
|
||||
std::vector<web_seed_entry>::iterator it = new_urlseeds.begin();
|
||||
@@ -1406,19 +1350,6 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren
|
||||
h_ex.add_url_seed(new_url);
|
||||
}
|
||||
}
|
||||
#else
|
||||
std::vector<std::string> new_urlseeds = t->url_seeds();
|
||||
|
||||
std::vector<std::string>::iterator it = new_urlseeds.begin();
|
||||
std::vector<std::string>::iterator itend = new_urlseeds.end();
|
||||
for ( ; it != itend; ++it) {
|
||||
const QString new_url = misc::toQString(it->c_str());
|
||||
if (!old_urlseeds.contains(new_url)) {
|
||||
urlseeds_added = true;
|
||||
h_ex.add_url_seed(new_url);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (urlseeds_added)
|
||||
addConsoleMessage(tr("Note: new URL seeds were added to the existing torrent."));
|
||||
}
|
||||
@@ -1462,17 +1393,6 @@ void QBtSession::exportTorrentFiles(QString path) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the maximum number of opened connections
|
||||
void QBtSession::setMaxConnections(int maxConnec) {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
Q_UNUSED(maxConnec);
|
||||
Q_ASSERT(0); // Should not be used
|
||||
#else
|
||||
qDebug() << Q_FUNC_INFO << maxConnec;
|
||||
s->set_max_connections(maxConnec);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QBtSession::setMaxConnectionsPerTorrent(int max) {
|
||||
qDebug() << Q_FUNC_INFO << max;
|
||||
// Apply this to all session torrents
|
||||
@@ -1563,15 +1483,10 @@ void QBtSession::loadSessionState() {
|
||||
state_file.read(&in[0], content_size);
|
||||
// bdecode
|
||||
lazy_entry e;
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
libtorrent::error_code ec;
|
||||
lazy_bdecode(&in[0], &in[0] + in.size(), e, ec);
|
||||
if (!ec) {
|
||||
#else
|
||||
if (lazy_bdecode(&in[0], &in[0] + in.size(), e) == 0) {
|
||||
#endif
|
||||
if (!ec)
|
||||
s->load_state(e);
|
||||
}
|
||||
}
|
||||
|
||||
void QBtSession::saveSessionState() {
|
||||
@@ -1653,9 +1568,7 @@ void QBtSession::saveTempFastResumeData() {
|
||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||
try {
|
||||
if (!h.is_valid() || !h.has_metadata() /*|| h.is_seed() || h.is_paused()*/) continue;
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
if (!h.need_save_resume_data()) continue;
|
||||
#endif
|
||||
if (h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking || h.has_error()) continue;
|
||||
qDebug("Saving fastresume data for %s", qPrintable(h.name()));
|
||||
h.save_resume_data();
|
||||
@@ -1948,17 +1861,11 @@ void QBtSession::setListeningPort(int port) {
|
||||
qDebug() << Q_FUNC_INFO << port;
|
||||
Preferences pref;
|
||||
std::pair<int,int> ports(port, port);
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
libtorrent::error_code ec;
|
||||
#endif
|
||||
const QString iface_name = pref.getNetworkInterface();
|
||||
if (iface_name.isEmpty()) {
|
||||
addConsoleMessage(tr("qBittorrent is trying to listen on any interface port: TCP/%1", "e.g: qBittorrent is trying to listen on any interface port: TCP/6881").arg(QString::number(port)), "blue");
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
s->listen_on(ports, ec, 0, session::listen_no_system_port);
|
||||
#else
|
||||
s->listen_on(ports);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
// Attempt to listen on provided interface
|
||||
@@ -1972,12 +1879,8 @@ void QBtSession::setListeningPort(int port) {
|
||||
qDebug("This network interface has %d IP addresses", network_iface.addressEntries().size());
|
||||
foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) {
|
||||
qDebug("Trying to listen on IP %s (%s)", qPrintable(entry.ip().toString()), qPrintable(iface_name));
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
s->listen_on(ports, ec, entry.ip().toString().toAscii().constData(), session::listen_no_system_port);
|
||||
if (!ec) {
|
||||
#else
|
||||
if (s->listen_on(ports, entry.ip().toString().toAscii().constData())) {
|
||||
#endif
|
||||
ip = entry.ip().toString();
|
||||
addConsoleMessage(tr("qBittorrent is trying to listen on interface %1 port: TCP/%2", "e.g: qBittorrent is trying to listen on interface 192.168.0.1 port: TCP/6881").arg(ip).arg(QString::number(port)), "blue");
|
||||
break;
|
||||
@@ -1990,13 +1893,9 @@ void QBtSession::setListeningPort(int port) {
|
||||
void QBtSession::setDownloadRateLimit(long rate) {
|
||||
qDebug() << Q_FUNC_INFO << rate;
|
||||
Q_ASSERT(rate == -1 || rate >= 0);
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
session_settings settings = s->settings();
|
||||
settings.download_rate_limit = rate;
|
||||
s->set_settings(settings);
|
||||
#else
|
||||
s->set_download_rate_limit(rate);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set upload rate limit
|
||||
@@ -2004,13 +1903,9 @@ void QBtSession::setDownloadRateLimit(long rate) {
|
||||
void QBtSession::setUploadRateLimit(long rate) {
|
||||
qDebug() << Q_FUNC_INFO << rate;
|
||||
Q_ASSERT(rate == -1 || rate >= 0);
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
session_settings settings = s->settings();
|
||||
settings.upload_rate_limit = rate;
|
||||
s->set_settings(settings);
|
||||
#else
|
||||
s->set_upload_rate_limit(rate);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Torrents will a ratio superior to the given value will
|
||||
@@ -2112,18 +2007,8 @@ void QBtSession::setSessionSettings(const session_settings &sessionSettings) {
|
||||
void QBtSession::setProxySettings(proxy_settings proxySettings) {
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
proxySettings.proxy_peer_connections = Preferences().proxyPeerConnections();
|
||||
s->set_proxy(proxySettings);
|
||||
#else
|
||||
s->set_tracker_proxy(proxySettings);
|
||||
proxy_settings peer_proxy;
|
||||
if (Preferences().proxyPeerConnections())
|
||||
peer_proxy = proxySettings;
|
||||
s->set_peer_proxy(peer_proxy);
|
||||
s->set_web_seed_proxy(peer_proxy);
|
||||
s->set_dht_proxy(peer_proxy);
|
||||
#endif
|
||||
|
||||
// Define environment variable
|
||||
QString proxy_str;
|
||||
@@ -2905,65 +2790,15 @@ void QBtSession::handleIPFilterError()
|
||||
emit ipFilterParsed(true, 0);
|
||||
}
|
||||
|
||||
entry QBtSession::generateFilePriorityResumeData(boost::intrusive_ptr<torrent_info> &t, const std::vector<int> &fp)
|
||||
{
|
||||
entry::dictionary_type rd;
|
||||
rd["file-format"] = "libtorrent resume file";
|
||||
rd["file-version"] = 1;
|
||||
rd["libtorrent-version"] = LIBTORRENT_VERSION;
|
||||
rd["allocation"] = "full";
|
||||
sha1_hash info_hash = t->info_hash();
|
||||
rd["info-hash"] = std::string((char*)info_hash.begin(), (char*)info_hash.end());
|
||||
// Priorities
|
||||
entry::list_type priorities;
|
||||
for (uint i=0; i<fp.size(); ++i) {
|
||||
priorities.push_back(entry(fp[i]));
|
||||
}
|
||||
rd["file_priority"] = entry(priorities);
|
||||
// files sizes (useless but required)
|
||||
entry::list_type sizes;
|
||||
for (int i=0; i<t->num_files(); ++i) {
|
||||
entry::list_type p;
|
||||
p.push_back(entry(0));
|
||||
p.push_back(entry(0));
|
||||
sizes.push_back(entry(p));
|
||||
}
|
||||
rd["file sizes"] = entry(sizes);
|
||||
// Slots
|
||||
entry::list_type tslots;
|
||||
for (int i=0; i<t->num_pieces(); ++i) {
|
||||
tslots.push_back(-1);
|
||||
}
|
||||
rd["slots"] = entry(tslots);
|
||||
|
||||
entry::string_type pieces;
|
||||
pieces.resize(t->num_pieces());
|
||||
std::memset(&pieces[0], 0, pieces.size());
|
||||
rd["pieces"] = entry(pieces);
|
||||
|
||||
entry ret(rd);
|
||||
Q_ASSERT(ret.type() == entry::dictionary_t);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void QBtSession::recoverPersistentData(const QString &hash, const std::vector<char> &buf) {
|
||||
if (TorrentPersistentData::isKnownTorrent(hash) || TorrentTempData::hasTempData(hash) || buf.empty())
|
||||
return;
|
||||
|
||||
libtorrent::lazy_entry fast;
|
||||
#if LIBTORRENT_VERSION_NUM < 001600
|
||||
try {
|
||||
libtorrent::lazy_bdecode(&(buf.front()), &(buf.back()), fast);
|
||||
} catch (std::exception&) {
|
||||
return;
|
||||
}
|
||||
if (fast.type() != libtorrent::lazy_entry::dict_t)
|
||||
#else
|
||||
libtorrent::error_code ec;
|
||||
|
||||
libtorrent::lazy_bdecode(&(buf.front()), &(buf.back()), fast, ec);
|
||||
if (fast.type() != libtorrent::lazy_entry::dict_t && !ec)
|
||||
#endif
|
||||
return;
|
||||
|
||||
QString savePath = QString::fromUtf8(fast.dict_find_string_value("qBt-savePath").c_str());
|
||||
|
||||
@@ -134,7 +134,6 @@ public slots:
|
||||
void downloadUrlAndSkipDialog(QString url, QString save_path=QString(), QString label=QString(), const QList<QNetworkCookie>& cookies = QList<QNetworkCookie>());
|
||||
// Session configuration - Setters
|
||||
void setListeningPort(int port);
|
||||
void setMaxConnections(int maxConnec);
|
||||
void setMaxConnectionsPerTorrent(int max);
|
||||
void setMaxUploadsPerTorrent(int max);
|
||||
void setDownloadRateLimit(long rate);
|
||||
@@ -183,7 +182,6 @@ private:
|
||||
void loadTorrentSettings(QTorrentHandle &h);
|
||||
void loadTorrentTempData(QTorrentHandle &h, QString savePath, bool magnet);
|
||||
void initializeAddTorrentParams(const QString &hash, libtorrent::add_torrent_params &p);
|
||||
libtorrent::entry generateFilePriorityResumeData(boost::intrusive_ptr<libtorrent::torrent_info> &t, const std::vector<int> &fp);
|
||||
void updateRatioTimer();
|
||||
void recoverPersistentData(const QString &hash, const std::vector<char> &buf);
|
||||
void backupPersistentData(const QString &hash, boost::shared_ptr<libtorrent::entry> data);
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
#include <libtorrent/bencode.hpp>
|
||||
#include <libtorrent/entry.hpp>
|
||||
#if LIBTORRENT_VERSION_NUM < 001600
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#include <Windows.h>
|
||||
@@ -93,37 +90,20 @@ QString QTorrentHandle::name() const {
|
||||
}
|
||||
|
||||
QString QTorrentHandle::creation_date() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
boost::optional<time_t> t = torrent_handle::get_torrent_info().creation_date();
|
||||
return t ? misc::toQString(*t) : "";
|
||||
#else
|
||||
boost::optional<boost::posix_time::ptime> boostDate = torrent_handle::get_torrent_info().creation_date();
|
||||
return boostDate ? misc::toQString(*boostDate) : "";
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QTorrentHandle::next_announce() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return misc::userFriendlyDuration(torrent_handle::status(0x0).next_announce.total_seconds());
|
||||
#else
|
||||
return misc::userFriendlyDuration(torrent_handle::status().next_announce.total_seconds());
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong QTorrentHandle::next_announce_s() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).next_announce.total_seconds();
|
||||
#else
|
||||
return torrent_handle::status().next_announce.total_seconds();
|
||||
#endif
|
||||
}
|
||||
|
||||
float QTorrentHandle::progress() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status st = torrent_handle::status(query_accurate_download_counters);
|
||||
#else
|
||||
torrent_status st = torrent_handle::status();
|
||||
#endif
|
||||
if (!st.total_wanted)
|
||||
return 0.;
|
||||
if (st.total_wanted_done == st.total_wanted)
|
||||
@@ -134,37 +114,21 @@ float QTorrentHandle::progress() const {
|
||||
}
|
||||
|
||||
bitfield QTorrentHandle::pieces() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(torrent_handle::query_pieces).pieces;
|
||||
#else
|
||||
return torrent_handle::status().pieces;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QTorrentHandle::current_tracker() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return misc::toQString(torrent_handle::status(0x0).current_tracker);
|
||||
#else
|
||||
return misc::toQString(torrent_handle::status().current_tracker);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_paused() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status st = torrent_handle::status(0x0);
|
||||
return st.paused && !st.auto_managed;
|
||||
#else
|
||||
return torrent_handle::is_paused() && !torrent_handle::is_auto_managed();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_queued() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status st = torrent_handle::status(0x0);
|
||||
return st.paused && st.auto_managed;
|
||||
#else
|
||||
return torrent_handle::is_paused() && torrent_handle::is_auto_managed();
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_size() const {
|
||||
@@ -185,11 +149,7 @@ bool QTorrentHandle::first_last_piece_first() const {
|
||||
// Get int first media file
|
||||
int index = 0;
|
||||
for (index = 0; index < t.num_files(); ++index) {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
QString path = misc::toQStringU(t.file_at(index).path);
|
||||
#else
|
||||
QString path = misc::toQStringU(t.file_at(index).path.string());
|
||||
#endif
|
||||
const QString ext = fsutils::fileExtension(path);
|
||||
if (misc::isPreviewable(ext) && torrent_handle::file_priority(index) > 0)
|
||||
break;
|
||||
@@ -206,75 +166,39 @@ bool QTorrentHandle::first_last_piece_first() const {
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_wanted_done() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(query_accurate_download_counters).total_wanted_done;
|
||||
#else
|
||||
return torrent_handle::status().total_wanted_done;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_wanted() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).total_wanted;
|
||||
#else
|
||||
return torrent_handle::status().total_wanted;
|
||||
#endif
|
||||
}
|
||||
|
||||
qreal QTorrentHandle::download_payload_rate() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).download_payload_rate;
|
||||
#else
|
||||
return torrent_handle::status().download_payload_rate;
|
||||
#endif
|
||||
}
|
||||
|
||||
qreal QTorrentHandle::upload_payload_rate() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).upload_payload_rate;
|
||||
#else
|
||||
return torrent_handle::status().upload_payload_rate;
|
||||
#endif
|
||||
}
|
||||
|
||||
int QTorrentHandle::num_peers() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).num_peers;
|
||||
#else
|
||||
return torrent_handle::status().num_peers;
|
||||
#endif
|
||||
}
|
||||
|
||||
int QTorrentHandle::num_seeds() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).num_seeds;
|
||||
#else
|
||||
return torrent_handle::status().num_seeds;
|
||||
#endif
|
||||
}
|
||||
|
||||
int QTorrentHandle::num_complete() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).num_complete;
|
||||
#else
|
||||
return torrent_handle::status().num_complete;
|
||||
#endif
|
||||
}
|
||||
|
||||
int QTorrentHandle::num_incomplete() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).num_incomplete;
|
||||
#else
|
||||
return torrent_handle::status().num_incomplete;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QTorrentHandle::save_path() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return misc::toQStringU(torrent_handle::save_path()).replace("\\", "/");
|
||||
#else
|
||||
return misc::toQStringU(torrent_handle::save_path().string()).replace("\\", "/");
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QTorrentHandle::save_path_parsed() const {
|
||||
@@ -311,11 +235,7 @@ QStringList QTorrentHandle::url_seeds() const {
|
||||
|
||||
// get the size of the torrent without the filtered files
|
||||
size_type QTorrentHandle::actual_size() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(query_accurate_download_counters).total_wanted;
|
||||
#else
|
||||
return torrent_handle::status().total_wanted;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QTorrentHandle::has_filtered_pieces() const {
|
||||
@@ -333,11 +253,7 @@ int QTorrentHandle::num_files() const {
|
||||
|
||||
QString QTorrentHandle::filename_at(unsigned int index) const {
|
||||
Q_ASSERT(index < (unsigned int)torrent_handle::get_torrent_info().num_files());
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return fsutils::fileName(filepath_at(index));
|
||||
#else
|
||||
return misc::toQStringU(torrent_handle::get_torrent_info().file_at(index).path.leaf());
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::filesize_at(unsigned int index) const {
|
||||
@@ -346,27 +262,15 @@ size_type QTorrentHandle::filesize_at(unsigned int index) const {
|
||||
}
|
||||
|
||||
QString QTorrentHandle::filepath_at(unsigned int index) const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return misc::toQStringU(torrent_handle::get_torrent_info().file_at(index).path);
|
||||
#else
|
||||
return misc::toQStringU(torrent_handle::get_torrent_info().file_at(index).path.string());
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QTorrentHandle::orig_filepath_at(unsigned int index) const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return misc::toQStringU(torrent_handle::get_torrent_info().orig_files().at(index).path);
|
||||
#else
|
||||
return misc::toQStringU(torrent_handle::get_torrent_info().orig_files().at(index).path.string());
|
||||
#endif
|
||||
}
|
||||
|
||||
torrent_status::state_t QTorrentHandle::state() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).state;
|
||||
#else
|
||||
return torrent_handle::status().state;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QTorrentHandle::creator() const {
|
||||
@@ -378,68 +282,36 @@ QString QTorrentHandle::comment() const {
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_failed_bytes() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).total_failed_bytes;
|
||||
#else
|
||||
return torrent_handle::status().total_failed_bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_redundant_bytes() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).total_redundant_bytes;
|
||||
#else
|
||||
return torrent_handle::status().total_redundant_bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_checking() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status st = torrent_handle::status(0x0);
|
||||
#else
|
||||
torrent_status st = torrent_handle::status();
|
||||
#endif
|
||||
return st.state == torrent_status::checking_files || st.state == torrent_status::checking_resume_data;
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_done() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(query_accurate_download_counters).total_done;
|
||||
#else
|
||||
return torrent_handle::status().total_done;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::all_time_download() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).all_time_download;
|
||||
#else
|
||||
return torrent_handle::status().all_time_download;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::all_time_upload() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).all_time_upload;
|
||||
#else
|
||||
return torrent_handle::status().all_time_upload;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_payload_download() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).total_payload_download;
|
||||
#else
|
||||
return torrent_handle::status().total_payload_download;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_type QTorrentHandle::total_payload_upload() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).total_payload_upload;
|
||||
#else
|
||||
return torrent_handle::status().total_payload_upload;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Return a list of absolute paths corresponding
|
||||
@@ -482,11 +354,7 @@ int QTorrentHandle::queue_position() const {
|
||||
}
|
||||
|
||||
int QTorrentHandle::num_uploads() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).num_uploads;
|
||||
#else
|
||||
return torrent_handle::status().num_uploads;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_seed() const {
|
||||
@@ -500,53 +368,29 @@ bool QTorrentHandle::is_seed() const {
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_auto_managed() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status status = torrent_handle::status(0x0);
|
||||
return status.auto_managed;
|
||||
#else
|
||||
return torrent_handle::is_auto_managed();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_sequential_download() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status status = torrent_handle::status(0x0);
|
||||
return status.sequential_download;
|
||||
#else
|
||||
return torrent_handle::is_sequential_download();
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong QTorrentHandle::active_time() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).active_time;
|
||||
#else
|
||||
return torrent_handle::status().active_time;
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong QTorrentHandle::seeding_time() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).seeding_time;
|
||||
#else
|
||||
return torrent_handle::status().seeding_time;
|
||||
#endif
|
||||
}
|
||||
|
||||
int QTorrentHandle::num_connections() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).num_connections;
|
||||
#else
|
||||
return torrent_handle::status().num_connections;
|
||||
#endif
|
||||
}
|
||||
|
||||
int QTorrentHandle::connections_limit() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).connections_limit;
|
||||
#else
|
||||
return torrent_handle::status().connections_limit;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QTorrentHandle::priv() const {
|
||||
@@ -580,20 +424,12 @@ QString QTorrentHandle::root_path() const
|
||||
}
|
||||
|
||||
bool QTorrentHandle::has_error() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status st = torrent_handle::status(0x0);
|
||||
return st.paused && !st.error.empty();
|
||||
#else
|
||||
return torrent_handle::is_paused() && !torrent_handle::status().error.empty();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QTorrentHandle::error() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return misc::toQString(torrent_handle::status(0x0).error);
|
||||
#else
|
||||
return misc::toQString(torrent_handle::status().error);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QTorrentHandle::downloading_pieces(bitfield &bf) const {
|
||||
@@ -609,19 +445,11 @@ void QTorrentHandle::downloading_pieces(bitfield &bf) const {
|
||||
}
|
||||
|
||||
bool QTorrentHandle::has_metadata() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(0x0).has_metadata;
|
||||
#else
|
||||
return torrent_handle::has_metadata();
|
||||
#endif
|
||||
}
|
||||
|
||||
float QTorrentHandle::distributed_copies() const {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
return torrent_handle::status(query_distributed_copies).distributed_copies;
|
||||
#else
|
||||
return torrent_handle::status().distributed_copies;
|
||||
#endif
|
||||
return torrent_handle::status(query_distributed_copies).distributed_copies;
|
||||
}
|
||||
|
||||
void QTorrentHandle::file_progress(std::vector<size_type>& fp) const {
|
||||
|
||||
@@ -161,13 +161,8 @@ void TorrentSpeedMonitor::getSamples()
|
||||
std::vector<torrent_handle>::const_iterator itend = torrents.end();
|
||||
for ( ; it != itend; ++it) {
|
||||
try {
|
||||
#if LIBTORRENT_VERSION_NUM >= 001600
|
||||
torrent_status st = it->status(0x0);
|
||||
if (!st.paused) {
|
||||
#else
|
||||
if (!it->is_paused()) {
|
||||
torrent_status st = it->status();
|
||||
#endif
|
||||
m_samples[misc::toQString(it->info_hash())].addSample(st.download_payload_rate, st.upload_payload_rate);
|
||||
}
|
||||
} catch(invalid_handle&) {}
|
||||
|
||||
Reference in New Issue
Block a user