NetworkDataUsage
Since: BlackBerry 10.2.0
#include <bb/device/NetworkDataUsage>
To link against this class, add the following line to your .pro file: LIBS += -lbbdevice
Allows monitoring of network traffic statistics.
The NetworkDataUsage classes measures the amount of data (in packets or bytes) sent or received by a particular network interface since the device was last reset. To determine the name of a valid network interface for use with this class, use the QNetworkInterface::allInterfaces() and QNetworkInterface::humanReadableName() methods.
The traffics statistics reported by NetworkDataUsage are not live. You must call update() to obtain the latest packet/byte counts. To montior network usage over time, you can attach the update() slot to the timeout signal of a QTimer. However, be aware that polling can prevent the device from entering a low power state, which adversely affects battery life. If you must poll, please use the lowest frequency possible and suspend polling whenever possible.
Overview
Properties Index
quint64 | bytesReceived [read-only] |
quint64 | bytesSent [read-only] |
QString | networkInterfaceName |
quint64 | packetsReceived [read-only] |
quint64 | packetsSent [read-only] |
Public Functions Index
NetworkDataUsage (QObject *parent=0) | |
NetworkDataUsage (const QString &networkInterfaceName, QObject *parent=0) | |
virtual | ~NetworkDataUsage () |
quint64 | bytesReceived () const |
quint64 | bytesSent () const |
QString | networkInterfaceName () const |
quint64 | packetsReceived () const |
quint64 | packetsSent () const |
void | setNetworkInterfaceName (const QString &name) |
Q_SLOT bool | update () |
Signals Index
void | bytesReceivedChanged (quint64 bytesReceived) |
void | bytesSentChanged (quint64 bytesSent) |
void | networkInterfaceNameChanged (const QString &networkInterfaceName) |
void | packetsReceivedChanged (quint64 packetsReceived) |
void | packetsSentChanged (quint64 packetsSent) |
Properties
quint64
The number of bytes received through the network interface since the device was last reset.
Javascript does not support 64-bit numbers so this property is represented as a floating point value in QML. As a result, rounding errors may occur at higher values of this property. For optimal precision, access this property from C++ instead.
BlackBerry 10.2.0
quint64
The number of bytes sent through the network interface since the device was last reset.
This value will only change as the result of call to update().
Javascript does not support 64-bit numbers so this property is represented as a floating point value in QML. As a result, rounding errors may occur at higher values of this property. For optimal precision, access this property from C++ instead.
BlackBerry 10.2.0
quint64
The number of packets received through the network interface since the device was last reset.
This value will only change as the result of call to update().
Javascript does not support 64-bit numbers so this property is represented as a floating point value in QML. As a result, rounding errors may occur at higher values of this property. For optimal precision, access this property from C++ instead.
BlackBerry 10.2.0
quint64
The number of packets sent through the network interface since the device was last reset.
This value will only change as the result of call to update().
Javascript does not support 64-bit numbers so this property is represented as a floating point value in QML. As a result, rounding errors may occur at higher values of this property. For optimal precision, access this property from C++ instead.
BlackBerry 10.2.0
Public Functions
Creates a NetworkDataUsage object which defaults to an invalid state - no network interface.
Parameters | |
---|---|
parent |
If not 0, the supplied parent will be responsible for deleting this instance. |
BlackBerry 10.2.0
Creates a NetworkDataUsage object for the specified network interface.
Parameters | |
---|---|
networkInterfaceName |
Name of the network interface this object represents. |
parent |
If not 0, the supplied parent will be responsible for deleting this instance. |
BlackBerry 10.2.0
virtual
Destructor.
BlackBerry 10.2.0
quint64
Retrieves the number of bytes received through the network interface since the device was last reset.
This value will only change as the result of call to update().
The number of bytes received through the network interface since the device was last reset.
BlackBerry 10.2.0
quint64
Retrieves the number of bytes sent through the network interface since the device was last reset.
This value will only change as the result of call to update().
The number of bytes sent through the network interface since the device was last reset.
BlackBerry 10.2.0
QString
Retrieves the name of the network interface represented by this object.
The name of the network interface represented by this object.
BlackBerry 10.2.0
quint64
Retrieves the number of packets received through the network interface since the device was last reset.
This value will only change as the result of call to update().
The number of packets received through the network interface since the device was last reset.
BlackBerry 10.2.0
quint64
Retrieves the number of packets sent through the network interface since the device was last reset.
This value will only change as the result of call to update().
The number of packets sent through the network interface since the device was last reset.
BlackBerry 10.2.0
void
Changes the network interface this object represents and resets all packet/byte counts to zero.
Parameters | |
---|---|
name |
The name of the network interface represented by this object. |
BlackBerry 10.2.0
Q_SLOT bool
Updates all packet/byte counts cached by this object.
True if the operation succeeded; false otherwise.
BlackBerry 10.2.0
Signals
void
Emitted when the number of bytes received through the network interface changes.
This property will only change as the result of a call to update().
Parameters | |
---|---|
bytesReceived |
The number of bytes received through the network interface since the device was last reset. |
BlackBerry 10.2.0
void
Emitted when the number of bytes sent through the network interface changes.
This property will only change as the result of a call to update().
Parameters | |
---|---|
bytesSent |
The number of bytes sent through the network interface since the device was last reset. |
BlackBerry 10.2.0
void
Emitted when the name of the network interface this object represents changes.
Parameters | |
---|---|
networkInterfaceName |
The name of the network interface represented by this object |
BlackBerry 10.2.0
void
Emitted when the number of packets received through the network interface changes.
This property will only change as the result of a call to update().
Parameters | |
---|---|
packetsReceived |
The number of packets received through the network interface since the device was last reset. |
BlackBerry 10.2.0
void
Emitted when the number of packets sent through the network interface changes.
This property will only change as the result of a call to update().
Parameters | |
---|---|
packetsSent |
The number of packets sent through the network interface since the device was last reset. |
BlackBerry 10.2.0