File indexing completed on 2024-12-01 03:45:01
0001 /* 0002 SPDX-FileCopyrightText: 2017 Jan Grulich <jgrulich@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef NETWORKMANAGERQT_DEVICE_STATISTICS_H 0008 #define NETWORKMANAGERQT_DEVICE_STATISTICS_H 0009 0010 #include <networkmanagerqt/networkmanagerqt_export.h> 0011 0012 #include <nm-version.h> 0013 0014 #include <QObject> 0015 #include <QSharedPointer> 0016 0017 namespace NetworkManager 0018 { 0019 class DeviceStatisticsPrivate; 0020 0021 /** 0022 * Represents device statistics interface 0023 */ 0024 class NETWORKMANAGERQT_EXPORT DeviceStatistics : public QObject 0025 { 0026 Q_OBJECT 0027 Q_PROPERTY(uint refreshRateMs READ refreshRateMs WRITE setRefreshRateMs NOTIFY refreshRateMsChanged) 0028 Q_PROPERTY(qulonglong txBytes READ txBytes NOTIFY txBytesChanged) 0029 Q_PROPERTY(qulonglong rxBytes READ rxBytes NOTIFY rxBytesChanged) 0030 0031 public: 0032 typedef QSharedPointer<DeviceStatistics> Ptr; 0033 typedef QList<Ptr> List; 0034 0035 explicit DeviceStatistics(const QString &path, QObject *parent = nullptr); 0036 ~DeviceStatistics() override; 0037 0038 /** 0039 * Refresh rate of the rest of properties of this interface. The properties are guaranteed to be refreshed 0040 * each RefreshRateMs milliseconds in case the underlying counter has changed too. If zero, there is no guaranteed 0041 * refresh rate of the properties. 0042 */ 0043 uint refreshRateMs() const; 0044 void setRefreshRateMs(uint refreshRate); 0045 /** 0046 * Number of received bytes 0047 */ 0048 qulonglong rxBytes() const; 0049 /** 0050 * Number of transmitted bytes 0051 */ 0052 qulonglong txBytes() const; 0053 0054 Q_SIGNALS: 0055 /** 0056 * Emitted when the refresh rate has changed 0057 */ 0058 void refreshRateMsChanged(uint refreshRate); 0059 /** 0060 * Emitted when the received bytes has changed 0061 */ 0062 void rxBytesChanged(qulonglong rxBytes); 0063 /** 0064 * Emitted when the transmitted bytes has changed 0065 */ 0066 void txBytesChanged(qulonglong txBytes); 0067 0068 private: 0069 Q_DECLARE_PRIVATE(DeviceStatistics) 0070 DeviceStatisticsPrivate *const d_ptr; 0071 }; 0072 0073 } 0074 #endif