From 29aaea2d80a9eb1715b6cddfac2d2aacf76358bd Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 11 Feb 2016 23:55:16 +0100 Subject: launchpad ~mzanetti/rockwork/trunk r87 --- rockworkd/libpebble/notificationendpoint.cpp | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 rockworkd/libpebble/notificationendpoint.cpp (limited to 'rockworkd/libpebble/notificationendpoint.cpp') diff --git a/rockworkd/libpebble/notificationendpoint.cpp b/rockworkd/libpebble/notificationendpoint.cpp new file mode 100644 index 0000000..363563a --- /dev/null +++ b/rockworkd/libpebble/notificationendpoint.cpp @@ -0,0 +1,46 @@ +#include "notificationendpoint.h" + +#include "watchconnection.h" +#include "pebble.h" +#include "blobdb.h" + +#include +#include + +NotificationEndpoint::NotificationEndpoint(Pebble *pebble, WatchConnection *watchConnection): + QObject(pebble), + m_pebble(pebble), + m_watchConnection(watchConnection) +{ +} + +void NotificationEndpoint::sendLegacyNotification(const Notification ¬ification) +{ + 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(); + +} -- cgit v1.2.3