blob: 4ce58bfaaa6b6ee72ee22b3e2ef182308915882b (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#ifndef WATCHLOGENDPOINT_H
#define WATCHLOGENDPOINT_H
#include <QObject>
#include <QDateTime>
#include "watchconnection.h"
class Pebble;
class LogMessage: public PebblePacket
{
public:
LogMessage(const QByteArray &data);
quint32 cookie() const { return m_cookie; }
QDateTime timestamp() const { return m_timestamp; }
QChar level() const { return m_level; }
quint8 length() const { return m_length; }
quint16 line() const { return m_line; }
QString filename() const { return m_filename; }
QString message() const { return m_message; }
QByteArray serialize() const override { return QByteArray(); }
private:
quint32 m_cookie;
QDateTime m_timestamp;
QChar m_level;
quint8 m_length;
quint16 m_line;
QString m_filename;
QString m_message;
};
class WatchLogEndpoint : public QObject
{
Q_OBJECT
public:
enum LogCommand {
LogCommandRequestLogs = 0x10,
LogCommandLogMessage = 0x80,
LogCommandLogMessageDone = 0x81,
LogCommandNoLogMessages = 0x82
};
explicit WatchLogEndpoint(Pebble *pebble, WatchConnection *connection);
void fetchLogs(const QString &fileName);
signals:
void logsFetched(bool success);
private slots:
void fetchForEpoch(quint8 epoch);
void logMessageReceived(const QByteArray &data);
private:
Pebble *m_pebble;
WatchConnection *m_connection;
quint8 m_currentEpoch = 0;
QFile m_currentFile;
QString m_targetArchive;
};
class RequestLogPacket: public PebblePacket
{
public:
RequestLogPacket(WatchLogEndpoint::LogCommand command, quint8 generation, quint32 cookie);
QByteArray serialize() const;
private:
WatchLogEndpoint::LogCommand m_command;
quint8 m_generation;
quint32 m_cookie;
};
#endif // WATCHLOGENDPOINT_H
|