From f1ca2a5b863ec6e04d4ecc349551758aa8517e66 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 10 Oct 2019 11:39:51 +0200 Subject: [PATCH] Add experience mode plugins --- .../experiences/experiencemanager.cpp | 11 ++++++++++ libnymea-core/experiences/experiencemanager.h | 22 +++++++++++++++++++ libnymea-core/jsonrpc/jsonrpcserver.h | 4 ++-- libnymea-core/libnymea-core.pro | 2 ++ libnymea-core/nymeacore.cpp | 3 +++ libnymea/experiences/experienceplugin.cpp | 6 +++++ libnymea/experiences/experienceplugin.h | 18 +++++++++++++++ libnymea/libnymea.pro | 2 ++ 8 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 libnymea-core/experiences/experiencemanager.cpp create mode 100644 libnymea-core/experiences/experiencemanager.h create mode 100644 libnymea/experiences/experienceplugin.cpp create mode 100644 libnymea/experiences/experienceplugin.h diff --git a/libnymea-core/experiences/experiencemanager.cpp b/libnymea-core/experiences/experiencemanager.cpp new file mode 100644 index 00000000..90e9e5e4 --- /dev/null +++ b/libnymea-core/experiences/experiencemanager.cpp @@ -0,0 +1,11 @@ +#include "experiencemanager.h" + +#include "jsonrpc/jsonrpcserver.h" +namespace nymeaserver { +ExperienceManager::ExperienceManager(JsonRPCServer *jsonRpcServer, QObject *parent) : QObject(parent) +{ +// jsonRpcServer->registerHandler(); + +} + +} diff --git a/libnymea-core/experiences/experiencemanager.h b/libnymea-core/experiences/experiencemanager.h new file mode 100644 index 00000000..2b0b25bc --- /dev/null +++ b/libnymea-core/experiences/experiencemanager.h @@ -0,0 +1,22 @@ +#ifndef EXPERIENCEMANAGER_H +#define EXPERIENCEMANAGER_H + +#include + +namespace nymeaserver { + +class JsonRPCServer; + +class ExperienceManager : public QObject +{ + Q_OBJECT +public: + explicit ExperienceManager(JsonRPCServer *jsonRpcServer, QObject *parent = nullptr); + +signals: + +public slots: +}; + +} +#endif // EXPERIENCEMANAGER_H diff --git a/libnymea-core/jsonrpc/jsonrpcserver.h b/libnymea-core/jsonrpc/jsonrpcserver.h index 28ee036a..d3709afa 100644 --- a/libnymea-core/jsonrpc/jsonrpcserver.h +++ b/libnymea-core/jsonrpc/jsonrpcserver.h @@ -71,6 +71,8 @@ public: void registerTransportInterface(TransportInterface *interface, bool authenticationRequired); void unregisterTransportInterface(TransportInterface *interface); + void registerHandler(JsonHandler *handler); + private: QHash handlers() const; @@ -117,8 +119,6 @@ private: int m_notificationId; - void registerHandler(JsonHandler *handler); - QString formatAssertion(const QString &targetNamespace, const QString &method, QMetaMethod::MethodType methodType, JsonHandler *handler, const QVariantMap &data) const; }; diff --git a/libnymea-core/libnymea-core.pro b/libnymea-core/libnymea-core.pro index 69a9807c..f99e9dcf 100644 --- a/libnymea-core/libnymea-core.pro +++ b/libnymea-core/libnymea-core.pro @@ -18,6 +18,7 @@ RESOURCES += $$top_srcdir/icons.qrc \ HEADERS += nymeacore.h \ devices/devicemanagerimplementation.h \ devices/translator.h \ + experiences/experiencemanager.h \ ruleengine/ruleengine.h \ ruleengine/rule.h \ ruleengine/stateevaluator.h \ @@ -95,6 +96,7 @@ HEADERS += nymeacore.h \ SOURCES += nymeacore.cpp \ devices/devicemanagerimplementation.cpp \ devices/translator.cpp \ + experiences/experiencemanager.cpp \ ruleengine/ruleengine.cpp \ ruleengine/rule.cpp \ ruleengine/stateevaluator.cpp \ diff --git a/libnymea-core/nymeacore.cpp b/libnymea-core/nymeacore.cpp index 6068d8d5..f4089ea9 100644 --- a/libnymea-core/nymeacore.cpp +++ b/libnymea-core/nymeacore.cpp @@ -171,6 +171,9 @@ void NymeaCore::init() { qCDebug(dcApplication) << "Creating Cloud Manager"; m_cloudManager = new CloudManager(m_configuration, m_networkManager, this); + qCDebug(dcApplication()) << "Loading experiences"; + + CloudNotifications *cloudNotifications = m_cloudManager->createNotificationsPlugin(); m_deviceManager->registerStaticPlugin(cloudNotifications, cloudNotifications->metaData()); diff --git a/libnymea/experiences/experienceplugin.cpp b/libnymea/experiences/experienceplugin.cpp new file mode 100644 index 00000000..2e7233a4 --- /dev/null +++ b/libnymea/experiences/experienceplugin.cpp @@ -0,0 +1,6 @@ +#include "experienceplugin.h" + +ExperiencePlugin::ExperiencePlugin(QObject *parent) : JsonHandler(parent) +{ + +} diff --git a/libnymea/experiences/experienceplugin.h b/libnymea/experiences/experienceplugin.h new file mode 100644 index 00000000..c6242672 --- /dev/null +++ b/libnymea/experiences/experienceplugin.h @@ -0,0 +1,18 @@ +#ifndef EXPERIENCEPLUGIN_H +#define EXPERIENCEPLUGIN_H + +#include +#include "jsonrpc/jsonhandler.h" + +class ExperiencePlugin : public JsonHandler +{ + Q_OBJECT +public: + explicit ExperiencePlugin(QObject *parent = nullptr); + +signals: + +public slots: +}; + +#endif // EXPERIENCEPLUGIN_H diff --git a/libnymea/libnymea.pro b/libnymea/libnymea.pro index 4d19b679..a3d6c0dd 100644 --- a/libnymea/libnymea.pro +++ b/libnymea/libnymea.pro @@ -26,6 +26,7 @@ HEADERS += \ devices/browseresult.h \ jsonrpc/jsonhandler.h \ jsonrpc/jsonreply.h \ + experiences/experienceplugin.h \ libnymea.h \ platform/package.h \ platform/repository.h \ @@ -102,6 +103,7 @@ SOURCES += \ devices/browseresult.cpp \ jsonrpc/jsonhandler.cpp \ jsonrpc/jsonreply.cpp \ + experiences/experienceplugin.cpp \ loggingcategories.cpp \ nymeasettings.cpp \ platform/package.cpp \