summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/jskit/jskitlocalstorage.h
diff options
context:
space:
mode:
Diffstat (limited to 'rockworkd/libpebble/jskit/jskitlocalstorage.h')
-rw-r--r--rockworkd/libpebble/jskit/jskitlocalstorage.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/rockworkd/libpebble/jskit/jskitlocalstorage.h b/rockworkd/libpebble/jskit/jskitlocalstorage.h
new file mode 100644
index 0000000..9719f83
--- /dev/null
+++ b/rockworkd/libpebble/jskit/jskitlocalstorage.h
@@ -0,0 +1,40 @@
+#ifndef JSKITLOCALSTORAGE_P_H
+#define JSKITLOCALSTORAGE_P_H
+
+#include <QSettings>
+#include <QJSEngine>
+#include <QUuid>
+
+class JSKitLocalStorage : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int length READ length)
+
+public:
+ explicit JSKitLocalStorage(QJSEngine *engine, const QString &storagePath, const QUuid &uuid);
+
+ int length() const;
+
+ Q_INVOKABLE QJSValue getItem(const QJSValue &key) const;
+ Q_INVOKABLE bool setItem(const QJSValue &key, const QJSValue &value);
+ Q_INVOKABLE bool removeItem(const QJSValue &key);
+ Q_INVOKABLE void clear();
+ Q_INVOKABLE QJSValue key(int index);
+
+ Q_INVOKABLE QJSValue get(const QJSValue &proxy, const QJSValue &key) const;
+ Q_INVOKABLE bool set(const QJSValue &proxy, const QJSValue &key, const QJSValue &value);
+ Q_INVOKABLE bool has(const QJSValue &proxy, const QJSValue &key);
+ Q_INVOKABLE bool deleteProperty(const QJSValue &proxy, const QJSValue &key);
+ Q_INVOKABLE QJSValue keys(const QJSValue &proxy=0);
+ Q_INVOKABLE QJSValue enumerate();
+
+private:
+ static QString getStorageFileFor(const QString &storageDir, const QUuid &uuid);
+
+private:
+ QJSEngine *m_engine;
+ QSettings *m_storage;
+};
+
+#endif // JSKITLOCALSTORAGE_P_H