1 | /* |
2 | SPDX-FileCopyrightText: 2017 Jan Grulich <jgrulich@redhat.com> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | |
7 | #ifndef NETWORKMANAGERQT_DEVICE_STATISTICS_H |
8 | #define NETWORKMANAGERQT_DEVICE_STATISTICS_H |
9 | |
10 | #include <networkmanagerqt/networkmanagerqt_export.h> |
11 | |
12 | #include <nm-version.h> |
13 | |
14 | #include <QObject> |
15 | #include <QSharedPointer> |
16 | |
17 | namespace NetworkManager |
18 | { |
19 | class DeviceStatisticsPrivate; |
20 | |
21 | /** |
22 | * Represents device statistics interface |
23 | */ |
24 | class NETWORKMANAGERQT_EXPORT DeviceStatistics : public QObject |
25 | { |
26 | Q_OBJECT |
27 | Q_PROPERTY(uint refreshRateMs READ refreshRateMs WRITE setRefreshRateMs NOTIFY refreshRateMsChanged) |
28 | Q_PROPERTY(qulonglong txBytes READ txBytes NOTIFY txBytesChanged) |
29 | Q_PROPERTY(qulonglong rxBytes READ rxBytes NOTIFY rxBytesChanged) |
30 | |
31 | public: |
32 | typedef QSharedPointer<DeviceStatistics> Ptr; |
33 | typedef QList<Ptr> List; |
34 | |
35 | explicit DeviceStatistics(const QString &path, QObject *parent = nullptr); |
36 | ~DeviceStatistics() override; |
37 | |
38 | /** |
39 | * Refresh rate of the rest of properties of this interface. The properties are guaranteed to be refreshed |
40 | * each RefreshRateMs milliseconds in case the underlying counter has changed too. If zero, there is no guaranteed |
41 | * refresh rate of the properties. |
42 | */ |
43 | uint refreshRateMs() const; |
44 | void setRefreshRateMs(uint refreshRate); |
45 | /** |
46 | * Number of received bytes |
47 | */ |
48 | qulonglong rxBytes() const; |
49 | /** |
50 | * Number of transmitted bytes |
51 | */ |
52 | qulonglong txBytes() const; |
53 | |
54 | Q_SIGNALS: |
55 | /** |
56 | * Emitted when the refresh rate has changed |
57 | */ |
58 | void refreshRateMsChanged(uint refreshRate); |
59 | /** |
60 | * Emitted when the received bytes has changed |
61 | */ |
62 | void rxBytesChanged(qulonglong rxBytes); |
63 | /** |
64 | * Emitted when the transmitted bytes has changed |
65 | */ |
66 | void txBytesChanged(qulonglong txBytes); |
67 | |
68 | private: |
69 | Q_DECLARE_PRIVATE(DeviceStatistics) |
70 | DeviceStatisticsPrivate *const d_ptr; |
71 | }; |
72 | |
73 | } |
74 | #endif |
75 | |