Simplify json notification api
This commit is contained in:
parent
6629686ea4
commit
125106309b
@ -8,7 +8,7 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
NYMEA_LOGGING_CATEGORY(dcAppData, "AppData")
|
NYMEA_LOGGING_CATEGORY(dcAppData, "AppData")
|
||||||
|
|
||||||
AppData::AppData(QObject *parent) : JsonHandler(parent)
|
AppData::AppData(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_syncTimer.setSingleShot(true);
|
m_syncTimer.setSingleShot(true);
|
||||||
connect(&m_syncTimer, &QTimer::timeout, this, &AppData::store);
|
connect(&m_syncTimer, &QTimer::timeout, this, &AppData::store);
|
||||||
@ -43,11 +43,6 @@ void AppData::componentComplete()
|
|||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppData::nameSpace() const
|
|
||||||
{
|
|
||||||
return "AppData";
|
|
||||||
}
|
|
||||||
|
|
||||||
Engine *AppData::engine() const
|
Engine *AppData::engine() const
|
||||||
{
|
{
|
||||||
return m_engine;
|
return m_engine;
|
||||||
@ -66,7 +61,7 @@ void AppData::setEngine(Engine *engine)
|
|||||||
m_engine = engine;
|
m_engine = engine;
|
||||||
|
|
||||||
if (m_engine) {
|
if (m_engine) {
|
||||||
m_engine->jsonRpcClient()->registerNotificationHandler(this, "notificationReceived");
|
m_engine->jsonRpcClient()->registerNotificationHandler(this, "AppData", "notificationReceived");
|
||||||
}
|
}
|
||||||
emit engineChanged();
|
emit engineChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
#ifndef APPDATA_H
|
#ifndef APPDATA_H
|
||||||
#define APPDATA_H
|
#define APPDATA_H
|
||||||
|
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
|
|
||||||
#include <QQmlParserStatus>
|
#include <QQmlParserStatus>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
|
||||||
class AppData : public JsonHandler, public QQmlParserStatus
|
class AppData : public QObject, public QQmlParserStatus
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(QQmlParserStatus)
|
Q_INTERFACES(QQmlParserStatus)
|
||||||
@ -22,8 +21,6 @@ public:
|
|||||||
void classBegin() override;
|
void classBegin() override;
|
||||||
void componentComplete() override;
|
void componentComplete() override;
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
Engine *engine() const;
|
Engine *engine() const;
|
||||||
void setEngine(Engine *engine);
|
void setEngine(Engine *engine);
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
NetworkManager::NetworkManager(QObject *parent):
|
NetworkManager::NetworkManager(QObject *parent):
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_wiredNetworkDevices(new WiredNetworkDevices(this)),
|
m_wiredNetworkDevices(new WiredNetworkDevices(this)),
|
||||||
m_wirelessNetworkDevices(new WirelessNetworkDevices(this))
|
m_wirelessNetworkDevices(new WirelessNetworkDevices(this))
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ void NetworkManager::setEngine(Engine *engine)
|
|||||||
m_engine = engine;
|
m_engine = engine;
|
||||||
emit engineChanged();
|
emit engineChanged();
|
||||||
|
|
||||||
m_engine->jsonRpcClient()->registerNotificationHandler(this, "notificationReceived");
|
m_engine->jsonRpcClient()->registerNotificationHandler(this, "NetworkManager", "notificationReceived");
|
||||||
init();
|
init();
|
||||||
|
|
||||||
connect(m_engine->jsonRpcClient(), &JsonRpcClient::connectedChanged, this, &NetworkManager::init);
|
connect(m_engine->jsonRpcClient(), &JsonRpcClient::connectedChanged, this, &NetworkManager::init);
|
||||||
@ -80,11 +80,6 @@ bool NetworkManager::loading()
|
|||||||
return m_loading;
|
return m_loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NetworkManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "NetworkManager";
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkManager::init()
|
void NetworkManager::init()
|
||||||
{
|
{
|
||||||
m_wiredNetworkDevices->clear();
|
m_wiredNetworkDevices->clear();
|
||||||
|
|||||||
@ -34,14 +34,12 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
class NetworkDevices;
|
class NetworkDevices;
|
||||||
class WiredNetworkDevices;
|
class WiredNetworkDevices;
|
||||||
class WirelessNetworkDevices;
|
class WirelessNetworkDevices;
|
||||||
|
|
||||||
class NetworkManager : public JsonHandler
|
class NetworkManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Engine *engine READ engine WRITE setEngine NOTIFY engineChanged)
|
Q_PROPERTY(Engine *engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
@ -77,8 +75,6 @@ public:
|
|||||||
|
|
||||||
bool loading();
|
bool loading();
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
bool available() const;
|
bool available() const;
|
||||||
NetworkManagerState state() const;
|
NetworkManagerState state() const;
|
||||||
bool networkingEnabled() const;
|
bool networkingEnabled() const;
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
NYMEA_LOGGING_CATEGORY(dcNymeaConfiguration, "NymeaConfiguration")
|
NYMEA_LOGGING_CATEGORY(dcNymeaConfiguration, "NymeaConfiguration")
|
||||||
|
|
||||||
NymeaConfiguration::NymeaConfiguration(JsonRpcClient *client, QObject *parent):
|
NymeaConfiguration::NymeaConfiguration(JsonRpcClient *client, QObject *parent):
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_client(client),
|
m_client(client),
|
||||||
m_tcpServerConfigurations(new ServerConfigurations(this)),
|
m_tcpServerConfigurations(new ServerConfigurations(this)),
|
||||||
m_webSocketServerConfigurations(new ServerConfigurations(this)),
|
m_webSocketServerConfigurations(new ServerConfigurations(this)),
|
||||||
@ -52,12 +52,7 @@ NymeaConfiguration::NymeaConfiguration(JsonRpcClient *client, QObject *parent):
|
|||||||
m_mqttServerConfigurations(new ServerConfigurations(this)),
|
m_mqttServerConfigurations(new ServerConfigurations(this)),
|
||||||
m_mqttPolicies(new MqttPolicies(this))
|
m_mqttPolicies(new MqttPolicies(this))
|
||||||
{
|
{
|
||||||
client->registerNotificationHandler(this, "notificationReceived");
|
client->registerNotificationHandler(this, "Configuration", "notificationReceived");
|
||||||
}
|
|
||||||
|
|
||||||
QString NymeaConfiguration::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Configuration";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NymeaConfiguration::init()
|
void NymeaConfiguration::init()
|
||||||
|
|||||||
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
|
|
||||||
class JsonRpcClient;
|
class JsonRpcClient;
|
||||||
class ServerConfiguration;
|
class ServerConfiguration;
|
||||||
class ServerConfigurations;
|
class ServerConfigurations;
|
||||||
@ -43,7 +41,7 @@ class WebServerConfigurations;
|
|||||||
class MqttPolicy;
|
class MqttPolicy;
|
||||||
class MqttPolicies;
|
class MqttPolicies;
|
||||||
|
|
||||||
class NymeaConfiguration : public JsonHandler
|
class NymeaConfiguration : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -62,8 +60,6 @@ class NymeaConfiguration : public JsonHandler
|
|||||||
public:
|
public:
|
||||||
explicit NymeaConfiguration(JsonRpcClient* client, QObject *parent = nullptr);
|
explicit NymeaConfiguration(JsonRpcClient* client, QObject *parent = nullptr);
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
QString serverName() const;
|
QString serverName() const;
|
||||||
void setServerName(const QString &serverName);
|
void setServerName(const QString &serverName);
|
||||||
|
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
*
|
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
|
||||||
* Contact: contact@nymea.io
|
|
||||||
*
|
|
||||||
* This file is part of nymea.
|
|
||||||
* This project including source code and documentation is protected by
|
|
||||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
|
||||||
* reproduction, publication, editing and translation, are reserved. The use of
|
|
||||||
* this project is subject to the terms of a license agreement to be concluded
|
|
||||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
|
||||||
* under https://nymea.io/license
|
|
||||||
*
|
|
||||||
* GNU General Public License Usage
|
|
||||||
* Alternatively, this project may be redistributed and/or modified under the
|
|
||||||
* terms of the GNU General Public License as published by the Free Software
|
|
||||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
|
||||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
||||||
* Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* For any further details and any questions please contact us under
|
|
||||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
|
||||||
* https://nymea.io/license/faq
|
|
||||||
*
|
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
||||||
|
|
||||||
#include "jsonhandler.h"
|
|
||||||
|
|
||||||
JsonHandler::JsonHandler(QObject *parent) :
|
|
||||||
QObject(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
*
|
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
|
||||||
* Contact: contact@nymea.io
|
|
||||||
*
|
|
||||||
* This file is part of nymea.
|
|
||||||
* This project including source code and documentation is protected by
|
|
||||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
|
||||||
* reproduction, publication, editing and translation, are reserved. The use of
|
|
||||||
* this project is subject to the terms of a license agreement to be concluded
|
|
||||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
|
||||||
* under https://nymea.io/license
|
|
||||||
*
|
|
||||||
* GNU General Public License Usage
|
|
||||||
* Alternatively, this project may be redistributed and/or modified under the
|
|
||||||
* terms of the GNU General Public License as published by the Free Software
|
|
||||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
|
||||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
||||||
* Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* For any further details and any questions please contact us under
|
|
||||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
|
||||||
* https://nymea.io/license/faq
|
|
||||||
*
|
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
||||||
|
|
||||||
#ifndef JSONHANDLER_H
|
|
||||||
#define JSONHANDLER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
class JsonHandler : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
JsonHandler(QObject *parent = nullptr);
|
|
||||||
virtual QString nameSpace() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // JSONHANDLER_H
|
|
||||||
@ -53,7 +53,7 @@
|
|||||||
NYMEA_LOGGING_CATEGORY(dcJsonRpc, "JsonRpc")
|
NYMEA_LOGGING_CATEGORY(dcJsonRpc, "JsonRpc")
|
||||||
|
|
||||||
JsonRpcClient::JsonRpcClient(QObject *parent) :
|
JsonRpcClient::JsonRpcClient(QObject *parent) :
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_id(0)
|
m_id(0)
|
||||||
{
|
{
|
||||||
m_connection = new NymeaConnection(this);
|
m_connection = new NymeaConnection(this);
|
||||||
@ -69,28 +69,25 @@ JsonRpcClient::JsonRpcClient(QObject *parent) :
|
|||||||
connect(m_connection, &NymeaConnection::currentConnectionChanged, this, &JsonRpcClient:: currentConnectionChanged);
|
connect(m_connection, &NymeaConnection::currentConnectionChanged, this, &JsonRpcClient:: currentConnectionChanged);
|
||||||
connect(m_connection, &NymeaConnection::dataAvailable, this, &JsonRpcClient::dataReceived);
|
connect(m_connection, &NymeaConnection::dataAvailable, this, &JsonRpcClient::dataReceived);
|
||||||
|
|
||||||
registerNotificationHandler(this, "notificationReceived");
|
registerNotificationHandler(this, QStringLiteral("JSONRPC"), "notificationReceived");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString JsonRpcClient::nameSpace() const
|
void JsonRpcClient::registerNotificationHandler(QObject *handler, const QString &nameSpace, const QString &method)
|
||||||
{
|
|
||||||
return QStringLiteral("JSONRPC");
|
|
||||||
}
|
|
||||||
|
|
||||||
void JsonRpcClient::registerNotificationHandler(JsonHandler *handler, const QString &method)
|
|
||||||
{
|
{
|
||||||
if (m_notificationHandlerMethods.contains(handler)) {
|
if (m_notificationHandlerMethods.contains(handler)) {
|
||||||
qWarning() << "Notification handler" << handler << " already registered";
|
qWarning() << "Notification handler" << handler << " already registered";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_notificationHandlers.insert(handler->nameSpace(), handler);
|
m_notificationHandlers.insert(nameSpace, handler);
|
||||||
m_notificationHandlerMethods.insert(handler, method);
|
m_notificationHandlerMethods.insert(handler, method);
|
||||||
setNotificationsEnabled();
|
setNotificationsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonRpcClient::unregisterNotificationHandler(JsonHandler *handler)
|
void JsonRpcClient::unregisterNotificationHandler(QObject *handler)
|
||||||
{
|
{
|
||||||
m_notificationHandlers.remove(handler->nameSpace(), handler);
|
foreach (const QString nameSpace, m_notificationHandlers.keys(handler)) {
|
||||||
|
m_notificationHandlers.remove(nameSpace, handler);
|
||||||
|
}
|
||||||
m_notificationHandlerMethods.remove(handler);
|
m_notificationHandlerMethods.remove(handler);
|
||||||
setNotificationsEnabled();
|
setNotificationsEnabled();
|
||||||
}
|
}
|
||||||
@ -358,6 +355,11 @@ QString JsonRpcClient::serverQtBuildVersion()
|
|||||||
return m_serverQtBuildVersion;
|
return m_serverQtBuildVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap JsonRpcClient::experiences() const
|
||||||
|
{
|
||||||
|
return m_experiences;
|
||||||
|
}
|
||||||
|
|
||||||
int JsonRpcClient::createUser(const QString &username, const QString &password)
|
int JsonRpcClient::createUser(const QString &username, const QString &password)
|
||||||
{
|
{
|
||||||
QVariantMap params;
|
QVariantMap params;
|
||||||
@ -572,7 +574,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
|||||||
// qDebug() << "Incoming notification:" << jsonDoc.toJson();
|
// qDebug() << "Incoming notification:" << jsonDoc.toJson();
|
||||||
QStringList notification = dataMap.value("notification").toString().split(".");
|
QStringList notification = dataMap.value("notification").toString().split(".");
|
||||||
QString nameSpace = notification.first();
|
QString nameSpace = notification.first();
|
||||||
foreach (JsonHandler *handler, m_notificationHandlers.values(nameSpace)) {
|
foreach (QObject *handler, m_notificationHandlers.values(nameSpace)) {
|
||||||
QMetaObject::invokeMethod(handler, m_notificationHandlerMethods.value(handler).toLatin1().data(), Q_ARG(QVariantMap, dataMap));
|
QMetaObject::invokeMethod(handler, m_notificationHandlerMethods.value(handler).toLatin1().data(), Q_ARG(QVariantMap, dataMap));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -644,6 +646,10 @@ void JsonRpcClient::helloReply(int /*commandId*/, const QVariantMap ¶ms)
|
|||||||
|
|
||||||
m_serverUuid = params.value("uuid").toString();
|
m_serverUuid = params.value("uuid").toString();
|
||||||
m_serverVersion = params.value("version").toString();
|
m_serverVersion = params.value("version").toString();
|
||||||
|
m_experiences.clear();
|
||||||
|
foreach (const QVariant &experience, params.value("experiences").toList()) {
|
||||||
|
m_experiences.insert(experience.toMap().value("name").toString(), experience.toMap().value("version").toString());
|
||||||
|
}
|
||||||
|
|
||||||
QString protoVersionString = params.value("protocol version").toString();
|
QString protoVersionString = params.value("protocol version").toString();
|
||||||
if (!protoVersionString.contains('.')) {
|
if (!protoVersionString.contains('.')) {
|
||||||
|
|||||||
@ -37,13 +37,12 @@
|
|||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
|
||||||
#include "connection/nymeaconnection.h"
|
#include "connection/nymeaconnection.h"
|
||||||
#include "jsonhandler.h"
|
|
||||||
|
|
||||||
class JsonRpcReply;
|
class JsonRpcReply;
|
||||||
class Param;
|
class Param;
|
||||||
class Params;
|
class Params;
|
||||||
|
|
||||||
class JsonRpcClient : public JsonHandler
|
class JsonRpcClient : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(NymeaConnection::BearerTypes availableBearerTypes READ availableBearerTypes NOTIFY availableBearerTypesChanged)
|
Q_PROPERTY(NymeaConnection::BearerTypes availableBearerTypes READ availableBearerTypes NOTIFY availableBearerTypesChanged)
|
||||||
@ -62,6 +61,7 @@ class JsonRpcClient : public JsonHandler
|
|||||||
Q_PROPERTY(QString serverQtVersion READ serverQtVersion NOTIFY serverQtVersionChanged)
|
Q_PROPERTY(QString serverQtVersion READ serverQtVersion NOTIFY serverQtVersionChanged)
|
||||||
Q_PROPERTY(QString serverQtBuildVersion READ serverQtBuildVersion NOTIFY serverQtVersionChanged)
|
Q_PROPERTY(QString serverQtBuildVersion READ serverQtBuildVersion NOTIFY serverQtVersionChanged)
|
||||||
Q_PROPERTY(QVariantMap certificateIssuerInfo READ certificateIssuerInfo NOTIFY currentConnectionChanged)
|
Q_PROPERTY(QVariantMap certificateIssuerInfo READ certificateIssuerInfo NOTIFY currentConnectionChanged)
|
||||||
|
Q_PROPERTY(QVariantMap experiences READ experiences NOTIFY currentConnectionChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum CloudConnectionState {
|
enum CloudConnectionState {
|
||||||
@ -74,10 +74,8 @@ public:
|
|||||||
|
|
||||||
explicit JsonRpcClient(QObject *parent = nullptr);
|
explicit JsonRpcClient(QObject *parent = nullptr);
|
||||||
|
|
||||||
QString nameSpace() const override;
|
void registerNotificationHandler(QObject *handler, const QString &nameSpace, const QString &method);
|
||||||
|
void unregisterNotificationHandler(QObject *handler);
|
||||||
void registerNotificationHandler(JsonHandler *handler, const QString &method);
|
|
||||||
void unregisterNotificationHandler(JsonHandler *handler);
|
|
||||||
|
|
||||||
int sendCommand(const QString &method, const QVariantMap ¶ms, QObject *caller = nullptr, const QString &callbackMethod = QString());
|
int sendCommand(const QString &method, const QVariantMap ¶ms, QObject *caller = nullptr, const QString &callbackMethod = QString());
|
||||||
int sendCommand(const QString &method, QObject *caller = nullptr, const QString &callbackMethod = QString());
|
int sendCommand(const QString &method, QObject *caller = nullptr, const QString &callbackMethod = QString());
|
||||||
@ -101,6 +99,7 @@ public:
|
|||||||
QString serverUuid() const;
|
QString serverUuid() const;
|
||||||
QString serverQtVersion();
|
QString serverQtVersion();
|
||||||
QString serverQtBuildVersion();
|
QString serverQtBuildVersion();
|
||||||
|
QVariantMap experiences() const;
|
||||||
|
|
||||||
// ui methods
|
// ui methods
|
||||||
Q_INVOKABLE void connectToHost(NymeaHost *host, Connection *connection = nullptr);
|
Q_INVOKABLE void connectToHost(NymeaHost *host, Connection *connection = nullptr);
|
||||||
@ -150,8 +149,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
int m_id;
|
int m_id;
|
||||||
// < namespace, method> >
|
// < namespace, method> >
|
||||||
QHash<JsonHandler*, QString> m_notificationHandlerMethods;
|
QHash<QObject*, QString> m_notificationHandlerMethods;
|
||||||
QMultiHash<QString, JsonHandler*> m_notificationHandlers;
|
QMultiHash<QString, QObject*> m_notificationHandlers;
|
||||||
QHash<int, JsonRpcReply *> m_replies;
|
QHash<int, JsonRpcReply *> m_replies;
|
||||||
NymeaConnection *m_connection = nullptr;
|
NymeaConnection *m_connection = nullptr;
|
||||||
|
|
||||||
@ -172,6 +171,7 @@ private:
|
|||||||
QByteArray m_token;
|
QByteArray m_token;
|
||||||
QByteArray m_receiveBuffer;
|
QByteArray m_receiveBuffer;
|
||||||
QHash<QString, QString> m_cacheHashes;
|
QHash<QString, QString> m_cacheHashes;
|
||||||
|
QVariantMap m_experiences;
|
||||||
|
|
||||||
void setNotificationsEnabled();
|
void setNotificationsEnabled();
|
||||||
void getCloudConnectionStatus();
|
void getCloudConnectionStatus();
|
||||||
|
|||||||
@ -121,7 +121,6 @@ SOURCES += \
|
|||||||
$${PWD}/connection/discovery/bluetoothservicediscovery.cpp \
|
$${PWD}/connection/discovery/bluetoothservicediscovery.cpp \
|
||||||
$${PWD}/thingmanager.cpp \
|
$${PWD}/thingmanager.cpp \
|
||||||
$${PWD}/jsonrpc/jsonrpcclient.cpp \
|
$${PWD}/jsonrpc/jsonrpcclient.cpp \
|
||||||
$${PWD}/jsonrpc/jsonhandler.cpp \
|
|
||||||
$${PWD}/things.cpp \
|
$${PWD}/things.cpp \
|
||||||
$${PWD}/thingsproxy.cpp \
|
$${PWD}/thingsproxy.cpp \
|
||||||
$${PWD}/thingclasses.cpp \
|
$${PWD}/thingclasses.cpp \
|
||||||
@ -279,7 +278,6 @@ HEADERS += \
|
|||||||
$${PWD}/connection/discovery/bluetoothservicediscovery.h \
|
$${PWD}/connection/discovery/bluetoothservicediscovery.h \
|
||||||
$${PWD}/thingmanager.h \
|
$${PWD}/thingmanager.h \
|
||||||
$${PWD}/jsonrpc/jsonrpcclient.h \
|
$${PWD}/jsonrpc/jsonrpcclient.h \
|
||||||
$${PWD}/jsonrpc/jsonhandler.h \
|
|
||||||
$${PWD}/things.h \
|
$${PWD}/things.h \
|
||||||
$${PWD}/thingsproxy.h \
|
$${PWD}/thingsproxy.h \
|
||||||
$${PWD}/thingclasses.h \
|
$${PWD}/thingclasses.h \
|
||||||
|
|||||||
@ -33,15 +33,10 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
LogManager::LogManager(JsonRpcClient *jsonClient, QObject *parent) :
|
LogManager::LogManager(JsonRpcClient *jsonClient, QObject *parent) :
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_client(jsonClient)
|
m_client(jsonClient)
|
||||||
{
|
{
|
||||||
m_client->registerNotificationHandler(this, "notificationReceived");
|
m_client->registerNotificationHandler(this, "Logging", "notificationReceived");
|
||||||
}
|
|
||||||
|
|
||||||
QString LogManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Logging";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogManager::notificationReceived(const QVariantMap &data)
|
void LogManager::notificationReceived(const QVariantMap &data)
|
||||||
|
|||||||
@ -33,18 +33,14 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
|
|
||||||
class JsonRpcClient;
|
class JsonRpcClient;
|
||||||
|
|
||||||
class LogManager : public JsonHandler
|
class LogManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LogManager(JsonRpcClient *jsonClient, QObject *parent = nullptr);
|
explicit LogManager(JsonRpcClient *jsonClient, QObject *parent = nullptr);
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void logEntryReceived(const QVariantMap &data);
|
void logEntryReceived(const QVariantMap &data);
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
ModbusRtuManager::ModbusRtuManager(QObject *parent) :
|
ModbusRtuManager::ModbusRtuManager(QObject *parent) :
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_serialPorts(new SerialPorts(this)),
|
m_serialPorts(new SerialPorts(this)),
|
||||||
m_modbusRtuMasters(new ModbusRtuMasters(this))
|
m_modbusRtuMasters(new ModbusRtuMasters(this))
|
||||||
{
|
{
|
||||||
@ -54,11 +54,6 @@ ModbusRtuManager::~ModbusRtuManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModbusRtuManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "ModbusRtu";
|
|
||||||
}
|
|
||||||
|
|
||||||
Engine *ModbusRtuManager::engine() const
|
Engine *ModbusRtuManager::engine() const
|
||||||
{
|
{
|
||||||
return m_engine;
|
return m_engine;
|
||||||
@ -137,7 +132,7 @@ void ModbusRtuManager::init()
|
|||||||
m_serialPorts->clear();
|
m_serialPorts->clear();
|
||||||
m_modbusRtuMasters->clear();
|
m_modbusRtuMasters->clear();
|
||||||
|
|
||||||
m_engine->jsonRpcClient()->registerNotificationHandler(this, "notificationReceived");
|
m_engine->jsonRpcClient()->registerNotificationHandler(this, "ModbusRtu", "notificationReceived");
|
||||||
m_engine->jsonRpcClient()->sendCommand("ModbusRtu.GetModbusRtuMasters", this, "getModbusRtuMastersResponse");
|
m_engine->jsonRpcClient()->sendCommand("ModbusRtu.GetModbusRtuMasters", this, "getModbusRtuMastersResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,14 +34,13 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "types/serialports.h"
|
#include "types/serialports.h"
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
class JsonRpcClient;
|
class JsonRpcClient;
|
||||||
class ModbusRtuMaster;
|
class ModbusRtuMaster;
|
||||||
class ModbusRtuMasters;
|
class ModbusRtuMasters;
|
||||||
|
|
||||||
class ModbusRtuManager : public JsonHandler
|
class ModbusRtuManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Engine *engine READ engine WRITE setEngine NOTIFY engineChanged)
|
Q_PROPERTY(Engine *engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
@ -53,8 +52,6 @@ public:
|
|||||||
explicit ModbusRtuManager(QObject *parent = nullptr);
|
explicit ModbusRtuManager(QObject *parent = nullptr);
|
||||||
~ModbusRtuManager();
|
~ModbusRtuManager();
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
Engine *engine() const;
|
Engine *engine() const;
|
||||||
void setEngine(Engine *engine);
|
void setEngine(Engine *engine);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "barseriesadapter.h"
|
#include "barseriesadapter.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
BarSeriesAdapter::BarSeriesAdapter(QObject *parent) : QObject(parent)
|
BarSeriesAdapter::BarSeriesAdapter(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,6 @@
|
|||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QQmlParserStatus>
|
#include <QQmlParserStatus>
|
||||||
|
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
#include "types/logentry.h"
|
#include "types/logentry.h"
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "xyseriesadapter.h"
|
#include "xyseriesadapter.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
XYSeriesAdapter::XYSeriesAdapter(QObject *parent) : QObject(parent)
|
XYSeriesAdapter::XYSeriesAdapter(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -55,16 +55,11 @@ NYMEA_LOGGING_CATEGORY(dcRuleManager, "RuleManager")
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
RuleManager::RuleManager(JsonRpcClient* jsonClient, QObject *parent) :
|
RuleManager::RuleManager(JsonRpcClient* jsonClient, QObject *parent) :
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_jsonClient(jsonClient),
|
m_jsonClient(jsonClient),
|
||||||
m_rules(new Rules(this))
|
m_rules(new Rules(this))
|
||||||
{
|
{
|
||||||
m_jsonClient->registerNotificationHandler(this, "handleRulesNotification");
|
m_jsonClient->registerNotificationHandler(this, "Rules", "handleRulesNotification");
|
||||||
}
|
|
||||||
|
|
||||||
QString RuleManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Rules";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleManager::clear()
|
void RuleManager::clear()
|
||||||
|
|||||||
@ -34,7 +34,6 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "types/rules.h"
|
#include "types/rules.h"
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
|
|
||||||
class JsonRpcClient;
|
class JsonRpcClient;
|
||||||
class EventDescriptors;
|
class EventDescriptors;
|
||||||
@ -46,7 +45,7 @@ class StateEvaluator;
|
|||||||
class RuleAction;
|
class RuleAction;
|
||||||
class RuleActions;
|
class RuleActions;
|
||||||
|
|
||||||
class RuleManager : public JsonHandler
|
class RuleManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Rules* rules READ rules CONSTANT)
|
Q_PROPERTY(Rules* rules READ rules CONSTANT)
|
||||||
@ -82,8 +81,6 @@ public:
|
|||||||
|
|
||||||
explicit RuleManager(JsonRpcClient *jsonClient, QObject *parent = nullptr);
|
explicit RuleManager(JsonRpcClient *jsonClient, QObject *parent = nullptr);
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void init();
|
void init();
|
||||||
bool fetchingData() const;
|
bool fetchingData() const;
|
||||||
|
|||||||
@ -37,12 +37,12 @@
|
|||||||
NYMEA_LOGGING_CATEGORY(dcScriptManager, "Scripts")
|
NYMEA_LOGGING_CATEGORY(dcScriptManager, "Scripts")
|
||||||
|
|
||||||
ScriptManager::ScriptManager(JsonRpcClient *jsonClient, QObject *parent):
|
ScriptManager::ScriptManager(JsonRpcClient *jsonClient, QObject *parent):
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_client(jsonClient)
|
m_client(jsonClient)
|
||||||
{
|
{
|
||||||
m_scripts = new Scripts(this);
|
m_scripts = new Scripts(this);
|
||||||
|
|
||||||
m_client->registerNotificationHandler(this, "onNotificationReceived");
|
m_client->registerNotificationHandler(this, "Scripts", "onNotificationReceived");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptManager::init()
|
void ScriptManager::init()
|
||||||
@ -58,11 +58,6 @@ bool ScriptManager::fetchingData() const
|
|||||||
return m_fetchingData;
|
return m_fetchingData;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ScriptManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Scripts";
|
|
||||||
}
|
|
||||||
|
|
||||||
Scripts *ScriptManager::scripts() const
|
Scripts *ScriptManager::scripts() const
|
||||||
{
|
{
|
||||||
return m_scripts;
|
return m_scripts;
|
||||||
@ -155,7 +150,7 @@ void ScriptManager::onScriptRemoved(int commandId, const QVariantMap ¶ms)
|
|||||||
|
|
||||||
void ScriptManager::onNotificationReceived(const QVariantMap ¶ms)
|
void ScriptManager::onNotificationReceived(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
qDebug() << "noticication" << params.value("notification").toString();
|
qCDebug(dcScriptManager()) << "noticication" << params.value("notification").toString();
|
||||||
if (params.value("notification").toString() == "Scripts.ScriptLogMessage") {
|
if (params.value("notification").toString() == "Scripts.ScriptLogMessage") {
|
||||||
emit scriptMessage(params.value("params").toMap().value("scriptId").toUuid(),
|
emit scriptMessage(params.value("params").toMap().value("scriptId").toUuid(),
|
||||||
params.value("params").toMap().value("type").toString(),
|
params.value("params").toMap().value("type").toString(),
|
||||||
@ -181,6 +176,6 @@ void ScriptManager::onNotificationReceived(const QVariantMap ¶ms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
qWarning() << "Unhandled notification" << params.value("notification").toString();
|
qCWarning(dcScriptManager()) << "Unhandled notification" << params.value("notification").toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
class Scripts;
|
class Scripts;
|
||||||
|
|
||||||
class ScriptManager : public JsonHandler
|
class ScriptManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Scripts* scripts READ scripts CONSTANT)
|
Q_PROPERTY(Scripts* scripts READ scripts CONSTANT)
|
||||||
@ -49,8 +49,6 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
bool fetchingData() const;
|
bool fetchingData() const;
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
Scripts *scripts() const;
|
Scripts *scripts() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@ -38,10 +38,10 @@
|
|||||||
#include <QTimeZone>
|
#include <QTimeZone>
|
||||||
|
|
||||||
SystemController::SystemController(JsonRpcClient *jsonRpcClient, QObject *parent):
|
SystemController::SystemController(JsonRpcClient *jsonRpcClient, QObject *parent):
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_jsonRpcClient(jsonRpcClient)
|
m_jsonRpcClient(jsonRpcClient)
|
||||||
{
|
{
|
||||||
m_jsonRpcClient->registerNotificationHandler(this, "notificationReceived");
|
m_jsonRpcClient->registerNotificationHandler(this, "System", "notificationReceived");
|
||||||
m_packages = new Packages(this);
|
m_packages = new Packages(this);
|
||||||
m_repositories = new Repositories(this);
|
m_repositories = new Repositories(this);
|
||||||
|
|
||||||
@ -66,11 +66,6 @@ void SystemController::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SystemController::nameSpace() const
|
|
||||||
{
|
|
||||||
return "System";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SystemController::powerManagementAvailable() const
|
bool SystemController::powerManagementAvailable() const
|
||||||
{
|
{
|
||||||
return m_powerManagementAvailable;
|
return m_powerManagementAvailable;
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
class Repositories;
|
class Repositories;
|
||||||
class Packages;
|
class Packages;
|
||||||
|
|
||||||
class SystemController : public JsonHandler
|
class SystemController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool powerManagementAvailable READ powerManagementAvailable NOTIFY powerManagementAvailableChanged)
|
Q_PROPERTY(bool powerManagementAvailable READ powerManagementAvailable NOTIFY powerManagementAvailableChanged)
|
||||||
@ -63,7 +63,6 @@ public:
|
|||||||
explicit SystemController(JsonRpcClient *jsonRpcClient, QObject *parent = nullptr);
|
explicit SystemController(JsonRpcClient *jsonRpcClient, QObject *parent = nullptr);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
bool powerManagementAvailable() const;
|
bool powerManagementAvailable() const;
|
||||||
Q_INVOKABLE int restart();
|
Q_INVOKABLE int restart();
|
||||||
|
|||||||
@ -36,16 +36,11 @@
|
|||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
TagsManager::TagsManager(JsonRpcClient *jsonClient, QObject *parent):
|
TagsManager::TagsManager(JsonRpcClient *jsonClient, QObject *parent):
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_jsonClient(jsonClient),
|
m_jsonClient(jsonClient),
|
||||||
m_tags(new Tags(this))
|
m_tags(new Tags(this))
|
||||||
{
|
{
|
||||||
jsonClient->registerNotificationHandler(this, "handleTagsNotification");
|
jsonClient->registerNotificationHandler(this, "Tags", "handleTagsNotification");
|
||||||
}
|
|
||||||
|
|
||||||
QString TagsManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Tags";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagsManager::init()
|
void TagsManager::init()
|
||||||
|
|||||||
@ -31,12 +31,11 @@
|
|||||||
#ifndef TAGSMANAGER_H
|
#ifndef TAGSMANAGER_H
|
||||||
#define TAGSMANAGER_H
|
#define TAGSMANAGER_H
|
||||||
|
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
#include "jsonrpc/jsonrpcclient.h"
|
#include "jsonrpc/jsonrpcclient.h"
|
||||||
|
|
||||||
#include "types/tags.h"
|
#include "types/tags.h"
|
||||||
|
|
||||||
class TagsManager : public JsonHandler
|
class TagsManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Tags* tags READ tags CONSTANT)
|
Q_PROPERTY(Tags* tags READ tags CONSTANT)
|
||||||
@ -52,7 +51,6 @@ public:
|
|||||||
Q_ENUM(TagError)
|
Q_ENUM(TagError)
|
||||||
|
|
||||||
explicit TagsManager(JsonRpcClient *jsonClient, QObject *parent = nullptr);
|
explicit TagsManager(JsonRpcClient *jsonClient, QObject *parent = nullptr);
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void clear();
|
void clear();
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
NYMEA_LOGGING_CATEGORY(dcThingManager, "ThingManager")
|
NYMEA_LOGGING_CATEGORY(dcThingManager, "ThingManager")
|
||||||
|
|
||||||
ThingManager::ThingManager(JsonRpcClient* jsonclient, QObject *parent) :
|
ThingManager::ThingManager(JsonRpcClient* jsonclient, QObject *parent) :
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_vendors(new Vendors(this)),
|
m_vendors(new Vendors(this)),
|
||||||
m_plugins(new Plugins(this)),
|
m_plugins(new Plugins(this)),
|
||||||
m_things(new Things(this)),
|
m_things(new Things(this)),
|
||||||
@ -53,7 +53,7 @@ ThingManager::ThingManager(JsonRpcClient* jsonclient, QObject *parent) :
|
|||||||
m_ioConnections(new IOConnections(this)),
|
m_ioConnections(new IOConnections(this)),
|
||||||
m_jsonClient(jsonclient)
|
m_jsonClient(jsonclient)
|
||||||
{
|
{
|
||||||
m_jsonClient->registerNotificationHandler(this, "notificationReceived");
|
m_jsonClient->registerNotificationHandler(this, "Integrations", "notificationReceived");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThingManager::clear()
|
void ThingManager::clear()
|
||||||
@ -75,11 +75,6 @@ void ThingManager::init()
|
|||||||
m_jsonClient->sendCommand("Integrations.GetThingClasses", this, "getThingClassesResponse");
|
m_jsonClient->sendCommand("Integrations.GetThingClasses", this, "getThingClassesResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ThingManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Integrations";
|
|
||||||
}
|
|
||||||
|
|
||||||
Vendors *ThingManager::vendors() const
|
Vendors *ThingManager::vendors() const
|
||||||
{
|
{
|
||||||
return m_vendors;
|
return m_vendors;
|
||||||
|
|||||||
@ -38,7 +38,6 @@
|
|||||||
#include "thingclasses.h"
|
#include "thingclasses.h"
|
||||||
#include "interfacesmodel.h"
|
#include "interfacesmodel.h"
|
||||||
#include "types/plugins.h"
|
#include "types/plugins.h"
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
#include "jsonrpc/jsonrpcclient.h"
|
#include "jsonrpc/jsonrpcclient.h"
|
||||||
|
|
||||||
class BrowserItem;
|
class BrowserItem;
|
||||||
@ -47,9 +46,8 @@ class ThingGroup;
|
|||||||
class Interface;
|
class Interface;
|
||||||
class IOConnections;
|
class IOConnections;
|
||||||
class EventHandler;
|
class EventHandler;
|
||||||
class IntegrationsHandler;
|
|
||||||
|
|
||||||
class ThingManager : public JsonHandler
|
class ThingManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Vendors* vendors READ vendors CONSTANT)
|
Q_PROPERTY(Vendors* vendors READ vendors CONSTANT)
|
||||||
@ -74,8 +72,6 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
Vendors* vendors() const;
|
Vendors* vendors() const;
|
||||||
Plugins* plugins() const;
|
Plugins* plugins() const;
|
||||||
Things* things() const;
|
Things* things() const;
|
||||||
@ -189,50 +185,6 @@ private:
|
|||||||
QHash<int, QPointer<BrowserItem> > m_browserDetailsRequests;
|
QHash<int, QPointer<BrowserItem> > m_browserDetailsRequests;
|
||||||
|
|
||||||
QDateTime m_connectionBenchmark;
|
QDateTime m_connectionBenchmark;
|
||||||
|
|
||||||
// Deprecated stuff for nymea < 0.17 (JSONRPC < 4.0)
|
|
||||||
EventHandler *m_eventHandler = nullptr;
|
|
||||||
// Register notifications for new stuff that's only available in the Integrations namespace for now
|
|
||||||
IntegrationsHandler *m_integrationsHandler = nullptr;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: This is deprecated in nymea now (JSONRPC 4.0/nymea 0.17). Keeping it for a bit for backwards compatibility
|
|
||||||
class EventHandler: public JsonHandler {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
EventHandler(QObject *parent = nullptr): JsonHandler(parent) {}
|
|
||||||
QString nameSpace() const override {
|
|
||||||
return "Events";
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void eventReceived(const QVariantMap &event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_INVOKABLE void notificationReceived(const QVariantMap &data) {
|
|
||||||
emit eventReceived(data.value("params").toMap().value("event").toMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class IntegrationsHandler: public JsonHandler {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
IntegrationsHandler(QObject *parent = nullptr): JsonHandler(parent) {}
|
|
||||||
QString nameSpace() const override {
|
|
||||||
return "Integrations";
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void onNotificationReceived(const QVariantMap &data);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_INVOKABLE void notificationReceived(const QVariantMap &data) {
|
|
||||||
emit onNotificationReceived(data);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // THINGMANAGER_H
|
#endif // THINGMANAGER_H
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
UserManager::UserManager(QObject *parent):
|
UserManager::UserManager(QObject *parent):
|
||||||
JsonHandler(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
m_userInfo = new UserInfo(this);
|
m_userInfo = new UserInfo(this);
|
||||||
m_tokenInfos = new TokenInfos(this);
|
m_tokenInfos = new TokenInfos(this);
|
||||||
@ -20,7 +20,7 @@ void UserManager::setEngine(Engine *engine)
|
|||||||
{
|
{
|
||||||
if (m_engine != engine) {
|
if (m_engine != engine) {
|
||||||
m_engine = engine;
|
m_engine = engine;
|
||||||
m_engine->jsonRpcClient()->registerNotificationHandler(this, "notificationReceived");
|
m_engine->jsonRpcClient()->registerNotificationHandler(this, "Users", "notificationReceived");
|
||||||
emit engineChanged();
|
emit engineChanged();
|
||||||
|
|
||||||
m_loading = true;
|
m_loading = true;
|
||||||
@ -46,11 +46,6 @@ TokenInfos *UserManager::tokenInfos() const
|
|||||||
return m_tokenInfos;
|
return m_tokenInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Users";
|
|
||||||
}
|
|
||||||
|
|
||||||
int UserManager::changePassword(const QString &newPassword)
|
int UserManager::changePassword(const QString &newPassword)
|
||||||
{
|
{
|
||||||
QVariantMap params;
|
QVariantMap params;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
#include "types/tokeninfos.h"
|
#include "types/tokeninfos.h"
|
||||||
#include "types/userinfo.h"
|
#include "types/userinfo.h"
|
||||||
|
|
||||||
class UserManager: public JsonHandler
|
class UserManager: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
@ -40,8 +40,6 @@ public:
|
|||||||
UserInfo* userInfo() const;
|
UserInfo* userInfo() const;
|
||||||
TokenInfos* tokenInfos() const;
|
TokenInfos* tokenInfos() const;
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
Q_INVOKABLE int changePassword(const QString &newPassword);
|
Q_INVOKABLE int changePassword(const QString &newPassword);
|
||||||
Q_INVOKABLE int removeToken(const QUuid &id);
|
Q_INVOKABLE int removeToken(const QUuid &id);
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
NYMEA_LOGGING_CATEGORY(dcZigbee, "Zigbee")
|
NYMEA_LOGGING_CATEGORY(dcZigbee, "Zigbee")
|
||||||
|
|
||||||
ZigbeeManager::ZigbeeManager(QObject *parent) :
|
ZigbeeManager::ZigbeeManager(QObject *parent) :
|
||||||
JsonHandler(parent),
|
QObject(parent),
|
||||||
m_adapters(new ZigbeeAdapters(this)),
|
m_adapters(new ZigbeeAdapters(this)),
|
||||||
m_networks(new ZigbeeNetworks(this))
|
m_networks(new ZigbeeNetworks(this))
|
||||||
{
|
{
|
||||||
@ -59,11 +59,6 @@ ZigbeeManager::~ZigbeeManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ZigbeeManager::nameSpace() const
|
|
||||||
{
|
|
||||||
return "Zigbee";
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZigbeeManager::setEngine(Engine *engine)
|
void ZigbeeManager::setEngine(Engine *engine)
|
||||||
{
|
{
|
||||||
if (m_engine != engine) {
|
if (m_engine != engine) {
|
||||||
@ -153,7 +148,7 @@ void ZigbeeManager::init()
|
|||||||
m_networks->clear();
|
m_networks->clear();
|
||||||
m_availableBackends.clear();
|
m_availableBackends.clear();
|
||||||
|
|
||||||
m_engine->jsonRpcClient()->registerNotificationHandler(this, "notificationReceived");
|
m_engine->jsonRpcClient()->registerNotificationHandler(this, "Zigbee", "notificationReceived");
|
||||||
|
|
||||||
m_engine->jsonRpcClient()->sendCommand("Zigbee.GetAvailableBackends", this, "getAvailableBackendsResponse");
|
m_engine->jsonRpcClient()->sendCommand("Zigbee.GetAvailableBackends", this, "getAvailableBackendsResponse");
|
||||||
m_engine->jsonRpcClient()->sendCommand("Zigbee.GetAdapters", this, "getAdaptersResponse");
|
m_engine->jsonRpcClient()->sendCommand("Zigbee.GetAdapters", this, "getAdaptersResponse");
|
||||||
|
|||||||
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "zigbeeadapter.h"
|
#include "zigbeeadapter.h"
|
||||||
#include "jsonrpc/jsonhandler.h"
|
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
class JsonRpcClient;
|
class JsonRpcClient;
|
||||||
@ -43,7 +42,7 @@ class ZigbeeNetworks;
|
|||||||
class ZigbeeNode;
|
class ZigbeeNode;
|
||||||
class ZigbeeNodes;
|
class ZigbeeNodes;
|
||||||
|
|
||||||
class ZigbeeManager : public JsonHandler
|
class ZigbeeManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
@ -56,8 +55,6 @@ public:
|
|||||||
explicit ZigbeeManager(QObject *parent = nullptr);
|
explicit ZigbeeManager(QObject *parent = nullptr);
|
||||||
~ZigbeeManager();
|
~ZigbeeManager();
|
||||||
|
|
||||||
QString nameSpace() const override;
|
|
||||||
|
|
||||||
void setEngine(Engine *engine);
|
void setEngine(Engine *engine);
|
||||||
Engine *engine() const;
|
Engine *engine() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user