diff --git a/doc/plugin-json.qdoc b/doc/plugin-json.qdoc index 710255d0..3e01b7b4 100644 --- a/doc/plugin-json.qdoc +++ b/doc/plugin-json.qdoc @@ -180,11 +180,11 @@ \li - \underline{\e name:} The visible name of the \l{DeviceClass} \unicode{0x2192} \l{DeviceClass::name()} \li - \underline{\e idName:} This parameter will be used to define the DeviceClassId variable named DeviceClassId in the plugininfo.h, so it can be used in the code. \li - \underline{\e deviceClassesId:} The actual uuid (\l{DeviceClassId}) of the \l{DeviceClass} \unicode{0x2192} \l{DeviceClass::id()}. - \li - \underline{\e basicTags:} A list of \l{Types::BasicTag}{BasicTags} for this device \unicode{0x2192} \l{DeviceClass::basicTags()}. A \l{DeviceClass} can have multiple \l{Types::BasicTag}{BasicTags} which describe the basic category of the DeviceClass. A \l{DeviceClass} should be eighter a Service or a Device, never both. See enum \l{Types::BasicTag} for more information. The expected value for the \e basicTags parameters matches the enum name like this: + \li - \underline{\e basicTags:} A list of \l{DeviceClass::BasicTag}{BasicTags} for this device \unicode{0x2192} \l{DeviceClass::basicTags()}. A \l{DeviceClass} can have multiple \l{DeviceClass::BasicTag}{BasicTags} which describe the basic category of the DeviceClass. A \l{DeviceClass} should be eighter a Service or a Device, never both. See enum \l{DeviceClass::BasicTag} for more information. The expected value for the \e basicTags parameters matches the enum name like this: - \tt {Types::BasicTagService} \unicode{0x2192} \tt {"basicTags": [ "Service" ]} + \tt {DeviceClass::BasicTagService} \unicode{0x2192} \tt {"basicTags": [ "Service" ]} - \tt {Types::BasicTagLighting} \unicode{0x2192} \tt {"basicTags": [ "Lighting" ]} + \tt {DeviceClass::BasicTagLighting} \unicode{0x2192} \tt {"basicTags": [ "Lighting" ]} \tt ... diff --git a/doc/typeutils.qdoc b/doc/typeutils.qdoc index f4da6ab1..ec2fceae 100644 --- a/doc/typeutils.qdoc +++ b/doc/typeutils.qdoc @@ -18,8 +18,6 @@ \li The logical OR \tt | operator for two \l{State}{States} \endtable - - \chapter Types::ValueOperator \table \header @@ -52,6 +50,7 @@ \li The \tt >= operator to compare two \a values of a \l{Param}. \endtable + \chapter Types::InputType \table \header @@ -100,88 +99,6 @@ \li The \l{ParamType} indicates that a MAC hardware address is requested as \l{Types::InputType}{InputType}. \endtable - - \chapter Types::BasicTag - A \l{DeviceClass} can have multiple \l{Types::BasicTag}{BasicTags} which describe the basic category of the DeviceClass. A \l{DeviceClass} should be at least a \tt Service or a \tt Device, never both. - \table - \header - \li Constant - \li Value - \li Description - \row - \li Types::BasicTagService - \li 0 - \li The \l{DeviceClass} describes a service. - \row - \li Types::BasicTagDevice - \li 1 - \li The \l{DeviceClass} describes a real device. - \row - \li Types::BasicTagSensor - \li 2 - \li The \l{DeviceClass} describes a sensor. Any device which can measure or detect something is a sensor. - \row - \li Types::BasicTagActuator - \li 3 - \li The \l{DeviceClass} describes an actuator. Any device which can do something is an actuator. - \row - \li Types::BasicTagLighting - \li 4 - \li The \l{DeviceClass} describes a lighting device. - \row - \li Types::BasicTagEnergy - \li 5 - \li The \l{DeviceClass} describes an energy device. - \row - \li Types::BasicTagMultimedia - \li 6 - \li The \l{DeviceClass} describes a multimedia device. - \row - \li Types::BasicTagWeather - \li 7 - \li The \l{DeviceClass} describes a weather service/device. - \row - \li Types::BasicTagGateway - \li 8 - \li The \l{DeviceClass} describes a gateway device. - \row - \li Types::BasicTagHeating - \li 9 - \li The \l{DeviceClass} describes a heating device. - \row - \li Types::BasicTagCooling - \li 10 - \li The \l{DeviceClass} describes a cooling device. - \row - \li Types::BasicTagNotification - \li 11 - \li The \l{DeviceClass} describes a notification device/service. - \row - \li Types::BasicTagSecurity - \li 12 - \li The \l{DeviceClass} describes a security device/service. - \row - \li Types::BasicTagTime - \li 13 - \li The \l{DeviceClass} describes a time device/service. - \row - \li Types::BasicTagShading - \li 14 - \li The \l{DeviceClass} describes a shading device. - \row - \li Types::BasicTagAppliance - \li 15 - \li The \l{DeviceClass} describes an appliance. - \row - \li Types::BasicTagCamera - \li 16 - \li The \l{DeviceClass} describes a camera device. - \row - \li Types::BasicTagLock - \li 17 - \li The \l{DeviceClass} describes a lock device. - \endtable - \chapter Types::Unit \table \header diff --git a/libguh/plugin/deviceclass.cpp b/libguh/plugin/deviceclass.cpp index b9d87b3f..f1f11174 100644 --- a/libguh/plugin/deviceclass.cpp +++ b/libguh/plugin/deviceclass.cpp @@ -60,6 +60,50 @@ During the setup, a button has to be pushed in order to pair the \l{Device}. */ +/*! \enum DeviceClass::BasicTag + + This enum type specifies the basic tags which describe the categories of the DeviceClass. + A DeviceClass can have multiple tags. + + \value BasicTagService + The \l{DeviceClass} describes a service. + \value BasicTagDevice + The \l{DeviceClass} describes a real device. + \value BasicTagSensor + The \l{DeviceClass} describes a sensor. Any device which can measure or detect something is a sensor. + \value BasicTagActuator + The \l{DeviceClass} describes an actuator. Any device which can do something is an actuator. + \value BasicTagLighting + The \l{DeviceClass} describes a lighting device. + \value BasicTagEnergy + The \l{DeviceClass} describes an energy device. + \value BasicTagMultimedia + The \l{DeviceClass} describes a multimedia device/service. + \value BasicTagWeather + The \l{DeviceClass} describes a weather device/service. + \value BasicTagGateway + The \l{DeviceClass} describes a gateway device. + \value BasicTagHeating + The \l{DeviceClass} describes a heating device. + \value BasicTagCooling + The \l{DeviceClass} describes a cooling device. + \value BasicTagNotification + The \l{DeviceClass} describes a notification service. + \value BasicTagSecurity + The \l{DeviceClass} describes a security device/service. + \value BasicTagTime + The \l{DeviceClass} describes a time device/service. + \value BasicTagShading + The \l{DeviceClass} describes a shading device. + \value BasicTagAppliance + The \l{DeviceClass} describes an appliance. + \value BasicTagCamera + The \l{DeviceClass} describes a camera device. + \value BasicTagLock + The \l{DeviceClass} describes a lock device. + +*/ + #include "deviceclass.h" /*! Constructs a DeviceClass with the give \a pluginId ,\a vendorId and \a id . @@ -113,18 +157,18 @@ void DeviceClass::setName(const QString &name) /*! Returns the list of basicTags of this DeviceClass. - \sa Types::BasicTag + \sa DeviceClass::BasicTag */ -QList DeviceClass::basicTags() const +QList DeviceClass::basicTags() const { return m_basicTags; } /*! Set the list of \a basicTags of this DeviceClass. - \sa Types::BasicTag + \sa DeviceClass::BasicTag */ -void DeviceClass::setBasicTags(const QList &basicTags) +void DeviceClass::setBasicTags(const QList &basicTags) { m_basicTags = basicTags; } diff --git a/libguh/plugin/deviceclass.h b/libguh/plugin/deviceclass.h index 294669be..a92cf50b 100644 --- a/libguh/plugin/deviceclass.h +++ b/libguh/plugin/deviceclass.h @@ -37,6 +37,8 @@ class DeviceClass Q_GADGET Q_ENUMS(CreateMethod) Q_ENUMS(SetupMethod) + Q_ENUMS(BasicTag) + public: enum CreateMethod { CreateMethodUser = 0x01, @@ -52,6 +54,28 @@ public: SetupMethodPushButton }; + enum BasicTag { + BasicTagService, + BasicTagDevice, + BasicTagSensor, + BasicTagActuator, + BasicTagLighting, + BasicTagEnergy, + BasicTagMultimedia, + BasicTagWeather, + BasicTagGateway, + BasicTagHeating, + BasicTagCooling, + BasicTagNotification, + BasicTagSecurity, + BasicTagTime, + BasicTagShading, + BasicTagAppliance, + BasicTagCamera, + BasicTagLock + }; + + DeviceClass(const PluginId &pluginId = PluginId(), const VendorId &vendorId = VendorId(), const DeviceClassId &id = DeviceClassId()); DeviceClassId id() const; @@ -62,8 +86,8 @@ public: QString name() const; void setName(const QString &name); - QList basicTags() const; - void setBasicTags(const QList &basicTags); + QList basicTags() const; + void setBasicTags(const QList &basicTags); QList stateTypes() const; void setStateTypes(const QList &stateTypes); @@ -99,7 +123,7 @@ private: VendorId m_vendorId; PluginId m_pluginId; QString m_name; - QList m_basicTags; + QList m_basicTags; QList m_stateTypes; QList m_eventTypes; QList m_allEventTypes; diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index 2feb9c67..18da0649 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -234,7 +234,7 @@ QList DevicePlugin::supportedDevices() const deviceClass.setPairingInfo(jo.value("pairingInfo").toString()); deviceClass.setParamTypes(parseParamTypes(jo.value("paramTypes").toArray())); - QList basicTags; + QList basicTags; foreach (const QJsonValue &basicTagJson, jo.value("basicTags").toArray()) { basicTags.append(basicTagStringToBasicTag(basicTagJson.toString())); } @@ -812,47 +812,47 @@ Types::InputType DevicePlugin::inputTypeStringToInputType(const QString &inputTy return Types::InputTypeNone; } -Types::BasicTag DevicePlugin::basicTagStringToBasicTag(const QString &basicTag) const +DeviceClass::BasicTag DevicePlugin::basicTagStringToBasicTag(const QString &basicTag) const { if (basicTag == "Device") { - return Types::BasicTagDevice; + return DeviceClass::BasicTagDevice; } else if (basicTag == "Service") { - return Types::BasicTagService; + return DeviceClass::BasicTagService; } else if (basicTag == "Actuator") { - return Types::BasicTagActuator; + return DeviceClass::BasicTagActuator; } else if (basicTag == "Sensor") { - return Types::BasicTagSensor; + return DeviceClass::BasicTagSensor; } else if (basicTag == "Lighting") { - return Types::BasicTagLighting; + return DeviceClass::BasicTagLighting; } else if (basicTag == "Energy") { - return Types::BasicTagEnergy; + return DeviceClass::BasicTagEnergy; } else if (basicTag == "Multimedia") { - return Types::BasicTagMultimedia; + return DeviceClass::BasicTagMultimedia; } else if (basicTag == "Weather") { - return Types::BasicTagWeather; + return DeviceClass::BasicTagWeather; } else if (basicTag == "Gateway") { - return Types::BasicTagGateway; + return DeviceClass::BasicTagGateway; } else if (basicTag == "Heating") { - return Types::BasicTagHeating; + return DeviceClass::BasicTagHeating; } else if (basicTag == "Cooling") { - return Types::BasicTagCooling; + return DeviceClass::BasicTagCooling; } else if (basicTag == "Notification") { - return Types::BasicTagNotification; + return DeviceClass::BasicTagNotification; } else if (basicTag == "Security") { - return Types::BasicTagSecurity; + return DeviceClass::BasicTagSecurity; } else if (basicTag == "Time") { - return Types::BasicTagTime; + return DeviceClass::BasicTagTime; } else if (basicTag == "Shading") { - return Types::BasicTagShading; + return DeviceClass::BasicTagShading; } else if (basicTag == "Appliance") { - return Types::BasicTagAppliance; + return DeviceClass::BasicTagAppliance; } else if (basicTag == "Camera") { - return Types::BasicTagCamera; + return DeviceClass::BasicTagCamera; } else if (basicTag == "Lock") { - return Types::BasicTagLock; + return DeviceClass::BasicTagLock; } else { qCWarning(dcDeviceManager) << "Could not parse basicTag:" << basicTag << "in plugin" << this->pluginName(); } - return Types::BasicTagDevice; + return DeviceClass::BasicTagDevice; } diff --git a/libguh/plugin/deviceplugin.h b/libguh/plugin/deviceplugin.h index 6bf8d112..fc7b709d 100644 --- a/libguh/plugin/deviceplugin.h +++ b/libguh/plugin/deviceplugin.h @@ -128,7 +128,7 @@ private: Types::Unit unitStringToUnit(const QString &unitString) const; Types::InputType inputTypeStringToInputType(const QString &inputType) const; - Types::BasicTag basicTagStringToBasicTag(const QString &basicTag) const; + DeviceClass::BasicTag basicTagStringToBasicTag(const QString &basicTag) const; DeviceManager *m_deviceManager; diff --git a/libguh/typeutils.h b/libguh/typeutils.h index 97e893c5..3a8453f9 100644 --- a/libguh/typeutils.h +++ b/libguh/typeutils.h @@ -59,7 +59,6 @@ class Types { Q_GADGET Q_ENUMS(InputType) - Q_ENUMS(BasicTag) Q_ENUMS(Unit) Q_ENUMS(StateOperator) Q_ENUMS(ValueOperator) @@ -78,27 +77,6 @@ public: InputTypeMacAddress }; - enum BasicTag { - BasicTagService, - BasicTagDevice, - BasicTagSensor, - BasicTagActuator, - BasicTagLighting, - BasicTagEnergy, - BasicTagMultimedia, - BasicTagWeather, - BasicTagGateway, - BasicTagHeating, - BasicTagCooling, - BasicTagNotification, - BasicTagSecurity, - BasicTagTime, - BasicTagShading, - BasicTagAppliance, - BasicTagCamera, - BasicTagLock - }; - enum Unit { UnitNone, UnitSeconds, @@ -161,7 +139,6 @@ public: Q_DECLARE_METATYPE(Types::InputType) Q_DECLARE_METATYPE(Types::Unit) -Q_DECLARE_METATYPE(Types::BasicTag) Q_DECLARE_METATYPE(Types::ValueOperator) Q_DECLARE_METATYPE(Types::StateOperator) diff --git a/server/jsonrpc/jsontypes.cpp b/server/jsonrpc/jsontypes.cpp index a8067e2c..fa98411b 100644 --- a/server/jsonrpc/jsontypes.cpp +++ b/server/jsonrpc/jsontypes.cpp @@ -80,7 +80,7 @@ void JsonTypes::init() { // BasicTypes s_basicType = enumToStrings(JsonTypes::staticMetaObject, "BasicType"); - s_basicTag = enumToStrings(Types::staticMetaObject, "BasicTag"); + s_basicTag = enumToStrings(DeviceClass::staticMetaObject, "BasicTag"); s_stateOperator = enumToStrings(Types::staticMetaObject, "StateOperator"); s_valueOperator = enumToStrings(Types::staticMetaObject, "ValueOperator"); s_inputType = enumToStrings(Types::staticMetaObject, "InputType"); @@ -522,7 +522,7 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass) variant.insert("vendorId", deviceClass.vendorId()); QVariantList basicTags; - foreach (const Types::BasicTag &basicTag, deviceClass.basicTags()) { + foreach (const DeviceClass::BasicTag &basicTag, deviceClass.basicTags()) { basicTags.append(s_basicTag.at(basicTag)); } QVariantList stateTypes; diff --git a/server/jsonrpc/jsontypes.h b/server/jsonrpc/jsontypes.h index d0ac1123..2e86b5b3 100644 --- a/server/jsonrpc/jsontypes.h +++ b/server/jsonrpc/jsontypes.h @@ -100,7 +100,7 @@ public: static QVariantMap allTypes(); DECLARE_TYPE(basicType, "BasicType", JsonTypes, BasicType) - DECLARE_TYPE(basicTag, "BasicTag", Types, BasicTag) + DECLARE_TYPE(basicTag, "BasicTag", DeviceClass, BasicTag) DECLARE_TYPE(stateOperator, "StateOperator", Types, StateOperator) DECLARE_TYPE(valueOperator, "ValueOperator", Types, ValueOperator) DECLARE_TYPE(inputType, "InputType", Types, InputType)