summaryrefslogtreecommitdiff
path: root/meegohandsetnotification/meegohandsetnotificationprovider.cpp
blob: fc84e4631fff37e4e0030ec41ba93466a1e2d55b (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
#include <QtDBus/QDBusConnection>
#include <notificationsystem/metatypedeclarations.h>
#include <notificationsystem/notificationsinkadaptor.h>
#include "watchnotificationsink.h"
#include "mnotificationmanagerinterface.h"
#include "meegohandsetnotificationprovider.h"

using namespace sowatch;

MeegoHandsetNotificationProvider::MeegoHandsetNotificationProvider(QObject *parent) :
	sowatch::NotificationProvider(parent),
	_manager(new MNotificationManagerInterface("com.meego.core.MNotificationManager", "/notificationsinkmanager", QDBusConnection::sessionBus(), this)),
	_sink(new WatchNotificationSink(this))
{
	qDBusRegisterMetaType< ::Notification >(); // Avoid a name collision with sowatch::Notification
	qDBusRegisterMetaType<QList< ::Notification > >();
	qDBusRegisterMetaType<NotificationGroup>();
	qDBusRegisterMetaType<QList<NotificationGroup> >();
	qDBusRegisterMetaType<NotificationParameters>();

	new NotificationSinkAdaptor(_sink);
	QDBusConnection::sessionBus().registerService("com.javispedro.sowatch.MeegoHandsetNotificationSink");
	QDBusConnection::sessionBus().registerObject("/meegohandsetnotificationsink", _sink);

	connect(_sink, SIGNAL(incomingNotification(sowatch::Notification)),
			SLOT(sinkNotification(sowatch::Notification)));
	connect(_sink, SIGNAL(countsChanged(sowatch::Notification::Type)),
			SLOT(sinkUnreadCountChanged(sowatch::Notification::Type)));

	_manager->registerSink("com.javispedro.sowatch.MeegoHandsetNotificationSink", "/meegohandsetnotificationsink");
}

MeegoHandsetNotificationProvider::~MeegoHandsetNotificationProvider()
{

}

int MeegoHandsetNotificationProvider::getCount(sowatch::Notification::Type type)
{
	return _sink->getCount(type);
}

void MeegoHandsetNotificationProvider::sinkNotification(const Notification &n)
{
	emit notification(n);
}

void MeegoHandsetNotificationProvider::sinkUnreadCountChanged(Notification::Type type)
{
	emit unreadCountChanged(type);
}