API Documentation
Documentation for developing SailfishOS applicationsCallStatistics 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.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::CallStatistics::AnyCallType | 0 | Match any type of phone call. |
Sailfish::Mdm::CallStatistics::OutgoingCall | 1 | Match phone calls that were dialed, i.e. outgoing calls. |
Sailfish::Mdm::CallStatistics::MissedCall | 2 | Match phone calls that were not answered. |
Sailfish::Mdm::CallStatistics::IncomingCall | 3 | Match 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.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::CallStatistics::NoTimeInterval | 0 | Do not group results. The list of results will consist of a single entry. |
Sailfish::Mdm::CallStatistics::Yearly | 1 | Group results by year. |
Sailfish::Mdm::CallStatistics::Monthly | 2 | Group results by month. |
Sailfish::Mdm::CallStatistics::Weekly | 3 | Group results by week number. |
Sailfish::Mdm::CallStatistics::Daily | 4 | Group 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.
void CallStatistics::search(const Sailfish::Mdm::CallStatistics::Filter &filter)
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.