Add a providedInterfaces property to thingClass
This commit is contained in:
parent
249393241c
commit
f2898b9fc8
@ -202,7 +202,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
|||||||
QJsonObject thingClassObject = thingClassJson.toObject();
|
QJsonObject thingClassObject = thingClassJson.toObject();
|
||||||
/*! Returns a list of all valid JSON properties a ThingClass JSON definition can have. */
|
/*! Returns a list of all valid JSON properties a ThingClass JSON definition can have. */
|
||||||
QStringList thingClassProperties = QStringList() << "id" << "name" << "displayName" << "createMethods" << "setupMethod"
|
QStringList thingClassProperties = QStringList() << "id" << "name" << "displayName" << "createMethods" << "setupMethod"
|
||||||
<< "interfaces" << "browsable" << "discoveryParamTypes"
|
<< "interfaces" << "providedInterfaces" << "browsable" << "discoveryParamTypes"
|
||||||
<< "paramTypes" << "settingsTypes" << "stateTypes" << "actionTypes" << "eventTypes" << "browserItemActionTypes";
|
<< "paramTypes" << "settingsTypes" << "stateTypes" << "actionTypes" << "eventTypes" << "browserItemActionTypes";
|
||||||
QStringList mandatoryThingClassProperties = QStringList() << "id" << "name" << "displayName";
|
QStringList mandatoryThingClassProperties = QStringList() << "id" << "name" << "displayName";
|
||||||
|
|
||||||
@ -870,6 +870,19 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
|||||||
interfaces.removeDuplicates();
|
interfaces.removeDuplicates();
|
||||||
thingClass.setInterfaces(interfaces);
|
thingClass.setInterfaces(interfaces);
|
||||||
|
|
||||||
|
QStringList providedInterfaces;
|
||||||
|
foreach (const QJsonValue &value, thingClassObject.value("providedInterfaces").toArray()) {
|
||||||
|
Interface iface = ThingUtils::loadInterface(value.toString());
|
||||||
|
if (!iface.isValid()) {
|
||||||
|
m_validationErrors.append("Thing class \"" + thingClass.name() + "\" uses non-existing interface \"" + value.toString() + "\" in providedInterfaces.");
|
||||||
|
hasError = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
providedInterfaces.append(iface.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
thingClass.setProvidedInterfaces(providedInterfaces);
|
||||||
|
|
||||||
thingClass.setStateTypes(stateTypes);
|
thingClass.setStateTypes(stateTypes);
|
||||||
thingClass.setActionTypes(actionTypes);
|
thingClass.setActionTypes(actionTypes);
|
||||||
thingClass.setEventTypes(eventTypes);
|
thingClass.setEventTypes(eventTypes);
|
||||||
|
|||||||
@ -357,6 +357,23 @@ void ThingClass::setInterfaces(const QStringList &interfaces)
|
|||||||
m_interfaces = interfaces;
|
m_interfaces = interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Returns the interfaces that a thing does not directly implement, but it may still cater for
|
||||||
|
them by creating childs that do implement those. This is used as a hint for clients to
|
||||||
|
filter for desired interfaces during thing setup.
|
||||||
|
*/
|
||||||
|
QStringList ThingClass::providedInterfaces() const
|
||||||
|
{
|
||||||
|
return m_providedInterfaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Set the list of provided interfaces. This list should contain interfaces for things that
|
||||||
|
may be created as childs of this thing class.
|
||||||
|
*/
|
||||||
|
void ThingClass::setProvidedInterfaces(const QStringList &providedInterfaces)
|
||||||
|
{
|
||||||
|
m_providedInterfaces = providedInterfaces;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns whether \l{Device}{Devices} created from this \l{DeviceClass} are browsable */
|
/*! Returns whether \l{Device}{Devices} created from this \l{DeviceClass} are browsable */
|
||||||
bool ThingClass::browsable() const
|
bool ThingClass::browsable() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,6 +51,7 @@ class LIBNYMEA_EXPORT ThingClass
|
|||||||
Q_PROPERTY(QString name READ name)
|
Q_PROPERTY(QString name READ name)
|
||||||
Q_PROPERTY(QString displayName READ displayName)
|
Q_PROPERTY(QString displayName READ displayName)
|
||||||
Q_PROPERTY(QStringList interfaces READ interfaces)
|
Q_PROPERTY(QStringList interfaces READ interfaces)
|
||||||
|
Q_PROPERTY(QStringList providedInterfaces READ providedInterfaces)
|
||||||
Q_PROPERTY(bool browsable READ browsable)
|
Q_PROPERTY(bool browsable READ browsable)
|
||||||
Q_PROPERTY(SetupMethod setupMethod READ setupMethod)
|
Q_PROPERTY(SetupMethod setupMethod READ setupMethod)
|
||||||
Q_PROPERTY(CreateMethods createMethods READ createMethods)
|
Q_PROPERTY(CreateMethods createMethods READ createMethods)
|
||||||
@ -136,6 +137,9 @@ public:
|
|||||||
QStringList interfaces() const;
|
QStringList interfaces() const;
|
||||||
void setInterfaces(const QStringList &interfaces);
|
void setInterfaces(const QStringList &interfaces);
|
||||||
|
|
||||||
|
QStringList providedInterfaces() const;
|
||||||
|
void setProvidedInterfaces(const QStringList &providedInterfaces);
|
||||||
|
|
||||||
bool operator==(const ThingClass &device) const;
|
bool operator==(const ThingClass &device) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -155,6 +159,7 @@ private:
|
|||||||
CreateMethods m_createMethods;
|
CreateMethods m_createMethods;
|
||||||
SetupMethod m_setupMethod;
|
SetupMethod m_setupMethod;
|
||||||
QStringList m_interfaces;
|
QStringList m_interfaces;
|
||||||
|
QStringList m_providedInterfaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ThingClass::CreateMethods)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(ThingClass::CreateMethods)
|
||||||
|
|||||||
@ -5,7 +5,7 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"
|
|||||||
|
|
||||||
# define protocol versions
|
# define protocol versions
|
||||||
JSON_PROTOCOL_VERSION_MAJOR=5
|
JSON_PROTOCOL_VERSION_MAJOR=5
|
||||||
JSON_PROTOCOL_VERSION_MINOR=7
|
JSON_PROTOCOL_VERSION_MINOR=8
|
||||||
JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}"
|
JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}"
|
||||||
LIBNYMEA_API_VERSION_MAJOR=7
|
LIBNYMEA_API_VERSION_MAJOR=7
|
||||||
LIBNYMEA_API_VERSION_MINOR=2
|
LIBNYMEA_API_VERSION_MINOR=2
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
5.7
|
5.8
|
||||||
{
|
{
|
||||||
"enums": {
|
"enums": {
|
||||||
"BasicType": [
|
"BasicType": [
|
||||||
@ -2788,6 +2788,7 @@
|
|||||||
"r:name": "String",
|
"r:name": "String",
|
||||||
"r:paramTypes": "$ref:ParamTypes",
|
"r:paramTypes": "$ref:ParamTypes",
|
||||||
"r:pluginId": "Uuid",
|
"r:pluginId": "Uuid",
|
||||||
|
"r:providedInterfaces": "StringList",
|
||||||
"r:settingsTypes": "$ref:ParamTypes",
|
"r:settingsTypes": "$ref:ParamTypes",
|
||||||
"r:setupMethod": "$ref:SetupMethod",
|
"r:setupMethod": "$ref:SetupMethod",
|
||||||
"r:stateTypes": "$ref:StateTypes",
|
"r:stateTypes": "$ref:StateTypes",
|
||||||
@ -3127,6 +3128,7 @@
|
|||||||
"r:name": "String",
|
"r:name": "String",
|
||||||
"r:paramTypes": "$ref:ParamTypes",
|
"r:paramTypes": "$ref:ParamTypes",
|
||||||
"r:pluginId": "Uuid",
|
"r:pluginId": "Uuid",
|
||||||
|
"r:providedInterfaces": "StringList",
|
||||||
"r:settingsTypes": "$ref:ParamTypes",
|
"r:settingsTypes": "$ref:ParamTypes",
|
||||||
"r:setupMethod": "$ref:SetupMethod",
|
"r:setupMethod": "$ref:SetupMethod",
|
||||||
"r:stateTypes": "$ref:StateTypes",
|
"r:stateTypes": "$ref:StateTypes",
|
||||||
|
|||||||
@ -7,7 +7,7 @@ packagesExist(Qt5SerialBus) {
|
|||||||
DEFINES += WITH_QTSERIALBUS
|
DEFINES += WITH_QTSERIALBUS
|
||||||
}
|
}
|
||||||
|
|
||||||
PKGCONFIG += nymea-zigbee
|
PKGCONFIG += nymea-zigbee nymea-networkmanager
|
||||||
|
|
||||||
INCLUDEPATH += $$top_srcdir/libnymea \
|
INCLUDEPATH += $$top_srcdir/libnymea \
|
||||||
$$top_srcdir/libnymea-core \
|
$$top_srcdir/libnymea-core \
|
||||||
|
|||||||
Reference in New Issue
Block a user