diff options
| author | Javier <dev.git@javispedro.com> | 2014-12-12 23:32:46 +0100 |
|---|---|---|
| committer | Javier <dev.git@javispedro.com> | 2014-12-12 23:32:46 +0100 |
| commit | 492a861a47c5165cf62a051303d4b45e5d5630cd (patch) | |
| tree | ee78b2cb3c176a2a9f76cf7fbf805404e0f23b69 | |
| parent | 75352f8cf5a60cfd291a26fe2c93d06281055f31 (diff) | |
query all apps from d-bus
| -rw-r--r-- | daemon/appmanager.cpp | 6 | ||||
| -rw-r--r-- | daemon/appmanager.h | 4 | ||||
| -rw-r--r-- | daemon/manager.cpp | 20 | ||||
| -rw-r--r-- | daemon/manager.h | 4 | ||||
| -rw-r--r-- | org.pebbled.Watch.xml | 6 |
5 files changed, 40 insertions, 0 deletions
diff --git a/daemon/appmanager.cpp b/daemon/appmanager.cpp index 2520ba6..10f2e3e 100644 --- a/daemon/appmanager.cpp +++ b/daemon/appmanager.cpp @@ -30,6 +30,11 @@ QStringList AppManager::appPaths() const QStandardPaths::LocateDirectory); } +QList<QUuid> AppManager::appUuids() const +{ + return _apps.keys(); +} + AppInfo AppManager::info(const QUuid &uuid) const { return _apps.value(uuid); @@ -71,6 +76,7 @@ void AppManager::rescan() } logger()->debug() << "now watching" << _watcher->directories() << _watcher->files(); + emit appsChanged(); } void AppManager::scanApp(const QString &path) diff --git a/daemon/appmanager.h b/daemon/appmanager.h index 7458e19..1725c14 100644 --- a/daemon/appmanager.h +++ b/daemon/appmanager.h @@ -17,6 +17,7 @@ public: explicit AppManager(QObject *parent = 0); QStringList appPaths() const; + QList<QUuid> appUuids() const; AppInfo info(const QUuid &uuid) const; AppInfo info(const QString &shortName) const; @@ -24,6 +25,9 @@ public: public slots: void rescan(); +signals: + void appsChanged(); + private: void scanApp(const QString &path); diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 73b80e5..25908e4 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -366,6 +366,26 @@ QStringList PebbledProxy::AppSlots() const return l; } +QVariantList PebbledProxy::AllApps() const +{ + QList<QUuid> uuids = manager()->apps->appUuids(); + QVariantList l; + + foreach (const QUuid &uuid, uuids) { + const AppInfo &info = manager()->apps->info(uuid); + QVariantMap m; + m.insert("uuid", QVariant::fromValue(uuid.toString())); + m.insert("short-name", QVariant::fromValue(info.shortName())); + m.insert("long-name", QVariant::fromValue(info.longName())); + m.insert("company-name", QVariant::fromValue(info.companyName())); + m.insert("version-label", QVariant::fromValue(info.versionLabel())); + m.insert("is-watchface", QVariant::fromValue(info.isWatchface())); + l.append(QVariant::fromValue(m)); + } + + return l; +} + bool PebbledProxy::SendAppMessage(const QString &uuid, const QVariantMap &data) { Q_ASSERT(calledFromDBus()); diff --git a/daemon/manager.h b/daemon/manager.h index c191b0c..efe9b82 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -110,6 +110,7 @@ class PebbledProxy : public QObject, protected QDBusContext Q_PROPERTY(bool Connected READ Connected NOTIFY ConnectedChanged) Q_PROPERTY(QString AppUuid READ AppUuid NOTIFY AppUuidChanged) Q_PROPERTY(QStringList AppSlots READ AppSlots NOTIFY AppSlotsChanged) + Q_PROPERTY(QVariantList AllApps READ AllApps NOTIFY AllAppsChanged) inline Manager* manager() const { return static_cast<Manager*>(parent()); } inline QVariantMap pebble() const { return manager()->dbus->pebble(); } @@ -124,6 +125,8 @@ public: QStringList AppSlots() const; + QVariantList AllApps() const; + public slots: inline void Disconnect() { manager()->watch->disconnect(); } inline void Reconnect() { manager()->watch->reconnect(); } @@ -146,6 +149,7 @@ signals: void ConnectedChanged(); void AppUuidChanged(); void AppSlotsChanged(); + void AllAppsChanged(); void AppOpened(const QString &uuid); void AppClosed(const QString &uuid); }; diff --git a/org.pebbled.Watch.xml b/org.pebbled.Watch.xml index e076d6c..6336d04 100644 --- a/org.pebbled.Watch.xml +++ b/org.pebbled.Watch.xml @@ -60,5 +60,11 @@ <arg name="uuid" type="s" direction="in"/> <arg name="slot" type="i" direction="in"/> </method> + + <!-- Installed apps (not necessarily uploaded) --> + <property name="AllApps" type="aa{sv}" access="read"> + <annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantList"/> + </property> + <signal name="AllAppsChanged"/> </interface> </node> |
