summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/notificationendpoint.h
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.h
launchpad ~mzanetti/rockwork/trunk r87
Diffstat (limited to 'rockworkd/libpebble/notificationendpoint.h')
-rw-r--r--rockworkd/libpebble/notificationendpoint.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/rockworkd/libpebble/notificationendpoint.h b/rockworkd/libpebble/notificationendpoint.h
new file mode 100644
index 0000000..211c8cd
--- /dev/null
+++ b/rockworkd/libpebble/notificationendpoint.h
@@ -0,0 +1,64 @@
+#include <QObject>
+#include <QUuid>
+#include <QDateTime>
+
+#include "pebble.h"
+#include "watchconnection.h"
+
+class LegacyNotification: public PebblePacket
+{
+// class Meta:
+// endpoint = 3000
+// endianness = '<'
+public:
+ enum Source {
+ SourceEmail = 0,
+ SourceSMS = 1,
+ SourceFacebook = 2,
+ SourceTwitter = 3
+ };
+
+ LegacyNotification(Source source, const QString &sender, const QString &body, const QDateTime &timestamp, const QString &subject):
+ PebblePacket(),
+ m_source(source),
+ m_sender(sender),
+ m_body(body),
+ m_timestamp(timestamp),
+ m_subject(subject)
+ {}
+
+ QByteArray serialize() const override
+ {
+ QByteArray ret;
+ ret.append((quint8)m_source);
+ ret.append(packString(m_sender));
+ ret.append(packString(m_body));
+ ret.append(packString(QString::number(m_timestamp.toMSecsSinceEpoch())));
+ ret.append(packString(m_subject));
+ return ret;
+ }
+
+private:
+
+ Source m_source; // uint8
+ QString m_sender;
+ QString m_body;
+ QDateTime m_timestamp;
+ QString m_subject;
+};
+
+class NotificationEndpoint: public QObject
+{
+ Q_OBJECT
+public:
+ NotificationEndpoint(Pebble *pebble, WatchConnection *watchConnection);
+
+ void sendLegacyNotification(const Notification &notification);
+
+private slots:
+ void notificationReply(const QByteArray &data);
+
+private:
+ Pebble *m_pebble;
+ WatchConnection *m_watchConnection;
+};