summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/pebbledinterface.cpp64
-rw-r--r--app/pebbledinterface.h1
-rw-r--r--daemon/daemon.cpp1
-rw-r--r--daemon/manager.cpp19
4 files changed, 43 insertions, 42 deletions
diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp
index a46cf45..05ca614 100644
--- a/app/pebbledinterface.cpp
+++ b/app/pebbledinterface.cpp
@@ -5,9 +5,11 @@ QString PebbledInterface::PEBBLED_DBUS_SERVICE("org.pebbled");
QString PebbledInterface::PEBBLED_DBUS_PATH("/");
QString PebbledInterface::PEBBLED_DBUS_IFACE("org.pebbled");
+#define PebbledDbusInterface QDBusInterface(PEBBLED_DBUS_SERVICE, PEBBLED_DBUS_PATH, PEBBLED_DBUS_IFACE)
+
PebbledInterface::PebbledInterface(QObject *parent) :
- QObject(parent), pebbled(0), systemd(0)
+ QObject(parent), systemd(0)
{
QDBusConnection::sessionBus().connect(
PEBBLED_DBUS_SERVICE, PEBBLED_DBUS_PATH, PEBBLED_DBUS_IFACE,
@@ -18,12 +20,10 @@ PebbledInterface::PebbledInterface(QObject *parent) :
"pebbleChanged", this, SLOT(onPebbleChanged()));
// simulate connected change on active changed
- // as the daemon might not had a chance to send connectedChanged()
+ // as the daemon might not had a chance to send 'connectedChanged'
+ // when going down
connect(this, SIGNAL(activeChanged()), SIGNAL(connectedChanged()));
- pebbled = new QDBusInterface(PEBBLED_DBUS_SERVICE, PEBBLED_DBUS_PATH, PEBBLED_DBUS_IFACE,
- QDBusConnection::sessionBus(), this);
-
systemd = new QDBusInterface("org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
@@ -83,83 +83,83 @@ void PebbledInterface::onPebbleChanged()
bool PebbledInterface::enabled() const
{
- qDebug() << "enabled()";
+ qDebug() << __FUNCTION__;
return properties["UnitFileState"].toString() == "enabled";
}
void PebbledInterface::setEnabled(bool enabled)
{
- if (systemd) {
- qDebug() << "setEnabled" << enabled;
- QDBusError reply;
- if (enabled) systemd->call("EnableUnitFiles", QStringList() << PEBBLED_SYSTEMD_UNIT, false, true);
- else systemd->call("DisableUnitFiles", QStringList() << PEBBLED_SYSTEMD_UNIT, false);
- if (reply.isValid()) {
- qWarning() << reply.message();
- } else {
- systemd->call("Reload");
- getUnitProperties();
- }
+ qDebug() << "setEnabled" << enabled;
+ QDBusError reply;
+ if (enabled) systemd->call("EnableUnitFiles", QStringList() << PEBBLED_SYSTEMD_UNIT, false, true);
+ else systemd->call("DisableUnitFiles", QStringList() << PEBBLED_SYSTEMD_UNIT, false);
+ if (reply.isValid()) {
+ qWarning() << reply.message();
+ } else {
+ systemd->call("Reload");
+ getUnitProperties();
}
}
bool PebbledInterface::active() const
{
- qDebug() << "active()";
+ qDebug() << __FUNCTION__;
return properties["ActiveState"].toString() == "active";
}
void PebbledInterface::setActive(bool active)
{
- if (systemd) {
- qDebug() << "setActive" << active;
- QDBusReply<QDBusObjectPath> reply = systemd->call(active?"StartUnit":"StopUnit", PEBBLED_SYSTEMD_UNIT, "replace");
- if (!reply.isValid()) {
- qWarning() << reply.error().message();
- }
+ qDebug() << "setActive" << active;
+ QDBusReply<QDBusObjectPath> reply = systemd->call(active?"StartUnit":"StopUnit", PEBBLED_SYSTEMD_UNIT, "replace");
+ if (!reply.isValid()) {
+ qWarning() << reply.error().message();
}
}
bool PebbledInterface::connected() const
{
qDebug() << __FUNCTION__;
- return pebbled->property(__FUNCTION__).toBool();
+ return PebbledDbusInterface.property(__FUNCTION__).toBool();
}
QVariantMap PebbledInterface::pebble() const
{
qDebug() << __FUNCTION__;
- return pebbled->property(__FUNCTION__).toMap();
+ return PebbledDbusInterface.property(__FUNCTION__).toMap();
}
QString PebbledInterface::name() const
{
qDebug() << __FUNCTION__;
- return pebbled->property(__FUNCTION__).toString();
+ return PebbledDbusInterface.property(__FUNCTION__).toString();
}
QString PebbledInterface::address() const
{
qDebug() << __FUNCTION__;
- return pebbled->property(__FUNCTION__).toString();
+ return PebbledDbusInterface.property(__FUNCTION__).toString();
}
void PebbledInterface::ping()
{
- pebbled->call("ping", 66);
+ qDebug() << __FUNCTION__;
+ PebbledDbusInterface.call("ping", 66);
}
void PebbledInterface::time()
{
- pebbled->call("time");
+ qDebug() << __FUNCTION__;
+ PebbledDbusInterface.call("time");
}
void PebbledInterface::disconnect()
{
- pebbled->call("disconnect");
+ qDebug() << __FUNCTION__;
+ PebbledDbusInterface.call("disconnect");
}
void PebbledInterface::reconnect()
{
- pebbled->call("reconnect");
+ qDebug() << __FUNCTION__;
+ PebbledDbusInterface.call("reconnect");
}
diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h
index cf87425..0a6f15d 100644
--- a/app/pebbledinterface.h
+++ b/app/pebbledinterface.h
@@ -59,7 +59,6 @@ private slots:
void onPebbleChanged();
private:
- QDBusInterface *pebbled;
QDBusInterface *systemd;
QDBusObjectPath unitPath;
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp
index 584710a..9d89980 100644
--- a/daemon/daemon.cpp
+++ b/daemon/daemon.cpp
@@ -87,6 +87,7 @@ int main(int argc, char *argv[])
signal(SIGINT, signalhandler);
signal(SIGTERM, signalhandler);
QObject::connect(&app, SIGNAL(aboutToQuit()), &watch, SLOT(endPhoneCall()));
+ QObject::connect(&app, SIGNAL(aboutToQuit()), &watch, SLOT(disconnect()));
return app.exec();
}
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index fd31e3d..b01006c 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -35,15 +35,6 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
connect(watch, SIGNAL(messageDecoded(uint,QByteArray)), commands, SLOT(processMessage(uint,QByteArray)));
connect(commands, SIGNAL(hangup()), SLOT(hangupAll()));
- // Set BT icon for notification
- notification.setImage("icon-system-bluetooth-device");
-
- if (btDevice.isValid()) {
- logger()->debug() << "BT local name:" << btDevice.name();
- connect(dbus, SIGNAL(pebbleChanged()), SLOT(onPebbleChanged()));
- dbus->findPebble();
- }
-
PebbledProxy *proxy = new PebbledProxy(this);
PebbledAdaptor *adaptor = new PebbledAdaptor(proxy);
QDBusConnection session = QDBusConnection::sessionBus();
@@ -62,6 +53,16 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
this, SLOT(onMprisPropertiesChanged(QString,QMap<QString,QVariant>,QStringList)));
connect(this, SIGNAL(mprisMetadataChanged(QVariantMap)), commands, SLOT(onMprisMetadataChanged(QVariantMap)));
+
+ // Set BT icon for notification
+ notification.setImage("icon-system-bluetooth-device");
+
+ if (btDevice.isValid()) {
+ logger()->debug() << "BT local name:" << btDevice.name();
+ connect(dbus, SIGNAL(pebbleChanged()), SLOT(onPebbleChanged()));
+ dbus->findPebble();
+ }
+
}
void Manager::onSettingChanged(const QString &key)