diff --git a/libnymea-core/jsonrpc/actionhandler.cpp b/libnymea-core/jsonrpc/actionhandler.cpp index 9d63e618..e981dda4 100644 --- a/libnymea-core/jsonrpc/actionhandler.cpp +++ b/libnymea-core/jsonrpc/actionhandler.cpp @@ -64,7 +64,7 @@ ActionHandler::ActionHandler(QObject *parent) : description = "Execute a single action."; params.insert("actionTypeId", enumValueName(Uuid)); params.insert("deviceId", enumValueName(Uuid)); - params.insert("o:params", QVariantList() << objectRef("Param")); + params.insert("o:params", objectRef()); returns.insert("deviceError", enumRef()); returns.insert("o:displayMessage", enumValueName(String)); registerMethod("ExecuteAction", description, params, returns); @@ -73,7 +73,7 @@ ActionHandler::ActionHandler(QObject *parent) : description = "Get the ActionType for the given ActionTypeId"; params.insert("actionTypeId", enumValueName(Uuid)); returns.insert("deviceError", enumRef()); - returns.insert("o:actionType", objectRef("ActionType")); + returns.insert("o:actionType", objectRef()); registerMethod("GetActionType", description, params, returns); params.clear(); returns.clear(); @@ -88,7 +88,7 @@ ActionHandler::ActionHandler(QObject *parent) : params.insert("deviceId", enumValueName(Uuid)); params.insert("itemId", enumValueName(String)); params.insert("actionTypeId", enumValueName(Uuid)); - params.insert("o:params", QVariantList() << objectRef("Param")); + params.insert("o:params", objectRef()); returns.insert("deviceError", enumRef()); registerMethod("ExecuteBrowserItemAction", description, params, returns); diff --git a/libnymea-core/jsonrpc/configurationhandler.cpp b/libnymea-core/jsonrpc/configurationhandler.cpp index 92b3b0eb..faf2ebff 100644 --- a/libnymea-core/jsonrpc/configurationhandler.cpp +++ b/libnymea-core/jsonrpc/configurationhandler.cpp @@ -98,16 +98,16 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): basicConfiguration.insert("debugServerEnabled", enumValueName(Bool)); returns.insert("basicConfiguration", basicConfiguration); QVariantList tcpServerConfigurations; - tcpServerConfigurations.append(objectRef("ServerConfiguration")); + tcpServerConfigurations.append(objectRef()); returns.insert("tcpServerConfigurations", tcpServerConfigurations); QVariantList webServerConfigurations; - webServerConfigurations.append(objectRef("WebServerConfiguration")); + webServerConfigurations.append(objectRef()); returns.insert("webServerConfigurations", webServerConfigurations); QVariantList webSocketServerConfigurations; - webSocketServerConfigurations.append(objectRef("ServerConfiguration")); + webSocketServerConfigurations.append(objectRef()); returns.insert("webSocketServerConfigurations", webSocketServerConfigurations); QVariantList mqttServerConfigurations; - mqttServerConfigurations.append(objectRef("ServerConfiguration")); + mqttServerConfigurations.append(objectRef()); QVariantMap cloudConfiguration; cloudConfiguration.insert("enabled", enumValueName(Bool)); returns.insert("cloud", cloudConfiguration); @@ -139,7 +139,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Configure a TCP interface of the server. If the ID is an existing one, the existing config will be modified, otherwise a new one will be added. Note: if you are changing the configuration for the interface you are currently connected to, the connection will be dropped."; - params.insert("configuration", objectRef("ServerConfiguration")); + params.insert("configuration", objectRef()); returns.insert("configurationError", enumRef()); registerMethod("SetTcpServerConfiguration", description, params, returns); @@ -151,7 +151,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Configure a WebSocket Server interface of the server. If the ID is an existing one, the existing config will be modified, otherwise a new one will be added. Note: if you are changing the configuration for the interface you are currently connected to, the connection will be dropped."; - params.insert("configuration", objectRef("ServerConfiguration")); + params.insert("configuration", objectRef()); returns.insert("configurationError", enumRef()); registerMethod("SetWebSocketServerConfiguration", description, params, returns); @@ -163,7 +163,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Configure a WebServer interface of the server. If the ID is an existing one, the existing config will be modified, otherwise a new one will be added."; - params.insert("configuration", objectRef("WebServerConfiguration")); + params.insert("configuration", objectRef()); returns.insert("configurationError", enumRef()); registerMethod("SetWebServerConfiguration", description, params, returns); @@ -182,12 +182,12 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): // MQTT params.clear(); returns.clear(); description = "Get all MQTT Server configurations."; - returns.insert("mqttServerConfigurations", QVariantList() << objectRef("ServerConfiguration")); + returns.insert("mqttServerConfigurations", QVariantList() << objectRef()); registerMethod("GetMqttServerConfigurations", description, params, returns); params.clear(); returns.clear(); description = "Configure a MQTT Server interface on the MQTT broker. If the ID is an existing one, the existing config will be modified, otherwise a new one will be added. Setting authenticationEnabled to true will require MQTT clients to use credentials set in the MQTT broker policies."; - params.insert("configuration", objectRef("ServerConfiguration")); + params.insert("configuration", objectRef()); returns.insert("configurationError", enumRef()); registerMethod("SetMqttServerConfiguration", description, params, returns); @@ -199,12 +199,12 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Get all MQTT broker policies."; - returns.insert("mqttPolicies", QVariantList() << objectRef("MqttPolicy")); + returns.insert("mqttPolicies", QVariantList() << objectRef()); registerMethod("GetMqttPolicies", description, params, returns); params.clear(); returns.clear(); description = "Configure a MQTT broker policy. If the ID is an existing one, the existing policy will be modified, otherwise a new one will be added."; - params.insert("policy", objectRef("MqttPolicy")); + params.insert("policy", objectRef()); returns.insert("configurationError", enumRef()); registerMethod("SetMqttPolicy", description, params, returns); @@ -227,7 +227,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Emitted whenever the TCP server configuration changes."; - params.insert("tcpServerConfiguration", objectRef("ServerConfiguration")); + params.insert("tcpServerConfiguration", objectRef()); registerNotification("TcpServerConfigurationChanged", description, params); params.clear(); returns.clear(); @@ -237,7 +237,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Emitted whenever the web socket server configuration changes."; - params.insert("webSocketServerConfiguration", objectRef("ServerConfiguration")); + params.insert("webSocketServerConfiguration", objectRef()); registerNotification("WebSocketServerConfigurationChanged", description, params); params.clear(); returns.clear(); @@ -247,7 +247,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Emitted whenever the MQTT broker configuration is changed."; - params.insert("mqttServerConfiguration", objectRef("ServerConfiguration")); + params.insert("mqttServerConfiguration", objectRef()); registerNotification("MqttServerConfigurationChanged", description, params); params.clear(); returns.clear(); @@ -257,7 +257,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Emitted whenever the web server configuration changes."; - params.insert("webServerConfiguration", objectRef("WebServerConfiguration")); + params.insert("webServerConfiguration", objectRef()); registerNotification("WebServerConfigurationChanged", description, params); params.clear(); returns.clear(); @@ -272,7 +272,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): params.clear(); returns.clear(); description = "Emitted whenever a MQTT broker policy is changed."; - params.insert("policy", objectRef("MqttPolicy")); + params.insert("policy", objectRef()); registerNotification("MqttPolicyChanged", description, params); params.clear(); returns.clear(); diff --git a/libnymea-core/jsonrpc/devicehandler.cpp b/libnymea-core/jsonrpc/devicehandler.cpp index 5fbc2e81..42e51c11 100644 --- a/libnymea-core/jsonrpc/devicehandler.cpp +++ b/libnymea-core/jsonrpc/devicehandler.cpp @@ -90,15 +90,15 @@ DeviceHandler::DeviceHandler(QObject *parent) : // Objects registerObject(); registerObject(); - registerUncreatableObject(); - registerObject(); + registerUncreatableObject(); + registerObject(); registerObject(); registerObject(); registerObject(); - registerObject(); - registerObject(); + registerObject(); + registerObject(); registerObject(); - registerUncreatableObject(); + registerUncreatableObject(); // Regsitering browseritem manually for now. Not sure how to deal with the // polymorphism in int (e.g MediaBrowserItem) @@ -119,31 +119,31 @@ DeviceHandler::DeviceHandler(QObject *parent) : // Methods QString description; QVariantMap returns; QVariantMap params; description = "Returns a list of supported Vendors."; - returns.insert("vendors", QVariantList() << objectRef("Vendor")); + returns.insert("vendors", objectRef()); registerMethod("GetSupportedVendors", description, params, returns); params.clear(); returns.clear(); description = "Returns a list of supported Device classes, optionally filtered by vendorId."; params.insert("o:vendorId", enumValueName(Uuid)); - returns.insert("deviceClasses", QVariantList() << objectRef("DeviceClass")); + returns.insert("deviceClasses", objectRef()); registerMethod("GetSupportedDevices", description, params, returns); params.clear(); returns.clear(); description = "Returns a list of loaded plugins."; - returns.insert("plugins", QVariantList() << objectRef("DevicePlugin")); + returns.insert("plugins", objectRef()); registerMethod("GetPlugins", description, params, returns); params.clear(); returns.clear(); description = "Get a plugin's params."; params.insert("pluginId", enumValueName(Uuid)); returns.insert("deviceError", enumRef()); - returns.insert("o:configuration", QVariantList() << objectRef("Param")); + returns.insert("o:configuration", objectRef()); registerMethod("GetPluginConfiguration", description, params, returns); params.clear(); returns.clear(); description = "Set a plugin's params."; params.insert("pluginId", enumValueName(Uuid)); - params.insert("configuration", QVariantList() << objectRef("Param")); + params.insert("configuration", objectRef()); returns.insert("deviceError", enumRef()); registerMethod("SetPluginConfiguration", description, params, returns); @@ -157,7 +157,7 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.insert("deviceClassId", enumValueName(Uuid)); params.insert("name", enumValueName(String)); params.insert("o:deviceDescriptorId", enumValueName(Uuid)); - params.insert("o:deviceParams", QVariantList() << objectRef("Param")); + params.insert("o:deviceParams", objectRef()); returns.insert("deviceError", enumRef()); returns.insert("o:deviceId", enumValueName(Uuid)); returns.insert("o:displayMessage", enumValueName(String)); @@ -184,7 +184,7 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.insert("o:deviceClassId", enumValueName(Uuid)); params.insert("o:name", enumValueName(String)); params.insert("o:deviceDescriptorId", enumValueName(Uuid)); - params.insert("o:deviceParams", QVariantList() << objectRef("Param")); + params.insert("o:deviceParams", objectRef()); params.insert("o:deviceId", enumValueName(Uuid)); returns.insert("deviceError", enumRef()); returns.insert("o:setupMethod", enumRef()); @@ -210,7 +210,7 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.clear(); returns.clear(); description = "Returns a list of configured devices, optionally filtered by deviceId."; params.insert("o:deviceId", enumValueName(Uuid)); - returns.insert("devices", QVariantList() << objectRef("Device")); + returns.insert("devices", objectRef()); registerMethod("GetConfiguredDevices", description, params, returns); params.clear(); returns.clear(); @@ -220,10 +220,10 @@ DeviceHandler::DeviceHandler(QObject *parent) : "added device. Such results may be used to reconfigure existing devices and might be filtered " "in cases where only unknown devices are of interest."; params.insert("deviceClassId", enumValueName(Uuid)); - params.insert("o:discoveryParams", QVariantList() << objectRef("Param")); + params.insert("o:discoveryParams", objectRef()); returns.insert("deviceError", enumRef()); returns.insert("o:displayMessage", enumValueName(String)); - returns.insert("o:deviceDescriptors", QVariantList() << objectRef("DeviceDescriptor")); + returns.insert("o:deviceDescriptors", objectRef()); registerMethod("GetDiscoveredDevices", description, params, returns); params.clear(); returns.clear(); @@ -236,7 +236,7 @@ DeviceHandler::DeviceHandler(QObject *parent) : "be changed."; params.insert("o:deviceId", enumValueName(Uuid)); params.insert("o:deviceDescriptorId", enumValueName(Uuid)); - params.insert("o:deviceParams", QVariantList() << objectRef("Param")); + params.insert("o:deviceParams", objectRef()); returns.insert("deviceError", enumRef()); returns.insert("o:displayMessage", enumValueName(String)); registerMethod("ReconfigureDevice", description, params, returns); @@ -252,7 +252,7 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.clear(); returns.clear(); description = "Change the settings of a device."; params.insert("deviceId", enumValueName(Uuid)); - params.insert("settings", QVariantList() << objectRef("Param")); + params.insert("settings", objectRef()); returns.insert("deviceError", enumRef()); registerMethod("SetDeviceSettings", description, params, returns); @@ -273,19 +273,19 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.clear(); returns.clear(); description = "Get event types for a specified deviceClassId."; params.insert("deviceClassId", enumValueName(Uuid)); - returns.insert("eventTypes", QVariantList() << objectRef("EventType")); + returns.insert("eventTypes", objectRef()); registerMethod("GetEventTypes", description, params, returns); params.clear(); returns.clear(); description = "Get action types for a specified deviceClassId."; params.insert("deviceClassId", enumValueName(Uuid)); - returns.insert("actionTypes", QVariantList() << objectRef("ActionType")); + returns.insert("actionTypes", objectRef()); registerMethod("GetActionTypes", description, params, returns); params.clear(); returns.clear(); description = "Get state types for a specified deviceClassId."; params.insert("deviceClassId", enumValueName(Uuid)); - returns.insert("stateTypes", QVariantList() << objectRef("StateType")); + returns.insert("stateTypes", objectRef()); registerMethod("GetStateTypes", description, params, returns); params.clear(); returns.clear(); @@ -300,10 +300,7 @@ DeviceHandler::DeviceHandler(QObject *parent) : description = "Get all the state values of the given device."; params.insert("deviceId", enumValueName(Uuid)); returns.insert("deviceError", enumRef()); - QVariantMap state; - state.insert("stateTypeId", enumValueName(Uuid)); - state.insert("value", enumValueName(Variant)); - returns.insert("o:values", QVariantList() << state); + returns.insert("o:values", objectRef()); registerMethod("GetStateValues", description, params, returns); params.clear(); returns.clear(); @@ -337,12 +334,12 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.clear(); returns.clear(); description = "Emitted whenever a Device was added."; - params.insert("device", objectRef("Device")); + params.insert("device", objectRef()); registerNotification("DeviceAdded", description, params); params.clear(); returns.clear(); description = "Emitted whenever the params or name of a Device are changed (by EditDevice or ReconfigureDevice)."; - params.insert("device", objectRef("Device")); + params.insert("device", objectRef()); registerNotification("DeviceChanged", description, params); params.clear(); returns.clear(); @@ -355,7 +352,7 @@ DeviceHandler::DeviceHandler(QObject *parent) : params.clear(); returns.clear(); description = "Emitted whenever a plugin's configuration is changed."; params.insert("pluginId", enumValueName(Uuid)); - params.insert("configuration", QVariantList() << objectRef("Param")); + params.insert("configuration", objectRef()); registerNotification("PluginConfigurationChanged", description, params); connect(NymeaCore::instance(), &NymeaCore::pluginConfigChanged, this, &DeviceHandler::pluginConfigChanged); diff --git a/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp b/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp index a66b28c0..69ce0848 100644 --- a/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp +++ b/libnymea-core/jsonrpc/jsonrpcserverimplementation.cpp @@ -737,7 +737,7 @@ void JsonRPCServerImplementation::asyncReplyFinished() JsonValidator validator; Q_ASSERT_X(validator.validateReturns(reply->data(), reply->handler()->name() + '.' + reply->method(), m_api).success() ,validator.result().where().toUtf8() - ,validator.result().errorString().toUtf8()); + ,validator.result().errorString().toUtf8() + "\nReturn value:\n" + QJsonDocument::fromVariant(reply->data()).toJson()); sendResponse(interface, reply->clientId(), reply->commandId(), reply->data()); } else { qCWarning(dcJsonRpc()) << "RPC call timed out:" << reply->handler()->name() << ":" << reply->method(); diff --git a/libnymea-core/jsonrpc/networkmanagerhandler.cpp b/libnymea-core/jsonrpc/networkmanagerhandler.cpp index 0535e621..e38c82ee 100644 --- a/libnymea-core/jsonrpc/networkmanagerhandler.cpp +++ b/libnymea-core/jsonrpc/networkmanagerhandler.cpp @@ -85,28 +85,15 @@ NetworkManagerHandler::NetworkManagerHandler(QObject *parent) : registerEnum(); // Objects - QVariantMap wirelessAccessPoint; - wirelessAccessPoint.insert("ssid", enumValueName(String)); - wirelessAccessPoint.insert("macAddress", enumValueName(String)); - wirelessAccessPoint.insert("frequency", enumValueName(Double)); - wirelessAccessPoint.insert("signalStrength", enumValueName(Int)); - wirelessAccessPoint.insert("protected", enumValueName(Bool)); - registerObject("WirelessAccessPoint", wirelessAccessPoint); - - QVariantMap wiredNetworkDevice; - wiredNetworkDevice.insert("interface", enumValueName(String)); - wiredNetworkDevice.insert("macAddress", enumValueName(String)); - wiredNetworkDevice.insert("state", enumRef()); - wiredNetworkDevice.insert("bitRate", enumValueName(String)); - wiredNetworkDevice.insert("pluggedIn", enumValueName(Bool)); - registerObject("WiredNetworkDevice", wiredNetworkDevice); + registerUncreatableObject(); + registerUncreatableObject(); QVariantMap wirelessNetworkDevice; wirelessNetworkDevice.insert("interface", enumValueName(String)); wirelessNetworkDevice.insert("macAddress", enumValueName(String)); wirelessNetworkDevice.insert("state", enumRef()); wirelessNetworkDevice.insert("bitRate", enumValueName(String)); - wirelessNetworkDevice.insert("o:currentAccessPoint", objectRef("WirelessAccessPoint")); + wirelessNetworkDevice.insert("o:currentAccessPoint", objectRef()); registerObject("WirelessNetworkDevice", wirelessNetworkDevice); // Methods diff --git a/libnymea-core/jsonrpc/networkmanagerhandler.h b/libnymea-core/jsonrpc/networkmanagerhandler.h index 6ef9d93c..d9d15b75 100644 --- a/libnymea-core/jsonrpc/networkmanagerhandler.h +++ b/libnymea-core/jsonrpc/networkmanagerhandler.h @@ -75,9 +75,9 @@ private slots: void onWiredNetworkDeviceChanged(WiredNetworkDevice *networkDevice); private: - static QVariantMap packWirelessAccessPoint(WirelessAccessPoint *wirelessAccessPoint); - static QVariantMap packWiredNetworkDevice(WiredNetworkDevice *networkDevice); - static QVariantMap packWirelessNetworkDevice(WirelessNetworkDevice *networkDevice); + QVariantMap packWirelessAccessPoint(WirelessAccessPoint *wirelessAccessPoint); + QVariantMap packWiredNetworkDevice(WiredNetworkDevice *networkDevice); + QVariantMap packWirelessNetworkDevice(WirelessNetworkDevice *networkDevice); QVariantMap statusToReply(NetworkManager::NetworkManagerError status) const; diff --git a/libnymea-core/networkmanager/networkdevice.cpp b/libnymea-core/networkmanager/networkdevice.cpp index c875cbcc..c31272e5 100644 --- a/libnymea-core/networkmanager/networkdevice.cpp +++ b/libnymea-core/networkmanager/networkdevice.cpp @@ -334,7 +334,7 @@ QString NetworkDevice::deviceStateReasonToString(const NetworkDevice::NetworkDev void NetworkDevice::onStateChanged(uint newState, uint oldState, uint reason) { - Q_UNUSED(oldState); + Q_UNUSED(oldState) qCDebug(dcNetworkManager()) << m_interface << "--> State changed:" << deviceStateToString(NetworkDeviceState(newState)) << ":" << deviceStateReasonToString(NetworkDeviceStateReason(reason)); if (m_deviceState != NetworkDeviceState(newState)) { m_deviceState = NetworkDeviceState(newState); diff --git a/libnymea-core/networkmanager/wirednetworkdevice.h b/libnymea-core/networkmanager/wirednetworkdevice.h index a3d12510..e605cc68 100644 --- a/libnymea-core/networkmanager/wirednetworkdevice.h +++ b/libnymea-core/networkmanager/wirednetworkdevice.h @@ -31,8 +31,14 @@ namespace nymeaserver { class WiredNetworkDevice : public NetworkDevice { Q_OBJECT + Q_PROPERTY(QString interface READ interface) + Q_PROPERTY(QString macAddress READ macAddress) + Q_PROPERTY(NetworkDeviceState state READ deviceState) + Q_PROPERTY(QString bitRate READ bitRate) + Q_PROPERTY(bool pluggedIn READ pluggedIn) + public: - explicit WiredNetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = 0); + explicit WiredNetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = nullptr); QString macAddress() const; int bitRate() const; diff --git a/libnymea-core/networkmanager/wirelessaccesspoint.h b/libnymea-core/networkmanager/wirelessaccesspoint.h index 6900658e..6c8375c9 100644 --- a/libnymea-core/networkmanager/wirelessaccesspoint.h +++ b/libnymea-core/networkmanager/wirelessaccesspoint.h @@ -36,6 +36,12 @@ class WirelessAccessPoint : public QObject Q_OBJECT Q_FLAGS(ApSecurityModes) + Q_PROPERTY(QString ssid READ ssid) + Q_PROPERTY(QString macAddress READ macAddress) + Q_PROPERTY(double frequency READ frequency) + Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged) + Q_PROPERTY(bool protected READ isProtected) + public: enum ApSecurityMode{ ApSecurityModeNone = 0x000, @@ -53,7 +59,7 @@ public: Q_DECLARE_FLAGS(ApSecurityModes, ApSecurityMode) - explicit WirelessAccessPoint(const QDBusObjectPath &objectPath, QObject *parent = 0); + explicit WirelessAccessPoint(const QDBusObjectPath &objectPath, QObject *parent = nullptr); QDBusObjectPath objectPath() const; diff --git a/libnymea-core/networkmanager/wirelessnetworkdevice.h b/libnymea-core/networkmanager/wirelessnetworkdevice.h index f33ac6ea..90c10079 100644 --- a/libnymea-core/networkmanager/wirelessnetworkdevice.h +++ b/libnymea-core/networkmanager/wirelessnetworkdevice.h @@ -37,9 +37,15 @@ namespace nymeaserver { class WirelessNetworkDevice : public NetworkDevice { Q_OBJECT + Q_PROPERTY(QString interface READ interface) + Q_PROPERTY(QString macAddress READ macAddress) + Q_PROPERTY(NetworkDeviceState state READ deviceState) + Q_PROPERTY(QString bitRate READ bitRate) + Q_PROPERTY(WirelessAccessPoint* currentAccessPoint READ activeAccessPoint) + public: - explicit WirelessNetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = 0); + explicit WirelessNetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = nullptr); // Properties QString macAddress() const; diff --git a/libnymea/devices/device.cpp b/libnymea/devices/device.cpp index a0e2b0b4..a6126261 100644 --- a/libnymea/devices/device.cpp +++ b/libnymea/devices/device.cpp @@ -471,3 +471,13 @@ Devices Devices::filterByInterface(const QString &interface) } return ret; } + +QVariant Devices::get(int index) const +{ + return QVariant::fromValue(at(index)); +} + +void Devices::put(const QVariant &variant) +{ + append(variant.value()); +} diff --git a/libnymea/devices/device.h b/libnymea/devices/device.h index 3ddc64f4..f2f14382 100644 --- a/libnymea/devices/device.h +++ b/libnymea/devices/device.h @@ -153,6 +153,8 @@ QDebug operator<<(QDebug dbg, Device *device); class LIBNYMEA_EXPORT Devices: public QList { + Q_GADGET + Q_PROPERTY(int count READ count) public: Devices() = default; Devices(const QList &other); @@ -162,6 +164,8 @@ public: Devices filterByDeviceClassId(const DeviceClassId &deviceClassId); Devices filterByParentDeviceId(const DeviceId &deviceId); Devices filterByInterface(const QString &interface); + Q_INVOKABLE QVariant get(int index) const; + Q_INVOKABLE void put(const QVariant &variant); }; Q_DECLARE_METATYPE(Device::DeviceError) diff --git a/libnymea/devices/devicedescriptor.cpp b/libnymea/devices/devicedescriptor.cpp index 654f5897..2d30d252 100644 --- a/libnymea/devices/devicedescriptor.cpp +++ b/libnymea/devices/devicedescriptor.cpp @@ -143,3 +143,13 @@ void DeviceDescriptor::setParams(const ParamList ¶ms) { m_params = params; } + +QVariant DeviceDescriptors::get(int index) const +{ + return QVariant::fromValue(at(index)); +} + +void DeviceDescriptors::put(const QVariant &variant) +{ + append(variant.value()); +} diff --git a/libnymea/devices/devicedescriptor.h b/libnymea/devices/devicedescriptor.h index 15e84fc7..b4032ccf 100644 --- a/libnymea/devices/devicedescriptor.h +++ b/libnymea/devices/devicedescriptor.h @@ -76,10 +76,14 @@ private: class DeviceDescriptors: public QList { + Q_GADGET + Q_PROPERTY(int count READ count) public: DeviceDescriptors() {} inline DeviceDescriptors(std::initializer_list args): QList(args) {} DeviceDescriptors(const QList &other): QList(other) {} + Q_INVOKABLE QVariant get(int index) const; + Q_INVOKABLE void put(const QVariant &variant); }; Q_DECLARE_METATYPE(DeviceDescriptor) diff --git a/libnymea/devices/deviceplugin.cpp b/libnymea/devices/deviceplugin.cpp index c0e00d16..f3409c19 100644 --- a/libnymea/devices/deviceplugin.cpp +++ b/libnymea/devices/deviceplugin.cpp @@ -487,3 +487,13 @@ DevicePlugin *DevicePlugins::findById(const PluginId &id) const } return nullptr; } + +QVariant DevicePlugins::get(int index) const +{ + return QVariant::fromValue(at(index)); +} + +void DevicePlugins::put(const QVariant &variant) +{ + append(variant.value()); +} diff --git a/libnymea/devices/deviceplugin.h b/libnymea/devices/deviceplugin.h index 8d485312..5efe5563 100644 --- a/libnymea/devices/deviceplugin.h +++ b/libnymea/devices/deviceplugin.h @@ -147,10 +147,14 @@ Q_DECLARE_METATYPE(DevicePlugin*) class LIBNYMEA_EXPORT DevicePlugins: public QList { + Q_GADGET + Q_PROPERTY(int count READ count) public: DevicePlugins(); DevicePlugins(const QList &other); DevicePlugin* findById(const PluginId &id) const; + Q_INVOKABLE QVariant get(int index) const; + Q_INVOKABLE void put(const QVariant &variant); }; Q_DECLARE_METATYPE(DevicePlugins) diff --git a/libnymea/jsonrpc/jsonhandler.cpp b/libnymea/jsonrpc/jsonhandler.cpp index df43d22c..fd44089b 100644 --- a/libnymea/jsonrpc/jsonhandler.cpp +++ b/libnymea/jsonrpc/jsonhandler.cpp @@ -195,6 +195,20 @@ void JsonHandler::registerObject(const QMetaObject &metaObject) m_metaObjects.insert(className, metaObject); } +void JsonHandler::registerObject(const QMetaObject &metaObject, const QMetaObject &listMetaObject) +{ + registerObject(metaObject); + QString listTypeName = QString(listMetaObject.className()).split("::").last(); + QString objectTypeName = QString(metaObject.className()).split("::").last(); + m_objects.insert(listTypeName, QVariantList() << QVariant(QString("$ref:%1").arg(objectTypeName))); + m_metaObjects.insert(listTypeName, listMetaObject); + m_listMetaObjects.insert(listTypeName, listMetaObject); + m_listEntryTypes.insert(listTypeName, objectTypeName); + Q_ASSERT_X(listMetaObject.indexOfProperty("count") >= 0, "JsonHandler", QString("List type %1 does not implement \"count\" property!").arg(listTypeName).toUtf8()); + Q_ASSERT_X(listMetaObject.indexOfMethod("get(int)") >= 0, "JsonHandler", QString("List type %1 does not implement \"Q_INVOKABLE QVariant get(int index)\" method!").arg(listTypeName).toUtf8()); + Q_ASSERT_X(listMetaObject.indexOfMethod("put(QVariant)") >= 0, "JsonHandler", QString("List type %1 does not implement \"Q_INVOKABLE void put(QVariant variant)\" method!").arg(listTypeName).toUtf8()); +} + QVariant JsonHandler::pack(const QMetaObject &metaObject, const void *value) const { QString className = QString(metaObject.className()).split("::").last(); diff --git a/libnymea/jsonrpc/jsonhandler.h b/libnymea/jsonrpc/jsonhandler.h index d4f5fa5f..c477856a 100644 --- a/libnymea/jsonrpc/jsonhandler.h +++ b/libnymea/jsonrpc/jsonhandler.h @@ -78,11 +78,19 @@ public: protected: template void registerEnum(); template void registerEnum(); + template void registerObject(); - template void registerUncreatableObject(); template void registerObject(); + + template void registerUncreatableObject(); + template void registerUncreatableObject(); + template void registerList(BasicTypeName typeName); + + // Deprecated QString based registerObject void registerObject(const QString &name, const QVariantMap &object); + + void registerMethod(const QString &name, const QString &description, const QVariantMap ¶ms, const QVariantMap &returns, bool deprecated = false); void registerNotification(const QString &name, const QString &description, const QVariantMap ¶ms, bool deprecated = false); @@ -92,6 +100,7 @@ protected: private: void registerObject(const QMetaObject &metaObject); + void registerObject(const QMetaObject &metaObject, const QMetaObject &listMetaObject); QVariant pack(const QMetaObject &metaObject, const void *gadget) const; QVariant unpack(const QMetaObject &metaObject, const QVariant &value) const; @@ -142,6 +151,16 @@ void JsonHandler::registerObject() registerObject(metaObject); } +template +void JsonHandler::registerObject() +{ + qRegisterMetaType(); + qRegisterMetaType(); + QMetaObject metaObject = ObjectType::staticMetaObject; + QMetaObject listMetaObject = ListType::staticMetaObject; + registerObject(metaObject, listMetaObject); +} + template void JsonHandler::registerUncreatableObject() { @@ -149,22 +168,12 @@ void JsonHandler::registerUncreatableObject() registerObject(metaObject); } -template -void JsonHandler::registerObject() +template +void JsonHandler::registerUncreatableObject() { - registerObject(); - qRegisterMetaType(); QMetaObject metaObject = ObjectType::staticMetaObject; QMetaObject listMetaObject = ListType::staticMetaObject; - QString listTypeName = QString(listMetaObject.className()).split("::").last(); - QString objectTypeName = QString(metaObject.className()).split("::").last(); - m_objects.insert(listTypeName, QVariantList() << QVariant(QString("$ref:%1").arg(objectTypeName))); - m_metaObjects.insert(listTypeName, listMetaObject); - m_listMetaObjects.insert(listTypeName, listMetaObject); - m_listEntryTypes.insert(listTypeName, objectTypeName); - Q_ASSERT_X(listMetaObject.indexOfProperty("count") >= 0, "JsonHandler", QString("List type %1 does not implement \"count\" property!").arg(listTypeName).toUtf8()); - Q_ASSERT_X(listMetaObject.indexOfMethod("get(int)") >= 0, "JsonHandler", QString("List type %1 does not implement \"Q_INVOKABLE QVariant get(int index)\" method!").arg(listTypeName).toUtf8()); - Q_ASSERT_X(listMetaObject.indexOfMethod("put(QVariant)") >= 0, "JsonHandler", QString("List type %1 does not implement \"Q_INVOKABLE void put(QVariant variant)\" method!").arg(listTypeName).toUtf8()); + registerObject(metaObject, listMetaObject); } template diff --git a/libnymea/types/deviceclass.cpp b/libnymea/types/deviceclass.cpp index 7a62f26e..986c79cb 100644 --- a/libnymea/types/deviceclass.cpp +++ b/libnymea/types/deviceclass.cpp @@ -375,3 +375,13 @@ DeviceClass DeviceClasses::findById(const DeviceClassId &id) const } return DeviceClass(); } + +QVariant DeviceClasses::get(int index) const +{ + return QVariant::fromValue(at(index)); +} + +void DeviceClasses::put(const QVariant &variant) +{ + append(variant.value()); +} diff --git a/libnymea/types/deviceclass.h b/libnymea/types/deviceclass.h index e03c494c..d65244a2 100644 --- a/libnymea/types/deviceclass.h +++ b/libnymea/types/deviceclass.h @@ -157,10 +157,14 @@ QDebug operator<<(QDebug &dbg, const DeviceClass &deviceClass); class LIBNYMEA_EXPORT DeviceClasses: public QList { + Q_GADGET + Q_PROPERTY(int count READ count) public: DeviceClasses(); DeviceClasses(const QList &other); DeviceClass findById(const DeviceClassId &id) const; + Q_INVOKABLE QVariant get(int index) const; + Q_INVOKABLE void put(const QVariant &variant); }; #endif diff --git a/libnymea/types/vendor.cpp b/libnymea/types/vendor.cpp index fc0904bd..b0d63b84 100644 --- a/libnymea/types/vendor.cpp +++ b/libnymea/types/vendor.cpp @@ -95,6 +95,16 @@ Vendors::Vendors(const QList &other): QList(other) } +QVariant Vendors::get(int index) const +{ + return QVariant::fromValue(at(index)); +} + +void Vendors::put(const QVariant &variant) +{ + append(variant.value()); +} + Vendor Vendors::findById(const VendorId &vendorId) const { foreach (const Vendor &vendor, *this) { diff --git a/libnymea/types/vendor.h b/libnymea/types/vendor.h index 08cce26d..d8c383ba 100644 --- a/libnymea/types/vendor.h +++ b/libnymea/types/vendor.h @@ -29,6 +29,7 @@ #include #include +#include class LIBNYMEA_EXPORT Vendor { @@ -61,10 +62,13 @@ Q_DECLARE_METATYPE(Vendor) class LIBNYMEA_EXPORT Vendors: public QList { + Q_GADGET + Q_PROPERTY(int count READ count) public: Vendors(); Vendors(const QList &other); - + Q_INVOKABLE QVariant get(int index) const; + Q_INVOKABLE void put(const QVariant &variant); Vendor findById(const VendorId &vendorId) const; }; Q_DECLARE_METATYPE(Vendors) diff --git a/tests/auto/api.json b/tests/auto/api.json index b703132d..57f5c4e5 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1,14 +1,314 @@ -3.2 +4.0 { + "enums": { + "BasicType": [ + "Uuid", + "String", + "StringList", + "Int", + "Uint", + "Double", + "Bool", + "Variant", + "Color", + "Time", + "Object" + ], + "BrowserIcon": [ + "BrowserIconNone", + "BrowserIconFolder", + "BrowserIconFile", + "BrowserIconMusic", + "BrowserIconVideo", + "BrowserIconPictures", + "BrowserIconApplication", + "BrowserIconDocument", + "BrowserIconPackage", + "BrowserIconFavorites" + ], + "CloudConnectionState": [ + "CloudConnectionStateDisabled", + "CloudConnectionStateUnconfigured", + "CloudConnectionStateConnecting", + "CloudConnectionStateConnected" + ], + "ConfigurationError": [ + "ConfigurationErrorNoError", + "ConfigurationErrorInvalidTimeZone", + "ConfigurationErrorInvalidStationName", + "ConfigurationErrorInvalidId", + "ConfigurationErrorInvalidPort", + "ConfigurationErrorInvalidHostAddress", + "ConfigurationErrorBluetoothHardwareNotAvailable", + "ConfigurationErrorInvalidCertificate" + ], + "CreateMethod": [ + "CreateMethodUser", + "CreateMethodAuto", + "CreateMethodDiscovery" + ], + "DeviceError": [ + "DeviceErrorNoError", + "DeviceErrorPluginNotFound", + "DeviceErrorVendorNotFound", + "DeviceErrorDeviceNotFound", + "DeviceErrorDeviceClassNotFound", + "DeviceErrorActionTypeNotFound", + "DeviceErrorStateTypeNotFound", + "DeviceErrorEventTypeNotFound", + "DeviceErrorDeviceDescriptorNotFound", + "DeviceErrorMissingParameter", + "DeviceErrorInvalidParameter", + "DeviceErrorSetupFailed", + "DeviceErrorDuplicateUuid", + "DeviceErrorCreationMethodNotSupported", + "DeviceErrorSetupMethodNotSupported", + "DeviceErrorHardwareNotAvailable", + "DeviceErrorHardwareFailure", + "DeviceErrorAuthenticationFailure", + "DeviceErrorDeviceInUse", + "DeviceErrorDeviceInRule", + "DeviceErrorDeviceIsChild", + "DeviceErrorPairingTransactionIdNotFound", + "DeviceErrorParameterNotWritable", + "DeviceErrorItemNotFound", + "DeviceErrorItemNotExecutable", + "DeviceErrorUnsupportedFeature", + "DeviceErrorTimeout" + ], + "InputType": [ + "InputTypeNone", + "InputTypeTextLine", + "InputTypeTextArea", + "InputTypePassword", + "InputTypeSearch", + "InputTypeMail", + "InputTypeIPv4Address", + "InputTypeIPv6Address", + "InputTypeUrl", + "InputTypeMacAddress" + ], + "LoggingError": [ + "LoggingErrorNoError", + "LoggingErrorLogEntryNotFound", + "LoggingErrorInvalidFilterParameter" + ], + "LoggingEventType": [ + "LoggingEventTypeTrigger", + "LoggingEventTypeActiveChange", + "LoggingEventTypeEnabledChange", + "LoggingEventTypeActionsExecuted", + "LoggingEventTypeExitActionsExecuted" + ], + "LoggingLevel": [ + "LoggingLevelInfo", + "LoggingLevelAlert" + ], + "LoggingSource": [ + "LoggingSourceSystem", + "LoggingSourceEvents", + "LoggingSourceActions", + "LoggingSourceStates", + "LoggingSourceRules", + "LoggingSourceBrowserActions" + ], + "MediaBrowserIcon": [ + "MediaBrowserIconNone", + "MediaBrowserIconPlaylist", + "MediaBrowserIconRecentlyPlayed", + "MediaBrowserIconLibrary", + "MediaBrowserIconMusicLibrary", + "MediaBrowserIconVideoLibrary", + "MediaBrowserIconPictureLibrary", + "MediaBrowserIconDisk", + "MediaBrowserIconUSB", + "MediaBrowserIconNetwork", + "MediaBrowserIconAux", + "MediaBrowserIconSpotify", + "MediaBrowserIconAmazon", + "MediaBrowserIconTuneIn", + "MediaBrowserIconSiriusXM", + "MediaBrowserIconVTuner", + "MediaBrowserIconTidal", + "MediaBrowserIconAirable", + "MediaBrowserIconDeezer", + "MediaBrowserIconNapster", + "MediaBrowserIconSoundCloud" + ], + "NetworkDeviceState": [ + "NetworkDeviceStateUnknown", + "NetworkDeviceStateUnmanaged", + "NetworkDeviceStateUnavailable", + "NetworkDeviceStateDisconnected", + "NetworkDeviceStatePrepare", + "NetworkDeviceStateConfig", + "NetworkDeviceStateNeedAuth", + "NetworkDeviceStateIpConfig", + "NetworkDeviceStateIpCheck", + "NetworkDeviceStateSecondaries", + "NetworkDeviceStateActivated", + "NetworkDeviceStateDeactivating", + "NetworkDeviceStateFailed" + ], + "NetworkManagerError": [ + "NetworkManagerErrorNoError", + "NetworkManagerErrorUnknownError", + "NetworkManagerErrorWirelessNotAvailable", + "NetworkManagerErrorAccessPointNotFound", + "NetworkManagerErrorNetworkInterfaceNotFound", + "NetworkManagerErrorInvalidNetworkDeviceType", + "NetworkManagerErrorWirelessNetworkingDisabled", + "NetworkManagerErrorWirelessConnectionFailed", + "NetworkManagerErrorNetworkingDisabled", + "NetworkManagerErrorNetworkManagerNotAvailable" + ], + "NetworkManagerState": [ + "NetworkManagerStateUnknown", + "NetworkManagerStateAsleep", + "NetworkManagerStateDisconnected", + "NetworkManagerStateDisconnecting", + "NetworkManagerStateConnecting", + "NetworkManagerStateConnectedLocal", + "NetworkManagerStateConnectedSite", + "NetworkManagerStateConnectedGlobal" + ], + "RemovePolicy": [ + "RemovePolicyCascade", + "RemovePolicyUpdate" + ], + "RepeatingMode": [ + "RepeatingModeNone", + "RepeatingModeHourly", + "RepeatingModeDaily", + "RepeatingModeWeekly", + "RepeatingModeMonthly", + "RepeatingModeYearly" + ], + "RuleError": [ + "RuleErrorNoError", + "RuleErrorInvalidRuleId", + "RuleErrorRuleNotFound", + "RuleErrorDeviceNotFound", + "RuleErrorEventTypeNotFound", + "RuleErrorStateTypeNotFound", + "RuleErrorActionTypeNotFound", + "RuleErrorInvalidParameter", + "RuleErrorInvalidRuleFormat", + "RuleErrorMissingParameter", + "RuleErrorInvalidRuleActionParameter", + "RuleErrorInvalidStateEvaluatorValue", + "RuleErrorTypesNotMatching", + "RuleErrorNotExecutable", + "RuleErrorInvalidTimeDescriptor", + "RuleErrorInvalidRepeatingOption", + "RuleErrorInvalidCalendarItem", + "RuleErrorInvalidTimeEventItem", + "RuleErrorContainsEventBasesAction", + "RuleErrorNoExitActions", + "RuleErrorInterfaceNotFound" + ], + "SetupMethod": [ + "SetupMethodJustAdd", + "SetupMethodDisplayPin", + "SetupMethodEnterPin", + "SetupMethodPushButton", + "SetupMethodUserAndPassword", + "SetupMethodOAuth" + ], + "StateOperator": [ + "StateOperatorAnd", + "StateOperatorOr" + ], + "TagError": [ + "TagErrorNoError", + "TagErrorDeviceNotFound", + "TagErrorRuleNotFound", + "TagErrorTagNotFound" + ], + "Unit": [ + "UnitNone", + "UnitSeconds", + "UnitMinutes", + "UnitHours", + "UnitUnixTime", + "UnitMeterPerSecond", + "UnitKiloMeterPerHour", + "UnitDegree", + "UnitRadiant", + "UnitDegreeCelsius", + "UnitDegreeKelvin", + "UnitMired", + "UnitMilliBar", + "UnitBar", + "UnitPascal", + "UnitHectoPascal", + "UnitAtmosphere", + "UnitLumen", + "UnitLux", + "UnitCandela", + "UnitMilliMeter", + "UnitCentiMeter", + "UnitMeter", + "UnitKiloMeter", + "UnitGram", + "UnitKiloGram", + "UnitDezibel", + "UnitBpm", + "UnitKiloByte", + "UnitMegaByte", + "UnitGigaByte", + "UnitTeraByte", + "UnitMilliWatt", + "UnitWatt", + "UnitKiloWatt", + "UnitKiloWattHour", + "UnitEuroPerMegaWattHour", + "UnitEuroCentPerKiloWattHour", + "UnitPercentage", + "UnitPartsPerMillion", + "UnitEuro", + "UnitDollar", + "UnitHertz", + "UnitAmpere", + "UnitMilliAmpere", + "UnitVolt", + "UnitMilliVolt", + "UnitVoltAmpere", + "UnitVoltAmpereReactive", + "UnitAmpereHour", + "UnitMicroSiemensPerCentimeter", + "UnitDuration" + ], + "UserError": [ + "UserErrorNoError", + "UserErrorBackendError", + "UserErrorInvalidUserId", + "UserErrorDuplicateUserId", + "UserErrorBadPassword", + "UserErrorTokenNotFound", + "UserErrorPermissionDenied" + ], + "ValueOperator": [ + "ValueOperatorEquals", + "ValueOperatorNotEquals", + "ValueOperatorLess", + "ValueOperatorGreater", + "ValueOperatorLessOrEqual", + "ValueOperatorGreaterOrEqual" + ] + }, + "flags": { + "CreateMethods": [ + "$ref:CreateMethod" + ] + }, "methods": { "Actions.ExecuteAction": { "description": "Execute a single action.", "params": { "actionTypeId": "Uuid", "deviceId": "Uuid", - "o:params": [ - "$ref:Param" - ] + "o:params": "$ref:ParamList" }, "returns": { "deviceError": "$ref:DeviceError", @@ -31,9 +331,7 @@ "actionTypeId": "Uuid", "deviceId": "Uuid", "itemId": "String", - "o:params": [ - "$ref:Param" - ] + "o:params": "$ref:ParamList" }, "returns": { "deviceError": "$ref:DeviceError" @@ -46,15 +344,7 @@ }, "returns": { "deviceError": "$ref:DeviceError", - "o:actionType": { - "displayName": "String", - "id": "Uuid", - "index": "Int", - "name": "String", - "paramTypes": [ - "$ref:ParamType" - ] - } + "o:actionType": "$ref:ActionType" } }, "Configuration.DeleteMqttPolicy": { @@ -265,9 +555,7 @@ "deviceClassId": "Uuid", "name": "String", "o:deviceDescriptorId": "Uuid", - "o:deviceParams": [ - "$ref:Param" - ] + "o:deviceParams": "$ref:ParamList" }, "returns": { "deviceError": "$ref:DeviceError", @@ -317,9 +605,7 @@ "deviceClassId": "Uuid" }, "returns": { - "actionTypes": [ - "$ref:ActionType" - ] + "actionTypes": "$ref:ActionTypes" } }, "Devices.GetBrowserItem": { @@ -339,24 +625,18 @@ "o:deviceId": "Uuid" }, "returns": { - "devices": [ - "$ref:Device" - ] + "devices": "$ref:Devices" } }, "Devices.GetDiscoveredDevices": { "description": "Performs a device discovery and returns the results. This function may take a while to return. Note that this method will include all the found devices, that is, including devices that may already have been added. Those devices will have deviceId set to the device id of the already added device. Such results may be used to reconfigure existing devices and might be filtered in cases where only unknown devices are of interest.", "params": { "deviceClassId": "Uuid", - "o:discoveryParams": [ - "$ref:Param" - ] + "o:discoveryParams": "$ref:ParamList" }, "returns": { "deviceError": "$ref:DeviceError", - "o:deviceDescriptors": [ - "$ref:DeviceDescriptor" - ], + "o:deviceDescriptors": "$ref:DeviceDescriptors", "o:displayMessage": "String" } }, @@ -366,9 +646,7 @@ "deviceClassId": "Uuid" }, "returns": { - "eventTypes": [ - "$ref:EventType" - ] + "eventTypes": "$ref:EventTypes" } }, "Devices.GetPluginConfiguration": { @@ -378,9 +656,7 @@ }, "returns": { "deviceError": "$ref:DeviceError", - "o:configuration": [ - "$ref:Param" - ] + "o:configuration": "$ref:ParamList" } }, "Devices.GetPlugins": { @@ -388,9 +664,7 @@ "params": { }, "returns": { - "plugins": [ - "$ref:Plugin" - ] + "plugins": "$ref:DevicePlugins" } }, "Devices.GetStateTypes": { @@ -399,9 +673,7 @@ "deviceClassId": "Uuid" }, "returns": { - "stateTypes": [ - "$ref:StateType" - ] + "stateTypes": "$ref:StateTypes" } }, "Devices.GetStateValue": { @@ -422,12 +694,7 @@ }, "returns": { "deviceError": "$ref:DeviceError", - "o:values": [ - { - "stateTypeId": "Uuid", - "value": "Variant" - } - ] + "o:values": "$ref:States" } }, "Devices.GetSupportedDevices": { @@ -436,9 +703,7 @@ "o:vendorId": "Uuid" }, "returns": { - "deviceClasses": [ - "$ref:DeviceClass" - ] + "deviceClasses": "$ref:DeviceClasses" } }, "Devices.GetSupportedVendors": { @@ -446,9 +711,7 @@ "params": { }, "returns": { - "vendors": [ - "$ref:Vendor" - ] + "vendors": "$ref:Vendors" } }, "Devices.PairDevice": { @@ -457,9 +720,7 @@ "o:deviceClassId": "Uuid", "o:deviceDescriptorId": "Uuid", "o:deviceId": "Uuid", - "o:deviceParams": [ - "$ref:Param" - ], + "o:deviceParams": "$ref:ParamList", "o:name": "String" }, "returns": { @@ -476,9 +737,7 @@ "params": { "o:deviceDescriptorId": "Uuid", "o:deviceId": "Uuid", - "o:deviceParams": [ - "$ref:Param" - ] + "o:deviceParams": "$ref:ParamList" }, "returns": { "deviceError": "$ref:DeviceError", @@ -508,9 +767,7 @@ "description": "Change the settings of a device.", "params": { "deviceId": "Uuid", - "settings": [ - "$ref:Param" - ] + "settings": "$ref:ParamList" }, "returns": { "deviceError": "$ref:DeviceError" @@ -519,9 +776,7 @@ "Devices.SetPluginConfiguration": { "description": "Set a plugin's params.", "params": { - "configuration": [ - "$ref:Param" - ], + "configuration": "$ref:ParamList", "pluginId": "Uuid" }, "returns": { @@ -571,6 +826,9 @@ "language": "String", "locale": "String", "name": "String", + "o:experiences": [ + "$ref:Experience" + ], "protocol version": "String", "pushButtonAuthAvailable": "Bool", "server": "String", @@ -630,15 +888,11 @@ "description": "Enable/Disable notifications for this connections. Either \"enabled\" or \"namespaces\" needs to be given but not both of them. The boolean based \"enabled\" parameter will enable/disable all notifications at once. If instead the list-based \"namespaces\" parameter is provided, all given namespaceswill be enabled, the others will be disabled. The return value of \"success\" will indicate success of the operation. The \"enabled\" property in the return value is deprecated and used for legacy compatibilty only. It will be set to true if at least one namespace has been enabled.", "params": { "o:enabled": "Bool", - "o:namespaces": [ - "$ref:Namespace" - ] + "o:namespaces": "StringList" }, "returns": { "enabled": "Bool", - "namespaces": [ - "$ref:Namespace" - ] + "namespaces": "StringList" } }, "JSONRPC.SetupCloudConnection": { @@ -717,9 +971,7 @@ "returns": { "count": "Int", "loggingError": "$ref:LoggingError", - "o:logEntries": [ - "$ref:LogEntry" - ], + "o:logEntries": "$ref:LogEntries", "offset": "Int" } }, @@ -974,9 +1226,7 @@ "params": { }, "returns": { - "packages": [ - "$ref:Package" - ] + "packages": "$ref:Packages" } }, "System.GetRepositories": { @@ -984,9 +1234,7 @@ "params": { }, "returns": { - "repositories": [ - "$ref:Repository" - ] + "repositories": "$ref:Repositories" } }, "System.GetUpdateStatus": { @@ -1065,9 +1313,7 @@ "o:tagId": "String" }, "returns": { - "o:tags": [ - "$ref:Tag" - ], + "o:tags": "$ref:Tags", "tagError": "$ref:TagError" } }, @@ -1198,9 +1444,7 @@ "Devices.PluginConfigurationChanged": { "description": "Emitted whenever a plugin's configuration is changed.", "params": { - "configuration": [ - "$ref:Param" - ], + "configuration": "$ref:ParamList", "pluginId": "Uuid" } }, @@ -1388,43 +1632,17 @@ "Action": { "actionTypeId": "Uuid", "deviceId": "Uuid", - "o:params": [ - "$ref:Param" - ] + "o:params": "$ref:ParamList" }, "ActionType": { "displayName": "String", "id": "Uuid", "index": "Int", "name": "String", - "paramTypes": [ - "$ref:ParamType" - ] + "paramTypes": "$ref:ParamTypes" }, - "BasicType": [ - "Uuid", - "String", - "StringList", - "Int", - "Uint", - "Double", - "Bool", - "Variant", - "Color", - "Time", - "Object" - ], - "BrowserIcon": [ - "BrowserIconNone", - "BrowserIconFolder", - "BrowserIconFile", - "BrowserIconMusic", - "BrowserIconVideo", - "BrowserIconPictures", - "BrowserIconApplication", - "BrowserIconDocument", - "BrowserIconPackage", - "BrowserIconFavorites" + "ActionTypes": [ + "$ref:ActionType" ], "BrowserItem": { "actionTypeIds": [ @@ -1446,156 +1664,93 @@ "o:repeating": "$ref:RepeatingOption", "o:startTime": "Time" }, - "CloudConnectionState": [ - "CloudConnectionStateDisabled", - "CloudConnectionStateUnconfigured", - "CloudConnectionStateConnecting", - "CloudConnectionStateConnected" - ], - "ConfigurationError": [ - "ConfigurationErrorNoError", - "ConfigurationErrorInvalidTimeZone", - "ConfigurationErrorInvalidStationName", - "ConfigurationErrorInvalidId", - "ConfigurationErrorInvalidPort", - "ConfigurationErrorInvalidHostAddress", - "ConfigurationErrorBluetoothHardwareNotAvailable", - "ConfigurationErrorInvalidCertificate" - ], - "CreateMethod": [ - "CreateMethodUser", - "CreateMethodAuto", - "CreateMethodDiscovery" + "CalendarItems": [ + "$ref:CalendarItem" ], "Device": { "deviceClassId": "Uuid", "id": "Uuid", "name": "String", "o:parentId": "Uuid", - "params": [ - "$ref:Param" - ], - "settings": [ - "$ref:Param" - ], + "params": "$ref:ParamList", + "settings": "$ref:ParamList", "setupComplete": "Bool", - "states": [ - { - "stateTypeId": "Uuid", - "value": "Variant" - } - ] + "states": "$ref:States" }, "DeviceClass": { - "actionTypes": [ - "$ref:ActionType" - ], + "actionTypes": "$ref:ActionTypes", "browsable": "Bool", - "browserItemActionTypes": [ - "$ref:ActionType" - ], - "createMethods": [ - "$ref:CreateMethod" - ], - "discoveryParamTypes": [ - "$ref:ParamType" - ], + "browserItemActionTypes": "$ref:ActionTypes", + "createMethods": "$ref:CreateMethods", + "discoveryParamTypes": "$ref:ParamTypes", "displayName": "String", - "eventTypes": [ - "$ref:EventType" - ], + "eventTypes": "$ref:EventTypes", "id": "Uuid", - "interfaces": [ - "String" - ], + "interfaces": "StringList", "name": "String", - "paramTypes": [ - "$ref:ParamType" - ], + "paramTypes": "$ref:ParamTypes", "pluginId": "Uuid", - "settingsTypes": [ - "$ref:ParamType" - ], + "settingsTypes": "$ref:ParamTypes", "setupMethod": "$ref:SetupMethod", - "stateTypes": [ - "$ref:StateType" - ], + "stateTypes": "$ref:StateTypes", "vendorId": "Uuid" }, + "DeviceClasses": [ + "$ref:DeviceClass" + ], "DeviceDescriptor": { "description": "String", - "deviceId": "Uuid", - "deviceParams": [ - "$ref:Param" - ], + "deviceParams": "$ref:ParamList", "id": "Uuid", + "o:deviceId": "Uuid", "title": "String" }, - "DeviceError": [ - "DeviceErrorNoError", - "DeviceErrorPluginNotFound", - "DeviceErrorVendorNotFound", - "DeviceErrorDeviceNotFound", - "DeviceErrorDeviceClassNotFound", - "DeviceErrorActionTypeNotFound", - "DeviceErrorStateTypeNotFound", - "DeviceErrorEventTypeNotFound", - "DeviceErrorDeviceDescriptorNotFound", - "DeviceErrorMissingParameter", - "DeviceErrorInvalidParameter", - "DeviceErrorSetupFailed", - "DeviceErrorDuplicateUuid", - "DeviceErrorCreationMethodNotSupported", - "DeviceErrorSetupMethodNotSupported", - "DeviceErrorHardwareNotAvailable", - "DeviceErrorHardwareFailure", - "DeviceErrorAuthenticationFailure", - "DeviceErrorDeviceInUse", - "DeviceErrorDeviceInRule", - "DeviceErrorDeviceIsChild", - "DeviceErrorPairingTransactionIdNotFound", - "DeviceErrorParameterNotWritable", - "DeviceErrorItemNotFound", - "DeviceErrorItemNotExecutable", - "DeviceErrorUnsupportedFeature", - "DeviceErrorTimeout" + "DeviceDescriptors": [ + "$ref:DeviceDescriptor" + ], + "DevicePlugin": { + "displayName": "String", + "id": "Uuid", + "name": "String", + "paramTypes": "$ref:ParamTypes" + }, + "DevicePlugins": [ + "$ref:DevicePlugin" + ], + "Devices": [ + "$ref:Device" ], "Event": { "deviceId": "Uuid", "eventTypeId": "Uuid", - "o:params": [ - "$ref:Param" - ] + "params": "$ref:ParamList" }, "EventDescriptor": { "o:deviceId": "Uuid", "o:eventTypeId": "Uuid", "o:interface": "String", "o:interfaceEvent": "String", - "o:paramDescriptors": [ - "$ref:ParamDescriptor" - ] + "o:paramDescriptors": "$ref:ParamDescriptors" }, + "EventDescriptors": [ + "$ref:EventDescriptor" + ], "EventType": { "displayName": "String", "id": "Uuid", "index": "Int", "name": "String", - "paramTypes": [ - "$ref:ParamType" - ] + "paramTypes": "$ref:ParamTypes" }, - "InputType": [ - "InputTypeNone", - "InputTypeTextLine", - "InputTypeTextArea", - "InputTypePassword", - "InputTypeSearch", - "InputTypeMail", - "InputTypeIPv4Address", - "InputTypeIPv6Address", - "InputTypeUrl", - "InputTypeMacAddress" + "EventTypes": [ + "$ref:EventType" + ], + "Experience": { + "name": "String", + "version": "String" + }, + "LogEntries": [ + "$ref:LogEntry" ], "LogEntry": { "loggingLevel": "$ref:LoggingLevel", @@ -1603,59 +1758,11 @@ "o:deviceId": "Uuid", "o:errorCode": "String", "o:eventType": "$ref:LoggingEventType", - "o:itemId": "String", "o:typeId": "Uuid", - "o:value": "String", + "o:value": "Variant", "source": "$ref:LoggingSource", - "timestamp": "Int" + "timestamp": "Uint" }, - "LoggingError": [ - "LoggingErrorNoError", - "LoggingErrorLogEntryNotFound", - "LoggingErrorInvalidFilterParameter" - ], - "LoggingEventType": [ - "LoggingEventTypeTrigger", - "LoggingEventTypeActiveChange", - "LoggingEventTypeEnabledChange", - "LoggingEventTypeActionsExecuted", - "LoggingEventTypeExitActionsExecuted" - ], - "LoggingLevel": [ - "LoggingLevelInfo", - "LoggingLevelAlert" - ], - "LoggingSource": [ - "LoggingSourceSystem", - "LoggingSourceEvents", - "LoggingSourceActions", - "LoggingSourceStates", - "LoggingSourceRules", - "LoggingSourceBrowserActions" - ], - "MediaBrowserIcon": [ - "MediaBrowserIconNone", - "MediaBrowserIconPlaylist", - "MediaBrowserIconRecentlyPlayed", - "MediaBrowserIconLibrary", - "MediaBrowserIconMusicLibrary", - "MediaBrowserIconVideoLibrary", - "MediaBrowserIconPictureLibrary", - "MediaBrowserIconDisk", - "MediaBrowserIconUSB", - "MediaBrowserIconNetwork", - "MediaBrowserIconAux", - "MediaBrowserIconSpotify", - "MediaBrowserIconAmazon", - "MediaBrowserIconTuneIn", - "MediaBrowserIconSiriusXM", - "MediaBrowserIconVTuner", - "MediaBrowserIconTidal", - "MediaBrowserIconAirable", - "MediaBrowserIconDeezer", - "MediaBrowserIconNapster", - "MediaBrowserIconSoundCloud" - ], "MqttPolicy": { "allowedPublishTopicFilters": "StringList", "allowedSubscribeTopicFilters": "StringList", @@ -1663,56 +1770,6 @@ "password": "String", "username": "String" }, - "Namespace": [ - "Actions", - "Configuration", - "Devices", - "Events", - "JSONRPC", - "Logging", - "NetworkManager", - "Rules", - "States", - "System", - "Tags" - ], - "NetworkDeviceState": [ - "NetworkDeviceStateUnknown", - "NetworkDeviceStateUnmanaged", - "NetworkDeviceStateUnavailable", - "NetworkDeviceStateDisconnected", - "NetworkDeviceStatePrepare", - "NetworkDeviceStateConfig", - "NetworkDeviceStateNeedAuth", - "NetworkDeviceStateIpConfig", - "NetworkDeviceStateIpCheck", - "NetworkDeviceStateSecondaries", - "NetworkDeviceStateActivated", - "NetworkDeviceStateDeactivating", - "NetworkDeviceStateFailed" - ], - "NetworkManagerError": [ - "NetworkManagerErrorNoError", - "NetworkManagerErrorUnknownError", - "NetworkManagerErrorWirelessNotAvailable", - "NetworkManagerErrorAccessPointNotFound", - "NetworkManagerErrorNetworkInterfaceNotFound", - "NetworkManagerErrorInvalidNetworkDeviceType", - "NetworkManagerErrorWirelessNetworkingDisabled", - "NetworkManagerErrorWirelessConnectionFailed", - "NetworkManagerErrorNetworkingDisabled", - "NetworkManagerErrorNetworkManagerNotAvailable" - ], - "NetworkManagerState": [ - "NetworkManagerStateUnknown", - "NetworkManagerStateAsleep", - "NetworkManagerStateDisconnected", - "NetworkManagerStateDisconnecting", - "NetworkManagerStateConnecting", - "NetworkManagerStateConnectedLocal", - "NetworkManagerStateConnectedSite", - "NetworkManagerStateConnectedGlobal" - ], "Package": { "canRemove": "Bool", "candidateVersion": "String", @@ -1724,16 +1781,25 @@ "summary": "String", "updateAvailable": "Bool" }, + "Packages": [ + "$ref:Package" + ], "Param": { - "paramTypeId": "Uuid", - "value": "$ref:BasicType" + "o:paramTypeId": "Uuid", + "value": "Variant" }, "ParamDescriptor": { - "o:paramName": "Uuid", + "o:paramName": "String", "o:paramTypeId": "Uuid", "operator": "$ref:ValueOperator", - "value": "$ref:BasicType" + "value": "Variant" }, + "ParamDescriptors": [ + "$ref:ParamDescriptor" + ], + "ParamList": [ + "$ref:Param" + ], "ParamType": { "displayName": "String", "id": "Uuid", @@ -1750,25 +1816,8 @@ "o:unit": "$ref:Unit", "type": "$ref:BasicType" }, - "Plugin": { - "displayName": "String", - "id": "Uuid", - "name": "String", - "paramTypes": [ - "$ref:ParamType" - ] - }, - "RemovePolicy": [ - "RemovePolicyCascade", - "RemovePolicyUpdate" - ], - "RepeatingMode": [ - "RepeatingModeNone", - "RepeatingModeHourly", - "RepeatingModeDaily", - "RepeatingModeWeekly", - "RepeatingModeMonthly", - "RepeatingModeYearly" + "ParamTypes": [ + "$ref:ParamType" ], "RepeatingOption": { "mode": "$ref:RepeatingMode", @@ -1779,28 +1828,25 @@ "Int" ] }, + "Repositories": [ + "$ref:Repository" + ], "Repository": { "displayName": "String", "enabled": "Bool", "id": "String" }, "Rule": { - "actions": [ - "$ref:RuleAction" - ], - "active": "Bool", - "enabled": "Bool", - "eventDescriptors": [ - "$ref:EventDescriptor" - ], - "executable": "Bool", - "exitActions": [ - "$ref:RuleAction" - ], - "id": "Uuid", + "actions": "$ref:RuleActions", "name": "String", - "stateEvaluator": "$ref:StateEvaluator", - "timeDescriptor": "$ref:TimeDescriptor" + "o:active": "Bool", + "o:enabled": "Bool", + "o:eventDescriptors": "$ref:EventDescriptors", + "o:executable": "Bool", + "o:exitActions": "$ref:RuleActions", + "o:id": "Uuid", + "o:stateEvaluator": "$ref:StateEvaluator", + "o:timeDescriptor": "$ref:TimeDescriptor" }, "RuleAction": { "o:actionTypeId": "Uuid", @@ -1808,9 +1854,7 @@ "o:deviceId": "Uuid", "o:interface": "String", "o:interfaceAction": "String", - "o:ruleActionParams": [ - "$ref:RuleActionParam" - ] + "o:ruleActionParams": "$ref:RuleActionParams" }, "RuleActionParam": { "o:eventParamTypeId": "Uuid", @@ -1819,8 +1863,14 @@ "o:paramTypeId": "Uuid", "o:stateDeviceId": "Uuid", "o:stateTypeId": "Uuid", - "o:value": "$ref:BasicType" + "o:value": "Variant" }, + "RuleActionParams": [ + "$ref:RuleActionParam" + ], + "RuleActions": [ + "$ref:RuleAction" + ], "RuleDescription": { "active": "Bool", "enabled": "Bool", @@ -1828,28 +1878,8 @@ "id": "Uuid", "name": "String" }, - "RuleError": [ - "RuleErrorNoError", - "RuleErrorInvalidRuleId", - "RuleErrorRuleNotFound", - "RuleErrorDeviceNotFound", - "RuleErrorEventTypeNotFound", - "RuleErrorStateTypeNotFound", - "RuleErrorActionTypeNotFound", - "RuleErrorInvalidParameter", - "RuleErrorInvalidRuleFormat", - "RuleErrorMissingParameter", - "RuleErrorInvalidRuleActionParameter", - "RuleErrorInvalidStateEvaluatorValue", - "RuleErrorTypesNotMatching", - "RuleErrorNotExecutable", - "RuleErrorInvalidTimeDescriptor", - "RuleErrorInvalidRepeatingOption", - "RuleErrorInvalidCalendarItem", - "RuleErrorInvalidTimeEventItem", - "RuleErrorContainsEventBasesAction", - "RuleErrorNoExitActions", - "RuleErrorInterfaceNotFound" + "Rules": [ + "$ref:Rule" ], "ServerConfiguration": { "address": "String", @@ -1858,16 +1888,7 @@ "port": "Uint", "sslEnabled": "Bool" }, - "SetupMethod": [ - "SetupMethodJustAdd", - "SetupMethodDisplayPin", - "SetupMethodEnterPin", - "SetupMethodPushButton", - "SetupMethodUserAndPassword", - "SetupMethodOAuth" - ], "State": { - "deviceId": "Uuid", "stateTypeId": "Uuid", "value": "Variant" }, @@ -1880,15 +1901,12 @@ "value": "Variant" }, "StateEvaluator": { - "o:childEvaluators": [ - "$ref:StateEvaluator" - ], + "o:childEvaluators": "$ref:StateEvaluators", "o:operator": "$ref:StateOperator", "o:stateDescriptor": "$ref:StateDescriptor" }, - "StateOperator": [ - "StateOperatorAnd", - "StateOperatorOr" + "StateEvaluators": [ + "$ref:StateEvaluator" ], "StateType": { "defaultValue": "Variant", @@ -1904,6 +1922,12 @@ "o:unit": "$ref:Unit", "type": "$ref:BasicType" }, + "StateTypes": [ + "$ref:StateType" + ], + "States": [ + "$ref:State" + ], "Tag": { "appId": "String", "o:deviceId": "Uuid", @@ -1911,112 +1935,41 @@ "o:value": "String", "tagId": "String" }, - "TagError": [ - "TagErrorNoError", - "TagErrorDeviceNotFound", - "TagErrorRuleNotFound", - "TagErrorTagNotFound" + "Tags": [ + "$ref:Tag" ], "TimeDescriptor": { - "o:calendarItems": [ - "$ref:CalendarItem" - ], - "o:timeEventItems": [ - "$ref:TimeEventItem" - ] + "o:calendarItems": "$ref:CalendarItems", + "o:timeEventItems": "$ref:TimeEventItems" }, "TimeEventItem": { "o:datetime": "Uint", "o:repeating": "$ref:RepeatingOption", "o:time": "Time" }, + "TimeEventItems": [ + "$ref:TimeEventItem" + ], "TokenInfo": { "creationTime": "Uint", - "deviceName": "String", + "deviveName": "String", "id": "Uuid", - "userName": "String" + "username": "String" }, - "Unit": [ - "UnitNone", - "UnitSeconds", - "UnitMinutes", - "UnitHours", - "UnitUnixTime", - "UnitMeterPerSecond", - "UnitKiloMeterPerHour", - "UnitDegree", - "UnitRadiant", - "UnitDegreeCelsius", - "UnitDegreeKelvin", - "UnitMired", - "UnitMilliBar", - "UnitBar", - "UnitPascal", - "UnitHectoPascal", - "UnitAtmosphere", - "UnitLumen", - "UnitLux", - "UnitCandela", - "UnitMilliMeter", - "UnitCentiMeter", - "UnitMeter", - "UnitKiloMeter", - "UnitGram", - "UnitKiloGram", - "UnitDezibel", - "UnitBpm", - "UnitKiloByte", - "UnitMegaByte", - "UnitGigaByte", - "UnitTeraByte", - "UnitMilliWatt", - "UnitWatt", - "UnitKiloWatt", - "UnitKiloWattHour", - "UnitEuroPerMegaWattHour", - "UnitEuroCentPerKiloWattHour", - "UnitPercentage", - "UnitPartsPerMillion", - "UnitEuro", - "UnitDollar", - "UnitHertz", - "UnitAmpere", - "UnitMilliAmpere", - "UnitVolt", - "UnitMilliVolt", - "UnitVoltAmpere", - "UnitVoltAmpereReactive", - "UnitAmpereHour", - "UnitMicroSiemensPerCentimeter", - "UnitDuration" - ], - "UserError": [ - "UserErrorNoError", - "UserErrorBackendError", - "UserErrorInvalidUserId", - "UserErrorDuplicateUserId", - "UserErrorBadPassword", - "UserErrorTokenNotFound", - "UserErrorPermissionDenied" - ], - "ValueOperator": [ - "ValueOperatorEquals", - "ValueOperatorNotEquals", - "ValueOperatorLess", - "ValueOperatorGreater", - "ValueOperatorLessOrEqual", - "ValueOperatorGreaterOrEqual" - ], "Vendor": { "displayName": "String", "id": "Uuid", "name": "String" }, + "Vendors": [ + "$ref:Vendor" + ], "WebServerConfiguration": { "address": "String", "authenticationEnabled": "Bool", "id": "String", "port": "Uint", + "publicFolder": "String", "sslEnabled": "Bool" }, "WiredNetworkDevice": { diff --git a/tests/auto/configurations/testconfigurations.cpp b/tests/auto/configurations/testconfigurations.cpp index 3412f670..3bcdb4de 100644 --- a/tests/auto/configurations/testconfigurations.cpp +++ b/tests/auto/configurations/testconfigurations.cpp @@ -321,7 +321,7 @@ void TestConfigurations::testDebugServerConfiguration() QVariantMap basicConfigurationMap = loadBasicConfiguration(); bool debugServerEnabled = basicConfigurationMap.value("debugServerEnabled").toBool(); - qDebug() << "Debug server enabled" << debugServerEnabled; + qCDebug(dcTests) << "Debug server enabled" << debugServerEnabled; QSignalSpy notificationSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); @@ -341,6 +341,8 @@ void TestConfigurations::testDebugServerConfiguration() params.clear(); response.clear(); configurationChangedNotifications.clear(); params.insert("enabled", newValue); + qCDebug(dcTests()) << "Enabling debug server"; + notificationSpy.clear(); response = injectAndWait("Configuration.SetDebugServerEnabled", params); verifyConfigurationError(response); @@ -361,7 +363,7 @@ void TestConfigurations::testDebugServerConfiguration() QVERIFY2(basicConfigurationNotificationMap.contains("debugServerEnabled"), "Notification does not contain key debugServerEnabled"); QVERIFY2(basicConfigurationNotificationMap.value("debugServerEnabled").toBool() == newValue, "Notification does not contain the new debugServerEnabled"); - qDebug() << "TestWebserver starting"; + qCDebug(dcTests()) << "TestWebserver starting"; foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; @@ -369,7 +371,7 @@ void TestConfigurations::testDebugServerConfiguration() } } - qDebug() << "Creating new webserver instance on 127.0.0.1:3333"; + qCDebug(dcTests) << "Creating new webserver instance on 127.0.0.1:3333"; WebServerConfiguration config; config.id = "Testwebserver for debug server interface"; config.address = QHostAddress("127.0.0.1"); diff --git a/tests/auto/jsonrpc/testjsonrpc.cpp b/tests/auto/jsonrpc/testjsonrpc.cpp index 51a666fd..e1c69d14 100644 --- a/tests/auto/jsonrpc/testjsonrpc.cpp +++ b/tests/auto/jsonrpc/testjsonrpc.cpp @@ -738,18 +738,17 @@ void TestJSONRPC::ruleAddedRemovedNotifications() QVariantMap actionNoParams; actionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId); actionNoParams.insert("deviceId", m_mockDeviceId); - actionNoParams.insert("ruleActionParams", QVariantList()); // EventDescriptor QVariantMap eventDescriptor; eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId); eventDescriptor.insert("deviceId", m_mockDeviceId); - eventDescriptor.insert("paramDescriptors", QVariantList()); + QVariantList eventDescriptors = QVariantList() << eventDescriptor; QVariantMap params; params.insert("name", "Test Rule notifications"); params.insert("actions", QVariantList() << actionNoParams); - params.insert("eventDescriptors", QVariantList() << eventDescriptor); + params.insert("eventDescriptors", eventDescriptors); params.insert("stateEvaluator", stateEvaluator); QVariant response = injectAndWait("Rules.AddRule", params); @@ -765,7 +764,11 @@ void TestJSONRPC::ruleAddedRemovedNotifications() QCOMPARE(notificationRuleMap.value("id").toString(), ruleId.toString()); QCOMPARE(notificationRuleMap.value("actions").toList(), QVariantList() << actionNoParams); QCOMPARE(notificationRuleMap.value("stateEvaluator").toMap().value("stateDescriptor").toMap(), stateDescriptor); - QCOMPARE(notificationRuleMap.value("eventDescriptors").toList(), QVariantList() << eventDescriptor); + QVERIFY2(notificationRuleMap.value("eventDescriptors").toList() == eventDescriptors, + QString("eventDescriptors not matching.\nExpected: %1\nGot %2") + .arg(QString(QJsonDocument::fromVariant(eventDescriptors).toJson())) + .arg(QString(QJsonDocument::fromVariant(notificationRuleMap.value("eventDescriptors").toList()).toJson())) + .toUtf8()); QCOMPARE(notificationRuleMap.value("exitActions").toList(), QVariantList()); // now remove the rule and check the RuleRemoved notification @@ -802,7 +805,6 @@ void TestJSONRPC::ruleActiveChangedNotifications() QVariantMap actionNoParams; actionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId); actionNoParams.insert("deviceId", m_mockDeviceId); - actionNoParams.insert("ruleActionParams", QVariantList()); params.clear(); response.clear(); params.insert("name", "Test Rule notifications"); diff --git a/tests/scripts/getconfigureddevices.sh b/tests/scripts/getconfigureddevices.sh index cbd8d221..1d6a39dd 100755 --- a/tests/scripts/getconfigureddevices.sh +++ b/tests/scripts/getconfigureddevices.sh @@ -6,14 +6,14 @@ if [ -z $1 ]; then fi if [ -z $2 ]; then -cat <