summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/screenshotendpoint.h
blob: cca6cfdbe469c80700aebbb580b80688043f1514 (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
#ifndef SCREENSHOTENDPOINT_H
#define SCREENSHOTENDPOINT_H

#include <QObject>

#include "watchconnection.h"
class Pebble;

class ScreenshotRequestPackage: public PebblePacket
{
public:
    QByteArray serialize() const override;
private:
    quint8 m_command = 0x00;
};

class ScreenshotEndpoint : public QObject
{
    Q_OBJECT
public:
    enum ResponseCode {
        ResponseCodeOK = 0,
        ResponseCodeMalformedCommand = 1,
        ResponseCodeOutOfMemory = 2,
        ResponseCodeAlreadyInProgress = 3
    };

    explicit ScreenshotEndpoint(Pebble *pebble, WatchConnection *connection, QObject *parent = 0);

    void requestScreenshot();
    void removeScreenshot(const QString &filename);

    QStringList screenshots() const;

signals:
    void screenshotAdded(const QString &filename);
    void screenshotRemoved(const QString &filename);

private slots:
    void handleScreenshotData(const QByteArray &data);

private:
    Pebble *m_pebble;
    WatchConnection *m_connection;
    quint32 m_waitingForMore = 0;
    quint32 m_version = 0;
    quint32 m_width = 0;
    quint32 m_height = 0;
    QByteArray m_accumulatedData;
};

#endif // SCREENSHOTENDPOINT_H