blob: 0d9756243cdb5480b3fe5c395e0f2227c32f6939 (
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
|
#include "meegohandsetnotificationprovider.h"
#include "watchnotificationsink.h"
WatchNotificationSink::WatchNotificationSink(sowatch::MeegoHandsetNotificationProvider *parent) :
NotificationSink(parent), _parent(parent)
{
for (uint i = 0; i < maxTypes; i++) {
_counts[i] = 0;
}
}
void WatchNotificationSink::addNotification(const Notification ¬ification)
{
const NotificationParameters& p = notification.parameters();
sowatch::Notification::Type type = notificationTypeFromEventType(p.value("eventType").toString());
uint count = p.value("count").toUInt();
_counts[type] += count;
_trackedNotifications[notification.notificationId()] = notification;
emit countsChanged(type);
QDateTime dt = QDateTime::fromTime_t(p.value("timestamp").toUInt());
QDateTime tenSecondsAgo = QDateTime::currentDateTimeUtc().addSecs(-10);
if (dt >= tenSecondsAgo) {
// If the notification happened recently, show it.
sowatch::Notification n(type, dt, p.value("summary").toString(), p.value("body").toString());
emit incomingNotification(n);
}
}
void WatchNotificationSink::removeNotification(uint notificationId)
{
Notification notification = _trackedNotifications[notificationId];
const NotificationParameters& p = notification.parameters();
sowatch::Notification::Type type = notificationTypeFromEventType(p.value("eventType").toString());
uint count = p.value("count").toUInt();
_counts[type] -= count;
_trackedNotifications.remove(notificationId);
emit countsChanged(type);
}
void WatchNotificationSink::addGroup(uint groupId, const NotificationParameters ¶meters)
{
// We do not care about notification groups
Q_UNUSED(groupId);
Q_UNUSED(parameters);
}
void WatchNotificationSink::removeGroup(uint groupId)
{
Q_UNUSED(groupId);
}
int WatchNotificationSink::getCount(sowatch::Notification::Type type)
{
return _counts[type];
}
sowatch::Notification::Type WatchNotificationSink::notificationTypeFromEventType(const QString& eventType)
{
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
return sowatch::Notification::OtherNotification;
}
|