API Documentation

Documentation for developing SailfishOS applications

CallStatistics Class

(Sailfish::Mdm::CallStatistics)

The CallStatistics class provides access to phone call statistics. More...

Header: #include <mdm-callstatistics.h>

Public Types

class Filter
class Result
enum CallType { AnyCallType, OutgoingCall, MissedCall, IncomingCall }
enum TimeInterval { NoTimeInterval, Yearly, Monthly, Weekly, Daily }

Public Functions

CallStatistics(QObject *parent = 0)
~CallStatistics()
void search(const Sailfish::Mdm::CallStatistics::Filter &filter)

Signals

void searchFinished(bool success, const QList<Sailfish::Mdm::CallStatistics::Result> &results)

Detailed Description

The CallStatistics class provides access to phone call statistics.

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

 CONFIG += link_pkgconfig
 PKGCONFIG += sailfishmdm

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

Example of usage:

 #include <mdm-callstatistics.h>

 using namespace Sailfish::Mdm;

 void printCallStatistics(QObject *parent)
 {
     CallStatistics filter;
     filter.callType = CallStatistics::MissedCall;
     filter.start = QDateTime(QDate(2000, 1, 1));

     CallStatistics *stats = new CallStatistics(parent);
     stats->search(filter);

     QString intervalFormat;
     switch (filter.timeInterval) {
     case CallStatistics::NoTimeInterval:
         break;
     case CallStatistics::Yearly:
         intervalFormat = "yyyy:";
         break;
     case CallStatistics::Monthly:
         intervalFormat = "yyyy MMM:";
         break;
     case CallStatistics::Weekly:
         intervalFormat = "Week starting yyyy-MM-ddd:";
         break;
     case CallStatistics::Daily:
         intervalFormat = "yyyy-MM-ddd:";
         break;
     }

     QObject::connect(stats, &CallStatistics::searchFinished, [stats, &intervalFormat](bool success, const QList<Sailfish::Mdm::CallStatistics::Result> &results) {
         if (success) {
             for (const CallStatistics::Result &result : results) {
                 qInfo() << result.when.toString(intervalFormat) << result.callCount << "calls";
             }
         } else {
             qInfo() << "Failed to fetch call statistics!";
         }
     });
 }

Note this API currently provides statistics for cellular calls only.

Member Type Documentation

enum CallStatistics::CallType

Types of phone calls to match in a Filter.

ConstantValueDescription
Sailfish::Mdm::CallStatistics::AnyCallType0Match any type of phone call.
Sailfish::Mdm::CallStatistics::OutgoingCall1Match phone calls that were dialed, i.e. outgoing calls.
Sailfish::Mdm::CallStatistics::MissedCall2Match phone calls that were not answered.
Sailfish::Mdm::CallStatistics::IncomingCall3Match phone calls that were received.

enum CallStatistics::TimeInterval

The time interval used to group the results of a search.

This applies grouping to the search results emitted by searchFinished(). When an interval is set, each item in the list of results will correspond to the statistics for a single day, month or year.

ConstantValueDescription
Sailfish::Mdm::CallStatistics::NoTimeInterval0Do not group results. The list of results will consist of a single entry.
Sailfish::Mdm::CallStatistics::Yearly1Group results by year.
Sailfish::Mdm::CallStatistics::Monthly2Group results by month.
Sailfish::Mdm::CallStatistics::Weekly3Group results by week number.
Sailfish::Mdm::CallStatistics::Daily4Group results by day.

For example, if Filter::start is July 1, 2000 and Filter::end is June 30, 2002, the list of results would consist of:

  • For Yearly - 3 results: 2000-07-01 to 2000-12-31, 2001-01-01 to 2001-12-31, 2002-01-01 to 2002-06-30
  • For Monthly - 24 results, one for each month between the start and end times (inclusive).
  • For Weekly - 107 results, one for each week between the start and end times (inclusive), where each full week starts on a Monday. Due to the days of the week on which the first and last dates fall, the first and last results are less than one full week: the first entry is from 2000-07-1 to 2007-07-04 and the last entry is 2002-06-25 to 2002-06-30.
  • For Daily - 701 results, one for each day between the start and end times (inclusive).

Entries are included for each interval, regardless of whether there were any calls in that day/month/year.

Member Function Documentation

CallStatistics::CallStatistics(QObject *parent = 0)

Constructs a CallStatistics instance with the given parent.

CallStatistics::~CallStatistics()

Destroys the CallStatistics instance.

Retrieves the number of phone calls that match the given filter.

Currently, only cellular phone call statistics are supported.

[signal] void CallStatistics::searchFinished(bool success, const QList<Sailfish::Mdm::CallStatistics::Result> &results)

Emitted when a search completes after calling search().

success is true if the call succeeded, and results holds the list of matching results.

We use cookies to improve your user experience and to help us to develop our services. By continuing to browse the site, you approve of our use of cookies.