This repository has been archived by the owner on Oct 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
tracker.h
74 lines (55 loc) · 1.82 KB
/
tracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// SPDX-FileCopyrightText: 2015-2023 Alexey Rochev
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef LIBTREMOTESF_TRACKER_H
#define LIBTREMOTESF_TRACKER_H
#include <QDateTime>
#include <QObject>
#include <QString>
#include "formatters.h"
class QJsonObject;
class QUrl;
namespace libtremotesf {
class Tracker {
Q_GADGET
public:
enum class Status {
// Tracker is inactive, possibly due to error
Inactive,
// Waiting for announce/scrape
WaitingForUpdate,
// Queued for immediate announce/scrape
QueuedForUpdate,
// We are announcing/scraping
Updating,
};
Q_ENUM(Status)
explicit Tracker(int id, const QJsonObject& trackerMap);
int id() const { return mId; };
const QString& announce() const { return mAnnounce; };
const QString& site() const { return mSite; };
Status status() const { return mStatus; };
QString errorMessage() const { return mErrorMessage; };
int peers() const { return mPeers; };
int seeders() const { return mSeeders; }
int leechers() const { return mLeechers; }
const QDateTime& nextUpdateTime() const { return mNextUpdateTime; };
bool update(const QJsonObject& trackerMap);
bool operator==(const Tracker& other) const = default;
private:
QString mAnnounce{};
QString mSite{};
Status mStatus{};
QString mErrorMessage{};
QDateTime mNextUpdateTime{{}, {}, Qt::UTC};
int mPeers{};
int mSeeders{};
int mLeechers{};
int mId{};
};
namespace impl {
QString registrableDomainFromUrl(const QUrl& url);
}
}
SPECIALIZE_FORMATTER_FOR_Q_ENUM(libtremotesf::Tracker::Status)
#endif // LIBTREMOTESF_TRACKER_H