blob: 5e00977eb6b0087fa57f327c5f5217316cec2871 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include <QtCore/QtDebug>
#include <contextsubscriber/contextproperty.h>
#include "ckitcallnotification.h"
#include "ckitcallprovider.h"
using namespace sowatch;
CKitCallProvider::CKitCallProvider(QObject *parent) :
NotificationProvider(parent),
_activeCall(new ContextProperty("/com/nokia/CallUi/ActiveCall")),
_notification(0)
{
connect(_activeCall, SIGNAL(valueChanged()), SLOT(activeCallChanged()));
}
CKitCallProvider::~CKitCallProvider()
{
}
void CKitCallProvider::activeCallChanged()
{
QVariantMap info = _activeCall->value().toMap();
qDebug() << "active call changed" << info;
if (!info.contains("state") || !info.value("status", false).toBool()) {
return; // Ignore until we get a map with all the required properties.
}
int state = info["state"].toInt();
if (state == 0) {
QString displayName = info["displayName"].toString();
if (displayName.isEmpty()) {
// Ignore call until display name is not empty.
return;
}
// "Incoming call"
if (_notification) {
// An existing incoming call has been updated
_notification->changeDisplayName(displayName);
} else {
// This is a new incoming call
_notification = new CKitCallNotification(displayName, this);
emit incomingNotification(_notification);
}
} else {
// Call has either been answered, rejected, missed, ..
if (_notification) {
_notification->remove();
_notification->deleteLater();
_notification = 0;
}
}
}
|