mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
Add preliminary support of libtorrent v1.2
libtorrent v1.2 should be built with deprecated features enabled.
This commit is contained in:
parent
20f2c86d25
commit
ead078a38e
37 changed files with 646 additions and 370 deletions
|
@ -28,6 +28,10 @@
|
|||
|
||||
#include "trackerentry.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <libtorrent/version.hpp>
|
||||
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
|
@ -48,6 +52,19 @@ QString TrackerEntry::url() const
|
|||
return QString::fromStdString(m_nativeEntry.url);
|
||||
}
|
||||
|
||||
bool TrackerEntry::isWorking() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeEntry.is_working();
|
||||
#else
|
||||
return std::any_of(m_nativeEntry.endpoints.begin(), m_nativeEntry.endpoints.end()
|
||||
, [](const lt::announce_endpoint &endpoint)
|
||||
{
|
||||
return endpoint.is_working();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
int TrackerEntry::tier() const
|
||||
{
|
||||
return m_nativeEntry.tier;
|
||||
|
@ -57,7 +74,7 @@ TrackerEntry::Status TrackerEntry::status() const
|
|||
{
|
||||
// libtorrent::announce_entry::is_working() returns
|
||||
// true when the tracker hasn't been tried yet.
|
||||
if (m_nativeEntry.verified && m_nativeEntry.is_working())
|
||||
if (m_nativeEntry.verified && isWorking())
|
||||
return Working;
|
||||
if ((m_nativeEntry.fails == 0) && m_nativeEntry.updating)
|
||||
return Updating;
|
||||
|
@ -72,6 +89,36 @@ void TrackerEntry::setTier(const int value)
|
|||
m_nativeEntry.tier = value;
|
||||
}
|
||||
|
||||
int TrackerEntry::numSeeds() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return nativeEntry().scrape_complete;
|
||||
#else
|
||||
// FIXME: Handle all possible endpoints.
|
||||
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_complete;
|
||||
#endif
|
||||
}
|
||||
|
||||
int TrackerEntry::numLeeches() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return nativeEntry().scrape_incomplete;
|
||||
#else
|
||||
// FIXME: Handle all possible endpoints.
|
||||
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete;
|
||||
#endif
|
||||
}
|
||||
|
||||
int TrackerEntry::numDownloaded() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return nativeEntry().scrape_downloaded;
|
||||
#else
|
||||
// FIXME: Handle all possible endpoints.
|
||||
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_downloaded;
|
||||
#endif
|
||||
}
|
||||
|
||||
libtorrent::announce_entry TrackerEntry::nativeEntry() const
|
||||
{
|
||||
return m_nativeEntry;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue