summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/notificationendpoint.cpp
blob: 363563a281eefee19448571c973b8300fd5b9b1a (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
#include "notificationendpoint.h"

#include "watchconnection.h"
#include "pebble.h"
#include "blobdb.h"

#include <QDebug>
#include <QDateTime>

NotificationEndpoint::NotificationEndpoint(Pebble *pebble, WatchConnection *watchConnection):
    QObject(pebble),
    m_pebble(pebble),
    m_watchConnection(watchConnection)
{
}

void NotificationEndpoint::sendLegacyNotification(const Notification &notification)
{
    LegacyNotification::Source source = LegacyNotification::SourceSMS;
    switch (notification.type()) {
    case Notification::NotificationTypeEmail:
        source = LegacyNotification::SourceEmail;
        break;
    case Notification::NotificationTypeFacebook:
        source = LegacyNotification::SourceFacebook;
        break;
    case Notification::NotificationTypeSMS:
        source = LegacyNotification::SourceSMS;
        break;
    case Notification::NotificationTypeTwitter:
        source = LegacyNotification::SourceTwitter;
        break;
    default:
        source = LegacyNotification::SourceSMS;
    }

    QString body = notification.subject().isEmpty() ? notification.body() : notification.subject();
    LegacyNotification legacyNotification(source, notification.sender(), body, QDateTime::currentDateTime(), notification.subject());
    m_watchConnection->writeToPebble(WatchConnection::EndpointNotification, legacyNotification.serialize());
}

void NotificationEndpoint::notificationReply(const QByteArray &data)
{
    qDebug() << "have notification reply" << data.toHex();

}