mirror of https://github.com/nymea/nymea.git
Merge PR #483: Add a providedInterfaces property to thingClass
commit
3d5c9b477b
|
|
@ -202,7 +202,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
|||
QJsonObject thingClassObject = thingClassJson.toObject();
|
||||
/*! Returns a list of all valid JSON properties a ThingClass JSON definition can have. */
|
||||
QStringList thingClassProperties = QStringList() << "id" << "name" << "displayName" << "createMethods" << "setupMethod"
|
||||
<< "interfaces" << "browsable" << "discoveryParamTypes"
|
||||
<< "interfaces" << "providedInterfaces" << "browsable" << "discoveryParamTypes"
|
||||
<< "paramTypes" << "settingsTypes" << "stateTypes" << "actionTypes" << "eventTypes" << "browserItemActionTypes";
|
||||
QStringList mandatoryThingClassProperties = QStringList() << "id" << "name" << "displayName";
|
||||
|
||||
|
|
@ -870,6 +870,19 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
|||
interfaces.removeDuplicates();
|
||||
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.setActionTypes(actionTypes);
|
||||
thingClass.setEventTypes(eventTypes);
|
||||
|
|
|
|||
|
|
@ -357,6 +357,23 @@ void ThingClass::setInterfaces(const QStringList &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 */
|
||||
bool ThingClass::browsable() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class LIBNYMEA_EXPORT ThingClass
|
|||
Q_PROPERTY(QString name READ name)
|
||||
Q_PROPERTY(QString displayName READ displayName)
|
||||
Q_PROPERTY(QStringList interfaces READ interfaces)
|
||||
Q_PROPERTY(QStringList providedInterfaces READ providedInterfaces)
|
||||
Q_PROPERTY(bool browsable READ browsable)
|
||||
Q_PROPERTY(SetupMethod setupMethod READ setupMethod)
|
||||
Q_PROPERTY(CreateMethods createMethods READ createMethods)
|
||||
|
|
@ -136,6 +137,9 @@ public:
|
|||
QStringList interfaces() const;
|
||||
void setInterfaces(const QStringList &interfaces);
|
||||
|
||||
QStringList providedInterfaces() const;
|
||||
void setProvidedInterfaces(const QStringList &providedInterfaces);
|
||||
|
||||
bool operator==(const ThingClass &device) const;
|
||||
|
||||
private:
|
||||
|
|
@ -155,6 +159,7 @@ private:
|
|||
CreateMethods m_createMethods;
|
||||
SetupMethod m_setupMethod;
|
||||
QStringList m_interfaces;
|
||||
QStringList m_providedInterfaces;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ThingClass::CreateMethods)
|
||||
|
|
|
|||
|
|
@ -2794,6 +2794,7 @@
|
|||
"r:name": "String",
|
||||
"r:paramTypes": "$ref:ParamTypes",
|
||||
"r:pluginId": "Uuid",
|
||||
"r:providedInterfaces": "StringList",
|
||||
"r:settingsTypes": "$ref:ParamTypes",
|
||||
"r:setupMethod": "$ref:SetupMethod",
|
||||
"r:stateTypes": "$ref:StateTypes",
|
||||
|
|
@ -3135,6 +3136,7 @@
|
|||
"r:name": "String",
|
||||
"r:paramTypes": "$ref:ParamTypes",
|
||||
"r:pluginId": "Uuid",
|
||||
"r:providedInterfaces": "StringList",
|
||||
"r:settingsTypes": "$ref:ParamTypes",
|
||||
"r:setupMethod": "$ref:SetupMethod",
|
||||
"r:stateTypes": "$ref:StateTypes",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ packagesExist(Qt5SerialBus) {
|
|||
DEFINES += WITH_QTSERIALBUS
|
||||
}
|
||||
|
||||
PKGCONFIG += nymea-zigbee
|
||||
PKGCONFIG += nymea-zigbee nymea-networkmanager
|
||||
|
||||
INCLUDEPATH += $$top_srcdir/libnymea \
|
||||
$$top_srcdir/libnymea-core \
|
||||
|
|
|
|||
Loading…
Reference in New Issue