summaryrefslogtreecommitdiff
path: root/ckitcallnotification/ckitcallprovider.cpp
blob: adcb6d54f7d1a859d4f48b9891c0fbe9451798a4 (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
#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();
	int state = info["state"].toInt();
	if (state == 0) {
		QString displayName = info["displayName"].toString();
		// "Incoming call"
		if (_notification) {
			_notification->changeDisplayName(displayName);
		} else {
			_notification = new CKitCallNotification(displayName, this);
			emit incomingNotification(_notification);
		}
	} else {
		// Call is either answered, dropped, missed, ..
		if (_notification) {
			_notification->clear();
			_notification->deleteLater();
			_notification = 0;
		}
	}
}