summaryrefslogtreecommitdiff
path: root/daemon/jskitmanager.h
blob: 7ffc0ad3403436afc3a54c10ff483a277bb56358 (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
#ifndef JSKITMANAGER_H
#define JSKITMANAGER_H

#include <QJSEngine>
#include "appmanager.h"
#include "appmsgmanager.h"

class JSKitPebble;
class JSKitConsole;
class JSKitLocalStorage;
class JSKitGeolocation;

class JSKitManager : public QObject
{
    Q_OBJECT
    LOG4QT_DECLARE_QCLASS_LOGGER

public:
    explicit JSKitManager(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);

signals:
    void appNotification(const QUuid &uuid, const QString &title, const QString &body);
    void appOpenUrl(const QUrl &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;

    AppManager *_apps;
    AppMsgManager *_appmsg;
    AppInfo _curApp;
    QJSEngine *_engine;
    QPointer<JSKitPebble> _jspebble;
    QPointer<JSKitConsole> _jsconsole;
    QPointer<JSKitLocalStorage> _jsstorage;
    QPointer<JSKitGeolocation> _jsgeo;
};

#endif // JSKITMANAGER_H