WebUI: disallow unnecessary quotes in property name
[qBittorrent.git] / src / base / bittorrent / peerinfo.h
blob86f3c0c7adb01ccb1e5ca287114d4d0326e1ee46
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2015-2023 Vladimir Golovnev <glassez@yandex.ru>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
29 #pragma once
31 #include <libtorrent/peer_info.hpp>
33 #include <QCoreApplication>
35 class QBitArray;
37 namespace BitTorrent
39 struct PeerAddress;
41 class PeerInfo
43 Q_DECLARE_TR_FUNCTIONS(PeerInfo)
45 public:
46 PeerInfo() = default;
47 PeerInfo(const lt::peer_info &nativeInfo, const QBitArray &allPieces);
49 bool fromDHT() const;
50 bool fromPeX() const;
51 bool fromLSD() const;
53 bool isInteresting() const;
54 bool isChocked() const;
55 bool isRemoteInterested() const;
56 bool isRemoteChocked() const;
57 bool isSupportsExtensions() const;
58 bool isLocalConnection() const;
60 bool isHandshake() const;
61 bool isConnecting() const;
62 bool isOnParole() const;
63 bool isSeed() const;
65 bool optimisticUnchoke() const;
66 bool isSnubbed() const;
67 bool isUploadOnly() const;
68 bool isEndgameMode() const;
69 bool isHolepunched() const;
71 bool useI2PSocket() const;
72 bool useUTPSocket() const;
73 bool useSSLSocket() const;
75 bool isRC4Encrypted() const;
76 bool isPlaintextEncrypted() const;
78 PeerAddress address() const;
79 QString I2PAddress() const;
80 QString client() const;
81 QString peerIdClient() const;
82 qreal progress() const;
83 int payloadUpSpeed() const;
84 int payloadDownSpeed() const;
85 qlonglong totalUpload() const;
86 qlonglong totalDownload() const;
87 QBitArray pieces() const;
88 QString connectionType() const;
89 qreal relevance() const;
90 QString flags() const;
91 QString flagsDescription() const;
92 QString country() const;
93 int downloadingPieceIndex() const;
95 private:
96 qreal calcRelevance(const QBitArray &allPieces) const;
97 void determineFlags();
99 lt::peer_info m_nativeInfo = {};
100 qreal m_relevance = 0;
101 QString m_flags;
102 QString m_flagsDescription;
104 mutable QString m_country;
105 mutable QString m_I2PAddress;