diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2016-02-11 23:55:16 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2016-02-11 23:55:16 +0100 |
| commit | 29aaea2d80a9eb1715b6cddfac2d2aacf76358bd (patch) | |
| tree | 012795b6bec16c72f38d33cff46324c9a0225868 /rockworkd/libpebble/watchlogendpoint.h | |
launchpad ~mzanetti/rockwork/trunk r87
Diffstat (limited to 'rockworkd/libpebble/watchlogendpoint.h')
| -rw-r--r-- | rockworkd/libpebble/watchlogendpoint.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/rockworkd/libpebble/watchlogendpoint.h b/rockworkd/libpebble/watchlogendpoint.h new file mode 100644 index 0000000..4ce58bf --- /dev/null +++ b/rockworkd/libpebble/watchlogendpoint.h @@ -0,0 +1,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 |
