summaryrefslogtreecommitdiff
path: root/rockworkd/libpebble/appmsgmanager.cpp
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2016-02-18 09:13:32 +0100
committerAndrew Branson <andrew.branson@cern.ch>2016-02-18 09:13:32 +0100
commitf4910b3ac84c72a7e17c99895a3b9abb0e9534fe (patch)
tree91ae8cfd80dc3d7a2adedee9cab0d407c5c23c84 /rockworkd/libpebble/appmsgmanager.cpp
parent7305ce8e080d0a6ee7505fe978a2e601b56a5ce8 (diff)
parent8f014f0915c7bdc97573f953aa9a3ae25a5f953a (diff)
Merge branch 'rockwork'
Conflicts: po/de.po po/en_GB.po po/eu.po po/fr.po po/hu.po po/it.po po/pt.po po/rockwork.mzanetti.pot po/ru.po po/template.pot rockwork/InfoPage.qml rockwork/Main.qml rockwork/NotificationsPage.qml rockworkd/rockworkd.pro version.pri
Diffstat (limited to 'rockworkd/libpebble/appmsgmanager.cpp')
-rw-r--r--rockworkd/libpebble/appmsgmanager.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/rockworkd/libpebble/appmsgmanager.cpp b/rockworkd/libpebble/appmsgmanager.cpp
index e20c8d0..350383b 100644
--- a/rockworkd/libpebble/appmsgmanager.cpp
+++ b/rockworkd/libpebble/appmsgmanager.cpp
@@ -11,10 +11,17 @@ AppMsgManager::AppMsgManager(Pebble *pebble, AppManager *apps, WatchConnection *
: QObject(pebble),
m_pebble(pebble),
apps(apps),
- m_connection(connection), _lastTransactionId(0), _timeout(new QTimer(this))
+ m_connection(connection),
+ _lastTransactionId(0),
+ m_currentUuid(QUuid()),
+ _timeout(new QTimer(this))
{
connect(m_connection, &WatchConnection::watchConnected,
this, &AppMsgManager::handleWatchConnectedChanged);
+ connect(m_connection, &WatchConnection::watchDisconnected,
+ this, &AppMsgManager::handleWatchConnectedChanged);
+ connect(m_pebble, &Pebble::pebbleConnected,
+ this, &AppMsgManager::handlePebbleConnected);
_timeout->setSingleShot(true);
_timeout->setInterval(3000);
@@ -250,7 +257,9 @@ QByteArray AppMsgManager::buildLaunchMessage(quint8 messageType, const QUuid &uu
QByteArray ba;
WatchDataWriter writer(&ba);
writer.write<quint8>(messageType);
- writer.writeUuid(uuid);
+ if (!uuid.isNull()) {
+ writer.writeUuid(uuid);
+ }
return ba;
}
@@ -282,6 +291,7 @@ void AppMsgManager::handleAppLaunchMessage(const QByteArray &data)
switch (data.at(0)) {
case LauncherActionStart:
qDebug() << "App starting in watch:" << uuid;
+ m_currentUuid = uuid;
emit appStarted(uuid);
break;
case LauncherActionStop:
@@ -317,6 +327,7 @@ void AppMsgManager::handleLauncherPushMessage(const QByteArray &data)
case LauncherActionStart:
qDebug() << "App starting in watch:" << uuid;
m_connection->writeToPebble(WatchConnection::EndpointLauncher, buildAckMessage(transaction));
+ m_currentUuid = uuid;
emit appStarted(uuid);
break;
case LauncherActionStop:
@@ -412,13 +423,22 @@ void AppMsgManager::handleAckMessage(const QByteArray &data, bool ack)
void AppMsgManager::handleWatchConnectedChanged()
{
- // If the watch is disconnected, everything breaks loose
- // TODO In the future we may want to avoid doing the following.
if (!m_connection->isConnected()) {
+ emit appStopped(m_currentUuid);
+
+ // If the watch is disconnected, everything breaks loose
+ // TODO In the future we may want to avoid doing the following.
+
abortPendingTransactions();
}
}
+void AppMsgManager::handlePebbleConnected()
+{
+ //Now that we have all the info from the pebble "relaunch" the current app
+ emit appStarted(m_currentUuid);
+}
+
void AppMsgManager::handleTimeout()
{
// Abort the first transaction