From 1288c7092befb5a38c86506c7bbe3560c1b92020 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 7 Jun 2010 08:47:56 +0000 Subject: [PATCH] Use libtorrent version.hpp instead of our own DEFINE --- configure | 15 -------- qcm/libtorrent-rasterbar.qcm | 15 -------- src/advancedsettings.h | 1 + src/bittorrent.cpp | 69 ++++++++++++++++++------------------ src/bittorrent.h | 13 +++---- src/createtorrent_imp.cpp | 3 +- src/eventmanager.cpp | 7 ++-- src/options_imp.cpp | 7 ++-- src/preferences.h | 3 +- src/previewselect.h | 3 +- src/propertieswidget.cpp | 7 ++-- src/qtorrenthandle.cpp | 7 ++-- src/qtorrenthandle.h | 5 +-- src/torrentadditiondlg.h | 5 +-- src/torrentpersistentdata.h | 3 +- src/trackerlist.cpp | 5 +-- src/trackerlist.h | 3 +- src/transferlistwidget.cpp | 11 +++--- src/transferlistwidget.h | 5 +-- 19 files changed, 87 insertions(+), 100 deletions(-) diff --git a/configure b/configure index c1e4f4220..0948228b7 100755 --- a/configure +++ b/configure @@ -355,27 +355,12 @@ public: bool exec(){ QStringList incs; QString req_ver = "0.14.4"; - QString adv_ver = "0.15.0"; QString version, libs, other; VersionMode mode = VersionMin; if(!conf->findPkgConfig("libtorrent-rasterbar", mode, req_ver, &version, &incs, &libs, &other)) return false; for(int n = 0; n < incs.count(); ++n) conf->addIncludePath(incs[n]); - //if(!libs.isEmpty()) - // conf->addLib(libs); - if(conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other)) { - //printf("\nWarning: libtorrent-rasterbar v%s was detected. Some feature will be disabled because they require v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data()); - //else - conf->addDefine("LIBTORRENT_0_15"); - } - // Get linking parameters - //QStringList params; - //QByteArray staticlibs; - //params << "--static" << "--libs" << "libtorrent-rasterbar"; - //conf->doCommand("pkg-config", params, &staticlibs); - //conf->addLib(staticlibs.trimmed()); - //libcrypto if(conf->getenv("QC_DISABLE_GUI").isEmpty()) { conf->addLib("-lcrypto"); } diff --git a/qcm/libtorrent-rasterbar.qcm b/qcm/libtorrent-rasterbar.qcm index 04c759efc..61688ad4e 100644 --- a/qcm/libtorrent-rasterbar.qcm +++ b/qcm/libtorrent-rasterbar.qcm @@ -13,27 +13,12 @@ public: bool exec(){ QStringList incs; QString req_ver = "0.14.4"; - QString adv_ver = "0.15.0"; QString version, libs, other; VersionMode mode = VersionMin; if(!conf->findPkgConfig("libtorrent-rasterbar", mode, req_ver, &version, &incs, &libs, &other)) return false; for(int n = 0; n < incs.count(); ++n) conf->addIncludePath(incs[n]); - //if(!libs.isEmpty()) - // conf->addLib(libs); - if(conf->findPkgConfig("libtorrent-rasterbar", mode, adv_ver, &version, &incs, &libs, &other)) { - //printf("\nWarning: libtorrent-rasterbar v%s was detected. Some feature will be disabled because they require v%s.\n", version.toLocal8Bit().data(), adv_ver.toUtf8().data()); - //else - conf->addDefine("LIBTORRENT_0_15"); - } - // Get linking parameters - //QStringList params; - //QByteArray staticlibs; - //params << "--static" << "--libs" << "libtorrent-rasterbar"; - //conf->doCommand("pkg-config", params, &staticlibs); - //conf->addLib(staticlibs.trimmed()); - //libcrypto if(conf->getenv("QC_DISABLE_GUI").isEmpty()) { conf->addLib("-lcrypto"); } diff --git a/src/advancedsettings.h b/src/advancedsettings.h index 261371e8f..799d78994 100644 --- a/src/advancedsettings.h +++ b/src/advancedsettings.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "preferences.h" enum AdvSettingsCols {PROPERTY, VALUE}; diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index e94f3100f..fb6c73755 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -48,7 +48,8 @@ #include "httpserver.h" #include "bandwidthscheduler.h" #include -#ifdef LIBTORRENT_0_15 +#include +#if LIBTORRENT_VERSION_MINOR > 14 #include #endif #include @@ -118,7 +119,7 @@ Bittorrent::Bittorrent() // Enabling plugins //s->add_extension(&create_metadata_plugin); s->add_extension(&create_ut_metadata_plugin); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 s->add_extension(create_lt_trackers_plugin); #endif if(Preferences::isPeXEnabled()) { @@ -138,7 +139,7 @@ Bittorrent::Bittorrent() connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString))); appendLabelToSavePath = Preferences::appendTorrentLabel(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 appendqBExtension = Preferences::useIncompleteFilesExtension(); #endif connect(m_scanFolders, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&))); @@ -148,19 +149,19 @@ Bittorrent::Bittorrent() } session_proxy Bittorrent::asyncDeletion() { - qDebug("Bittorrent session async deletion IN"); - exiting = true; - // Do some BT related saving -#ifndef LIBTORRENT_0_15 - saveDHTEntry(); + qDebug("Bittorrent session async deletion IN"); + exiting = true; + // Do some BT related saving +#if LIBTORRENT_VERSION_MINOR < 15 + saveDHTEntry(); #endif - saveSessionState(); - saveFastResumeData(); - // Delete session - session_proxy sp = s->abort(); - delete s; - qDebug("Bittorrent session async deletion OUT"); - return sp; + saveSessionState(); + saveFastResumeData(); + // Delete session + session_proxy sp = s->abort(); + delete s; + qDebug("Bittorrent session async deletion OUT"); + return sp; } // Main destructor @@ -168,7 +169,7 @@ Bittorrent::~Bittorrent() { qDebug("BTSession destructor IN"); if(!exiting) { // Do some BT related saving -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 saveDHTEntry(); #endif saveSessionState(); @@ -278,7 +279,7 @@ void Bittorrent::configureSession() { setDefaultTempPath(QString::null); } setAppendLabelToSavePath(Preferences::appendTorrentLabel()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 setAppendqBExtension(Preferences::useIncompleteFilesExtension()); #endif preAllocateAllFiles(Preferences::preAllocateAllFiles()); @@ -420,7 +421,7 @@ void Bittorrent::configureSession() { sessionSettings.stop_tracker_timeout = 1; //sessionSettings.announce_to_all_trackers = true; sessionSettings.auto_scrape_interval = 1200; // 20 minutes -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 sessionSettings.announce_to_all_trackers = true; sessionSettings.announce_to_all_tiers = true; //uTorrent behavior sessionSettings.auto_scrape_min_interval = 900; // 15 minutes @@ -852,7 +853,7 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) { qDebug("addMagnetURI: using save_path: %s", qPrintable(savePath)); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Skip checking and directly start seeding (new in libtorrent v0.15) if(TorrentTempData::isSeedingMode(hash)){ p.seed_mode=true; @@ -1075,7 +1076,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr qDebug("addTorrent: using save_path: %s", qPrintable(savePath)); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Skip checking and directly start seeding (new in libtorrent v0.15) if(TorrentTempData::isSeedingMode(hash)){ p.seed_mode=true; @@ -1166,7 +1167,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath)); TorrentPersistentData::saveSavePath(hash, savePath); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Append .!qB to incomplete files if(appendqBExtension) appendqBextensionToTorrent(h, true); @@ -1350,7 +1351,7 @@ void Bittorrent::enableLSD(bool b) { void Bittorrent::loadSessionState() { const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state"); if(!QFile::exists(state_path)) return; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 std::vector in; if (load_file(state_path.toLocal8Bit().constData(), in) == 0) { @@ -1371,7 +1372,7 @@ void Bittorrent::loadSessionState() { void Bittorrent::saveSessionState() { qDebug("Saving session state to disk..."); const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state"); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 entry session_state; s->save_state(session_state); std::vector out; @@ -1397,7 +1398,7 @@ void Bittorrent::saveSessionState() { bool Bittorrent::enableDHT(bool b) { if(b) { if(!DHTEnabled) { -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 entry dht_state; const QString dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state"); if(QFile::exists(dht_state_path)) { @@ -1409,7 +1410,7 @@ bool Bittorrent::enableDHT(bool b) { } #endif try { -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 s->start_dht(); #else s->start_dht(dht_state); @@ -1625,7 +1626,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { defaultTempPath = temppath; } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) { if(!h.is_valid() || !h.has_metadata()) return; std::vector fp; @@ -1713,7 +1714,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void Bittorrent::setAppendqBExtension(bool append) { if(appendqBExtension != append) { appendqBExtension = !appendqBExtension; @@ -1926,7 +1927,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { if(h.is_valid()) { emit finishedTorrent(h); const QString &hash = h.hash(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Remove .!qB extension if necessary if(appendqBExtension) appendqBextensionToTorrent(h, false); @@ -2032,7 +2033,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { QTorrentHandle h(p->handle); if(h.is_valid()) { qDebug("Received metadata for %s", qPrintable(h.hash())); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Append .!qB to incomplete files if(appendqBExtension) appendqBextensionToTorrent(h, true); @@ -2083,7 +2084,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 else if (file_completed_alert* p = dynamic_cast(a.get())) { QTorrentHandle h(p->handle); if(appendqBExtension) { @@ -2113,7 +2114,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { QHash trackers_data = trackersInfos.value(h.hash(), QHash()); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); data.last_message = misc::toQString(p->msg); -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 data.verified = false; ++data.fail_count; #endif @@ -2134,7 +2135,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); data.last_message = ""; // Reset error/warning message data.num_peers = p->num_peers; -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 data.fail_count = 0; data.verified = true; #endif @@ -2149,7 +2150,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { const QString &tracker_url = misc::toQString(p->url); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); data.last_message = misc::toQString(p->msg); // Store warning message -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 data.verified = true; data.fail_count = 0; #endif @@ -2368,7 +2369,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { return sessionStatus.payload_upload_rate; } -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 // Save DHT entry to hard drive void Bittorrent::saveDHTEntry() { // Save DHT entry diff --git a/src/bittorrent.h b/src/bittorrent.h index 889962537..ab9f91146 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include "qtorrenthandle.h" @@ -63,7 +64,7 @@ public: QString name_or_url; QString last_message; unsigned long num_peers; -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 bool verified; uint fail_count; #endif @@ -74,13 +75,13 @@ public: Q_ASSERT(!name_or_url.isEmpty()); last_message = b.last_message; num_peers = b.num_peers; -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 verified = b.verified; fail_count = b.fail_count; #endif } TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) { -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 fail_count = 0; verified = false; #endif @@ -135,7 +136,7 @@ public slots: void resumeTorrent(QString hash); void resumeAllTorrents(); /* End Web UI */ -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 void saveDHTEntry(); #endif void preAllocateAllFiles(bool b); @@ -163,7 +164,7 @@ public slots: void setAppendLabelToSavePath(bool append); void appendLabelToTorrentSavePath(QTorrentHandle h); void changeLabelInTorrentSavePath(QTorrentHandle h, QString old_label, QString new_label); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void appendqBextensionToTorrent(QTorrentHandle h, bool append); void setAppendqBExtension(bool append); #endif @@ -249,7 +250,7 @@ private: bool queueingEnabled; bool appendLabelToSavePath; bool torrentExport; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool appendqBExtension; #endif QString defaultSavePath; diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index 641f57ef4..17ae24ed0 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -208,7 +209,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path) } QString hash = misc::toQString(t->info_hash()); TorrentTempData::setSavePath(hash, QString::fromLocal8Bit(branch_path)); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Enable seeding mode (do not recheck the files) TorrentTempData::setSeedingMode(hash, true); #endif diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 5bdbdc52e..84457f888 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -29,6 +29,7 @@ */ +#include #include "eventmanager.h" #include "bittorrent.h" #include "scannedfoldersmodel.h" @@ -60,7 +61,7 @@ QList EventManager::getPropTrackersInfo(QString hash) const { tracker["url"] = tracker_url; TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); QString error_message = data.last_message.trimmed(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(it->verified) { tracker["status"] = tr("Working"); } else { @@ -169,7 +170,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const { Preferences::setMaxActiveTorrents(m["max_active_torrents"].toInt()); if(m.contains("max_active_uploads")) Preferences::setMaxActiveUploads(m["max_active_uploads"].toInt()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(m.contains("incomplete_files_ext")) Preferences::useIncompleteFilesExtension(m["incomplete_files_ext"].toBool()); #endif @@ -272,7 +273,7 @@ QVariantMap EventManager::getGlobalPreferences() const { data["max_active_downloads"] = Preferences::getMaxActiveDownloads(); data["max_active_torrents"] = Preferences::getMaxActiveTorrents(); data["max_active_uploads"] = Preferences::getMaxActiveUploads(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 data["incomplete_files_ext"] = Preferences::useIncompleteFilesExtension(); #endif // Connection diff --git a/src/options_imp.cpp b/src/options_imp.cpp index ea41bedaf..f04058d06 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -283,7 +284,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ } // Tab selection mecanism connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 checkAppendqB->setVisible(false); #endif // Load Advanced settings @@ -402,7 +403,7 @@ void options_imp::saveOptions(){ #endif settings.setValue(QString::fromUtf8("TempPath"), temp_path); settings.setValue(QString::fromUtf8("AppendLabel"), checkAppendLabel->isChecked()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked()); #endif settings.setValue(QString::fromUtf8("PreAllocation"), preAllocateAllFiles()); @@ -642,7 +643,7 @@ void options_imp::loadOptions(){ #endif textTempPath->setText(temp_path); checkAppendLabel->setChecked(Preferences::appendTorrentLabel()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension()); #endif checkPreallocateAll->setChecked(Preferences::preAllocateAllFiles()); diff --git a/src/preferences.h b/src/preferences.h index 8fb8f90a5..874590786 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -37,6 +37,7 @@ #include #include #include +#include #ifndef DISABLE_GUI #include @@ -168,7 +169,7 @@ public: settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 static bool useIncompleteFilesExtension() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool(); diff --git a/src/previewselect.h b/src/previewselect.h index 59a867cfd..8f6905626 100644 --- a/src/previewselect.h +++ b/src/previewselect.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "ui_preview.h" #include "previewlistdelegate.h" @@ -65,7 +66,7 @@ protected slots: QModelIndex index; QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME); if(selectedIndexes.size() == 0) return; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Flush data h.flush_cache(); #endif diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index d89e80633..65e49ad70 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "propertieswidget.h" #include "transferlistwidget.h" #include "torrentpersistentdata.h" @@ -101,7 +102,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi ProgressHLayout_2->insertWidget(1, pieces_availability); // Tracker list trackerList = new TrackerList(this); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 trackerUpButton->setVisible(false); trackerDownButton->setVisible(false); #else @@ -483,7 +484,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { const QString &filename = misc::toQStringU(h.get_torrent_info().file_at(i).path.string()); const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename)); qDebug("Trying to open file at %s", qPrintable(file_path)); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Flush data h.flush_cache(); #endif @@ -509,7 +510,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { const QString &filename = path_items.join(QDir::separator()); const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename)); qDebug("Trying to open folder at %s", qPrintable(file_path)); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Flush data h.flush_cache(); #endif diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 2e88b9270..58d5fd6ff 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -37,6 +37,7 @@ #include "misc.h" #include "qtorrenthandle.h" #include "torrentpersistentdata.h" +#include #include #include #include @@ -218,7 +219,7 @@ QString QTorrentHandle::save_path() const { return misc::toQString(h.save_path().string()); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool QTorrentHandle::super_seeding() const { Q_ASSERT(h.is_valid()); return h.super_seeding(); @@ -580,7 +581,7 @@ void QTorrentHandle::file_priority(int index, int priority) const { TorrentPersistentData::saveSeedStatus(*this); } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void QTorrentHandle::super_seeding(bool on) const { Q_ASSERT(h.is_valid()); h.super_seeding(on); @@ -633,7 +634,7 @@ void QTorrentHandle::set_peer_download_limit(libtorrent::asio::ip::tcp::endpoint void QTorrentHandle::add_tracker(announce_entry const& url) { Q_ASSERT(h.is_valid()); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 h.add_tracker(url); #else std::vector trackers = h.trackers(); diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 64ce17d5f..6055497cc 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -31,6 +31,7 @@ #ifndef QTORRENTHANDLE_H #define QTORRENTHANDLE_H +#include #include #include @@ -117,7 +118,7 @@ class QTorrentHandle { qlonglong seeding_time() const; std::vector file_priorities() const; bool is_sequential_download() const; - #ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool super_seeding() const; #endif QString creation_date() const; @@ -155,7 +156,7 @@ class QTorrentHandle { void auto_managed(bool) const; void force_recheck() const; void move_storage(QString path) const; - #ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void super_seeding(bool on) const; void flush_cache() const; #endif diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index da9b2e5e6..9d705dd6c 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include "bittorrent.h" @@ -101,7 +102,7 @@ public: addInPause->setChecked(true); //addInPause->setEnabled(false); } -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 addInSeed->setVisible(false); #endif } @@ -491,7 +492,7 @@ public slots: TorrentTempData::setFilesPath(hash, files_path); } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 // Skip file checking and directly start seeding if(addInSeed->isChecked()) { // Check if local file(s) actually exist diff --git a/src/torrentpersistentdata.h b/src/torrentpersistentdata.h index 44d1b2184..e5c501027 100644 --- a/src/torrentpersistentdata.h +++ b/src/torrentpersistentdata.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "qtorrenthandle.h" #include "misc.h" @@ -126,7 +127,7 @@ public: } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 static void setSeedingMode(QString hash,bool seed){ QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QHash all_data = settings.value("torrents-tmp", QHash()).toHash(); diff --git a/src/trackerlist.cpp b/src/trackerlist.cpp index 29d8c3bb0..cc065fb90 100644 --- a/src/trackerlist.cpp +++ b/src/trackerlist.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "trackerlist.h" #include "propertieswidget.h" @@ -93,7 +94,7 @@ void TrackerList::setRowColor(int row, QColor color) { } } -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 void TrackerList::moveSelectionUp() { QTorrentHandle h = properties->getCurrentTorrent(); if(!h.is_valid()) { @@ -241,7 +242,7 @@ void TrackerList::loadTrackers() { } TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); QString error_message = data.last_message.trimmed(); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(it->verified) { item->setText(COL_STATUS, tr("Working")); item->setText(COL_MSG, ""); diff --git a/src/trackerlist.h b/src/trackerlist.h index 45ec383fe..e6bce7ba2 100644 --- a/src/trackerlist.h +++ b/src/trackerlist.h @@ -34,6 +34,7 @@ #include #include +#include #include "qtorrenthandle.h" enum TrackerListColumn {COL_URL, COL_STATUS, COL_PEERS, COL_MSG}; @@ -62,7 +63,7 @@ protected: public slots: void setRowColor(int row, QColor color); -#ifndef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR < 15 void moveSelectionUp(); void moveSelectionDown(); #endif diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 49c9853ba..46ffd8eb0 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -38,6 +38,7 @@ #include "GUI.h" #include "preferences.h" #include "deletionconfirmationdlg.h" +#include #include #include #include @@ -891,7 +892,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&){ } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const { const QStringList &hashes = getSelectedTorrentsHashes(); foreach(const QString &hash, hashes) { @@ -1012,7 +1013,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents())); QAction actionCopy_magnet_link(QIcon(QString::fromUtf8(":/Icons/magnet.png")), tr("Copy magnet link"), 0); connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs())); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0); connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding())); #endif @@ -1027,7 +1028,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { // Enable/disable pause/start action given the DL state QModelIndexList selectedIndexes = selectionModel()->selectedRows(); bool has_pause = false, has_start = false, has_preview = false; -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 bool all_same_super_seeding = true; bool super_seeding_mode = false; #endif @@ -1061,7 +1062,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { } } } -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 else { if(!one_not_seed && all_same_super_seeding && h.has_metadata()) { if(first) { @@ -1111,7 +1112,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { if(one_not_seed) listMenu.addAction(&actionSet_download_limit); listMenu.addAction(&actionSet_upload_limit); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 if(!one_not_seed && all_same_super_seeding && one_has_metadata) { QIcon ico; if(super_seeding_mode) { diff --git a/src/transferlistwidget.h b/src/transferlistwidget.h index bad59f83c..7203df493 100644 --- a/src/transferlistwidget.h +++ b/src/transferlistwidget.h @@ -31,7 +31,8 @@ #ifndef TRANSFERLISTWIDGET_H #define TRANSFERLISTWIDGET_H -#include +#include +#include #include "qtorrenthandle.h" class QStandardItemModel; @@ -105,7 +106,7 @@ protected slots: void updateMetadata(QTorrentHandle &h); void currentChanged(const QModelIndex& current, const QModelIndex&); void resumeTorrent(QTorrentHandle &h); -#ifdef LIBTORRENT_0_15 +#if LIBTORRENT_VERSION_MINOR > 14 void toggleSelectedTorrentsSuperSeeding() const; #endif void toggleSelectedTorrentsSequentialDownload() const;