|
|
@ -52,24 +52,6 @@ QString TrackerEntry::url() const |
|
|
|
return QString::fromStdString(nativeEntry().url); |
|
|
|
return QString::fromStdString(nativeEntry().url); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TrackerEntry::isWorking() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// lt::announce_entry::is_working() returns
|
|
|
|
|
|
|
|
// true when the tracker hasn't been tried yet.
|
|
|
|
|
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
|
|
|
|
return nativeEntry().verified && nativeEntry().is_working(); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
if (!nativeEntry().verified) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
const auto &endpoints = nativeEntry().endpoints; |
|
|
|
|
|
|
|
return std::any_of(endpoints.begin(), endpoints.end() |
|
|
|
|
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return endpoint.is_working(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int TrackerEntry::tier() const |
|
|
|
int TrackerEntry::tier() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return nativeEntry().tier; |
|
|
|
return nativeEntry().tier; |
|
|
@ -77,35 +59,36 @@ int TrackerEntry::tier() const |
|
|
|
|
|
|
|
|
|
|
|
TrackerEntry::Status TrackerEntry::status() const |
|
|
|
TrackerEntry::Status TrackerEntry::status() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (isWorking()) |
|
|
|
|
|
|
|
return Working; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
#if (LIBTORRENT_VERSION_NUM < 10200) |
|
|
|
if ((nativeEntry().fails == 0) && nativeEntry().updating) |
|
|
|
if (nativeEntry().fails > 0) |
|
|
|
|
|
|
|
return NotWorking; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (nativeEntry().updating) |
|
|
|
return Updating; |
|
|
|
return Updating; |
|
|
|
if (nativeEntry().fails == 0) |
|
|
|
|
|
|
|
return NotContacted; |
|
|
|
|
|
|
|
#else |
|
|
|
#else |
|
|
|
const auto &endpoints = nativeEntry().endpoints; |
|
|
|
const auto &endpoints = nativeEntry().endpoints; |
|
|
|
const bool allFailed = std::all_of(endpoints.begin(), endpoints.end() |
|
|
|
|
|
|
|
|
|
|
|
const bool allFailed = !endpoints.empty() && std::all_of(endpoints.begin(), endpoints.end() |
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return (endpoint.fails > 0); |
|
|
|
return (endpoint.fails > 0); |
|
|
|
}); |
|
|
|
}); |
|
|
|
const bool updating = std::any_of(endpoints.begin(), endpoints.end() |
|
|
|
if (allFailed) |
|
|
|
|
|
|
|
return NotWorking; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bool isUpdating = std::any_of(endpoints.begin(), endpoints.end() |
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
, [](const lt::announce_endpoint &endpoint) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return endpoint.updating; |
|
|
|
return endpoint.updating; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
if (isUpdating) |
|
|
|
if (!allFailed && updating) |
|
|
|
|
|
|
|
return Updating; |
|
|
|
return Updating; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if (!allFailed) |
|
|
|
if (!nativeEntry().verified) |
|
|
|
return NotContacted; |
|
|
|
return NotContacted; |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NotWorking; |
|
|
|
return Working; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TrackerEntry::setTier(const int value) |
|
|
|
void TrackerEntry::setTier(const int value) |
|
|
|