Improve tracker entries handling

This commit is contained in:
Vladimir Golovnev (Glassez) 2021-03-01 16:06:08 +03:00
parent 6b3c6c12ff
commit 7a8c05dc7c
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
17 changed files with 194 additions and 215 deletions

View file

@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2015, 2021 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -28,17 +28,14 @@
#pragma once
#include <libtorrent/announce_entry.hpp>
#include <QtGlobal>
class QString;
#include <QString>
#include <QVector>
namespace BitTorrent
{
class TrackerEntry
struct TrackerEntry
{
public:
enum Status
{
NotContacted = 1,
@ -47,26 +44,26 @@ namespace BitTorrent
NotWorking = 4
};
TrackerEntry() = default;
TrackerEntry(const QString &url);
TrackerEntry(const lt::announce_entry &nativeEntry);
TrackerEntry(const TrackerEntry &other) = default;
TrackerEntry &operator=(const TrackerEntry &other) = default;
struct EndpointStats
{
int protocolVersion = 1;
QString url() const;
Status status() const;
Status status = NotContacted;
int numSeeds = -1;
int numLeeches = -1;
int numDownloaded = -1;
};
int tier() const;
void setTier(int value);
QString url;
int tier = 0;
int numSeeds() const;
int numLeeches() const;
int numDownloaded() const;
QVector<EndpointStats> endpoints {};
const lt::announce_entry &nativeEntry() const;
private:
lt::announce_entry m_nativeEntry;
// Deprecated fields
Status status = NotContacted;
int numSeeds = -1;
int numLeeches = -1;
int numDownloaded = -1;
};
bool operator==(const TrackerEntry &left, const TrackerEntry &right);