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

quint64bytesReceived [read-only]
quint64bytesSent [read-only]
QStringnetworkInterfaceName
quint64packetsReceived [read-only]
quint64packetsSent [read-only]

Public Functions Index

NetworkDataUsage (QObject *parent=0)
NetworkDataUsage (const QString &networkInterfaceName, QObject *parent=0)
virtual ~NetworkDataUsage ()
quint64bytesReceived () const
quint64bytesSent () const
QStringnetworkInterfaceName () const
quint64packetsReceived () const
quint64packetsSent () const
voidsetNetworkInterfaceName (const QString &name)
Q_SLOT boolupdate ()

Signals Index

voidbytesReceivedChanged (quint64 bytesReceived)
voidbytesSentChanged (quint64 bytesSent)
voidnetworkInterfaceNameChanged (const QString &networkInterfaceName)
voidpacketsReceivedChanged (quint64 packetsReceived)
voidpacketsSentChanged (quint64 packetsSent)

Properties

quint64 bytesReceived[read-only]

The number of bytes received through the network interface since the device was last reset.

Note:

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.

Since:

BlackBerry 10.2.0

quint64 bytesSent[read-only]

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().

Note:

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.

Since:

BlackBerry 10.2.0

QString networkInterfaceName

Name of the network interface represented by this object.

Since:

BlackBerry 10.2.0

quint64 packetsReceived[read-only]

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().

Note:

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.

Since:

BlackBerry 10.2.0

quint64 packetsSent[read-only]

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().

Note:

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.

Since:

BlackBerry 10.2.0

Public Functions

NetworkDataUsage (

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.

Since:

BlackBerry 10.2.0

NetworkDataUsage (

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.

Since:

BlackBerry 10.2.0

virtual~NetworkDataUsage ()

Destructor.

Since:

BlackBerry 10.2.0

quint64 bytesReceived ()

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().

Return:

The number of bytes received through the network interface since the device was last reset.

Since:

BlackBerry 10.2.0

quint64 bytesSent ()

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().

Return:

The number of bytes sent through the network interface since the device was last reset.

Since:

BlackBerry 10.2.0

QString networkInterfaceName ()

Retrieves the name of the network interface represented by this object.

Return:

The name of the network interface represented by this object.

Since:

BlackBerry 10.2.0

quint64 packetsReceived ()

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().

Return:

The number of packets received through the network interface since the device was last reset.

Since:

BlackBerry 10.2.0

quint64 packetsSent ()

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().

Return:

The number of packets sent through the network interface since the device was last reset.

Since:

BlackBerry 10.2.0

void setNetworkInterfaceName (

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.

Since:

BlackBerry 10.2.0

Q_SLOT bool update ()

Updates all packet/byte counts cached by this object.

Return:

True if the operation succeeded; false otherwise.

Since:

BlackBerry 10.2.0

Signals

void bytesReceivedChanged (
  • quint64bytesReceived)

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.

Since:

BlackBerry 10.2.0

void bytesSentChanged (
  • quint64bytesSent)

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.

Since:

BlackBerry 10.2.0

void networkInterfaceNameChanged (
  • const QString &networkInterfaceName)

Emitted when the name of the network interface this object represents changes.

Parameters
networkInterfaceName

The name of the network interface represented by this object

Since:

BlackBerry 10.2.0

void packetsReceivedChanged (
  • quint64packetsReceived)

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.

Since:

BlackBerry 10.2.0

void packetsSentChanged (
  • quint64packetsSent)

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.

Since:

BlackBerry 10.2.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus