diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2021-10-25 20:23:24 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-11-04 12:02:25 +0100 |
commit | bd52c1bba6f5a0b7e820596e566146b5cf8a4ee7 (patch) | |
tree | 728aa2010288daee21336992428d57e306f22282 /src/network/kernel/qnetworkinformation.h | |
parent | 2148e1f0e6026ad7a87c7eec0362d1250c1f09e9 (diff) |
QNI: Add API to check if connection is metered
This may be a useful factor in deciding whether or not you should
perform communications over the network which are not purely essential.
For example, if you have a logging mechanism you can delay uploading
them until you are no longer on a metered network.
Task-number: QTBUG-91024
Change-Id: I19d32f031a3893512dc440914133678004987fb1
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/kernel/qnetworkinformation.h')
-rw-r--r-- | src/network/kernel/qnetworkinformation.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/network/kernel/qnetworkinformation.h b/src/network/kernel/qnetworkinformation.h index e280894fef..9b09fcee98 100644 --- a/src/network/kernel/qnetworkinformation.h +++ b/src/network/kernel/qnetworkinformation.h @@ -58,6 +58,7 @@ class Q_NETWORK_EXPORT QNetworkInformation : public QObject Q_PROPERTY(bool isBehindCaptivePortal READ isBehindCaptivePortal NOTIFY isBehindCaptivePortalChanged) Q_PROPERTY(TransportMedium transportMedium READ transportMedium NOTIFY transportMediumChanged) + Q_PROPERTY(bool isMetered READ isMetered NOTIFY isMeteredChanged) public: enum class Reachability { Unknown, @@ -81,6 +82,7 @@ public: Reachability = 0x1, CaptivePortal = 0x2, TransportMedium = 0x4, + Metered = 0x8, }; Q_DECLARE_FLAGS(Features, Feature) Q_FLAG(Features) @@ -91,6 +93,8 @@ public: TransportMedium transportMedium() const; + bool isMetered() const; + QString backendName() const; bool supports(Features features) const; @@ -106,6 +110,7 @@ Q_SIGNALS: void reachabilityChanged(Reachability newReachability); void isBehindCaptivePortalChanged(bool state); void transportMediumChanged(TransportMedium current); + void isMeteredChanged(bool isMetered); private: friend struct QNetworkInformationDeleter; |