summaryrefslogtreecommitdiff
path: root/daemon/jskitobjects.h
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2015-09-21 23:58:29 +0200
committerAndrew Branson <andrew.branson@cern.ch>2015-09-21 23:58:29 +0200
commit8123900781037703d54730a6032b09745c69007f (patch)
treec72a0e446cb075ade41dd199a3d6822fa153e139 /daemon/jskitobjects.h
parente2c1fb71995cd799e83b7644140750454a3b5900 (diff)
Support JS timers
Add support for set and clear Intervals and Timeouts for Javascript apps. The QT JS engine doesn't support them natively.
Diffstat (limited to 'daemon/jskitobjects.h')
-rw-r--r--daemon/jskitobjects.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/daemon/jskitobjects.h b/daemon/jskitobjects.h
index 43e1c30..9f5308f 100644
--- a/daemon/jskitobjects.h
+++ b/daemon/jskitobjects.h
@@ -19,6 +19,12 @@ public:
Q_INVOKABLE void addEventListener(const QString &type, QJSValue function);
Q_INVOKABLE void removeEventListener(const QString &type, QJSValue function);
+ Q_INVOKABLE int setInterval(QJSValue expression, int delay);
+ Q_INVOKABLE void clearInterval(int timerId);
+
+ Q_INVOKABLE int setTimeout(QJSValue expression, int delay);
+ Q_INVOKABLE void clearTimeout(int timerId);
+
Q_INVOKABLE uint sendAppMessage(QJSValue message, QJSValue callbackForAck = QJSValue(), QJSValue callbackForNack = QJSValue());
Q_INVOKABLE void showSimpleNotificationOnPebble(const QString &title, const QString &body);
@@ -32,6 +38,9 @@ public:
void invokeCallbacks(const QString &type, const QJSValueList &args = QJSValueList());
+protected:
+ void timerEvent(QTimerEvent *event);
+
private:
QJSValue buildAckEventObject(uint transaction, const QString &message = QString()) const;
@@ -39,6 +48,8 @@ private:
AppInfo _appInfo;
JSKitManager *_mgr;
QHash<QString, QList<QJSValue>> _callbacks;
+ QHash<int, QJSValue> _intervals;
+ QHash<int, QJSValue> _timeouts;
};
class JSKitConsole : public QObject