Sailfish OS
  • Info
  • User Experience
  • Cases
  • Community
  • Developers
  • Contact
  • Get Sailfish OS
Select Page

API Documentation

Documentation for developing SailfishOS applications
  • API Documentation
  • Libsailfishapp
  • Sailfish Silica
    • Documentation
    • Icon Reference
  • Sailfish Components
    • Sailfish Accounts
    • Sailfish Bluetooth
    • Sailfish Contacts
    • Sailfish Crypto
    • Sailfish Gallery
    • Sailfish Media
    • Sailfish Pickers
    • Sailfish Secrets
    • Sailfish Share
    • Sailfish Telephony
    • Sailfish Webview
    • Amber Web Authorization
    • Amber MPRIS
  • Nemo QML Plugins
    • Configuration
    • Contacts
    • D-Bus
    • Keepalive
    • Notifications
    • Thumbnailer
  • Sailfish Middleware
    • MDM Framework
    • MDM Policy Framework
    • User Manager Daemon

Contents

  • Public Types
  • Properties
  • Public Functions
  • Signals
  • Detailed Description

NetworkDataCounter Class

(Sailfish::Mdm::NetworkDataCounter)

The NetworkDataCounter class monitors network data usage. More...

Header: #include <mdm-networkdatacounter.h>
  • List of all members, including inherited members

Public Types

class Update
enum NetworkType { MobileDataHome, MobileDataRoaming, Wlan }

Properties

  • active : bool
  • updateAccuracy : int
  • updateInterval : int

Public Functions

NetworkDataCounter(QObject *parent = 0)
~NetworkDataCounter()
bool active() const
void resetCounter(const QString &servicePath)
void setActive(bool active)
void setUpdateAccuracy(int updateAccuracy)
void setUpdateInterval(int updateInterval)
int updateAccuracy() const
int updateInterval() const

Signals

void activeChanged()
void counterUpdate(const Sailfish::Mdm::NetworkDataCounter::Update &update)
void updateAccuracyChanged()
void updateIntervalChanged()

Detailed Description

The NetworkDataCounter class monitors network data usage.

To use this class, clients must add the following to their qmake project:

 CONFIG += link_pkgconfig
 PKGCONFIG += sailfishmdm

and then #include <mdm-networkdatacounter.h>.

The counterUpdate() signal is emitted whenever an update of network data traffic is available.

Example of usage:

 #include <mdm-networkdatacounter.h>

 void queryNetworkDataUsage(QObject *parent)
 {
     Sailfish::Mdm::NetworkDataCounter *counter = new Sailfish::Mdm::NetworkDataCounter(parent);
     QObject::connect(counter, &Sailfish::Mdm::NetworkDataCounter::counterUpdate, [](const Sailfish::Mdm::NetworkDataCounter::Update &update) {
         qInfo() << "Service:" << update.servicePath;
         qInfo() << "    Sent:" << update.bytesSent << "bytes";
         qInfo() << "    Received:" << update.bytesReceived << "bytes";
         qInfo() << "    Time online:" << update.timeOnline << "seconds";
     });
 }

Member Type Documentation

enum NetworkDataCounter::NetworkType

Describes the network types for which data counters are provided.

ConstantValueDescription
Sailfish::Mdm::NetworkDataCounter::MobileDataHome0Mobile data on the home network.
Sailfish::Mdm::NetworkDataCounter::MobileDataRoaming1Mobile data when roaming outside of the home network.
Sailfish::Mdm::NetworkDataCounter::Wlan2WLAN network data.

Property Documentation

active : bool

This property holds true if the counter is active and able to provide updates.

Access functions:

bool active() const
void setActive(bool active)

Notifier signal:

void activeChanged()

updateAccuracy : int

This property holds the accuracy threshold for updates, in kilobytes.

Updates are provided when data traffic changes exceeds this accuracy threshold and the period specified by updateInterval has passed. A low threshold can result in excessive updates that impact performance; it is recommended to set a minimum value of 10kB, or or preferably 1MB.

The default value is 1024kB.

Access functions:

int updateAccuracy() const
void setUpdateAccuracy(int updateAccuracy)

Notifier signal:

void updateAccuracyChanged()

See also updateInterval.

updateInterval : int

This property holds how often updates should be provided, in seconds.

Note that updates are only provided when available. If there is no current network traffic then updates will not be provided.

The default value is 60 seconds.

Access functions:

int updateInterval() const
void setUpdateInterval(int updateInterval)

Notifier signal:

void updateIntervalChanged()

See also updateAccuracy.

Member Function Documentation

NetworkDataCounter::NetworkDataCounter(QObject *parent = 0)

Constructs a NetworkDataCounter with the given parent.

NetworkDataCounter::~NetworkDataCounter()

Destroys the NetworkDataCounter.

[signal] void NetworkDataCounter::counterUpdate(const Sailfish::Mdm::NetworkDataCounter::Update &update)

Provides an update of network data statistics.

This is provided when active is true and an update of network data traffic is available. Updates are provided according to the current updateInterval and updateAccuracy.

void NetworkDataCounter::resetCounter(const QString &servicePath)

Resets the counter located at the specified servicePath.

See also Update::servicePath.

  • Legal
  • Contact Us
  • Jolla Mobile Ltd © 2025

  • Facebook
  • Twitter
  • Mastodon
  • YouTube
  • LinkedIn