summaryrefslogtreecommitdiff
path: root/meegohandsetnotification/meegohandsetnotification.cpp
blob: 41264b6c8f6a804d1d196ad197b3e8e4274898b5 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "meegohandsetnotification.h"

MeegoHandsetNotification::MeegoHandsetNotification(const ::Notification& n, QObject *parent) :
	sowatch::Notification(parent), _n(n)
{
}

sowatch::Notification::Type MeegoHandsetNotification::type() const
{
	QString eventType = _n.parameters().value("eventType").toString();
	if (eventType == "email.arrived")
		return sowatch::Notification::EmailNotification;
	else if (eventType == "x-nokia.call.missed")
		return sowatch::Notification::MissedCallNotification;
	else if (eventType == "x-nokia.messaging.im")
		return sowatch::Notification::ImNotification;
	else if (eventType == "x-nokia.messaging.sms")
		return sowatch::Notification::SmsNotification;
	else if (eventType == "x-nokia.messaging.mms")
		return sowatch::Notification::MmsNotification;
	else
		return sowatch::Notification::OtherNotification;
}

uint MeegoHandsetNotification::count() const
{
	return _n.parameters().value("count").toUInt();
}

QDateTime MeegoHandsetNotification::dateTime() const
{
	const uint timestamp = _n.parameters().value("timestamp").toUInt();
	return QDateTime::fromTime_t(timestamp);
}

QString MeegoHandsetNotification::title() const
{
	return _n.parameters().value("summary").toString();
}

QString MeegoHandsetNotification::body() const
{
	return _n.parameters().value("body").toString();
}

void MeegoHandsetNotification::activate()
{
	// TODO Actually do something
}

void MeegoHandsetNotification::dismiss()
{
	// TODO Actually dismiss
}

void MeegoHandsetNotification::changeTo(const ::Notification &notification)
{
	uint oldCount = count();
	QDateTime oldDateTime = dateTime();
	QString oldTitle = title();
	QString oldBody = body();
	_n = notification;
	if (oldCount != count()) {
		emit countChanged();
	}
	if (oldDateTime != dateTime()) {
		emit dateTimeChanged();
		emit displayTimeChanged();
	}
	if (oldTitle != title()) {
		emit titleChanged();
	}
	if (oldBody != body()) {
		emit bodyChanged();
	}
	emit changed();
}

void MeegoHandsetNotification::remove()
{
	emit dismissed();
}