summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/appmanager.h
blob: 4766ebc36a395954a552717d39b01385e4ec9f69 (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
77
78
79
80
#ifndef APPMANAGER_H
#define APPMANAGER_H

#include <QObject>
#include <QHash>
#include <QUuid>
#include "appinfo.h"
#include "watchconnection.h"

class Pebble;

class AppFetchResponse: public PebblePacket
{
public:
    enum Status {
        StatusStart = 0x01,
        StatusBusy = 0x02,
        StatusInvalidUUID = 0x03,
        StatusNoData = 0x04
    };
    AppFetchResponse(Status status = StatusNoData);
    void setStatus(Status status);

    QByteArray serialize() const override;

private:
    quint8 m_command = 1; // I guess there's only one command for now
    Status m_status = StatusNoData;
};

class AppManager : public QObject
{
    Q_OBJECT

public:
    enum Action {
        ActionGetAppBankStatus = 1,
        ActionRemoveApp = 2,
        ActionRefreshApp = 3,
        ActionGetAppBankUuids = 5
    };

    explicit AppManager(Pebble *pebble, WatchConnection *connection);

    QList<QUuid> appUuids() const;

    AppInfo info(const QUuid &uuid) const;

    void insertAppInfo(const AppInfo &info);

    QUuid scanApp(const QString &path);

    void removeApp(const QUuid &uuid);

    void setAppOrder(const QList<QUuid> &newList);

public slots:
    void rescan();

private slots:
    void handleAppFetchMessage(const QByteArray &data);
    void sortingReply(const QByteArray &data);

signals:
    void appsChanged();

    void uploadRequested(const QString &file, quint32 appInstallId);

    void idMismatchDetected();

private:

private:
    Pebble *m_pebble;
    WatchConnection *m_connection;
    QList<QUuid> m_appList;
    QHash<QUuid, AppInfo> m_apps;
};

#endif // APPMANAGER_H