summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/notificationendpoint.cpp
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2016-02-11 23:55:16 +0100
committerAndrew Branson <andrew.branson@cern.ch>2016-02-11 23:55:16 +0100
commit29aaea2d80a9eb1715b6cddfac2d2aacf76358bd (patch)
tree012795b6bec16c72f38d33cff46324c9a0225868 /rockworkd/libpebble/notificationendpoint.cpp
launchpad ~mzanetti/rockwork/trunk r87
Diffstat (limited to 'rockworkd/libpebble/notificationendpoint.cpp')
-rw-r--r--rockworkd/libpebble/notificationendpoint.cpp46
1 files changed, 46 insertions, 0 deletions
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 <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();
+
+}