diff options
| author | Tomasz Sterna <tomek@xiaoka.com> | 2014-07-07 00:50:22 +0200 |
|---|---|---|
| committer | Tomasz Sterna <tomek@xiaoka.com> | 2014-07-09 01:57:32 +0200 |
| commit | 54a34201f993c3dc5bff0347349e1727febacf97 (patch) | |
| tree | c6c651b2d361187e2d73c2e06952d8282701c96d | |
| parent | 7283842cbed6a378d430552d327eab4a27775538 (diff) | |
Implemented org.pebbled service QML interface
| -rw-r--r-- | app/app.pro | 4 | ||||
| -rw-r--r-- | app/daemonproxy.cpp | 26 | ||||
| -rw-r--r-- | app/daemonproxy.h | 66 | ||||
| -rw-r--r-- | app/pebble.cpp | 4 | ||||
| -rw-r--r-- | app/pebbledinterface.cpp | 82 | ||||
| -rw-r--r-- | app/pebbledinterface.h | 53 |
6 files changed, 139 insertions, 96 deletions
diff --git a/app/app.pro b/app/app.pro index 5d587cd..f09a142 100644 --- a/app/app.pro +++ b/app/app.pro @@ -4,10 +4,10 @@ CONFIG += sailfishapp SOURCES += \ pebble.cpp \ - daemonproxy.cpp + pebbledinterface.cpp HEADERS += \ - daemonproxy.h + pebbledinterface.h QT += dbus QMAKE_CXXFLAGS += -std=c++0x diff --git a/app/daemonproxy.cpp b/app/daemonproxy.cpp deleted file mode 100644 index 24eedb5..0000000 --- a/app/daemonproxy.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -a daemon/dbusadaptor -p app/daemonproxy daemon/org.pebbled.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "daemonproxy.h" - -/* - * Implementation of interface class OrgPebbledInterface - */ - -OrgPebbledInterface::OrgPebbledInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -OrgPebbledInterface::~OrgPebbledInterface() -{ -} - diff --git a/app/daemonproxy.h b/app/daemonproxy.h deleted file mode 100644 index 7535b00..0000000 --- a/app/daemonproxy.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -a daemon/dbusadaptor -p app/daemonproxy daemon/org.pebbled.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef DAEMONPROXY_H_1404657374 -#define DAEMONPROXY_H_1404657374 - -#include <QtCore/QObject> -#include <QtCore/QByteArray> -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVariant> -#include <QtDBus/QtDBus> - -/* - * Proxy class for interface org.pebbled - */ -class OrgPebbledInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "org.pebbled"; } - -public: - OrgPebbledInterface(const QString &service = "org.pebbled", - const QString &path = "/", - const QDBusConnection &connection = QDBusConnection::sessionBus(), - QObject *parent = 0); - - ~OrgPebbledInterface(); - - Q_PROPERTY(QString address READ address) - inline QString address() const - { return qvariant_cast< QString >(property("address")); } - - Q_PROPERTY(bool connected READ connected) - inline bool connected() const - { return qvariant_cast< bool >(property("connected")); } - - Q_PROPERTY(QString name READ name) - inline QString name() const - { return qvariant_cast< QString >(property("name")); } - - Q_PROPERTY(QVariantMap pebble READ pebble) - inline QVariantMap pebble() const - { return qvariant_cast< QVariantMap >(property("pebble")); } - -public Q_SLOTS: // METHODS -Q_SIGNALS: // SIGNALS - void connectedChanged(); - void pebbleChanged(); -}; - -namespace org { - typedef ::OrgPebbledInterface pebbled; -} -#endif diff --git a/app/pebble.cpp b/app/pebble.cpp index 623621d..b2f4d09 100644 --- a/app/pebble.cpp +++ b/app/pebble.cpp @@ -32,12 +32,12 @@ #include <QtQuick> #include <sailfishapp.h> -#include "daemonproxy.h" +#include "pebbledinterface.h" int main(int argc, char *argv[]) { // Register Pebble daemon interface object on QML side - qmlRegisterType<org::pebbled>("org.pebbled", 0, 1, "PebbledInterface"); + qmlRegisterType<PebbledInterface>("org.pebbled", 0, 1, "PebbledInterface"); return SailfishApp::main(argc, argv); } diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp new file mode 100644 index 0000000..4b56bed --- /dev/null +++ b/app/pebbledinterface.cpp @@ -0,0 +1,82 @@ +#include "pebbledinterface.h" + +PebbledInterface::PebbledInterface(QObject *parent) : + QObject(parent), + systemd() +{ + systemd = new QDBusInterface("org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + QDBusConnection::systemBus(), this); + + pebbled = new QDBusInterface("org.pebbled", + "/", + "org.pebbled", + QDBusConnection::sessionBus(), this); + + QDBusReply<QDBusObjectPath> unit = systemd->call("LoadUnit", "pebbled.service"); + if (not unit.isValid()) { + qWarning() << unit.error().message(); + } else { + systemdUnit = unit.value().path(); + } + qDebug() << "pebbled.service unit:" << systemdUnit; +} + +bool PebbledInterface::enabled() const +{ + qDebug() << "enabled()"; + // FIXME: implement + return true; +} + +void PebbledInterface::setEnabled(bool enabled) +{ + bool doEmit = (this->enabled() != enabled); + qDebug() << "setEnabled" << this->enabled() << enabled; + // FIXME: implement + if (doEmit) emit enabledChanged(); +} + +bool PebbledInterface::active() const +{ + qDebug() << "active()"; + // FIXME: implement + return true; +} + +void PebbledInterface::setActive(bool active) +{ + bool doEmit = (this->active() != active); + qDebug() << "setActive" << this->active() << active; + // FIXME: implement + if (doEmit) emit activeChanged(); +} + +bool PebbledInterface::connected() const +{ + qDebug() << "connected()"; + // FIXME: implement + return true; +} + +QVariantMap PebbledInterface::pebble() const +{ + qDebug() << "pebble()"; + // FIXME: implement + return QVariantMap(); +} + +QString PebbledInterface::name() const +{ + qDebug() << "name()"; + // FIXME: implement + return QString("Pebble XXX"); +} + +QString PebbledInterface::address() const +{ + qDebug() << "address()"; + // FIXME: implement + return QString(""); +} diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h new file mode 100644 index 0000000..110cecc --- /dev/null +++ b/app/pebbledinterface.h @@ -0,0 +1,53 @@ +#ifndef PEBBLEDINTERFACE_H +#define PEBBLEDINTERFACE_H + +#include <QObject> +#include <QtDBus/QtDBus> + +class PebbledInterface : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + bool enabled() const; + void setEnabled(bool); + + Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) + bool active() const; + void setActive(bool); + + Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) + bool connected() const; + + Q_PROPERTY(QVariantMap pebble READ pebble NOTIFY pebbleChanged) + QVariantMap pebble() const; + + Q_PROPERTY(QString name READ name NOTIFY nameChanged) + QString name() const; + + Q_PROPERTY(QString address READ address NOTIFY addressChanged) + QString address() const; + + +public: + explicit PebbledInterface(QObject *parent = 0); + +signals: + void enabledChanged(); + void activeChanged(); + + void connectedChanged(); + void pebbleChanged(); + void nameChanged(); + void addressChanged(); + +public slots: + +private: + QDBusInterface *systemd; + QString systemdUnit; + + QDBusInterface *pebbled; +}; + +#endif // PEBBLEDINTERFACE_H |
