From 9987eba0373015a9f50b90d5d4f67a200cd03802 Mon Sep 17 00:00:00 2001 From: Jens Drescher Date: Tue, 21 Nov 2017 09:44:00 +0100 Subject: [PATCH] Added a signal to DBus interface which is fired if a button is pressed within a watch app. --- rockworkd/dbusinterface.cpp | 1 + rockworkd/dbusinterface.h | 2 ++ rockworkd/libpebble/appmsgmanager.cpp | 1 + rockworkd/libpebble/appmsgmanager.h | 1 + rockworkd/libpebble/pebble.cpp | 6 ++++++ rockworkd/libpebble/pebble.h | 4 ++++ 6 files changed, 15 insertions(+) diff --git a/rockworkd/dbusinterface.cpp b/rockworkd/dbusinterface.cpp index f632bae..de1f8ae 100644 --- a/rockworkd/dbusinterface.cpp +++ b/rockworkd/dbusinterface.cpp @@ -30,6 +30,7 @@ DBusPebble::DBusPebble(Pebble *pebble, QObject *parent): connect(pebble, &Pebble::voiceSessionStream, this, &DBusPebble::voiceSessionStream); connect(pebble, &Pebble::voiceSessionDumped, this, &DBusPebble::voiceSessionDumped); connect(pebble, &Pebble::voiceSessionClosed, this, &DBusPebble::voiceSessionClosed); + connect(pebble, &Pebble::appButtonPressed, this, &DBusPebble::AppButtonPressed); } QString DBusPebble::Address() const diff --git a/rockworkd/dbusinterface.h b/rockworkd/dbusinterface.h index 2b417b1..d999d72 100644 --- a/rockworkd/dbusinterface.h +++ b/rockworkd/dbusinterface.h @@ -47,6 +47,8 @@ class DBusPebble: public QObject void voiceSessionDumped(const QString &dumpFile); void voiceSessionClosed(const QString &dumpFIle); + void AppButtonPressed(const QString &uuid, const int &key); + public slots: QString Address() const; QString Name() const; diff --git a/rockworkd/libpebble/appmsgmanager.cpp b/rockworkd/libpebble/appmsgmanager.cpp index e4d639e..8503b0a 100644 --- a/rockworkd/libpebble/appmsgmanager.cpp +++ b/rockworkd/libpebble/appmsgmanager.cpp @@ -201,6 +201,7 @@ QVariantMap AppMsgManager::mapAppKeys(const QUuid &uuid, const WatchConnection:: data.insert(info.appKeys().key(it.key()), it.value()); } else { qWarning() << "Unknown appKey value" << it.key() << "for app with GUID" << uuid; + emit appButtonPressed(uuid.toString(), it.key()); data.insert(QString::number(it.key()), it.value()); } } diff --git a/rockworkd/libpebble/appmsgmanager.h b/rockworkd/libpebble/appmsgmanager.h index 5d28609..bf5f98f 100644 --- a/rockworkd/libpebble/appmsgmanager.h +++ b/rockworkd/libpebble/appmsgmanager.h @@ -45,6 +45,7 @@ public slots: signals: void appStarted(const QUuid &uuid); void appStopped(const QUuid &uuid); + void appButtonPressed(const QString &uuid, const int &key); private: WatchConnection::Dict mapAppKeys(const QUuid &uuid, const QVariantMap &data); diff --git a/rockworkd/libpebble/pebble.cpp b/rockworkd/libpebble/pebble.cpp index ce67c85..65a8020 100644 --- a/rockworkd/libpebble/pebble.cpp +++ b/rockworkd/libpebble/pebble.cpp @@ -99,6 +99,7 @@ Pebble::Pebble(const QBluetoothAddress &address, QObject *parent): QObject::connect(m_jskitManager, &JSKitManager::openURL, this, &Pebble::openURL); QObject::connect(m_jskitManager, &JSKitManager::appNotification, this, &Pebble::insertPin); QObject::connect(m_appMsgManager, &AppMsgManager::appStarted, this, &Pebble::appStarted); + QObject::connect(m_appMsgManager, &AppMsgManager::appButtonPressed, this, &Pebble::onAppButtonPressed); m_weatherApp = new WeatherApp(this, getWeatherLocations()); QObject::connect(m_weatherApp, &WeatherApp::locationsChanged, this, &Pebble::saveWeatherLocations); @@ -1512,6 +1513,11 @@ void Pebble::appStarted(const QUuid &uuid) } } +void Pebble::onAppButtonPressed(const QString &uuid, const int &key) +{ + emit appButtonPressed(uuid, key); +} + void Pebble::muteNotificationSource(const QString &source) { qDebug() << "Request to mute" << source; diff --git a/rockworkd/libpebble/pebble.h b/rockworkd/libpebble/pebble.h index b162b4e..97cb8ac 100644 --- a/rockworkd/libpebble/pebble.h +++ b/rockworkd/libpebble/pebble.h @@ -211,6 +211,8 @@ private slots: void slotUpdateAvailableChanged(); + void onAppButtonPressed(const QString &uuid, const int &key); + signals: void pebbleConnected(); void pebbleDisconnected(); @@ -239,6 +241,8 @@ private slots: void devConServerStateChanged(bool state); void devConCloudStateChanged(bool state); void oauthTokenChanged(const QString &token); + + void appButtonPressed(const QString &uuid, const int &key); private: void setHardwareRevision(HardwareRevision hardwareRevision);