From b4dca951b24c1140c6276a9811a85ea1984d7ea0 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Wed, 23 Oct 2013 22:16:23 +0300 Subject: [PATCH] Drop libtorrent 0.15.x support. --- .travis.yml | 9 +- configure | 4 +- src/addnewtorrentdialog.cpp | 20 --- src/mainwindow.cpp | 12 +- src/misc.cpp | 15 -- src/misc.h | 4 - src/preferences/advancedsettings.h | 12 +- src/preferences/options_imp.cpp | 14 -- src/preferences/preferences.h | 8 - src/properties/peerlistwidget.cpp | 8 - src/properties/propertieswidget.cpp | 4 - src/properties/proplistdelegate.h | 7 +- src/qtlibtorrent/qbtsession.cpp | 175 +------------------- src/qtlibtorrent/qbtsession.h | 2 - src/qtlibtorrent/qtorrenthandle.cpp | 174 +------------------ src/qtlibtorrent/torrentspeedmonitor.cpp | 5 - src/statusbar.h | 8 - src/torrentcontentmodel.cpp | 4 - src/torrentcontentmodelfile.cpp | 4 - src/torrentcreator/torrentcreatorthread.cpp | 20 --- src/torrentimportdlg.cpp | 12 -- src/webui/httpconnection.cpp | 8 - src/webui/prefjson.cpp | 8 - 23 files changed, 19 insertions(+), 518 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e4ca6134..ade815c6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,9 @@ language: env: # use libtorrent 0.15.10 - - lt_source=from_dist gui=true - - lt_source=from_dist gui=false + # uncomment when Travis doesn't use Ubuntu 12.04 LTS, which has libtorrent 0.15.10 as package + #- lt_source=from_dist gui=true + #- lt_source=from_dist gui=false # use libtorrent 0.16.X from RC_0_16 svn branch - lt_source=from_svn gui=true - lt_source=from_svn gui=false @@ -38,7 +39,9 @@ before_install: - sudo apt-get -qq update # Travis can stall during heavy load if these packages are installed in one step - split the command - sudo apt-get -qq install debhelper qconf colormake libssl-dev libgeoip-dev - - sudo apt-get -qq install libboost-dev libboost-filesystem-dev libboost-system-dev + # uncomment when Travis doesn't use Ubuntu 12.04 LTS, which has libtorrent 0.15.10 as package + #- sudo apt-get -qq install libboost-dev libboost-filesystem-dev libboost-system-dev + - sudo apt-get -qq install libboost-dev libboost-system-dev - sudo apt-get -qq install libqt4-dev install: diff --git a/configure b/configure index 61350e20b..53c8b8980 100755 --- a/configure +++ b/configure @@ -419,11 +419,11 @@ class qc_libtorrent_rasterbar : public ConfObj { public: qc_libtorrent_rasterbar(Conf *c) : ConfObj(c) {} - QString name() const { return "libtorrent-rasterbar >= 0.15.0"; } + QString name() const { return "libtorrent-rasterbar >= 0.16.0"; } QString shortname() const { return "libtorrent-rasterbar"; } bool exec(){ QStringList incs; - QString req_ver = "0.15.0"; + QString req_ver = "0.16.0"; QString version, libs, other; VersionMode mode = VersionMin; if(!conf->findPkgConfig("libtorrent-rasterbar", mode, req_ver, &version, &incs, &libs, &other)) diff --git a/src/addnewtorrentdialog.cpp b/src/addnewtorrentdialog.cpp index 91343f14e..4ed0994b2 100644 --- a/src/addnewtorrentdialog.cpp +++ b/src/addnewtorrentdialog.cpp @@ -213,17 +213,11 @@ bool AddNewTorrentDialog::loadTorrent(const QString& torrent_path, const QString ui->date_lbl->setText(m_torrentInfo->creation_date() ? misc::toQString(*m_torrentInfo->creation_date()) : tr("Not available")); updateDiskSpaceLabel(); -#if LIBTORRENT_VERSION_NUM >= 001600 file_storage fs = m_torrentInfo->files(); -#endif // Populate m_filesList for (int i = 0; i < m_torrentInfo->num_files(); ++i) { -#if LIBTORRENT_VERSION_NUM >= 001600 m_filesPath << misc::toQStringU(fs.file_path(m_torrentInfo->file_at(i))); -#else - m_filesPath << misc::toQStringU(m_torrentInfo->file_at(i).path.string()); -#endif } // Prepare content tree @@ -245,11 +239,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString& torrent_path, const QString ui->content_tree->header()->setResizeMode(0, QHeaderView::Stretch); } else { // Update save paths (append file name to them) -#if LIBTORRENT_VERSION_NUM >= 001600 QString single_file_relpath = misc::toQStringU(fs.file_path(m_torrentInfo->file_at(0))); -#else - QString single_file_relpath = misc::toQStringU(m_torrentInfo->file_at(0).path.string()); -#endif for (int i=0; isave_path_combo->count()-1; ++i) { ui->save_path_combo->setItemText(i, fsutils::toDisplayPath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath))); } @@ -674,17 +664,11 @@ void AddNewTorrentDialog::updateMetadata(const QTorrentHandle &h) { ui->date_lbl->setText(m_torrentInfo->creation_date() ? misc::toQString(*m_torrentInfo->creation_date()) : tr("Not available")); updateDiskSpaceLabel(); -#if LIBTORRENT_VERSION_NUM >= 001600 file_storage fs = m_torrentInfo->files(); -#endif // Populate m_filesList for (int i = 0; i < m_torrentInfo->num_files(); ++i) { -#if LIBTORRENT_VERSION_NUM >= 001600 m_filesPath << misc::toQStringU(fs.file_path(m_torrentInfo->file_at(i))); -#else - m_filesPath << misc::toQStringU(m_torrentInfo->file_at(i).path.string()); -#endif } // Prepare content tree @@ -706,11 +690,7 @@ void AddNewTorrentDialog::updateMetadata(const QTorrentHandle &h) { ui->content_tree->header()->setResizeMode(0, QHeaderView::Stretch); } else { // Update save paths (append file name to them) -#if LIBTORRENT_VERSION_NUM >= 001600 QString single_file_relpath = misc::toQStringU(fs.file_path(m_torrentInfo->file_at(0))); -#else - QString single_file_relpath = misc::toQStringU(m_torrentInfo->file_at(0).path.string()); -#endif for (int i=0; isave_path_combo->count()-1; ++i) { ui->save_path_combo->setItemText(i, fsutils::toDisplayPath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath))); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7ad6a0b49..f54bcc18d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -620,11 +620,7 @@ void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const void MainWindow::on_actionSet_global_upload_limit_triggered() { qDebug("actionSet_global_upload_limit_triggered"); bool ok; -#if LIBTORRENT_VERSION_NUM >= 001600 - int cur_limit = QBtSession::instance()->getSession()->settings().upload_rate_limit; -#else - int cur_limit = QBtSession::instance()->getSession()->upload_rate_limit(); -#endif + int cur_limit = QBtSession::instance()->getSession()->settings().upload_rate_limit; const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit); if (ok) { qDebug("Setting global upload rate limit to %.1fKb/s", new_limit/1024.); @@ -639,11 +635,7 @@ void MainWindow::on_actionSet_global_upload_limit_triggered() { void MainWindow::on_actionSet_global_download_limit_triggered() { qDebug("actionSet_global_download_limit_triggered"); bool ok; -#if LIBTORRENT_VERSION_NUM >= 001600 - int cur_limit = QBtSession::instance()->getSession()->settings().download_rate_limit; -#else - int cur_limit = QBtSession::instance()->getSession()->download_rate_limit(); -#endif + int cur_limit = QBtSession::instance()->getSession()->settings().download_rate_limit; const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), cur_limit); if (ok) { qDebug("Setting global download rate limit to %.1fKb/s", new_limit/1024.); diff --git a/src/misc.cpp b/src/misc.cpp index 05b07453a..5f5356ec6 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -504,25 +504,10 @@ QString misc::parseHtmlLinks(const QString &raw_text) return result; } -#if LIBTORRENT_VERSION_NUM < 001600 -QString misc::toQString(const boost::posix_time::ptime& boostDate) { - if (boostDate.is_not_a_date_time()) return ""; - struct std::tm tm; - try { - tm = boost::posix_time::to_tm(boostDate); - } catch(std::exception e) { - return ""; - } - const time_t t = mktime(&tm); - const QDateTime dt = QDateTime::fromTime_t(t); - return dt.toString(Qt::DefaultLocaleLongDate); -} -#else QString misc::toQString(time_t t) { return QDateTime::fromTime_t(t).toString(Qt::DefaultLocaleLongDate); } -#endif #ifndef DISABLE_GUI bool misc::naturalSort(QString left, QString right, bool &result) { // uses lessThan comparison diff --git a/src/misc.h b/src/misc.h index 883aef26f..6aeb2db90 100644 --- a/src/misc.h +++ b/src/misc.h @@ -107,11 +107,7 @@ namespace misc QList intListfromStringList(const QStringList &l); QList boolListfromStringList(const QStringList &l); -#if LIBTORRENT_VERSION_NUM < 001600 - QString toQString(const boost::posix_time::ptime& boostDate); -#else QString toQString(time_t t); -#endif #ifndef DISABLE_GUI bool naturalSort(QString left, QString right, bool& result); diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index db030447c..1b7dad66c 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -13,11 +13,7 @@ #include "preferences.h" enum AdvSettingsCols {PROPERTY, VALUE}; -enum AdvSettingsRows {DISK_CACHE, - #if LIBTORRENT_VERSION_NUM >= 001610 - DISK_CACHE_TTL, - #endif - OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, +enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, #if defined(Q_WS_WIN) || defined(Q_WS_MAC) UPDATE_CHECK, #endif @@ -37,9 +33,7 @@ private: cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion, cb_enable_tracker_ext; QComboBox combo_iface; -#if LIBTORRENT_VERSION_NUM >= 001610 QSpinBox spin_cache_ttl; -#endif #if defined(Q_WS_WIN) || defined(Q_WS_MAC) QCheckBox cb_update_check; #endif @@ -76,9 +70,7 @@ public slots: Preferences pref; // Disk write cache pref.setDiskCacheSize(spin_cache.value()); -#if LIBTORRENT_VERSION_NUM >= 001610 pref.setDiskCacheTTL(spin_cache_ttl.value()); -#endif // Outgoing ports pref.setOutgoingPortsMin(outgoing_ports_min.value()); pref.setOutgoingPortsMax(outgoing_ports_max.value()); @@ -182,14 +174,12 @@ private slots: spin_cache.setValue(pref.diskCacheSize()); updateCacheSpinSuffix(spin_cache.value()); setRow(DISK_CACHE, tr("Disk write cache size"), &spin_cache); -#if LIBTORRENT_VERSION_NUM >= 001610 // Disk cache expiry spin_cache_ttl.setMinimum(15); spin_cache_ttl.setMaximum(600); spin_cache_ttl.setValue(pref.diskCacheTTL()); spin_cache_ttl.setSuffix(tr(" s", " seconds")); setRow(DISK_CACHE_TTL, tr("Disk cache expiry interval"), &spin_cache_ttl); -#endif // Outgoing port Min outgoing_ports_min.setMinimum(0); outgoing_ports_min.setMaximum(65535); diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index 15401a9d5..ef28b51e4 100755 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -122,10 +122,6 @@ options_imp::options_imp(QWidget *parent): checkStartup->setVisible(false); groupFileAssociation->setVisible(false); #endif -#if LIBTORRENT_VERSION_NUM < 001600 - checkAnonymousMode->setVisible(false); - label_anonymous->setVisible(false); -#endif // Connect signals / slots connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int))); @@ -208,9 +204,7 @@ options_imp::options_imp(QWidget *parent): connect(spinMaxUploads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxUploadsPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(checkDHT, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); -#if LIBTORRENT_VERSION_NUM >= 001600 connect(checkAnonymousMode, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); -#endif connect(checkPeX, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkDifferentDHTPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(spinDHTPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); @@ -254,10 +248,6 @@ options_imp::options_imp(QWidget *parent): applyButton->setEnabled(false); // Tab selection mecanism connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); -#if LIBTORRENT_VERSION_NUM < 001600 - checkuTP->setVisible(false); - checkLimituTPConnections->setVisible(false); -#endif // Load Advanced settings QVBoxLayout *adv_layout = new QVBoxLayout(); advancedSettings = new AdvancedSettings(); @@ -459,9 +449,7 @@ void options_imp::saveOptions() { pref.setDHTPort(getDHTPort()); pref.setLSDEnabled(isLSDEnabled()); pref.setEncryptionSetting(getEncryptionSetting()); -#if LIBTORRENT_VERSION_NUM >= 001600 pref.enableAnonymousMode(checkAnonymousMode->isChecked()); -#endif pref.setGlobalMaxRatio(getMaxRatio()); pref.setMaxRatioAction(comboRatioLimitAct->currentIndex()); // End Bittorrent preferences @@ -745,11 +733,9 @@ void options_imp::loadOptions() { checkPeX->setChecked(pref.isPeXEnabled()); checkLSD->setChecked(pref.isLSDEnabled()); comboEncryption->setCurrentIndex(pref.getEncryptionSetting()); -#if LIBTORRENT_VERSION_NUM >= 001600 checkAnonymousMode->setChecked(pref.isAnonymousModeEnabled()); /* make sure ui matches options */ toggleAnonymousMode(checkAnonymousMode->isChecked()); -#endif // Ratio limit floatValue = pref.getGlobalMaxRatio(); if (floatValue >= 0.) { diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index 5a44ab7d4..f5606b27a 100755 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -976,18 +976,13 @@ public: } uint diskCacheSize() const { -#if LIBTORRENT_VERSION_NUM >= 001610 return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 0).toUInt(); -#else - return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 128).toUInt(); -#endif } void setDiskCacheSize(uint size) { setValue(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), size); } -#if LIBTORRENT_VERSION_NUM >= 001610 uint diskCacheTTL() const { return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheTTL"), 60).toUInt(); } @@ -995,7 +990,6 @@ public: void setDiskCacheTTL(uint ttl) { setValue(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheTTL"), ttl); } -#endif uint outgoingPortsMin() const { return value(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMin"), 0).toUInt(); @@ -1105,7 +1099,6 @@ public: return value(QString::fromUtf8("Preferences/Connection/InetAddress"), QString()).toString(); } -#if LIBTORRENT_VERSION_NUM >= 001600 bool isAnonymousModeEnabled() const { return value(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), false).toBool(); } @@ -1113,7 +1106,6 @@ public: void enableAnonymousMode(bool enabled) { setValue(QString::fromUtf8("Preferences/Advanced/AnonymousMode"), enabled); } -#endif bool isSuperSeedingEnabled() const { return value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool(); diff --git a/src/properties/peerlistwidget.cpp b/src/properties/peerlistwidget.cpp index dad6e8d76..6f64aa1ea 100644 --- a/src/properties/peerlistwidget.cpp +++ b/src/properties/peerlistwidget.cpp @@ -238,12 +238,10 @@ void PeerListWidget::limitUpRateSelectedPeers(const QStringList& peer_ips) bool ok = false; int cur_limit = -1; -#if LIBTORRENT_VERSION_NUM >= 001600 boost::asio::ip::tcp::endpoint first_ep = m_peerEndpoints.value(peer_ips.first(), boost::asio::ip::tcp::endpoint()); if (first_ep != boost::asio::ip::tcp::endpoint()) cur_limit = h.get_peer_upload_limit(first_ep); -#endif long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Upload rate limiting"), cur_limit, @@ -273,12 +271,10 @@ void PeerListWidget::limitDlRateSelectedPeers(const QStringList& peer_ips) return; bool ok = false; int cur_limit = -1; -#if LIBTORRENT_VERSION_NUM >= 001600 boost::asio::ip::tcp::endpoint first_ep = m_peerEndpoints.value(peer_ips.first(), boost::asio::ip::tcp::endpoint()); if (first_ep != boost::asio::ip::tcp::endpoint()) cur_limit = h.get_peer_download_limit(first_ep); -#endif long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Download rate limiting"), cur_limit, Preferences().getGlobalDownloadLimit()*1024.); if (!ok) return; @@ -435,12 +431,10 @@ QString PeerListWidget::getConnectionString(int connection_type) { QString connection; switch(connection_type) { -#if LIBTORRENT_VERSION_NUM >= 001600 case peer_info::bittorrent_utp: connection = "uTP"; break; case peer_info::http_seed: -#endif case peer_info::web_seed: connection = "Web"; break; @@ -506,11 +500,9 @@ QString PeerListWidget::getFlags(const peer_info& peer) if (peer.flags & peer_info::plaintext_encrypted) flags += "e "; -#if LIBTORRENT_VERSION_NUM > 001500 //P = Peer is using uTorrent uTP if (peer.connection_type & peer_info::bittorrent_utp) flags += "P "; -#endif //L = Peer is local if (peer.source & peer_info::lsd) diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index 7c32dcf7d..82016ebd5 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -453,11 +453,7 @@ void PropertiesWidget::displayFilesListMenu(const QPoint&) { myFilesLlistMenu.addSeparator(); } QMenu subMenu; -#if LIBTORRENT_VERSION_NUM >= 001600 if (!h.status(0x0).is_seeding) { -#else - if (!static_cast(h).is_seed()) { -#endif subMenu.setTitle(tr("Priority")); subMenu.addAction(actionNot_downloaded); subMenu.addAction(actionNormal); diff --git a/src/properties/proplistdelegate.h b/src/properties/proplistdelegate.h index 30855f16b..3b03b41fb 100644 --- a/src/properties/proplistdelegate.h +++ b/src/properties/proplistdelegate.h @@ -159,11 +159,8 @@ public: if (index.column() != PRIORITY) return 0; if (properties) { QTorrentHandle h = properties->getCurrentTorrent(); -#if LIBTORRENT_VERSION_NUM >= 001600 - if (!h.is_valid() || !h.has_metadata() || h.status(0x0).is_seeding) return 0; -#else - if (!h.is_valid() || !h.has_metadata() || static_cast(h).is_seed()) return 0; -#endif + if (!h.is_valid() || !h.has_metadata() || h.status(0x0).is_seeding) + return 0; } if (index.data().toInt() <= 0) { // IGNORED or MIXED diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index ad5b06ec9..c22cbcd12 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -69,14 +69,7 @@ #include #include #include -#if LIBTORRENT_VERSION_NUM < 001600 -#include -#include -#include -#endif -#if LIBTORRENT_VERSION_NUM >= 001600 -#include "libtorrent/error_code.hpp" -#endif +#include #include #include #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 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 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 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= 001600 std::vector new_urlseeds = t->web_seeds(); std::vector::iterator it = new_urlseeds.begin(); @@ -1406,19 +1350,6 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr new_urlseeds = t->url_seeds(); - - std::vector::iterator it = new_urlseeds.begin(); - std::vector::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 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 &t, const std::vector &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; inum_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; inum_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 &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()); diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h index 0ce181c7b..e2b1fd30c 100755 --- a/src/qtlibtorrent/qbtsession.h +++ b/src/qtlibtorrent/qbtsession.h @@ -134,7 +134,6 @@ public slots: void downloadUrlAndSkipDialog(QString url, QString save_path=QString(), QString label=QString(), const QList& cookies = QList()); // 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 &t, const std::vector &fp); void updateRatioTimer(); void recoverPersistentData(const QString &hash, const std::vector &buf); void backupPersistentData(const QString &hash, boost::shared_ptr data); diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index 19e12e247..0c55244e6 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -44,9 +44,6 @@ #include #include #include -#if LIBTORRENT_VERSION_NUM < 001600 -#include -#endif #ifdef Q_WS_WIN #include @@ -93,37 +90,20 @@ QString QTorrentHandle::name() const { } QString QTorrentHandle::creation_date() const { -#if LIBTORRENT_VERSION_NUM >= 001600 boost::optional t = torrent_handle::get_torrent_info().creation_date(); return t ? misc::toQString(*t) : ""; -#else - boost::optional 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& fp) const { diff --git a/src/qtlibtorrent/torrentspeedmonitor.cpp b/src/qtlibtorrent/torrentspeedmonitor.cpp index e8a119d56..5b9d55cab 100644 --- a/src/qtlibtorrent/torrentspeedmonitor.cpp +++ b/src/qtlibtorrent/torrentspeedmonitor.cpp @@ -161,13 +161,8 @@ void TorrentSpeedMonitor::getSamples() std::vector::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&) {} diff --git a/src/statusbar.h b/src/statusbar.h index 784cc7493..323f11013 100644 --- a/src/statusbar.h +++ b/src/statusbar.h @@ -217,11 +217,7 @@ public slots: void capDownloadSpeed() { bool ok = false; -#if LIBTORRENT_VERSION_NUM >= 001600 int cur_limit = QBtSession::instance()->getSession()->settings().download_rate_limit; -#else - int cur_limit = QBtSession::instance()->getSession()->download_rate_limit(); -#endif long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), cur_limit); if (ok) { Preferences pref; @@ -242,11 +238,7 @@ public slots: void capUploadSpeed() { bool ok = false; -#if LIBTORRENT_VERSION_NUM >= 001600 int cur_limit = QBtSession::instance()->getSession()->settings().upload_rate_limit; -#else - int cur_limit = QBtSession::instance()->getSession()->upload_rate_limit(); -#endif long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit); if (ok) { Preferences pref; diff --git a/src/torrentcontentmodel.cpp b/src/torrentcontentmodel.cpp index 65d3354ec..b3c677594 100644 --- a/src/torrentcontentmodel.cpp +++ b/src/torrentcontentmodel.cpp @@ -283,11 +283,7 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info& t) for (int i = 0; i < t.num_files(); ++i) { const libtorrent::file_entry& fentry = t.file_at(i); current_parent = m_rootItem; -#if LIBTORRENT_VERSION_NUM >= 001600 QString path = misc::toQStringU(fentry.path); -#else - QString path = misc::toQStringU(fentry.path.string()); -#endif // Iterate of parts of the path to create necessary folders QStringList pathFolders = path.split(QRegExp("[/\\\\]"), QString::SkipEmptyParts); pathFolders.removeLast(); diff --git a/src/torrentcontentmodelfile.cpp b/src/torrentcontentmodelfile.cpp index 8f8ea2dbc..d8312e8c7 100644 --- a/src/torrentcontentmodelfile.cpp +++ b/src/torrentcontentmodelfile.cpp @@ -41,11 +41,7 @@ TorrentContentModelFile::TorrentContentModelFile(const libtorrent::file_entry& f { Q_ASSERT(parent); -#if LIBTORRENT_VERSION_MINOR >= 16 || LIBTORRENT_VERSION_MAJOR > 0 m_name = fsutils::fileName(misc::toQStringU(f.path.c_str())); -#else - m_name = misc::toQStringU(f.path.filename()); -#endif // Do not display incomplete extensions if (m_name.endsWith(".!qB")) diff --git a/src/torrentcreator/torrentcreatorthread.cpp b/src/torrentcreator/torrentcreatorthread.cpp index faafcf2c4..6b573a179 100644 --- a/src/torrentcreator/torrentcreatorthread.cpp +++ b/src/torrentcreator/torrentcreatorthread.cpp @@ -43,36 +43,19 @@ #include "torrentcreatorthread.h" #include "fs_utils.h" -#if LIBTORRENT_VERSION_NUM < 001600 -#include -#include -#include -#endif #include #include #include using namespace libtorrent; -#if LIBTORRENT_VERSION_NUM < 001600 -using namespace boost::filesystem; -#endif // do not include files and folders whose // name starts with a . -#if LIBTORRENT_VERSION_NUM >= 001600 bool file_filter(std::string const& f) { if (filename(f)[0] == '.') return false; return true; } -#else -bool file_filter(boost::filesystem::path const& filename) -{ - if (filename.leaf()[0] == '.') return false; - std::cerr << filename << std::endl; - return true; -} -#endif void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size) { @@ -85,9 +68,6 @@ void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStri comment = _comment; is_private = _is_private; piece_size = _piece_size; -#if LIBTORRENT_VERSION_NUM < 001600 - path::default_name_check(no_check); -#endif abort = false; start(); } diff --git a/src/torrentimportdlg.cpp b/src/torrentimportdlg.cpp index eaa6721c8..ee9ffc383 100644 --- a/src/torrentimportdlg.cpp +++ b/src/torrentimportdlg.cpp @@ -79,11 +79,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked() const QString default_dir = settings.value(QString::fromUtf8("TorrentImport/LastContentDir"), QDir::homePath()).toString(); if (t->num_files() == 1) { // Single file torrent -#if LIBTORRENT_VERSION_NUM >= 001600 const QString file_name = fsutils::fileName(misc::toQStringU(t->file_at(0).path)); -#else - const QString file_name = misc::toQStringU(t->file_at(0).path.filename()); -#endif qDebug("Torrent has only one file: %s", qPrintable(file_name)); QString extension = fsutils::fileExtension(file_name); qDebug("File extension is : %s", qPrintable(extension)); @@ -146,11 +142,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked() content_dir.cdUp(); // Check file sizes for (int i=0; inum_files(); ++i) { -#if LIBTORRENT_VERSION_NUM >= 001600 const QString rel_path = misc::toQStringU(t->file_at(i).path); -#else - const QString rel_path = misc::toQStringU(t->file_at(i).path.string()); -#endif if (QFile(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))).size() != t->file_at(i).size) { qDebug("%s is %lld", qPrintable(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))), (long long int) QFile(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))).size()); @@ -252,11 +244,7 @@ void TorrentImportDlg::initializeFilesPath() m_filesPath.clear(); // Loads files path in the torrent for (int i=0; inum_files(); ++i) { -#if LIBTORRENT_VERSION_NUM >= 001600 m_filesPath << misc::toQStringU(t->file_at(i).path).replace("\\", "/"); -#else - m_filesPath << misc::toQStringU(t->file_at(i).path.string()).replace("\\", "/"); -#endif } } diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index 2547f5296..f3e7514e3 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -508,11 +508,7 @@ void HttpConnection::respondCommand(const QString& command) { if (command == "getGlobalUpLimit") { m_generator.setStatusLine(200, "OK"); m_generator.setContentTypeByExt("html"); -#if LIBTORRENT_VERSION_NUM >= 001600 m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->settings().upload_rate_limit)); -#else - m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->upload_rate_limit())); -#endif m_generator.setContentEncoding(m_parser.acceptsEncoding()); write(); return; @@ -520,11 +516,7 @@ void HttpConnection::respondCommand(const QString& command) { if (command == "getGlobalDlLimit") { m_generator.setStatusLine(200, "OK"); m_generator.setContentTypeByExt("html"); -#if LIBTORRENT_VERSION_NUM >= 001600 m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->settings().download_rate_limit)); -#else - m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->download_rate_limit())); -#endif m_generator.setContentEncoding(m_parser.acceptsEncoding()); write(); return; diff --git a/src/webui/prefjson.cpp b/src/webui/prefjson.cpp index 1ba67e791..50f6187a0 100644 --- a/src/webui/prefjson.cpp +++ b/src/webui/prefjson.cpp @@ -88,10 +88,8 @@ QString prefjson::getPreferences() data.add("max_connec", pref.getMaxConnecs()); data.add("max_connec_per_torrent", pref.getMaxConnecsPerTorrent()); data.add("max_uploads_per_torrent", pref.getMaxUploadsPerTorrent()); -#if LIBTORRENT_VERSION_NUM >= 001600 data.add("enable_utp", pref.isuTPEnabled()); data.add("limit_utp_rate", pref.isuTPRateLimited()); -#endif data.add("limit_tcp_overhead", pref.includeOverheadInLimits()); data.add("alt_dl_limit", pref.getAltGlobalDownloadLimit()); data.add("alt_up_limit", pref.getAltGlobalUploadLimit()); @@ -110,9 +108,7 @@ QString prefjson::getPreferences() data.add("pex", pref.isPeXEnabled()); data.add("lsd", pref.isLSDEnabled()); data.add("encryption", pref.getEncryptionSetting()); -#if LIBTORRENT_VERSION_NUM >= 001600 data.add("anonymous_mode", pref.isAnonymousModeEnabled()); -#endif // Proxy data.add("proxy_type", pref.getProxyType()); data.add("proxy_ip", pref.getProxyIp()); @@ -246,12 +242,10 @@ void prefjson::setPreferences(const QString& json) pref.setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt()); if (m.contains("max_uploads_per_torrent")) pref.setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt()); -#if LIBTORRENT_VERSION_NUM >= 001600 if (m.contains("enable_utp")) pref.setuTPEnabled(m["enable_utp"].toBool()); if (m.contains("limit_utp_rate")) pref.setuTPRateLimited(m["limit_utp_rate"].toBool()); -#endif if (m.contains("limit_tcp_overhead")) pref.includeOverheadInLimits(m["limit_tcp_overhead"].toBool()); if (m.contains("alt_dl_limit")) @@ -284,10 +278,8 @@ void prefjson::setPreferences(const QString& json) pref.setLSDEnabled(m["lsd"].toBool()); if (m.contains("encryption")) pref.setEncryptionSetting(m["encryption"].toInt()); -#if LIBTORRENT_VERSION_NUM >= 001600 if (m.contains("anonymous_mode")) pref.enableAnonymousMode(m["anonymous_mode"].toBool()); -#endif // Proxy if (m.contains("proxy_type")) pref.setProxyType(m["proxy_type"].toInt());