summaryrefslogtreecommitdiff
path: root/daemon/jskitobjects.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-12-04 01:21:32 +0100
committerJavier <dev.git@javispedro.com>2014-12-04 01:21:32 +0100
commit8722bee52922f8c6707103795fdf69f9ed7d0240 (patch)
treed8da8ea953f606abd05a87f6910104e6c7a848b1 /daemon/jskitobjects.h
parent1b920c3c0593f6810dd900c882e4760cbbbeeb56 (diff)
add stub geolocation API
Diffstat (limited to 'daemon/jskitobjects.h')
-rw-r--r--daemon/jskitobjects.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/daemon/jskitobjects.h b/daemon/jskitobjects.h
index 849529f..9c9b84e 100644
--- a/daemon/jskitobjects.h
+++ b/daemon/jskitobjects.h
@@ -4,6 +4,7 @@
#include <QSettings>
#include <QNetworkRequest>
#include <QNetworkReply>
+#include <QGeoPositionInfoSource>
#include "jskitmanager.h"
class JSKitPebble : public QObject
@@ -134,4 +135,46 @@ private:
QJSValue _onerror;
};
+class JSKitGeolocation : public QObject
+{
+ Q_OBJECT
+ LOG4QT_DECLARE_QCLASS_LOGGER
+
+ struct Watcher;
+
+public:
+ explicit JSKitGeolocation(JSKitManager *mgr);
+
+ Q_INVOKABLE void getCurrentPosition(const QJSValue &successCallback, const QJSValue &errorCallback = QJSValue(), const QVariantMap &options = QVariantMap());
+ Q_INVOKABLE int watchPosition(const QJSValue &successCallback, const QJSValue &errorCallback = QJSValue(), const QVariantMap &options = QVariantMap());
+ Q_INVOKABLE void clearWatch(int watchId);
+
+private slots:
+ void handleError(const QGeoPositionInfoSource::Error error);
+ void handlePosition(const QGeoPositionInfo &pos);
+ void handleTimeout();
+
+private:
+ int setupWatcher(const QJSValue &successCallback, const QJSValue &errorCallback, const QVariantMap &options, bool once);
+ void invokeSuccessCallback(Watcher &watcher, const QGeoPositionInfo &pos);
+ void invokeErrorCallback(Watcher &watcher);
+
+private:
+ JSKitManager *_mgr;
+ QGeoPositionInfoSource *_source;
+
+ struct Watcher {
+ QJSValue successCallback;
+ QJSValue errorCallback;
+ int watchId;
+ bool once;
+ bool highAccuracy;
+ uint timeout;
+ uint maximumAge;
+ };
+
+ QList<Watcher> _watches;
+ int _lastWatchId;
+};
+
#endif // JSKITMANAGER_P_H