From 65736e1034162ddb9cdcfe48a51c1a4db40e2602 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sat, 5 Nov 2022 13:53:40 +0100 Subject: [PATCH] Fix suggestLogging property not working for eventTypes --- libnymea/integrations/pluginmetadata.cpp | 14 +++++++++++--- libnymea/types/actiontype.cpp | 12 ------------ libnymea/types/actiontype.h | 3 --- libnymea/types/eventtype.cpp | 12 ------------ libnymea/types/eventtype.h | 3 --- 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/libnymea/integrations/pluginmetadata.cpp b/libnymea/integrations/pluginmetadata.cpp index c34eca98..4e13684b 100644 --- a/libnymea/integrations/pluginmetadata.cpp +++ b/libnymea/integrations/pluginmetadata.cpp @@ -533,7 +533,10 @@ void PluginMetadata::parse(const QJsonObject &jsonObject) index = 0; foreach (const QJsonValue &actionTypesJson, thingClassObject.value("actionTypes").toArray()) { QJsonObject at = actionTypesJson.toObject(); - QPair verificationResult = verifyFields(ActionType::typeProperties(), ActionType::mandatoryTypeProperties(), at); + + QStringList actionTypeProperties = {"id", "name", "displayName", "paramTypes"}; + QStringList mandatoryActionTypeProperties = {"id", "name", "displayName"}; + QPair verificationResult = verifyFields(actionTypeProperties, mandatoryActionTypeProperties, at); // Check mandatory fields if (!verificationResult.first.isEmpty()) { @@ -580,7 +583,10 @@ void PluginMetadata::parse(const QJsonObject &jsonObject) foreach (const QJsonValue &eventTypesJson, thingClassObject.value("eventTypes").toArray()) { QJsonObject et = eventTypesJson.toObject(); - QPair verificationResult = verifyFields(EventType::typeProperties(), EventType::mandatoryTypeProperties(), et); + QStringList eventTypeProperties = {"id", "name", "displayName", "paramTypes", "suggestLogging"}; + QStringList mandatoryEventTypeProperties = {"id", "name", "displayName"}; + + QPair verificationResult = verifyFields(eventTypeProperties, mandatoryEventTypeProperties, et); // Check mandatory fields if (!verificationResult.first.isEmpty()) { @@ -625,7 +631,9 @@ void PluginMetadata::parse(const QJsonObject &jsonObject) index = 0; foreach (const QJsonValue &browserItemActionTypesJson, thingClassObject.value("browserItemActionTypes").toArray()) { QJsonObject at = browserItemActionTypesJson.toObject(); - QPair verificationResult = verifyFields(ActionType::typeProperties(), ActionType::mandatoryTypeProperties(), at); + QStringList actionTypeProperties = {"id", "name", "displayName", "paramTypes"}; + QStringList mandatoryActionTypeProperties = {"id", "name", "displayName"}; + QPair verificationResult = verifyFields(actionTypeProperties, mandatoryActionTypeProperties, at); // Check mandatory fields if (!verificationResult.first.isEmpty()) { diff --git a/libnymea/types/actiontype.cpp b/libnymea/types/actiontype.cpp index 6afbf15f..8014be79 100644 --- a/libnymea/types/actiontype.cpp +++ b/libnymea/types/actiontype.cpp @@ -111,18 +111,6 @@ void ActionType::setParamTypes(const ParamTypes ¶mTypes) m_paramTypes = paramTypes; } -/*! Returns a list of all valid properties a ActionType definition can have. */ -QStringList ActionType::typeProperties() -{ - return QStringList() << "id" << "name" << "displayName" << "paramTypes"; -} - -/*! Returns a list of mandatory properties a ActionType definition must have. */ -QStringList ActionType::mandatoryTypeProperties() -{ - return QStringList() << "id" << "name" << "displayName"; -} - ActionTypes::ActionTypes(const QList &other) { foreach (const ActionType &at, other) { diff --git a/libnymea/types/actiontype.h b/libnymea/types/actiontype.h index 9a216ab2..779609f9 100644 --- a/libnymea/types/actiontype.h +++ b/libnymea/types/actiontype.h @@ -63,9 +63,6 @@ public: ParamTypes paramTypes() const; void setParamTypes(const ParamTypes ¶mTypes); - static QStringList typeProperties(); - static QStringList mandatoryTypeProperties(); - private: ActionTypeId m_id; QString m_name; diff --git a/libnymea/types/eventtype.cpp b/libnymea/types/eventtype.cpp index 42e589bb..750c7959 100644 --- a/libnymea/types/eventtype.cpp +++ b/libnymea/types/eventtype.cpp @@ -126,18 +126,6 @@ bool EventType::isValid() const return !m_id.isNull() && !m_name.isEmpty(); } -/*! Returns a list of all valid JSON properties a EventType JSON definition can have. */ -QStringList EventType::typeProperties() -{ - return QStringList() << "id" << "name" << "displayName" << "paramTypes"; -} - -/*! Returns a list of mandatory JSON properties a EventType JSON definition must have. */ -QStringList EventType::mandatoryTypeProperties() -{ - return QStringList() << "id" << "name" << "displayName"; -} - EventTypes::EventTypes(const QList &other) { foreach (const EventType &et, other) { diff --git a/libnymea/types/eventtype.h b/libnymea/types/eventtype.h index 237bb9bb..d32fd46b 100644 --- a/libnymea/types/eventtype.h +++ b/libnymea/types/eventtype.h @@ -69,9 +69,6 @@ public: bool isValid() const; - static QStringList typeProperties(); - static QStringList mandatoryTypeProperties(); - private: EventTypeId m_id; QString m_name;