diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 537525b17..27c2c1a2f 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -65,7 +65,6 @@ const QString QB_EXT {QStringLiteral(".!qB")}; -namespace libt = libtorrent; using namespace BitTorrent; namespace @@ -92,7 +91,7 @@ namespace return out; } - using ListType = libt::entry::list_type; + using ListType = lt::entry::list_type; ListType setToEntryList(const QSet &input) { @@ -366,12 +365,33 @@ QString TorrentHandle::nativeActualSavePath() const return QString::fromStdString(m_nativeStatus.save_path); } +bool TorrentHandle::isAutoManaged() const +{ +#if (LIBTORRENT_VERSION_NUM < 10200) + return m_nativeStatus.auto_managed; +#else + return (m_nativeStatus.flags & lt::torrent_flags::auto_managed); +#endif +} + +void TorrentHandle::setAutoManaged(const bool enable) +{ +#if (LIBTORRENT_VERSION_NUM < 10200) + m_nativeHandle.auto_managed(enable); +#else + if (enable) + m_nativeHandle.set_flags(lt::torrent_flags::auto_managed); + else + m_nativeHandle.unset_flags(lt::torrent_flags::auto_managed); +#endif +} + QList TorrentHandle::trackers() const { QList entries; - const std::vector announces = m_nativeHandle.trackers(); + const std::vector announces = m_nativeHandle.trackers(); - for (const libt::announce_entry &tracker : announces) + for (const lt::announce_entry &tracker : announces) entries << tracker; return entries; @@ -399,7 +419,7 @@ void TorrentHandle::replaceTrackers(const QList &trackers) QList existingTrackers = this->trackers(); QList addedTrackers; - std::vector announces; + std::vector announces; for (const TrackerEntry &tracker : trackers) { announces.push_back(tracker.nativeEntry()); if (!existingTrackers.contains(tracker)) @@ -484,8 +504,8 @@ bool TorrentHandle::removeUrlSeed(const QUrl &urlSeed) bool TorrentHandle::connectPeer(const PeerAddress &peerAddress) { - libt::error_code ec; - const libt::address addr = libt::address::from_string(peerAddress.ip.toString().toStdString(), ec); + lt::error_code ec; + const lt::address addr = lt::address::from_string(peerAddress.ip.toString().toStdString(), ec); if (ec) return false; const boost::asio::ip::tcp::endpoint ep(addr, peerAddress.port); @@ -596,7 +616,7 @@ void TorrentHandle::removeAllTags() QDateTime TorrentHandle::addedTime() const { - return QDateTime::fromTime_t(m_nativeStatus.added_time); + return QDateTime::fromSecsSinceEpoch(m_nativeStatus.added_time); } qreal TorrentHandle::ratioLimit() const @@ -643,11 +663,14 @@ QStringList TorrentHandle::absoluteFilePathsUnwanted() const if (!hasMetadata()) return {}; const QDir saveDir(savePath(true)); - QStringList res; - const std::vector fp = m_nativeHandle.file_priorities(); +#if (LIBTORRENT_VERSION_NUM < 10200) + const std::vector fp = m_nativeHandle.file_priorities(); +#else + const std::vector fp = m_nativeHandle.get_file_priorities(); +#endif - const int count = static_cast(fp.size()); - for (int i = 0; i < count; ++i) { + QStringList res; + for (int i = 0; i < static_cast(fp.size()); ++i) { if (fp[i] == 0) { const QString path = Utils::Fs::expandPathAbs(saveDir.absoluteFilePath(filePath(i))); if (path.contains(".unwanted")) @@ -682,7 +705,12 @@ TorrentInfo TorrentHandle::info() const bool TorrentHandle::isPaused() const { - return (m_nativeStatus.paused && !m_nativeStatus.auto_managed); +#if (LIBTORRENT_VERSION_NUM < 10200) + return (m_nativeStatus.paused && !isAutoManaged()); +#else + return ((m_nativeStatus.flags & lt::torrent_flags::paused) + && !isAutoManaged()); +#endif } bool TorrentHandle::isResumed() const @@ -692,13 +720,18 @@ bool TorrentHandle::isResumed() const bool TorrentHandle::isQueued() const { - return (m_nativeStatus.paused && m_nativeStatus.auto_managed); +#if (LIBTORRENT_VERSION_NUM < 10200) + return (m_nativeStatus.paused && isAutoManaged()); +#else + return ((m_nativeStatus.flags & lt::torrent_flags::paused) + && isAutoManaged()); +#endif } bool TorrentHandle::isChecking() const { - return ((m_nativeStatus.state == libt::torrent_status::checking_files) - || (m_nativeStatus.state == libt::torrent_status::checking_resume_data)); + return ((m_nativeStatus.state == lt::torrent_status::checking_files) + || (m_nativeStatus.state == lt::torrent_status::checking_resume_data)); } bool TorrentHandle::isDownloading() const @@ -764,18 +797,27 @@ bool TorrentHandle::isSeed() const // May suffer from approximation problems //return (progress() == 1.); // This looks safe - return ((m_nativeStatus.state == libt::torrent_status::finished) - || (m_nativeStatus.state == libt::torrent_status::seeding)); + return ((m_nativeStatus.state == lt::torrent_status::finished) + || (m_nativeStatus.state == lt::torrent_status::seeding)); } bool TorrentHandle::isForced() const { - return (!m_nativeStatus.paused && !m_nativeStatus.auto_managed); +#if (LIBTORRENT_VERSION_NUM < 10200) + return (!m_nativeStatus.paused && !isAutoManaged()); +#else + return (!(m_nativeStatus.flags & lt::torrent_flags::paused) + && !isAutoManaged()); +#endif } bool TorrentHandle::isSequentialDownload() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.sequential_download; +#else + return (m_nativeStatus.flags & lt::torrent_flags::sequential_download); +#endif } bool TorrentHandle::hasFirstLastPiecePriority() const @@ -783,7 +825,11 @@ bool TorrentHandle::hasFirstLastPiecePriority() const if (!hasMetadata()) return m_needsToSetFirstLastPiecePriority; - const std::vector filePriorities = nativeHandle().file_priorities(); +#if (LIBTORRENT_VERSION_NUM < 10200) + const std::vector filePriorities = nativeHandle().file_priorities(); +#else + const std::vector filePriorities = nativeHandle().get_file_priorities(); +#endif for (int i = 0; i < static_cast(filePriorities.size()); ++i) { if (filePriorities[i] <= 0) continue; @@ -804,7 +850,7 @@ TorrentState TorrentHandle::state() const void TorrentHandle::updateState() { - if (m_nativeStatus.state == libt::torrent_status::checking_resume_data) { + if (m_nativeStatus.state == lt::torrent_status::checking_resume_data) { m_state = TorrentState::CheckingResumeData; } else if (isMoveInProgress()) { @@ -824,23 +870,23 @@ void TorrentHandle::updateState() } else { switch (m_nativeStatus.state) { - case libt::torrent_status::finished: - case libt::torrent_status::seeding: + case lt::torrent_status::finished: + case lt::torrent_status::seeding: if (isForced()) m_state = TorrentState::ForcedUploading; else m_state = m_nativeStatus.upload_payload_rate > 0 ? TorrentState::Uploading : TorrentState::StalledUploading; break; - case libt::torrent_status::allocating: + case lt::torrent_status::allocating: m_state = TorrentState::Allocating; break; - case libt::torrent_status::checking_files: + case lt::torrent_status::checking_files: m_state = m_hasSeedStatus ? TorrentState::CheckingUploading : TorrentState::CheckingDownloading; break; - case libt::torrent_status::downloading_metadata: + case lt::torrent_status::downloading_metadata: m_state = TorrentState::DownloadingMetadata; break; - case libt::torrent_status::downloading: + case lt::torrent_status::downloading: if (isForced()) m_state = TorrentState::ForcedDownloading; else @@ -866,7 +912,12 @@ bool TorrentHandle::hasMissingFiles() const bool TorrentHandle::hasError() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return (m_nativeStatus.paused && m_nativeStatus.errc); +#else + return ((m_nativeStatus.flags & lt::torrent_flags::paused) + && m_nativeStatus.errc); +#endif } bool TorrentHandle::hasFilteredPieces() const @@ -904,19 +955,31 @@ qlonglong TorrentHandle::totalUpload() const return m_nativeStatus.all_time_upload; } -int TorrentHandle::activeTime() const +qlonglong TorrentHandle::activeTime() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.active_time; +#else + return lt::total_seconds(m_nativeStatus.active_duration); +#endif } -int TorrentHandle::finishedTime() const +qlonglong TorrentHandle::finishedTime() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.finished_time; +#else + return lt::total_seconds(m_nativeStatus.finished_duration); +#endif } -int TorrentHandle::seedingTime() const +qlonglong TorrentHandle::seedingTime() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.seeding_time; +#else + return lt::total_seconds(m_nativeStatus.seeding_duration); +#endif } qulonglong TorrentHandle::eta() const @@ -960,7 +1023,7 @@ qulonglong TorrentHandle::eta() const QVector TorrentHandle::filesProgress() const { std::vector fp; - m_nativeHandle.file_progress(fp, libt::torrent_handle::piece_granularity); + m_nativeHandle.file_progress(fp, lt::torrent_handle::piece_granularity); const int count = static_cast(fp.size()); QVector result; @@ -1022,7 +1085,7 @@ int TorrentHandle::incompleteCount() const QDateTime TorrentHandle::lastSeenComplete() const { if (m_nativeStatus.last_seen_complete > 0) - return QDateTime::fromTime_t(m_nativeStatus.last_seen_complete); + return QDateTime::fromSecsSinceEpoch(m_nativeStatus.last_seen_complete); else return {}; } @@ -1030,26 +1093,36 @@ QDateTime TorrentHandle::lastSeenComplete() const QDateTime TorrentHandle::completedTime() const { if (m_nativeStatus.completed_time > 0) - return QDateTime::fromTime_t(m_nativeStatus.completed_time); + return QDateTime::fromSecsSinceEpoch(m_nativeStatus.completed_time); else return {}; } -int TorrentHandle::timeSinceUpload() const +qlonglong TorrentHandle::timeSinceUpload() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.time_since_upload; +#else + return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_upload); +#endif } -int TorrentHandle::timeSinceDownload() const +qlonglong TorrentHandle::timeSinceDownload() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.time_since_download; +#else + return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_download); +#endif } -int TorrentHandle::timeSinceActivity() const +qlonglong TorrentHandle::timeSinceActivity() const { - return ((m_nativeStatus.time_since_upload < 0) != (m_nativeStatus.time_since_download < 0)) - ? std::max(m_nativeStatus.time_since_upload, m_nativeStatus.time_since_download) - : std::min(m_nativeStatus.time_since_upload, m_nativeStatus.time_since_download); + const qlonglong upTime = timeSinceUpload(); + const qlonglong downTime = timeSinceDownload(); + return ((upTime < 0) != (downTime < 0)) + ? std::max(upTime, downTime) + : std::min(upTime, downTime); } int TorrentHandle::downloadLimit() const @@ -1064,17 +1137,21 @@ int TorrentHandle::uploadLimit() const bool TorrentHandle::superSeeding() const { +#if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.super_seeding; +#else + return (m_nativeStatus.flags & lt::torrent_flags::super_seeding); +#endif } QList TorrentHandle::peers() const { QList peers; - std::vector nativePeers; + std::vector nativePeers; m_nativeHandle.get_peer_info(nativePeers); - for (const libt::peer_info &peer : nativePeers) + for (const lt::peer_info &peer : nativePeers) peers << PeerInfo(this, peer); return peers; @@ -1094,11 +1171,11 @@ QBitArray TorrentHandle::downloadingPieces() const { QBitArray result(piecesCount()); - std::vector queue; + std::vector queue; m_nativeHandle.get_download_queue(queue); - std::vector::const_iterator it = queue.begin(); - std::vector::const_iterator itend = queue.end(); + std::vector::const_iterator it = queue.begin(); + std::vector::const_iterator itend = queue.end(); for (; it != itend; ++it) result.setBit(it->piece_index); @@ -1180,7 +1257,7 @@ int TorrentHandle::connectionsLimit() const qlonglong TorrentHandle::nextAnnounce() const { - return libt::duration_cast(m_nativeStatus.next_announce).count(); + return lt::total_seconds(m_nativeStatus.next_announce); } void TorrentHandle::setName(const QString &name) @@ -1258,17 +1335,30 @@ void TorrentHandle::forceRecheck() m_unchecked = false; if (isPaused()) { +#if (LIBTORRENT_VERSION_NUM < 10200) m_nativeHandle.stop_when_ready(true); +#else + m_nativeHandle.set_flags(lt::torrent_flags::stop_when_ready); +#endif resume_impl(false); } } -void TorrentHandle::setSequentialDownload(const bool b) +void TorrentHandle::setSequentialDownload(const bool enable) { - if (b != isSequentialDownload()) { - m_nativeHandle.set_sequential_download(b); - m_nativeStatus.sequential_download = b; // prevent return cached value +#if (LIBTORRENT_VERSION_NUM < 10200) + m_nativeHandle.set_sequential_download(enable); + m_nativeStatus.sequential_download = enable; // prevent return cached value +#else + if (enable) { + m_nativeHandle.set_flags(lt::torrent_flags::sequential_download); + m_nativeStatus.flags |= lt::torrent_flags::sequential_download; // prevent return cached value + } + else { + m_nativeHandle.unset_flags(lt::torrent_flags::sequential_download); + m_nativeStatus.flags &= ~lt::torrent_flags::sequential_download; // prevent return cached value } +#endif } void TorrentHandle::toggleSequentialDownload() @@ -1333,7 +1423,7 @@ void TorrentHandle::pause() { if (isPaused()) return; - m_nativeHandle.auto_managed(false); + setAutoManaged(false); m_nativeHandle.pause(); // Libtorrent doesn't emit a torrent_paused_alert when the @@ -1358,7 +1448,7 @@ void TorrentHandle::resume_impl(bool forced) m_nativeHandle.force_recheck(); } - m_nativeHandle.auto_managed(!forced); + setAutoManaged(!forced); m_nativeHandle.resume(); } @@ -1375,8 +1465,13 @@ void TorrentHandle::moveStorage(const QString &newPath, bool overwrite) qDebug("move storage: %s to %s", qUtf8Printable(oldPath), qUtf8Printable(newPath)); // Actually move the storage +#if (LIBTORRENT_VERSION_NUM < 10200) m_nativeHandle.move_storage(newPath.toUtf8().constData() - , (overwrite ? libt::always_replace_files : libt::dont_replace)); + , (overwrite ? lt::always_replace_files : lt::dont_replace)); +#else + m_nativeHandle.move_storage(newPath.toUtf8().constData() + , (overwrite ? lt::move_flags_t::always_replace_files : lt::move_flags_t::dont_replace)); +#endif m_moveStorageInfo.oldPath = oldPath; m_moveStorageInfo.newPath = newPath; updateState(); @@ -1394,14 +1489,14 @@ bool TorrentHandle::saveTorrentFile(const QString &path) { if (!m_torrentInfo.isValid()) return false; #if (LIBTORRENT_VERSION_NUM < 10200) - const libt::create_torrent torrentCreator = libt::create_torrent(*(m_torrentInfo.nativeInfo()), true); + const lt::create_torrent torrentCreator = lt::create_torrent(*(m_torrentInfo.nativeInfo()), true); #else - const libt::create_torrent torrentCreator = libt::create_torrent(*(m_torrentInfo.nativeInfo())); + const lt::create_torrent torrentCreator = lt::create_torrent(*(m_torrentInfo.nativeInfo())); #endif - const libt::entry torrentEntry = torrentCreator.generate(); + const lt::entry torrentEntry = torrentCreator.generate(); QVector out; - libt::bencode(std::back_inserter(out), torrentEntry); + lt::bencode(std::back_inserter(out), torrentEntry); QFile torrentFile(path); if (!out.empty() && torrentFile.open(QIODevice::WriteOnly)) return (torrentFile.write(&out[0], out.size()) == out.size()); @@ -1409,7 +1504,7 @@ bool TorrentHandle::saveTorrentFile(const QString &path) return false; } -void TorrentHandle::handleStateUpdate(const libt::torrent_status &nativeStatus) +void TorrentHandle::handleStateUpdate(const lt::torrent_status &nativeStatus) { updateStatus(nativeStatus); } @@ -1629,7 +1724,7 @@ void TorrentHandle::handleSaveResumeDataFailedAlert(const libtorrent::save_resum { // if torrent has no metadata we should save dummy fastresume data // containing Magnet URI and qBittorrent own resume data only - if (p->error.value() == libt::errors::no_metadata) + if (p->error.value() == lt::errors::no_metadata) handleSaveResumeDataAlert(nullptr); else m_session->handleTorrentResumeDataFailed(this); @@ -1637,7 +1732,7 @@ void TorrentHandle::handleSaveResumeDataFailedAlert(const libtorrent::save_resum void TorrentHandle::handleFastResumeRejectedAlert(const libtorrent::fastresume_rejected_alert *p) { - if (p->error.value() == libt::errors::mismatching_file_size) { + if (p->error.value() == lt::errors::mismatching_file_size) { // Mismatching file size (files were probably moved) m_hasMissingFiles = true; LogMsg(tr("File sizes mismatch for torrent '%1', pausing it.").arg(name()), Log::CRITICAL); @@ -1708,12 +1803,12 @@ void TorrentHandle::handleFileCompletedAlert(const libtorrent::file_completed_al void TorrentHandle::handleStatsAlert(const libtorrent::stats_alert *p) { Q_ASSERT(p->interval >= 1000); - const SpeedSample transferred(p->transferred[libt::stats_alert::download_payload] * 1000LL / p->interval, - p->transferred[libt::stats_alert::upload_payload] * 1000LL / p->interval); + const SpeedSample transferred(p->transferred[lt::stats_alert::download_payload] * 1000LL / p->interval, + p->transferred[lt::stats_alert::upload_payload] * 1000LL / p->interval); m_speedMonitor.addSample(transferred); } -void TorrentHandle::handleMetadataReceivedAlert(const libt::metadata_received_alert *p) +void TorrentHandle::handleMetadataReceivedAlert(const lt::metadata_received_alert *p) { Q_UNUSED(p); qDebug("Metadata received for torrent %s.", qUtf8Printable(name())); @@ -1762,56 +1857,56 @@ void TorrentHandle::handleAppendExtensionToggled() void TorrentHandle::handleAlert(const libtorrent::alert *a) { switch (a->type()) { - case libt::stats_alert::alert_type: - handleStatsAlert(static_cast(a)); + case lt::stats_alert::alert_type: + handleStatsAlert(static_cast(a)); break; - case libt::file_renamed_alert::alert_type: - handleFileRenamedAlert(static_cast(a)); + case lt::file_renamed_alert::alert_type: + handleFileRenamedAlert(static_cast(a)); break; - case libt::file_rename_failed_alert::alert_type: - handleFileRenameFailedAlert(static_cast(a)); + case lt::file_rename_failed_alert::alert_type: + handleFileRenameFailedAlert(static_cast(a)); break; - case libt::file_completed_alert::alert_type: - handleFileCompletedAlert(static_cast(a)); + case lt::file_completed_alert::alert_type: + handleFileCompletedAlert(static_cast(a)); break; - case libt::torrent_finished_alert::alert_type: - handleTorrentFinishedAlert(static_cast(a)); + case lt::torrent_finished_alert::alert_type: + handleTorrentFinishedAlert(static_cast(a)); break; - case libt::save_resume_data_alert::alert_type: - handleSaveResumeDataAlert(static_cast(a)); + case lt::save_resume_data_alert::alert_type: + handleSaveResumeDataAlert(static_cast(a)); break; - case libt::save_resume_data_failed_alert::alert_type: - handleSaveResumeDataFailedAlert(static_cast(a)); + case lt::save_resume_data_failed_alert::alert_type: + handleSaveResumeDataFailedAlert(static_cast(a)); break; - case libt::storage_moved_alert::alert_type: - handleStorageMovedAlert(static_cast(a)); + case lt::storage_moved_alert::alert_type: + handleStorageMovedAlert(static_cast(a)); break; - case libt::storage_moved_failed_alert::alert_type: - handleStorageMovedFailedAlert(static_cast(a)); + case lt::storage_moved_failed_alert::alert_type: + handleStorageMovedFailedAlert(static_cast(a)); break; - case libt::torrent_paused_alert::alert_type: - handleTorrentPausedAlert(static_cast(a)); + case lt::torrent_paused_alert::alert_type: + handleTorrentPausedAlert(static_cast(a)); break; - case libt::torrent_resumed_alert::alert_type: - handleTorrentResumedAlert(static_cast(a)); + case lt::torrent_resumed_alert::alert_type: + handleTorrentResumedAlert(static_cast(a)); break; - case libt::tracker_error_alert::alert_type: - handleTrackerErrorAlert(static_cast(a)); + case lt::tracker_error_alert::alert_type: + handleTrackerErrorAlert(static_cast(a)); break; - case libt::tracker_reply_alert::alert_type: - handleTrackerReplyAlert(static_cast(a)); + case lt::tracker_reply_alert::alert_type: + handleTrackerReplyAlert(static_cast(a)); break; - case libt::tracker_warning_alert::alert_type: - handleTrackerWarningAlert(static_cast(a)); + case lt::tracker_warning_alert::alert_type: + handleTrackerWarningAlert(static_cast(a)); break; - case libt::metadata_received_alert::alert_type: - handleMetadataReceivedAlert(static_cast(a)); + case lt::metadata_received_alert::alert_type: + handleMetadataReceivedAlert(static_cast(a)); break; - case libt::fastresume_rejected_alert::alert_type: - handleFastResumeRejectedAlert(static_cast(a)); + case lt::fastresume_rejected_alert::alert_type: + handleFastResumeRejectedAlert(static_cast(a)); break; - case libt::torrent_checked_alert::alert_type: - handleTorrentCheckedAlert(static_cast(a)); + case lt::torrent_checked_alert::alert_type: + handleTorrentCheckedAlert(static_cast(a)); break; } } @@ -1950,7 +2045,14 @@ void TorrentHandle::setDownloadLimit(const int limit) void TorrentHandle::setSuperSeeding(const bool enable) { +#if (LIBTORRENT_VERSION_NUM < 10200) m_nativeHandle.super_seeding(enable); +#else + if (enable) + m_nativeHandle.set_flags(lt::torrent_flags::super_seeding); + else + m_nativeHandle.unset_flags(lt::torrent_flags::super_seeding); +#endif } void TorrentHandle::flushCache() @@ -1960,7 +2062,7 @@ void TorrentHandle::flushCache() QString TorrentHandle::toMagnetUri() const { - return QString::fromStdString(libt::make_magnet_uri(m_nativeHandle)); + return QString::fromStdString(lt::make_magnet_uri(m_nativeHandle)); } void TorrentHandle::prioritizeFiles(const QVector &priorities) diff --git a/src/base/bittorrent/torrenthandle.h b/src/base/bittorrent/torrenthandle.h index 7a0b0d29b..40c3e30ce 100644 --- a/src/base/bittorrent/torrenthandle.h +++ b/src/base/bittorrent/torrenthandle.h @@ -266,9 +266,9 @@ namespace BitTorrent QString error() const; qlonglong totalDownload() const; qlonglong totalUpload() const; - int activeTime() const; - int finishedTime() const; - int seedingTime() const; + qlonglong activeTime() const; + qlonglong finishedTime() const; + qlonglong seedingTime() const; qulonglong eta() const; QVector filesProgress() const; int seedsCount() const; @@ -281,9 +281,9 @@ namespace BitTorrent int incompleteCount() const; QDateTime lastSeenComplete() const; QDateTime completedTime() const; - int timeSinceUpload() const; - int timeSinceDownload() const; - int timeSinceActivity() const; + qlonglong timeSinceUpload() const; + qlonglong timeSinceDownload() const; + qlonglong timeSinceActivity() const; int downloadLimit() const; int uploadLimit() const; bool superSeeding() const; @@ -304,7 +304,7 @@ namespace BitTorrent qlonglong nextAnnounce() const; void setName(const QString &name); - void setSequentialDownload(bool b); + void setSequentialDownload(bool enable); void toggleSequentialDownload(); void setFirstLastPiecePriority(bool enabled); void toggleFirstLastPiecePriority(); @@ -380,6 +380,8 @@ namespace BitTorrent void resume_impl(bool forced); bool isMoveInProgress() const; QString nativeActualSavePath() const; + bool isAutoManaged() const; + void setAutoManaged(bool enable); void adjustActualSavePath(); void adjustActualSavePath_impl(); diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index 17fd58f65..623bc9875 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -28,7 +28,10 @@ #include "torrentinfo.h" +#if (LIBTORRENT_VERSION_NUM < 10200) #include +#endif + #include #include @@ -164,8 +167,14 @@ QString TorrentInfo::name() const QDateTime TorrentInfo::creationDate() const { if (!isValid()) return {}; - const boost::optional t = m_nativeInfo->creation_date(); - return t ? QDateTime::fromTime_t(*t) : QDateTime(); + +#if (LIBTORRENT_VERSION_NUM < 10200) + const boost::optional date = m_nativeInfo->creation_date(); + return (date ? QDateTime::fromSecsSinceEpoch(*date) : QDateTime()); +#else + const std::time_t date = m_nativeInfo->creation_date(); + return ((date != 0) ? QDateTime::fromSecsSinceEpoch(date) : QDateTime()); +#endif } QString TorrentInfo::creator() const diff --git a/src/base/net/private/geoipdatabase.cpp b/src/base/net/private/geoipdatabase.cpp index 28dbe9f49..233a6fb7a 100644 --- a/src/base/net/private/geoipdatabase.cpp +++ b/src/base/net/private/geoipdatabase.cpp @@ -261,7 +261,7 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error) } CHECK_METADATA_REQ(build_epoch, ULongLong); - m_buildEpoch = QDateTime::fromTime_t(metadata.value("build_epoch").toULongLong()); + m_buildEpoch = QDateTime::fromSecsSinceEpoch(metadata.value("build_epoch").toULongLong()); CHECK_METADATA_OPT(languages, QVariantList); CHECK_METADATA_OPT(description, QVariantHash);