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
|
#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 ×tamp, 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 ¬ification);
private slots:
void notificationReply(const QByteArray &data);
private:
Pebble *m_pebble;
WatchConnection *m_watchConnection;
};
|