summaryrefslogtreecommitdiff
path: root/daemon/manager.cpp
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2014-06-30 01:59:14 +0200
committerTomasz Sterna <tomek@xiaoka.com>2014-06-30 01:59:14 +0200
commit3c52767b24f27ac166f9c68e2fc73811527bafe1 (patch)
treed4a4050de526967ac4c3407f643b51d616cc31fe /daemon/manager.cpp
parent1d5e1b8dbb04d1ba916ff90445d22e0a145fd041 (diff)
Reworked WatchConnector connection/disconnection handling
Fixed crash after Pebble disconnecting
Diffstat (limited to 'daemon/manager.cpp')
-rw-r--r--daemon/manager.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index 5e09c75..691d7a5 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -5,7 +5,8 @@
#include <QtContacts/QContactPhoneNumber>
Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice) :
- QObject(0), watch(watch), dbus(dbus), voice(voice)
+ QObject(0), watch(watch), dbus(dbus), voice(voice),
+ notification(MNotification::DeviceEvent)
{
// We don't need to handle presence changes, so report them separately and ignore them
QMap<QString, QString> parameters;
@@ -26,10 +27,23 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
// Watch instantiated hangup, follow the orders
connect(watch, SIGNAL(hangup()), SLOT(hangupAll()));
+ connect(watch, SIGNAL(connectedChanged()), SLOT(onConnectedChanged()));
if (btDevice.isValid()) {
qDebug() << "BT local name:" << btDevice.name();
- watch->deviceConnect(dbus->pebbleName, dbus->pebbleAddress);
+ connect(dbus, SIGNAL(pebbleChanged()), SLOT(onPebbleChanged()));
+ dbus->findPebble();
+ }
+}
+
+void Manager::onPebbleChanged()
+{
+ const QVariantMap & pebble = dbus->pebble();
+ QString name = pebble["Name"].toString();
+ if (name.isEmpty()) {
+ qDebug() << "Pebble gone";
+ } else {
+ watch->deviceConnect(name, pebble["Address"].toString());
}
}