Browse Source

Use libtorrent version.hpp instead of our own DEFINE

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
5f23cbc470
  1. 5
      src/advancedsettings.h
  2. 47
      src/bittorrent.cpp
  3. 13
      src/bittorrent.h
  4. 3
      src/createtorrent_imp.cpp
  5. 7
      src/eventmanager.cpp
  6. 7
      src/options_imp.cpp
  7. 5
      src/preferences.h
  8. 3
      src/previewselect.h
  9. 7
      src/propertieswidget.cpp
  10. 7
      src/qtorrenthandle.cpp
  11. 5
      src/qtorrenthandle.h
  12. 5
      src/torrentadditiondlg.h
  13. 3
      src/torrentpersistentdata.h
  14. 5
      src/trackerlist.cpp
  15. 3
      src/trackerlist.h
  16. 11
      src/transferlistwidget.cpp
  17. 5
      src/transferlistwidget.h

5
src/advancedsettings.h

@ -7,6 +7,7 @@
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
#include <QNetworkInterface> #include <QNetworkInterface>
#include <libtorrent/version.hpp>
#include "preferences.h" #include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE}; enum AdvSettingsCols {PROPERTY, VALUE};
@ -73,7 +74,7 @@ public slots:
Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked()); Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked());
// Max Half-Open connections // Max Half-Open connections
Preferences::setMaxHalfOpenConnections(spin_maxhalfopen->value()); Preferences::setMaxHalfOpenConnections(spin_maxhalfopen->value());
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Super seeding // Super seeding
Preferences::enableSuperSeeding(cb_super_seeding->isChecked()); Preferences::enableSuperSeeding(cb_super_seeding->isChecked());
#endif #endif
@ -164,7 +165,7 @@ protected slots:
setItem(SUPER_SEEDING, PROPERTY, new QTableWidgetItem(tr("Strict super seeding"))); setItem(SUPER_SEEDING, PROPERTY, new QTableWidgetItem(tr("Strict super seeding")));
cb_super_seeding = new QCheckBox(); cb_super_seeding = new QCheckBox();
connect(cb_super_seeding, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); connect(cb_super_seeding, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
cb_super_seeding->setChecked(Preferences::isSuperSeedingEnabled()); cb_super_seeding->setChecked(Preferences::isSuperSeedingEnabled());
#else #else
cb_super_seeding->setEnabled(false); cb_super_seeding->setEnabled(false);

47
src/bittorrent.cpp

@ -51,7 +51,8 @@
#include "httpserver.h" #include "httpserver.h"
#include "bandwidthscheduler.h" #include "bandwidthscheduler.h"
#include <libtorrent/extensions/ut_metadata.hpp> #include <libtorrent/extensions/ut_metadata.hpp>
#ifdef LIBTORRENT_0_15 #include <libtorrent/version.hpp>
#if LIBTORRENT_VERSION_MINOR > 14
#include <libtorrent/extensions/lt_trackers.hpp> #include <libtorrent/extensions/lt_trackers.hpp>
#endif #endif
#include <libtorrent/extensions/ut_pex.hpp> #include <libtorrent/extensions/ut_pex.hpp>
@ -121,7 +122,7 @@ Bittorrent::Bittorrent()
// Enabling plugins // Enabling plugins
//s->add_extension(&create_metadata_plugin); //s->add_extension(&create_metadata_plugin);
s->add_extension(&create_ut_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); s->add_extension(create_lt_trackers_plugin);
#endif #endif
if(Preferences::isPeXEnabled()) { if(Preferences::isPeXEnabled()) {
@ -141,7 +142,7 @@ Bittorrent::Bittorrent()
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString))); connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
appendLabelToSavePath = Preferences::appendTorrentLabel(); appendLabelToSavePath = Preferences::appendTorrentLabel();
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
appendqBExtension = Preferences::useIncompleteFilesExtension(); appendqBExtension = Preferences::useIncompleteFilesExtension();
#endif #endif
connect(m_scanFolders, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&))); connect(m_scanFolders, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&)));
@ -154,7 +155,7 @@ session_proxy Bittorrent::asyncDeletion() {
qDebug("Bittorrent session async deletion IN"); qDebug("Bittorrent session async deletion IN");
exiting = true; exiting = true;
// Do some BT related saving // Do some BT related saving
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
saveDHTEntry(); saveDHTEntry();
#endif #endif
saveSessionState(); saveSessionState();
@ -171,7 +172,7 @@ Bittorrent::~Bittorrent() {
qDebug("BTSession destructor IN"); qDebug("BTSession destructor IN");
if(!exiting) { if(!exiting) {
// Do some BT related saving // Do some BT related saving
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
saveDHTEntry(); saveDHTEntry();
#endif #endif
saveSessionState(); saveSessionState();
@ -281,7 +282,7 @@ void Bittorrent::configureSession() {
setDefaultTempPath(QString::null); setDefaultTempPath(QString::null);
} }
setAppendLabelToSavePath(Preferences::appendTorrentLabel()); setAppendLabelToSavePath(Preferences::appendTorrentLabel());
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
setAppendqBExtension(Preferences::useIncompleteFilesExtension()); setAppendqBExtension(Preferences::useIncompleteFilesExtension());
#endif #endif
preAllocateAllFiles(Preferences::preAllocateAllFiles()); preAllocateAllFiles(Preferences::preAllocateAllFiles());
@ -423,7 +424,7 @@ void Bittorrent::configureSession() {
sessionSettings.stop_tracker_timeout = 1; sessionSettings.stop_tracker_timeout = 1;
//sessionSettings.announce_to_all_trackers = true; //sessionSettings.announce_to_all_trackers = true;
sessionSettings.auto_scrape_interval = 1200; // 20 minutes 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_trackers = true;
sessionSettings.announce_to_all_tiers = true; //uTorrent behavior sessionSettings.announce_to_all_tiers = true; //uTorrent behavior
sessionSettings.auto_scrape_min_interval = 900; // 15 minutes sessionSettings.auto_scrape_min_interval = 900; // 15 minutes
@ -858,7 +859,7 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
qDebug("addMagnetURI: using save_path: %s", qPrintable(savePath)); 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) // Skip checking and directly start seeding (new in libtorrent v0.15)
if(TorrentTempData::isSeedingMode(hash)){ if(TorrentTempData::isSeedingMode(hash)){
p.seed_mode=true; p.seed_mode=true;
@ -1082,7 +1083,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
qDebug("addTorrent: using save_path: %s", qPrintable(savePath)); 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) // Skip checking and directly start seeding (new in libtorrent v0.15)
if(TorrentTempData::isSeedingMode(hash)){ if(TorrentTempData::isSeedingMode(hash)){
p.seed_mode=true; p.seed_mode=true;
@ -1173,7 +1174,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath)); qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath));
TorrentPersistentData::saveSavePath(hash, savePath); TorrentPersistentData::saveSavePath(hash, savePath);
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Append .!qB to incomplete files // Append .!qB to incomplete files
if(appendqBExtension) if(appendqBExtension)
appendqBextensionToTorrent(h, true); appendqBextensionToTorrent(h, true);
@ -1357,7 +1358,7 @@ void Bittorrent::enableLSD(bool b) {
void Bittorrent::loadSessionState() { void Bittorrent::loadSessionState() {
const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state"); const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
if(!QFile::exists(state_path)) return; if(!QFile::exists(state_path)) return;
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
std::vector<char> in; std::vector<char> in;
if (load_file(state_path.toLocal8Bit().constData(), in) == 0) if (load_file(state_path.toLocal8Bit().constData(), in) == 0)
{ {
@ -1378,7 +1379,7 @@ void Bittorrent::loadSessionState() {
void Bittorrent::saveSessionState() { void Bittorrent::saveSessionState() {
qDebug("Saving session state to disk..."); qDebug("Saving session state to disk...");
const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state"); const QString state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
entry session_state; entry session_state;
s->save_state(session_state); s->save_state(session_state);
std::vector<char> out; std::vector<char> out;
@ -1404,7 +1405,7 @@ void Bittorrent::saveSessionState() {
bool Bittorrent::enableDHT(bool b) { bool Bittorrent::enableDHT(bool b) {
if(b) { if(b) {
if(!DHTEnabled) { if(!DHTEnabled) {
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
entry dht_state; entry dht_state;
const QString dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state"); const QString dht_state_path = misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state");
if(QFile::exists(dht_state_path)) { if(QFile::exists(dht_state_path)) {
@ -1416,7 +1417,7 @@ bool Bittorrent::enableDHT(bool b) {
} }
#endif #endif
try { try {
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
s->start_dht(); s->start_dht();
#else #else
s->start_dht(dht_state); s->start_dht(dht_state);
@ -1632,7 +1633,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
defaultTempPath = temppath; defaultTempPath = temppath;
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) { void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) {
if(!h.is_valid() || !h.has_metadata()) return; if(!h.is_valid() || !h.has_metadata()) return;
std::vector<size_type> fp; std::vector<size_type> fp;
@ -1704,7 +1705,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
} }
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
void Bittorrent::setAppendqBExtension(bool append) { void Bittorrent::setAppendqBExtension(bool append) {
if(appendqBExtension != append) { if(appendqBExtension != append) {
appendqBExtension = !appendqBExtension; appendqBExtension = !appendqBExtension;
@ -1932,7 +1933,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
if(h.is_valid()) { if(h.is_valid()) {
emit finishedTorrent(h); emit finishedTorrent(h);
const QString &hash = h.hash(); const QString &hash = h.hash();
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Remove .!qB extension if necessary // Remove .!qB extension if necessary
if(appendqBExtension) if(appendqBExtension)
appendqBextensionToTorrent(h, false); appendqBextensionToTorrent(h, false);
@ -2059,7 +2060,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
} }
} }
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Append .!qB to incomplete files // Append .!qB to incomplete files
if(appendqBExtension) if(appendqBExtension)
appendqBextensionToTorrent(h, true); appendqBextensionToTorrent(h, true);
@ -2089,7 +2090,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
} }
} }
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
else if (file_completed_alert* p = dynamic_cast<file_completed_alert*>(a.get())) { else if (file_completed_alert* p = dynamic_cast<file_completed_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
if(appendqBExtension) { if(appendqBExtension) {
@ -2119,7 +2120,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>()); QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
data.last_message = misc::toQString(p->msg); data.last_message = misc::toQString(p->msg);
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
data.verified = false; data.verified = false;
++data.fail_count; ++data.fail_count;
#endif #endif
@ -2140,7 +2141,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
data.last_message = ""; // Reset error/warning message data.last_message = ""; // Reset error/warning message
data.num_peers = p->num_peers; data.num_peers = p->num_peers;
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
data.fail_count = 0; data.fail_count = 0;
data.verified = true; data.verified = true;
#endif #endif
@ -2155,7 +2156,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
const QString &tracker_url = misc::toQString(p->url); const QString &tracker_url = misc::toQString(p->url);
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
data.last_message = misc::toQString(p->msg); // Store warning message data.last_message = misc::toQString(p->msg); // Store warning message
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
data.verified = true; data.verified = true;
data.fail_count = 0; data.fail_count = 0;
#endif #endif
@ -2388,7 +2389,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
return sessionStatus.payload_upload_rate; return sessionStatus.payload_upload_rate;
} }
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
// Save DHT entry to hard drive // Save DHT entry to hard drive
void Bittorrent::saveDHTEntry() { void Bittorrent::saveDHTEntry() {
// Save DHT entry // Save DHT entry

13
src/bittorrent.h

@ -43,6 +43,7 @@
#include <QPointer> #include <QPointer>
#include <QTimer> #include <QTimer>
#include <libtorrent/version.hpp>
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/ip_filter.hpp> #include <libtorrent/ip_filter.hpp>
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
@ -63,7 +64,7 @@ public:
QString name_or_url; QString name_or_url;
QString last_message; QString last_message;
unsigned long num_peers; unsigned long num_peers;
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
bool verified; bool verified;
uint fail_count; uint fail_count;
#endif #endif
@ -74,13 +75,13 @@ public:
Q_ASSERT(!name_or_url.isEmpty()); Q_ASSERT(!name_or_url.isEmpty());
last_message = b.last_message; last_message = b.last_message;
num_peers = b.num_peers; num_peers = b.num_peers;
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
verified = b.verified; verified = b.verified;
fail_count = b.fail_count; fail_count = b.fail_count;
#endif #endif
} }
TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) { 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; fail_count = 0;
verified = false; verified = false;
#endif #endif
@ -135,7 +136,7 @@ public slots:
void resumeTorrent(QString hash); void resumeTorrent(QString hash);
void resumeAllTorrents(); void resumeAllTorrents();
/* End Web UI */ /* End Web UI */
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
void saveDHTEntry(); void saveDHTEntry();
#endif #endif
void preAllocateAllFiles(bool b); void preAllocateAllFiles(bool b);
@ -163,7 +164,7 @@ public slots:
void setAppendLabelToSavePath(bool append); void setAppendLabelToSavePath(bool append);
void appendLabelToTorrentSavePath(QTorrentHandle h); void appendLabelToTorrentSavePath(QTorrentHandle h);
void changeLabelInTorrentSavePath(QTorrentHandle h, QString old_label, QString new_label); 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 appendqBextensionToTorrent(QTorrentHandle h, bool append);
void setAppendqBExtension(bool append); void setAppendqBExtension(bool append);
#endif #endif
@ -249,7 +250,7 @@ private:
bool queueingEnabled; bool queueingEnabled;
bool appendLabelToSavePath; bool appendLabelToSavePath;
bool torrentExport; bool torrentExport;
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
bool appendqBExtension; bool appendqBExtension;
#endif #endif
QString defaultSavePath; QString defaultSavePath;

3
src/createtorrent_imp.cpp

@ -37,6 +37,7 @@
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <libtorrent/version.hpp>
#include <libtorrent/entry.hpp> #include <libtorrent/entry.hpp>
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#include <libtorrent/torrent_info.hpp> #include <libtorrent/torrent_info.hpp>
@ -208,7 +209,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path)
} }
QString hash = misc::toQString(t->info_hash()); QString hash = misc::toQString(t->info_hash());
TorrentTempData::setSavePath(hash, QString::fromLocal8Bit(branch_path)); TorrentTempData::setSavePath(hash, QString::fromLocal8Bit(branch_path));
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Enable seeding mode (do not recheck the files) // Enable seeding mode (do not recheck the files)
TorrentTempData::setSeedingMode(hash, true); TorrentTempData::setSeedingMode(hash, true);
#endif #endif

7
src/eventmanager.cpp

@ -29,6 +29,7 @@
*/ */
#include <libtorrent/version.hpp>
#include "eventmanager.h" #include "eventmanager.h"
#include "bittorrent.h" #include "bittorrent.h"
#include "scannedfoldersmodel.h" #include "scannedfoldersmodel.h"
@ -60,7 +61,7 @@ QList<QVariantMap> EventManager::getPropTrackersInfo(QString hash) const {
tracker["url"] = tracker_url; tracker["url"] = tracker_url;
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
QString error_message = data.last_message.trimmed(); QString error_message = data.last_message.trimmed();
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
if(it->verified) { if(it->verified) {
tracker["status"] = tr("Working"); tracker["status"] = tr("Working");
} else { } else {
@ -171,7 +172,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
Preferences::setMaxActiveTorrents(m["max_active_torrents"].toInt()); Preferences::setMaxActiveTorrents(m["max_active_torrents"].toInt());
if(m.contains("max_active_uploads")) if(m.contains("max_active_uploads"))
Preferences::setMaxActiveUploads(m["max_active_uploads"].toInt()); Preferences::setMaxActiveUploads(m["max_active_uploads"].toInt());
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
if(m.contains("incomplete_files_ext")) if(m.contains("incomplete_files_ext"))
Preferences::useIncompleteFilesExtension(m["incomplete_files_ext"].toBool()); Preferences::useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
#endif #endif
@ -274,7 +275,7 @@ QVariantMap EventManager::getGlobalPreferences() const {
data["max_active_downloads"] = Preferences::getMaxActiveDownloads(); data["max_active_downloads"] = Preferences::getMaxActiveDownloads();
data["max_active_torrents"] = Preferences::getMaxActiveTorrents(); data["max_active_torrents"] = Preferences::getMaxActiveTorrents();
data["max_active_uploads"] = Preferences::getMaxActiveUploads(); data["max_active_uploads"] = Preferences::getMaxActiveUploads();
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
data["incomplete_files_ext"] = Preferences::useIncompleteFilesExtension(); data["incomplete_files_ext"] = Preferences::useIncompleteFilesExtension();
#endif #endif
// Connection // Connection

7
src/options_imp.cpp

@ -39,6 +39,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QStyleFactory> #include <QStyleFactory>
#include <libtorrent/version.hpp>
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
@ -283,7 +284,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
} }
// Tab selection mecanism // Tab selection mecanism
connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
checkAppendqB->setVisible(false); checkAppendqB->setVisible(false);
#endif #endif
// Load Advanced settings // Load Advanced settings
@ -403,7 +404,7 @@ void options_imp::saveOptions(){
#endif #endif
settings.setValue(QString::fromUtf8("TempPath"), temp_path); settings.setValue(QString::fromUtf8("TempPath"), temp_path);
settings.setValue(QString::fromUtf8("AppendLabel"), checkAppendLabel->isChecked()); settings.setValue(QString::fromUtf8("AppendLabel"), checkAppendLabel->isChecked());
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked()); settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked());
#endif #endif
settings.setValue(QString::fromUtf8("PreAllocation"), preAllocateAllFiles()); settings.setValue(QString::fromUtf8("PreAllocation"), preAllocateAllFiles());
@ -644,7 +645,7 @@ void options_imp::loadOptions(){
#endif #endif
textTempPath->setText(temp_path); textTempPath->setText(temp_path);
checkAppendLabel->setChecked(Preferences::appendTorrentLabel()); checkAppendLabel->setChecked(Preferences::appendTorrentLabel());
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension()); checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension());
#endif #endif
checkPreallocateAll->setChecked(Preferences::preAllocateAllFiles()); checkPreallocateAll->setChecked(Preferences::preAllocateAllFiles());

5
src/preferences.h

@ -37,6 +37,7 @@
#include <QDir> #include <QDir>
#include <QTime> #include <QTime>
#include <QList> #include <QList>
#include <libtorrent/version.hpp>
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
#include <QApplication> #include <QApplication>
@ -178,7 +179,7 @@ public:
settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path); settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path);
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
static bool useIncompleteFilesExtension() { static bool useIncompleteFilesExtension() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool(); return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool();
@ -967,7 +968,7 @@ public:
return settings.value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString(); return settings.value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString();
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
static bool isSuperSeedingEnabled() { static bool isSuperSeedingEnabled() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool(); return settings.value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool();

3
src/previewselect.h

@ -36,6 +36,7 @@
#include <QHeaderView> #include <QHeaderView>
#include <QMessageBox> #include <QMessageBox>
#include <QFile> #include <QFile>
#include <libtorrent/version.hpp>
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include "ui_preview.h" #include "ui_preview.h"
#include "previewlistdelegate.h" #include "previewlistdelegate.h"
@ -65,7 +66,7 @@ protected slots:
QModelIndex index; QModelIndex index;
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME); QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(NAME);
if(selectedIndexes.size() == 0) return; if(selectedIndexes.size() == 0) return;
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Flush data // Flush data
h.flush_cache(); h.flush_cache();
#endif #endif

7
src/propertieswidget.cpp

@ -40,6 +40,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QDesktopServices> #include <QDesktopServices>
#include <QInputDialog> #include <QInputDialog>
#include <libtorrent/version.hpp>
#include "propertieswidget.h" #include "propertieswidget.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
#include "torrentpersistentdata.h" #include "torrentpersistentdata.h"
@ -101,7 +102,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
ProgressHLayout_2->insertWidget(1, pieces_availability); ProgressHLayout_2->insertWidget(1, pieces_availability);
// Tracker list // Tracker list
trackerList = new TrackerList(this); trackerList = new TrackerList(this);
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
trackerUpButton->setVisible(false); trackerUpButton->setVisible(false);
trackerDownButton->setVisible(false); trackerDownButton->setVisible(false);
#else #else
@ -492,7 +493,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
const QString &filename = misc::toQStringU(h.get_torrent_info().file_at(i).path.string()); const QString &filename = misc::toQStringU(h.get_torrent_info().file_at(i).path.string());
const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename)); const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename));
qDebug("Trying to open file at %s", qPrintable(file_path)); qDebug("Trying to open file at %s", qPrintable(file_path));
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Flush data // Flush data
h.flush_cache(); h.flush_cache();
#endif #endif
@ -518,7 +519,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
const QString &filename = path_items.join(QDir::separator()); const QString &filename = path_items.join(QDir::separator());
const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename)); const QString &file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename));
qDebug("Trying to open folder at %s", qPrintable(file_path)); qDebug("Trying to open folder at %s", qPrintable(file_path));
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Flush data // Flush data
h.flush_cache(); h.flush_cache();
#endif #endif

7
src/qtorrenthandle.cpp

@ -37,6 +37,7 @@
#include "misc.h" #include "misc.h"
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
#include "torrentpersistentdata.h" #include "torrentpersistentdata.h"
#include <libtorrent/version.hpp>
#include <libtorrent/magnet_uri.hpp> #include <libtorrent/magnet_uri.hpp>
#include <libtorrent/torrent_info.hpp> #include <libtorrent/torrent_info.hpp>
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
@ -228,7 +229,7 @@ QString QTorrentHandle::save_path() const {
return misc::toQString(h.save_path().string()); return misc::toQString(h.save_path().string());
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
bool QTorrentHandle::super_seeding() const { bool QTorrentHandle::super_seeding() const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.super_seeding(); return h.super_seeding();
@ -595,7 +596,7 @@ void QTorrentHandle::file_priority(int index, int priority) const {
TorrentPersistentData::saveSeedStatus(*this); TorrentPersistentData::saveSeedStatus(*this);
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
void QTorrentHandle::super_seeding(bool on) const { void QTorrentHandle::super_seeding(bool on) const {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.super_seeding(on); h.super_seeding(on);
@ -648,7 +649,7 @@ void QTorrentHandle::set_peer_download_limit(libtorrent::asio::ip::tcp::endpoint
void QTorrentHandle::add_tracker(announce_entry const& url) { void QTorrentHandle::add_tracker(announce_entry const& url) {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
h.add_tracker(url); h.add_tracker(url);
#else #else
std::vector<announce_entry> trackers = h.trackers(); std::vector<announce_entry> trackers = h.trackers();

5
src/qtorrenthandle.h

@ -31,6 +31,7 @@
#ifndef QTORRENTHANDLE_H #ifndef QTORRENTHANDLE_H
#define QTORRENTHANDLE_H #define QTORRENTHANDLE_H
#include <libtorrent/version.hpp>
#include <libtorrent/torrent_handle.hpp> #include <libtorrent/torrent_handle.hpp>
#include <libtorrent/torrent_info.hpp> #include <libtorrent/torrent_info.hpp>
@ -117,7 +118,7 @@ class QTorrentHandle {
qlonglong seeding_time() const; qlonglong seeding_time() const;
std::vector<int> file_priorities() const; std::vector<int> file_priorities() const;
bool is_sequential_download() const; bool is_sequential_download() const;
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
bool super_seeding() const; bool super_seeding() const;
#endif #endif
QString creation_date() const; QString creation_date() const;
@ -158,7 +159,7 @@ class QTorrentHandle {
void auto_managed(bool) const; void auto_managed(bool) const;
void force_recheck() const; void force_recheck() const;
void move_storage(QString path) const; void move_storage(QString path) const;
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
void super_seeding(bool on) const; void super_seeding(bool on) const;
void flush_cache() const; void flush_cache() const;
#endif #endif

5
src/torrentadditiondlg.h

@ -43,6 +43,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QInputDialog> #include <QInputDialog>
#include <libtorrent/version.hpp>
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#include "bittorrent.h" #include "bittorrent.h"
@ -108,7 +109,7 @@ public:
addInPause->setChecked(true); addInPause->setChecked(true);
//addInPause->setEnabled(false); //addInPause->setEnabled(false);
} }
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
addInSeed->setVisible(false); addInSeed->setVisible(false);
#endif #endif
} }
@ -512,7 +513,7 @@ public slots:
TorrentTempData::setFilesPath(hash, files_path); TorrentTempData::setFilesPath(hash, files_path);
} }
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
// Skip file checking and directly start seeding // Skip file checking and directly start seeding
if(addInSeed->isChecked()) { if(addInSeed->isChecked()) {
// Check if local file(s) actually exist // Check if local file(s) actually exist

3
src/torrentpersistentdata.h

@ -34,6 +34,7 @@
#include <QSettings> #include <QSettings>
#include <QVariant> #include <QVariant>
#include <QDateTime> #include <QDateTime>
#include <libtorrent/version.hpp>
#include <libtorrent/magnet_uri.hpp> #include <libtorrent/magnet_uri.hpp>
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
#include "misc.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){ static void setSeedingMode(QString hash,bool seed){
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();

5
src/trackerlist.cpp

@ -35,6 +35,7 @@
#include <QHash> #include <QHash>
#include <QAction> #include <QAction>
#include <QColor> #include <QColor>
#include <libtorrent/version.hpp>
#include "trackerlist.h" #include "trackerlist.h"
#include "propertieswidget.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() { void TrackerList::moveSelectionUp() {
QTorrentHandle h = properties->getCurrentTorrent(); QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) { if(!h.is_valid()) {
@ -241,7 +242,7 @@ void TrackerList::loadTrackers() {
} }
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url)); TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
QString error_message = data.last_message.trimmed(); QString error_message = data.last_message.trimmed();
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
if(it->verified) { if(it->verified) {
item->setText(COL_STATUS, tr("Working")); item->setText(COL_STATUS, tr("Working"));
item->setText(COL_MSG, ""); item->setText(COL_MSG, "");

3
src/trackerlist.h

@ -34,6 +34,7 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QList> #include <QList>
#include <libtorrent/version.hpp>
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
enum TrackerListColumn {COL_URL, COL_STATUS, COL_PEERS, COL_MSG}; enum TrackerListColumn {COL_URL, COL_STATUS, COL_PEERS, COL_MSG};
@ -62,7 +63,7 @@ protected:
public slots: public slots:
void setRowColor(int row, QColor color); void setRowColor(int row, QColor color);
#ifndef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR < 15
void moveSelectionUp(); void moveSelectionUp();
void moveSelectionDown(); void moveSelectionDown();
#endif #endif

11
src/transferlistwidget.cpp

@ -38,6 +38,7 @@
#include "GUI.h" #include "GUI.h"
#include "preferences.h" #include "preferences.h"
#include "deletionconfirmationdlg.h" #include "deletionconfirmationdlg.h"
#include <libtorrent/version.hpp>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QDesktopServices> #include <QDesktopServices>
@ -932,7 +933,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&){
} }
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const { void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const {
const QStringList &hashes = getSelectedTorrentsHashes(); const QStringList &hashes = getSelectedTorrentsHashes();
foreach(const QString &hash, hashes) { foreach(const QString &hash, hashes) {
@ -1055,7 +1056,7 @@ void TransferListWidget::displayListMenu(const QPoint&) {
connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents())); connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents()));
QAction actionCopy_magnet_link(QIcon(QString::fromUtf8(":/Icons/magnet.png")), tr("Copy magnet link"), 0); QAction actionCopy_magnet_link(QIcon(QString::fromUtf8(":/Icons/magnet.png")), tr("Copy magnet link"), 0);
connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs())); 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); QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0);
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding())); connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
#endif #endif
@ -1070,7 +1071,7 @@ void TransferListWidget::displayListMenu(const QPoint&) {
// Enable/disable pause/start action given the DL state // Enable/disable pause/start action given the DL state
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
bool has_pause = false, has_start = false, has_preview = false; 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 all_same_super_seeding = true;
bool super_seeding_mode = false; bool super_seeding_mode = false;
#endif #endif
@ -1104,7 +1105,7 @@ void TransferListWidget::displayListMenu(const QPoint&) {
} }
} }
} }
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
else { else {
if(!one_not_seed && all_same_super_seeding && h.has_metadata()) { if(!one_not_seed && all_same_super_seeding && h.has_metadata()) {
if(first) { if(first) {
@ -1155,7 +1156,7 @@ void TransferListWidget::displayListMenu(const QPoint&) {
if(one_not_seed) if(one_not_seed)
listMenu.addAction(&actionSet_download_limit); listMenu.addAction(&actionSet_download_limit);
listMenu.addAction(&actionSet_upload_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) { if(!one_not_seed && all_same_super_seeding && one_has_metadata) {
QIcon ico; QIcon ico;
if(super_seeding_mode) { if(super_seeding_mode) {

5
src/transferlistwidget.h

@ -31,7 +31,8 @@
#ifndef TRANSFERLISTWIDGET_H #ifndef TRANSFERLISTWIDGET_H
#define TRANSFERLISTWIDGET_H #define TRANSFERLISTWIDGET_H
#include<QTreeView> #include <QTreeView>
#include <libtorrent/version.hpp>
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
class QStandardItemModel; class QStandardItemModel;
@ -106,7 +107,7 @@ protected slots:
void updateMetadata(QTorrentHandle &h); void updateMetadata(QTorrentHandle &h);
void currentChanged(const QModelIndex& current, const QModelIndex&); void currentChanged(const QModelIndex& current, const QModelIndex&);
void resumeTorrent(QTorrentHandle &h); void resumeTorrent(QTorrentHandle &h);
#ifdef LIBTORRENT_0_15 #if LIBTORRENT_VERSION_MINOR > 14
void toggleSelectedTorrentsSuperSeeding() const; void toggleSelectedTorrentsSuperSeeding() const;
#endif #endif
void toggleSelectedTorrentsSequentialDownload() const; void toggleSelectedTorrentsSequentialDownload() const;

Loading…
Cancel
Save