diff options
| author | Tomasz Sterna <tomek@xiaoka.com> | 2014-07-06 17:22:25 +0200 |
|---|---|---|
| committer | Tomasz Sterna <tomek@xiaoka.com> | 2014-07-09 01:57:32 +0200 |
| commit | 7283842cbed6a378d430552d327eab4a27775538 (patch) | |
| tree | 708f4a2b4e702ddcc07bef8e6fdcd8f8a32a23ef | |
| parent | d3d54722d8532bd649db6792126c0a990712e26c (diff) | |
Moved watchConnector to daemon and implemented daemon interface for QML
| -rw-r--r-- | app/app.pro | 9 | ||||
| -rw-r--r-- | app/daemonproxy.cpp | 26 | ||||
| -rw-r--r-- | app/daemonproxy.h | 66 | ||||
| -rw-r--r-- | app/pebble.cpp | 8 | ||||
| -rw-r--r-- | daemon/daemon.pro | 9 | ||||
| -rw-r--r-- | daemon/dbusadaptor.cpp | 16 | ||||
| -rw-r--r-- | daemon/dbusadaptor.h | 12 | ||||
| -rw-r--r-- | daemon/manager.cpp | 4 | ||||
| -rw-r--r-- | daemon/manager.h | 6 | ||||
| -rw-r--r-- | daemon/watchconnector.cpp (renamed from lib/watchconnector.cpp) | 0 | ||||
| -rw-r--r-- | daemon/watchconnector.h (renamed from lib/watchconnector.h) | 0 | ||||
| -rw-r--r-- | lib/lib.pro | 14 | ||||
| -rw-r--r-- | pebble.pro | 2 |
13 files changed, 124 insertions, 48 deletions
diff --git a/app/app.pro b/app/app.pro index c9156f0..5d587cd 100644 --- a/app/app.pro +++ b/app/app.pro @@ -3,12 +3,13 @@ TARGET = pebble CONFIG += sailfishapp SOURCES += \ - pebble.cpp + pebble.cpp \ + daemonproxy.cpp -INCLUDEPATH += ../lib -LIBS += -L$$OUT_PWD/../lib -lpebble +HEADERS += \ + daemonproxy.h -QT += bluetooth +QT += dbus QMAKE_CXXFLAGS += -std=c++0x OTHER_FILES += \ diff --git a/app/daemonproxy.cpp b/app/daemonproxy.cpp new file mode 100644 index 0000000..24eedb5 --- /dev/null +++ b/app/daemonproxy.cpp @@ -0,0 +1,26 @@ +/* + * 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 new file mode 100644 index 0000000..7535b00 --- /dev/null +++ b/app/daemonproxy.h @@ -0,0 +1,66 @@ +/* + * 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 46e6298..623621d 100644 --- a/app/pebble.cpp +++ b/app/pebble.cpp @@ -32,14 +32,12 @@ #include <QtQuick> #include <sailfishapp.h> -#include "watchconnector.h" - -using namespace watch; +#include "daemonproxy.h" int main(int argc, char *argv[]) { - // Registert WatchController object on QML side - qmlRegisterType<WatchConnector>("watch", 0, 1, "WatchConnector"); + // Register Pebble daemon interface object on QML side + qmlRegisterType<org::pebbled>("org.pebbled", 0, 1, "PebbledInterface"); return SailfishApp::main(argc, argv); } diff --git a/daemon/daemon.pro b/daemon/daemon.pro index c4b6a76..deadea0 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -5,25 +5,24 @@ CONFIG -= app_bundle CONFIG += link_pkgconfig QT -= gui -INCLUDEPATH += ../lib -LIBS += -L$$OUT_PWD/../lib -lpebble - QT += bluetooth dbus contacts PKGCONFIG += commhistory-qt5 mlite5 QMAKE_CXXFLAGS += -std=c++0x SOURCES += \ daemon.cpp \ + manager.cpp \ voicecallmanager.cpp \ voicecallhandler.cpp \ - manager.cpp \ + watchconnector.cpp \ dbusconnector.cpp \ dbusadaptor.cpp HEADERS += \ + manager.h \ voicecallmanager.h \ voicecallhandler.h \ - manager.h \ + watchconnector.h \ dbusconnector.h \ dbusadaptor.h diff --git a/daemon/dbusadaptor.cpp b/daemon/dbusadaptor.cpp index 914f9f2..6460dca 100644 --- a/daemon/dbusadaptor.cpp +++ b/daemon/dbusadaptor.cpp @@ -1,6 +1,6 @@ /* * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DBusAdaptor -a dbusadaptor org.pebbled.xml + * 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). * @@ -18,40 +18,40 @@ #include <QtCore/QVariant> /* - * Implementation of adaptor class DBusAdaptor + * Implementation of adaptor class PebbledAdaptor */ -DBusAdaptor::DBusAdaptor(QObject *parent) +PebbledAdaptor::PebbledAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) { // constructor setAutoRelaySignals(true); } -DBusAdaptor::~DBusAdaptor() +PebbledAdaptor::~PebbledAdaptor() { // destructor } -QString DBusAdaptor::address() const +QString PebbledAdaptor::address() const { // get the value of property address return qvariant_cast< QString >(parent()->property("address")); } -bool DBusAdaptor::connected() const +bool PebbledAdaptor::connected() const { // get the value of property connected return qvariant_cast< bool >(parent()->property("connected")); } -QString DBusAdaptor::name() const +QString PebbledAdaptor::name() const { // get the value of property name return qvariant_cast< QString >(parent()->property("name")); } -QVariantMap DBusAdaptor::pebble() const +QVariantMap PebbledAdaptor::pebble() const { // get the value of property pebble return qvariant_cast< QVariantMap >(parent()->property("pebble")); diff --git a/daemon/dbusadaptor.h b/daemon/dbusadaptor.h index 9d8759a..d1662c6 100644 --- a/daemon/dbusadaptor.h +++ b/daemon/dbusadaptor.h @@ -1,6 +1,6 @@ /* * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DBusAdaptor -a dbusadaptor org.pebbled.xml + * 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). * @@ -9,8 +9,8 @@ * before re-generating it. */ -#ifndef DBUSADAPTOR_H_1404605591 -#define DBUSADAPTOR_H_1404605591 +#ifndef DBUSADAPTOR_H_1404660047 +#define DBUSADAPTOR_H_1404660047 #include <QtCore/QObject> #include <QtDBus/QtDBus> @@ -26,7 +26,7 @@ QT_END_NAMESPACE /* * Adaptor class for interface org.pebbled */ -class DBusAdaptor: public QDBusAbstractAdaptor +class PebbledAdaptor: public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.pebbled") @@ -43,8 +43,8 @@ class DBusAdaptor: public QDBusAbstractAdaptor " </interface>\n" "") public: - DBusAdaptor(QObject *parent); - virtual ~DBusAdaptor(); + PebbledAdaptor(QObject *parent); + virtual ~PebbledAdaptor(); public: // PROPERTIES Q_PROPERTY(QString address READ address) diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 4ba2a8b..f25e724 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -37,8 +37,8 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan dbus->findPebble(); } - DBusProxy *proxy = new DBusProxy(this); - DBusAdaptor *adaptor = new DBusAdaptor(proxy); + PebbledProxy *proxy = new PebbledProxy(this); + PebbledAdaptor *adaptor = new PebbledAdaptor(proxy); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerObject("/", proxy); connection.registerService("org.pebbled"); diff --git a/daemon/manager.h b/daemon/manager.h index b052355..b9aa01b 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -19,7 +19,7 @@ class Manager : public QObject { Q_OBJECT - friend class DBusProxy; + friend class PebbledProxy; QBluetoothLocalDevice btDevice; @@ -55,7 +55,7 @@ protected slots: }; -class DBusProxy : public QObject +class PebbledProxy : public QObject { Q_OBJECT Q_PROPERTY(QVariantMap pebble READ pebble) @@ -69,7 +69,7 @@ class DBusProxy : public QObject bool pebbleConnected() { return static_cast<Manager*>(parent())->watch->isConnected(); } public: - explicit DBusProxy(QObject *parent) : QObject(parent) {} + explicit PebbledProxy(QObject *parent) : QObject(parent) {} }; diff --git a/lib/watchconnector.cpp b/daemon/watchconnector.cpp index 18d287e..18d287e 100644 --- a/lib/watchconnector.cpp +++ b/daemon/watchconnector.cpp diff --git a/lib/watchconnector.h b/daemon/watchconnector.h index 493856b..493856b 100644 --- a/lib/watchconnector.h +++ b/daemon/watchconnector.h diff --git a/lib/lib.pro b/lib/lib.pro deleted file mode 100644 index d9e24db..0000000 --- a/lib/lib.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = lib -TARGET = pebble - -HEADERS += \ - watchconnector.h - -SOURCES += \ - watchconnector.cpp - -QT += bluetooth -QMAKE_CXXFLAGS += -std=c++0x - -INSTALLS += target -target.path = /usr/lib @@ -1,6 +1,6 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = lib daemon app +SUBDIRS = daemon app OTHER_FILES += \ rpm/pebble.spec \ rpm/pebble.yaml |
