summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/jskit/jskitmanager.h
blob: 570948e7803dc5a729a099349f5385bffe009624 (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
#ifndef JSKITMANAGER_H
#define JSKITMANAGER_H

#include <QJSEngine>
#include <QPointer>
#include <QLoggingCategory>

#include "../appmanager.h"
#include "../watchconnection.h"
#include "../pebble.h"
#include "../appmsgmanager.h"

#include "jskitconsole.h"
#include "jskitgeolocation.h"
#include "jskitlocalstorage.h"
#include "jskittimer.h"
#include "jskitperformance.h"

class JSKitPebble;

class JSKitManager : public QObject
{
    Q_OBJECT
    QLoggingCategory l;

public:
    explicit JSKitManager(Pebble *pebble, WatchConnection *connection, AppManager *apps, AppMsgManager *appmsg, QObject *parent = 0);
    ~JSKitManager();

    QJSEngine * engine();
    bool isJSKitAppRunning() const;

    static QString describeError(QJSValue error);

    void showConfiguration();
    void handleWebviewClosed(const QString &result);
    void setConfigurationId(const QUuid &uuid);
    AppInfo currentApp();

signals:
    void appNotification(const QUuid &uuid, const QString &title, const QString &body);
    void openURL(const QString &uuid, const QString &url);

private slots:
    void handleAppStarted(const QUuid &uuid);
    void handleAppStopped(const QUuid &uuid);
    void handleAppMessage(const QUuid &uuid, const QVariantMap &msg);

private:
    bool loadJsFile(const QString &filename);
    void startJsApp();
    void stopJsApp();

private:
    friend class JSKitPebble;

    Pebble *m_pebble;
    WatchConnection *m_connection;
    AppManager *m_apps;
    AppMsgManager *m_appmsg;
    AppInfo m_curApp;
    QJSEngine *m_engine;
    QPointer<JSKitPebble> m_jspebble;
    QPointer<JSKitConsole> m_jsconsole;
    QPointer<JSKitLocalStorage> m_jsstorage;
    QPointer<JSKitGeolocation> m_jsgeo;
    QPointer<JSKitTimer> m_jstimer;
    QPointer<JSKitPerformance> m_jsperformance;
    QUuid m_configurationUuid;
};

#endif // JSKITMANAGER_H