summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPhilipp Andreas <github@smurfy.de>2014-07-12 09:29:47 +0200
committerPhilipp Andreas <github@smurfy.de>2014-07-12 09:30:49 +0200
commit2101baf2911d7965c86e5308e4d8350790a6956c (patch)
tree2acb875cabca055797620458baad26d5f8612105 /app
parent959e251f2336e21d3615b1525a38773fe58ab2e7 (diff)
parent84e775d768f0675ee733132b3762db647f1409ac (diff)
Merge branch 'master' into notifications
Conflicts: daemon/manager.cpp
Diffstat (limited to 'app')
-rw-r--r--app/app.pro6
-rw-r--r--app/pebbledinterface.cpp62
-rw-r--r--app/pebbledinterface.h6
-rw-r--r--app/qml/cover/CoverPage.qml1
-rw-r--r--app/qml/pages/ManagerPage.qml2
5 files changed, 42 insertions, 35 deletions
diff --git a/app/app.pro b/app/app.pro
index 40a4a1d..48aff06 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -2,6 +2,9 @@ TARGET = pebble
CONFIG += sailfishapp
+QT += dbus
+QMAKE_CXXFLAGS += -std=c++0x
+
SOURCES += \
pebble.cpp \
pebbledinterface.cpp
@@ -9,9 +12,6 @@ SOURCES += \
HEADERS += \
pebbledinterface.h
-QT += dbus
-QMAKE_CXXFLAGS += -std=c++0x
-
OTHER_FILES += \
qml/cover/CoverPage.qml \
qml/pages/ManagerPage.qml \
diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp
index 390964a..1bd9b50 100644
--- a/app/pebbledinterface.cpp
+++ b/app/pebbledinterface.cpp
@@ -1,25 +1,28 @@
#include "pebbledinterface.h"
QString PebbledInterface::PEBBLED_SYSTEMD_UNIT("pebbled.service");
-QString PebbledInterface::SYSTEMD_UNIT_IFACE("org.freedesktop.systemd1.Unit");
+QString PebbledInterface::PEBBLED_DBUS_SERVICE("org.pebbled");
+QString PebbledInterface::PEBBLED_DBUS_PATH("/");
+QString PebbledInterface::PEBBLED_DBUS_IFACE("org.pebbled");
PebbledInterface::PebbledInterface(QObject *parent) :
- QObject(parent), pebbled(0), systemd(0), unitprops(0)
+ QObject(parent), pebbled(0), systemd(0)
{
- pebbled = new QDBusInterface("org.pebbled",
- "/",
- "org.pebbled",
- QDBusConnection::sessionBus(), this);
- pebbled->connection()
- .connect(pebbled->service(), pebbled->path(), pebbled->interface(),
- "connectedChanged", this, SIGNAL(connectedChanged()));
- pebbled->connection()
- .connect(pebbled->service(), pebbled->path(), pebbled->interface(),
- "pebbleChanged", this, SLOT(onPebbleChanged()));
+ QDBusConnection::sessionBus().connect(
+ PEBBLED_DBUS_SERVICE, PEBBLED_DBUS_PATH, PEBBLED_DBUS_IFACE,
+ "connectedChanged", this, SIGNAL(connectedChanged()));
+
+ QDBusConnection::sessionBus().connect(
+ PEBBLED_DBUS_SERVICE, PEBBLED_DBUS_PATH, PEBBLED_DBUS_IFACE,
+ "pebbleChanged", this, SLOT(onPebbleChanged()));
// simulate connected change on active changed
- connect(this, SIGNAL(activeChanged()), this, SIGNAL(connectedChanged()));
+ // as the daemon might not had a chance to send connectedChanged()
+ 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",
@@ -29,29 +32,30 @@ PebbledInterface::PebbledInterface(QObject *parent) :
systemd->call("Subscribe");
QDBusReply<QDBusObjectPath> unit = systemd->call("LoadUnit", PEBBLED_SYSTEMD_UNIT);
- if (not unit.isValid()) {
- qWarning() << unit.error().message();
- } else {
- unitprops = new QDBusInterface("org.freedesktop.systemd1",
- unit.value().path(),
- "org.freedesktop.DBus.Properties",
- QDBusConnection::sessionBus(), this);
+ if (unit.isValid()) {
+ unitPath = unit.value();
+
getUnitProperties();
- unitprops->connection()
- .connect("org.freedesktop.systemd1",
- unitprops->path(),
- "org.freedesktop.DBus.Properties",
- "PropertiesChanged",
- this,
- SLOT(onPropertiesChanged(QString,QMap<QString,QVariant>,QStringList))
- );
+ QDBusConnection::sessionBus().connect(
+ "org.freedesktop.systemd1",
+ unitPath.path(),
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ this,
+ SLOT(onPropertiesChanged(QString,QMap<QString,QVariant>,QStringList)));
+ } else {
+ qWarning() << unit.error().message();
}
}
void PebbledInterface::getUnitProperties()
{
- QDBusReply<QVariantMap> reply = unitprops->call("GetAll", SYSTEMD_UNIT_IFACE);
+ QDBusMessage request = QDBusMessage::createMethodCall(
+ "org.freedesktop.systemd1", unitPath.path(),
+ "org.freedesktop.DBus.Properties", "GetAll");
+ request << "org.freedesktop.systemd1.Unit";
+ QDBusReply<QVariantMap> reply = QDBusConnection::sessionBus().call(request);
if (reply.isValid()) {
QVariantMap newProperties = reply.value();
bool emitEnabledChanged = (properties["UnitFileState"] != newProperties["UnitFileState"]);
diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h
index eccc766..df9cd3d 100644
--- a/app/pebbledinterface.h
+++ b/app/pebbledinterface.h
@@ -10,7 +10,9 @@ class PebbledInterface : public QObject
Q_OBJECT
static QString PEBBLED_SYSTEMD_UNIT;
- static QString SYSTEMD_UNIT_IFACE;
+ static QString PEBBLED_DBUS_SERVICE;
+ static QString PEBBLED_DBUS_PATH;
+ static QString PEBBLED_DBUS_IFACE;
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
bool enabled() const;
@@ -58,7 +60,7 @@ private slots:
private:
QDBusInterface *pebbled;
QDBusInterface *systemd;
- QDBusInterface *unitprops;
+ QDBusObjectPath unitPath;
QVariantMap properties;
};
diff --git a/app/qml/cover/CoverPage.qml b/app/qml/cover/CoverPage.qml
index 767799e..186de30 100644
--- a/app/qml/cover/CoverPage.qml
+++ b/app/qml/cover/CoverPage.qml
@@ -58,6 +58,7 @@ CoverBackground {
CoverActionList {
id: coverAction
+ enabled: pebbled.active
CoverAction {
iconSource: pebbled.connected ? "image://theme/icon-cover-transfers" : "image://theme/icon-cover-sync"
diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml
index adb1cf4..92d79b1 100644
--- a/app/qml/pages/ManagerPage.qml
+++ b/app/qml/pages/ManagerPage.qml
@@ -107,7 +107,7 @@ Page {
if (pebbled.connected) {
pebbled.disconnect();
} else {
- pebbled.connect();
+ pebbled.reconnect();
}
}
}