|
|
@ -49,15 +49,16 @@ TrackerEntry::TrackerEntry(const lt::announce_entry &nativeEntry) |
|
|
|
|
|
|
|
|
|
|
|
QString TrackerEntry::url() const |
|
|
|
QString TrackerEntry::url() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return QString::fromStdString(m_nativeEntry.url); |
|
|
|
return QString::fromStdString(nativeEntry().url); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TrackerEntry::isWorking() const |
|
|
|
bool TrackerEntry::isWorking() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
return m_nativeEntry.is_working(); |
|
|
|
return nativeEntry().is_working(); |
|
|
|
#else |
|
|
|
#else |
|
|
|
return std::any_of(m_nativeEntry.endpoints.begin(), m_nativeEntry.endpoints.end() |
|
|
|
const auto &endpoints = nativeEntry().endpoints; |
|
|
|
|
|
|
|
return std::any_of(endpoints.begin(), endpoints.end() |
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return endpoint.is_working(); |
|
|
|
return endpoint.is_working(); |
|
|
@ -67,19 +68,40 @@ bool TrackerEntry::isWorking() const |
|
|
|
|
|
|
|
|
|
|
|
int TrackerEntry::tier() const |
|
|
|
int TrackerEntry::tier() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return m_nativeEntry.tier; |
|
|
|
return nativeEntry().tier; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TrackerEntry::Status TrackerEntry::status() const |
|
|
|
TrackerEntry::Status TrackerEntry::status() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
// lt::announce_entry::is_working() returns
|
|
|
|
// lt::announce_entry::is_working() returns
|
|
|
|
// true when the tracker hasn't been tried yet.
|
|
|
|
// true when the tracker hasn't been tried yet.
|
|
|
|
if (m_nativeEntry.verified && isWorking()) |
|
|
|
if (nativeEntry().verified && isWorking()) |
|
|
|
return Working; |
|
|
|
return Working; |
|
|
|
if ((m_nativeEntry.fails == 0) && m_nativeEntry.updating) |
|
|
|
|
|
|
|
|
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
|
|
|
|
if ((nativeEntry().fails == 0) && nativeEntry().updating) |
|
|
|
|
|
|
|
return Updating; |
|
|
|
|
|
|
|
if (nativeEntry().fails == 0) |
|
|
|
|
|
|
|
return NotContacted; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
const auto &endpoints = nativeEntry().endpoints; |
|
|
|
|
|
|
|
const bool allFailed = std::all_of(endpoints.begin(), endpoints.end() |
|
|
|
|
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (endpoint.fails > 0); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const bool updating = std::any_of(endpoints.begin(), endpoints.end() |
|
|
|
|
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return endpoint.updating; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!allFailed && updating) |
|
|
|
return Updating; |
|
|
|
return Updating; |
|
|
|
if (m_nativeEntry.fails == 0) |
|
|
|
|
|
|
|
|
|
|
|
if (!allFailed) |
|
|
|
return NotContacted; |
|
|
|
return NotContacted; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return NotWorking; |
|
|
|
return NotWorking; |
|
|
|
} |
|
|
|
} |
|
|
@ -94,8 +116,11 @@ int TrackerEntry::numSeeds() const |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
return nativeEntry().scrape_complete; |
|
|
|
return nativeEntry().scrape_complete; |
|
|
|
#else |
|
|
|
#else |
|
|
|
// FIXME: Handle all possible endpoints.
|
|
|
|
int max = -1; |
|
|
|
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_complete; |
|
|
|
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete; |
|
|
|
|
|
|
|
for (const lt::announce_endpoint &endpoint : nativeEntry().endpoints) |
|
|
|
|
|
|
|
max = std::max(max, endpoint.scrape_complete); |
|
|
|
|
|
|
|
return max; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,8 +129,11 @@ int TrackerEntry::numLeeches() const |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
return nativeEntry().scrape_incomplete; |
|
|
|
return nativeEntry().scrape_incomplete; |
|
|
|
#else |
|
|
|
#else |
|
|
|
// FIXME: Handle all possible endpoints.
|
|
|
|
int max = -1; |
|
|
|
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete; |
|
|
|
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete; |
|
|
|
|
|
|
|
for (const lt::announce_endpoint &endpoint : nativeEntry().endpoints) |
|
|
|
|
|
|
|
max = std::max(max, endpoint.scrape_incomplete); |
|
|
|
|
|
|
|
return max; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -114,12 +142,15 @@ int TrackerEntry::numDownloaded() const |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
return nativeEntry().scrape_downloaded; |
|
|
|
return nativeEntry().scrape_downloaded; |
|
|
|
#else |
|
|
|
#else |
|
|
|
// FIXME: Handle all possible endpoints.
|
|
|
|
int max = -1; |
|
|
|
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_downloaded; |
|
|
|
return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete; |
|
|
|
|
|
|
|
for (const lt::announce_endpoint &endpoint : nativeEntry().endpoints) |
|
|
|
|
|
|
|
max = std::max(max, endpoint.scrape_downloaded); |
|
|
|
|
|
|
|
return max; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lt::announce_entry TrackerEntry::nativeEntry() const |
|
|
|
const lt::announce_entry &TrackerEntry::nativeEntry() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return m_nativeEntry; |
|
|
|
return m_nativeEntry; |
|
|
|
} |
|
|
|
} |
|
|
|