diff --git a/doc/jsonrpc-api.qdoc b/doc/jsonrpc-api.qdoc index b48bda9e..0b325e4b 100644 --- a/doc/jsonrpc-api.qdoc +++ b/doc/jsonrpc-api.qdoc @@ -122,7 +122,7 @@ See also: \l{RepeatingOption} \section2 Device \code { - "deviceClassId": "Uuid", + "thingClassId": "Uuid", "id": "Uuid", "name": "String", "o:parentId": "Uuid", @@ -1287,7 +1287,7 @@ Add a configured device with a setupMethod of SetupMethodJustAdd. For devices wi Params \code { - "deviceClassId": "Uuid", + "thingClassId": "Uuid", "name": "String", "o:deviceDescriptorId": "Uuid", "o:deviceParams": [ @@ -1359,11 +1359,11 @@ Returns \endcode See also: \l{DeviceError} \section2 Devices.GetActionTypes -Get action types for a specified deviceClassId. +Get action types for a specified thingClassId. Params \code { - "deviceClassId": "Uuid" + "thingClassId": "Uuid" } \endcode Returns @@ -1414,7 +1414,7 @@ Performs a device discovery and returns the results. This function may take a wh Params \code { - "deviceClassId": "Uuid", + "thingClassId": "Uuid", "o:discoveryParams": [ "$ref:Param" ] @@ -1432,11 +1432,11 @@ Returns \endcode See also: \l{DeviceDescriptor}, \l{DeviceError}, \l{Param} \section2 Devices.GetEventTypes -Get event types for a specified deviceClassId. +Get event types for a specified thingClassId. Params \code { - "deviceClassId": "Uuid" + "thingClassId": "Uuid" } \endcode Returns @@ -1482,11 +1482,11 @@ Returns \endcode See also: \l{Plugin} \section2 Devices.GetStateTypes -Get state types for a specified deviceClassId. +Get state types for a specified thingClassId. Params \code { - "deviceClassId": "Uuid" + "thingClassId": "Uuid" } \endcode Returns @@ -1547,7 +1547,7 @@ Params Returns \code { - "deviceClasses": [ + "thingClasses": [ "$ref:DeviceClass" ] } @@ -1573,7 +1573,7 @@ Pair a device. Use this for DeviceClasses with a setupMethod different than Setu Params \code { - "deviceClassId": "Uuid", + "thingClassId": "Uuid", "name": "String", "o:deviceDescriptorId": "Uuid", "o:deviceParams": [ @@ -3206,7 +3206,7 @@ See also: \l{Tag} "Devices.AddConfiguredDevice": { "description": "Add a configured device with a setupMethod of SetupMethodJustAdd. For devices with a setupMethod different than SetupMethodJustAdd, use PairDevice. Devices with CreateMethodJustAdd require all parameters to be supplied here. Devices with CreateMethodDiscovery require the use of a deviceDescriptorId. For discovered devices params are not required and will be taken from the DeviceDescriptor, however, they may be overridden by supplying parameters here.", "params": { - "deviceClassId": "Uuid", + "thingClassId": "Uuid", "name": "String", "o:deviceDescriptorId": "Uuid", "o:deviceParams": [ @@ -3256,9 +3256,9 @@ See also: \l{Tag} } }, "Devices.GetActionTypes": { - "description": "Get action types for a specified deviceClassId.", + "description": "Get action types for a specified thingClassId.", "params": { - "deviceClassId": "Uuid" + "thingClassId": "Uuid" }, "returns": { "actionTypes": [ @@ -3291,7 +3291,7 @@ See also: \l{Tag} "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", + "thingClassId": "Uuid", "o:discoveryParams": [ "$ref:Param" ] @@ -3305,9 +3305,9 @@ See also: \l{Tag} } }, "Devices.GetEventTypes": { - "description": "Get event types for a specified deviceClassId.", + "description": "Get event types for a specified thingClassId.", "params": { - "deviceClassId": "Uuid" + "thingClassId": "Uuid" }, "returns": { "eventTypes": [ @@ -3337,9 +3337,9 @@ See also: \l{Tag} } }, "Devices.GetStateTypes": { - "description": "Get state types for a specified deviceClassId.", + "description": "Get state types for a specified thingClassId.", "params": { - "deviceClassId": "Uuid" + "thingClassId": "Uuid" }, "returns": { "stateTypes": [ @@ -3379,7 +3379,7 @@ See also: \l{Tag} "o:vendorId": "Uuid" }, "returns": { - "deviceClasses": [ + "thingClasses": [ "$ref:DeviceClass" ] } @@ -3396,7 +3396,7 @@ See also: \l{Tag} "Devices.PairDevice": { "description": "Pair a device. Use this for DeviceClasses with a setupMethod different than SetupMethodJustAdd. Use deviceDescriptorId or deviceParams, depending on the createMethod of the device class. CreateMethodJustAdd takes the parameters you want to have with that device. CreateMethodDiscovery requires the use of a deviceDescriptorId, optionally, parameters can be overridden here. If success is true, the return values will contain a pairingTransactionId, a displayMessage and the setupMethod. Depending on the setupMethod you should either proceed with AddConfiguredDevice or PairDevice.", "params": { - "deviceClassId": "Uuid", + "thingClassId": "Uuid", "name": "String", "o:deviceDescriptorId": "Uuid", "o:deviceParams": [ @@ -4393,7 +4393,7 @@ See also: \l{Tag} "CreateMethodDiscovery" ], "Device": { - "deviceClassId": "Uuid", + "thingClassId": "Uuid", "id": "Uuid", "name": "String", "o:parentId": "Uuid", diff --git a/doc/plugin-json.qdoc b/doc/plugin-json.qdoc index 43adf97f..968a9501 100644 --- a/doc/plugin-json.qdoc +++ b/doc/plugin-json.qdoc @@ -39,7 +39,7 @@ "name": "VendorName", "displayName": "Name of the vendor", "id": "uuid", - "deviceClasses": [ + "thingClasses": [ ... ] } @@ -139,7 +139,7 @@ "id": "uuid", "name": "vendorName", "displayName": "Name of the vendor (translatable)", - "deviceClasses": [ + "thingClasses": [ ... ] } @@ -166,7 +166,7 @@ \li string \li The visible name of the vendor \unicode{0x2192} \l{Vendor::displayName()}. This string will be available for translations. \row - \li \tt deviceClasses + \li \tt thingClasses \li \b M \li array \li A list of \l{DeviceClass}{DeviceClasses} objects. @@ -176,7 +176,7 @@ \endtable \section2 The DeviceClass definition - A \l{Vendor} can support more then one \l{DeviceClass}, so the parameter \e deviceClasses in the vendor definition is a list. + A \l{Vendor} can support more then one \l{DeviceClass}, so the parameter \e thingClasses in the vendor definition is a list. Each element of this list represents a \l{DeviceClass} in nymea. \code @@ -185,10 +185,10 @@ "vendors": [ { .. - "deviceClasses": [ + "thingClasses": [ { "id": "uuid", - "name": "deviceClassName", + "name": "thingClassName", "displayName": "The name of the device class (translatable)", "o:createMethods": [ ], "o:setupMethod": "SetupMethod", @@ -344,7 +344,7 @@ \li \tt name \li \b M \li string - \li This parameter will be used to define the ParamTypeId variable named \tt{deviceClassNameParamTypeId} in the plugininfo.h, so it can be used in the code. + \li This parameter will be used to define the ParamTypeId variable named \tt{thingClassNameParamTypeId} in the plugininfo.h, so it can be used in the code. \row \li \tt displayName \li \b M @@ -454,7 +454,7 @@ A \l{StateType} has following parameters: \li \tt name \li \b M \li string - \li This parameter will be used to define the StateTypeId variable named \tt{deviceClassNameStateTypeId} in the plugininfo.h, so it can be used in the code. + \li This parameter will be used to define the StateTypeId variable named \tt{thingClassNameStateTypeId} in the plugininfo.h, so it can be used in the code. \row \li \tt displayName \li \b M @@ -618,7 +618,7 @@ A \l{StateType} has following parameters: \li \tt name \li \b M \li string - \li This parameter will be used to define the ActionTypeId variable named \tt{deviceClassNameActionTypeId} in the plugininfo.h, so it can be used in the code. + \li This parameter will be used to define the ActionTypeId variable named \tt{thingClassNameActionTypeId} in the plugininfo.h, so it can be used in the code. \row \li \tt displayName \li \b M @@ -665,7 +665,7 @@ A \l{StateType} has following parameters: \li \tt name \li \b M \li string - \li This parameter will be used to define the EventTypeId variable named \tt{deviceClassNameEventTypeId} in the plugininfo.h, so it can be used in the code. + \li This parameter will be used to define the EventTypeId variable named \tt{thingClassNameEventTypeId} in the plugininfo.h, so it can be used in the code. \row \li \tt displayName \li \b M diff --git a/doc/tutorials/plugin-wizard.qdoc b/doc/tutorials/plugin-wizard.qdoc index 3860dbf7..d80dc172 100644 --- a/doc/tutorials/plugin-wizard.qdoc +++ b/doc/tutorials/plugin-wizard.qdoc @@ -128,7 +128,7 @@ each with its own device classes. The uuid of the vendor guh is known, and therefore already filled out. You have to update the vendor uuid, name and id with your plugin information. - \printuntil "deviceClasses" + \printuntil "thingClasses" Here you can see the default created deviceclass, showing you the basic structure of a device class. diff --git a/libnymea-core/integrations/thingmanagerimplementation.cpp b/libnymea-core/integrations/thingmanagerimplementation.cpp index c869929a..3e61c91b 100644 --- a/libnymea-core/integrations/thingmanagerimplementation.cpp +++ b/libnymea-core/integrations/thingmanagerimplementation.cpp @@ -223,8 +223,10 @@ Thing::ThingError ThingManagerImplementation::setPluginConfig(const PluginId &pl } Thing::ThingError verify = ThingUtils::verifyParams(plugin->configurationDescription(), pluginConfig); - if (verify != Thing::ThingErrorNoError) + if (verify != Thing::ThingErrorNoError) { + qCWarning(dcThingManager()) << "Could not set plugin configuration of" << plugin << "because the param verification failed with error" << verify; return verify; + } ParamList params = buildParams(plugin->configurationDescription(), pluginConfig); Thing::ThingError result = plugin->setConfiguration(params); @@ -280,14 +282,14 @@ ThingDiscoveryInfo* ThingManagerImplementation::discoverThings(const ThingClassI return discoveryInfo; } if (!thingClass.createMethods().testFlag(ThingClass::CreateMethodDiscovery)) { - qCWarning(dcThingManager) << "Thing discovery failed. Thing class" << thingClass.name() << "cannot be discovered."; + qCWarning(dcThingManager) << "Thing discovery failed." << thingClass << "cannot be discovered."; ThingDiscoveryInfo *discoveryInfo = new ThingDiscoveryInfo(thingClassId, params, this); discoveryInfo->finish(Thing::ThingErrorCreationMethodNotSupported); return discoveryInfo; } IntegrationPlugin *plugin = m_integrationPlugins.value(thingClass.pluginId()); if (!plugin) { - qCWarning(dcThingManager) << "Thing discovery failed. Plugin not found for thing class" << thingClass.name(); + qCWarning(dcThingManager) << "Thing discovery failed. Plugin not found for" << thingClass; ThingDiscoveryInfo *discoveryInfo = new ThingDiscoveryInfo(thingClassId, params, this); discoveryInfo->finish(Thing::ThingErrorPluginNotFound, tr("The plugin for this thing is not loaded.")); return discoveryInfo; @@ -295,7 +297,7 @@ ThingDiscoveryInfo* ThingManagerImplementation::discoverThings(const ThingClassI Thing::ThingError result = ThingUtils::verifyParams(thingClass.discoveryParamTypes(), params); if (result != Thing::ThingErrorNoError) { - qCWarning(dcThingManager) << "Thing discovery failed. Parameter verification failed."; + qCWarning(dcThingManager()) << "Could not discover thing of" << thingClass << "from" << plugin << "because the param verification failed with error" << result; ThingDiscoveryInfo *discoveryInfo = new ThingDiscoveryInfo(thingClassId, params, this); discoveryInfo->finish(result); return discoveryInfo; @@ -318,7 +320,7 @@ ThingDiscoveryInfo* ThingManagerImplementation::discoverThings(const ThingClassI } }); - qCDebug(dcThingManager) << "Thing discovery for" << thingClass.name() << "started..."; + qCDebug(dcThingManager) << "Thing discovery for" << thingClass << "started..."; plugin->discoverThings(discoveryInfo); return discoveryInfo; } @@ -346,7 +348,7 @@ ThingSetupInfo *ThingManagerImplementation::addConfiguredThing(const ThingDescri return info; } if (!thingClass.createMethods().testFlag(ThingClass::CreateMethodDiscovery)) { - qCWarning(dcThingManager()) << "Cannot add thing. This thing cannot be added via discovery."; + qCWarning(dcThingManager()) << "Cannot add thing. This thing of" << thingClass << "cannot be added via discovery."; ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); info->finish(Thing::ThingErrorCreationMethodNotSupported); return info; @@ -379,7 +381,7 @@ ThingSetupInfo* ThingManagerImplementation::reconfigureThing(const ThingId &thin foreach (const ParamType ¶mType, thingClass.paramTypes()) { if (paramType.readOnly() && params.hasParam(paramType.id())) { ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); - qCWarning(dcThingManager()) << "Parameter" << paramType.name() << paramType.id() << "is not writable"; + qCWarning(dcThingManager()) << "Cannot reconfigure thing" << thing << "because the parameter" << paramType.name() << paramType.id().toString() << "is not writable"; info->finish(Thing::ThingErrorParameterNotWritable); return info; } @@ -410,7 +412,7 @@ ThingSetupInfo *ThingManagerImplementation::reconfigureThing(const ThingDescript ThingClass thingClass = findThingClass(thing->thingClassId()); if (!thingClass.isValid()) { - qCWarning(dcThingManager()) << "Cannot reconfigure tning. No ThingClass with ID" << thing->thingClassId() << "found."; + qCWarning(dcThingManager()) << "Cannot reconfigure thing. No ThingClass with ID" << thing->thingClassId() << "found."; ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); info->finish(Thing::ThingErrorThingClassNotFound); return info; @@ -432,7 +434,7 @@ ThingSetupInfo *ThingManagerImplementation::reconfigureThingInternal(Thing *thin Thing::ThingError result = ThingUtils::verifyParams(thing->thingClass().paramTypes(), params); if (result != Thing::ThingErrorNoError) { - qCWarning(dcThingManager()) << "Cannot reconfigure thing. Params failed validation."; + qCWarning(dcThingManager()) << "Cannot reconfigure" << thing << "from" << plugin << "because the param verification failed with error" << result; ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); info->finish(result); return info; @@ -500,7 +502,7 @@ Thing::ThingError ThingManagerImplementation::setThingSettings(const ThingId &th } Thing::ThingError status = ThingUtils::verifyParams(thing->thingClass().settingsTypes(), settings); if (status != Thing::ThingErrorNoError) { - qCWarning(dcThingManager()) << "Error setting thing settings for" << thing->name() << thing->id().toString(); + qCWarning(dcThingManager()) << "Cannot set thing settings of" << thing << "from" << "because the param verification failed with error" << status; return status; } // build a list of settings using: a) provided new settings b) previous settings and c) default values @@ -517,7 +519,7 @@ Thing::ThingError ThingManagerImplementation::setStateLogging(const ThingId &thi return Thing::ThingErrorThingNotFound; } if (!thing->thingClass().stateTypes().findById(stateTypeId).isValid()) { - qCWarning(dcThingManager()) << "Cannot configure state logging. Thing" << thingId.toString() << "has no state type with id" << stateTypeId; + qCWarning(dcThingManager()) << "Cannot configure state logging. Thing" << thing << "has no state type with id" << stateTypeId; return Thing::ThingErrorStateTypeNotFound; } QList loggedStateTypes = thing->loggedStateTypeIds(); @@ -541,7 +543,7 @@ Thing::ThingError ThingManagerImplementation::setEventLogging(const ThingId &thi return Thing::ThingErrorThingNotFound; } if (!thing->thingClass().eventTypes().findById(eventTypeId).isValid()) { - qCWarning(dcThingManager()) << "Cannot configure event logging. Thing" << thingId.toString() << "has no event type with id" << eventTypeId; + qCWarning(dcThingManager()) << "Cannot configure event logging. Thing" << thing << "has no event type with id" << eventTypeId; return Thing::ThingErrorEventTypeNotFound; } QList loggedEventTypes = thing->loggedEventTypeIds(); @@ -565,7 +567,7 @@ Thing::ThingError ThingManagerImplementation::setStateFilter(const ThingId &thin return Thing::ThingErrorThingNotFound; } if (!thing->thingClass().stateTypes().findById(stateTypeId).isValid()) { - qCWarning(dcThingManager()) << "Cannot configure state filter. Thing" << thingId.toString() << "has no state type with id" << stateTypeId; + qCWarning(dcThingManager()) << "Cannot configure state filter. Thing" << thing << "has no state type with id" << stateTypeId; return Thing::ThingErrorEventTypeNotFound; } @@ -665,7 +667,7 @@ ThingPairingInfo *ThingManagerImplementation::confirmPairing(const PairingTransa ThingClass thingClass = m_supportedThings.value(thingClassId); IntegrationPlugin *plugin = m_integrationPlugins.value(thingClass.pluginId()); if (!plugin) { - qCWarning(dcThingManager) << "Can't find a plugin for this thing class:" << thingClass; + qCWarning(dcThingManager) << "Can't find a plugin for this" << thingClass; ThingPairingInfo *info = new ThingPairingInfo(pairingTransactionId, thingClassId, context.thingId, context.thingName, context.params, context.parentId, this); info->finish(Thing::ThingErrorPluginNotFound); return info; @@ -727,13 +729,13 @@ ThingPairingInfo *ThingManagerImplementation::confirmPairing(const PairingTransa if (info->status() != Thing::ThingErrorNoError) { if (addNewThing) { - qCWarning(dcThingManager()) << "Failed to set up thing" << info->thing()->name() + qCWarning(dcThingManager()) << "Failed to set up thing" << info->thing() << "Not adding thing to the system. Error:" << info->status() << info->displayMessage(); info->thing()->deleteLater(); } else { - qCWarning(dcThingManager()) << "Failed to reconfigure thing" << info->thing()->name() << + qCWarning(dcThingManager()) << "Failed to reconfigure thing" << info->thing() << "Error:" << info->status() << info->displayMessage(); info->thing()->setSetupStatus(Thing::ThingSetupStatusFailed, info->status(), info->displayMessage()); // TODO: restore parameters? @@ -766,14 +768,14 @@ ThingSetupInfo* ThingManagerImplementation::addConfiguredThingInternal(const Thi { ThingClass thingClass = findThingClass(thingClassId); if (thingClass.id().isNull()) { - qCWarning(dcThingManager()) << "Cannot add thing. ThingClass" << thingClassId << "not found."; + qCWarning(dcThingManager()) << "Cannot add thing. The ThingClass ID" << thingClassId.toString() << "could not be found."; ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); info->finish(Thing::ThingErrorThingClassNotFound); return info; } if (thingClass.setupMethod() != ThingClass::SetupMethodJustAdd) { - qCWarning(dcThingManager()) << "Cannot add thing. This thing cannot be added this way. (SetupMethodJustAdd)"; + qCWarning(dcThingManager()) << "Cannot add thing of" << thingClass << "this way. (SetupMethodJustAdd)"; ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); info->finish(Thing::ThingErrorCreationMethodNotSupported); return info; @@ -787,16 +789,16 @@ ThingSetupInfo* ThingManagerImplementation::addConfiguredThingInternal(const Thi IntegrationPlugin *plugin = m_integrationPlugins.value(thingClass.pluginId()); if (!plugin) { - qCWarning(dcThingManager()) << "Cannot add thing. Plugin for thing class" << thingClass.name() << "not found."; + qCWarning(dcThingManager()) << "Cannot add thing. Plugin for thing class" << thingClass << "not found."; ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); info->finish(Thing::ThingErrorPluginNotFound); return info; } - // set params + // Set params Thing::ThingError paramsResult = ThingUtils::verifyParams(thingClass.paramTypes(), params); if (paramsResult != Thing::ThingErrorNoError) { - qCWarning(dcThingManager()) << "Cannot add thing. Parameter verification failed."; + qCWarning(dcThingManager()) << "Cannot add thing of" << thingClass << "from" << plugin << "because the param verification failed with error" << paramsResult; ThingSetupInfo *info = new ThingSetupInfo(nullptr, this); info->finish(paramsResult); return info; @@ -822,14 +824,14 @@ ThingSetupInfo* ThingManagerImplementation::addConfiguredThingInternal(const Thi ThingSetupInfo *info = setupThing(thing); connect(info, &ThingSetupInfo::finished, this, [this, info](){ if (info->status() != Thing::ThingErrorNoError) { - qCWarning(dcThingManager) << "Thing setup failed. Not adding thing to system."; + qCWarning(dcThingManager) << "Thing setup failed for" << info->thing() << "Not adding thing to system."; info->thing()->deleteLater(); return; } info->thing()->setSetupStatus(Thing::ThingSetupStatusComplete, Thing::ThingErrorNoError); - qCDebug(dcThingManager) << "Thing setup complete."; + qCDebug(dcThingManager) << "Thing setup complete for" << info->thing(); registerThing(info->thing()); storeConfiguredThings(); emit thingAdded(info->thing()); @@ -852,9 +854,9 @@ Thing::ThingError ThingManagerImplementation::removeConfiguredThing(const ThingI } IntegrationPlugin *plugin = m_integrationPlugins.value(thing->pluginId()); if (!plugin) { - qCWarning(dcThingManager()).nospace() << "Plugin not loaded for thing " << thing->name() << ". Not calling thingRemoved on plugin."; + qCWarning(dcThingManager()).nospace() << "Plugin not loaded for thing " << thing << ". Not calling thingRemoved on plugin."; } else if (thing->setupStatus() == Thing::ThingSetupStatusInProgress) { - qCWarning(dcThingManager()).nospace() << "Thing " << thing->name() << " is still being set up. Aborting setup."; + qCWarning(dcThingManager()).nospace() << "Thing " << thing << " is still being set up. Aborting setup."; ThingSetupInfo *setupInfo = m_pendingSetups.value(thingId); emit setupInfo->aborted(); } else if (thing->setupStatus() == Thing::ThingSetupStatusComplete) { @@ -890,14 +892,14 @@ BrowseResult *ThingManagerImplementation::browseThing(const ThingId &thingId, co BrowseResult *result = new BrowseResult(thing, this, itemId, locale, this, 30000); if (!thing) { - qCWarning(dcThingManager()) << "Cannot browse thing. No such thing:" << thingId.toString(); + qCWarning(dcThingManager()) << "Cannot browse thing. No thing with ID:" << thingId.toString(); result->finish(Thing::ThingErrorThingNotFound); return result; } IntegrationPlugin *plugin = m_integrationPlugins.value(thing->pluginId()); if (!plugin) { - qCWarning(dcThingManager()) << "Cannot browse thing. Plugin not found for thing" << thing; + qCWarning(dcThingManager()) << "Cannot browse thing. Plugin not found for" << thing; return result; } @@ -907,7 +909,7 @@ BrowseResult *ThingManagerImplementation::browseThing(const ThingId &thingId, co } if (!thing->thingClass().browsable()) { - qCWarning(dcThingManager()) << "Cannot browse thing. ThingClass" << thing->thingClass().name() << "is not browsable."; + qCWarning(dcThingManager()) << "Cannot browse thing. ThingClass" << thing->thingClass() << "is not browsable."; result->finish(Thing::ThingErrorUnsupportedFeature); return result; } @@ -915,7 +917,7 @@ BrowseResult *ThingManagerImplementation::browseThing(const ThingId &thingId, co plugin->browseThing(result); connect(result, &BrowseResult::finished, this, [result](){ if (result->status() != Thing::ThingErrorNoError) { - qCWarning(dcThingManager()) << "Browse thing failed:" << result->status(); + qCWarning(dcThingManager()) << "Browsing" << result->thing() << "failed:" << result->status(); } }); return result; @@ -928,14 +930,14 @@ BrowserItemResult *ThingManagerImplementation::browserItemDetails(const ThingId BrowserItemResult *result = new BrowserItemResult(thing, this, itemId, locale, this, 30000); if (!thing) { - qCWarning(dcThingManager()) << "Cannot browse thing. No such thing:" << thingId.toString(); + qCWarning(dcThingManager()) << "Cannot browse thing. No thing with ID:" << thingId.toString(); result->finish(Thing::ThingErrorThingNotFound); return result; } IntegrationPlugin *plugin = m_integrationPlugins.value(thing->pluginId()); if (!plugin) { - qCWarning(dcThingManager()) << "Cannot browse thing. Plugin not found for thing" << thing; + qCWarning(dcThingManager()) << "Cannot browse thing. Plugin not found for" << thing; return result; } @@ -945,7 +947,7 @@ BrowserItemResult *ThingManagerImplementation::browserItemDetails(const ThingId } if (!thing->thingClass().browsable()) { - qCWarning(dcThingManager()) << "Cannot browse thing. ThingClass" << thing->thingClass().name() << "is not browsable."; + qCWarning(dcThingManager()) << "Cannot browse thing. ThingClass" << thing->thingClass() << "is not browsable."; result->finish(Thing::ThingErrorUnsupportedFeature); return result; } @@ -953,7 +955,7 @@ BrowserItemResult *ThingManagerImplementation::browserItemDetails(const ThingId plugin->browserItem(result); connect(result, &BrowserItemResult::finished, this, [result](){ if (result->status() != Thing::ThingErrorNoError) { - qCWarning(dcThingManager()) << "Browsing thing failed:" << result->status(); + qCWarning(dcThingManager()) << "Browsing" << result->thing() << "failed:" << result->status(); } }); return result; @@ -972,7 +974,7 @@ BrowserActionInfo* ThingManagerImplementation::executeBrowserItem(const BrowserA IntegrationPlugin *plugin = m_integrationPlugins.value(thing->pluginId()); if (!plugin) { - qCWarning(dcThingManager()) << "Cannot browse thing. Plugin not found for thing" << thing; + qCWarning(dcThingManager()) << "Cannot browse thing. Plugin not found for" << thing; info->finish(Thing::ThingErrorPluginNotFound); return info; } @@ -1051,7 +1053,7 @@ IOConnectionResult ThingManagerImplementation::connectIO(const IOConnection &con return result; } if (!inputThing->thingClass().stateTypes().contains(connection.inputStateTypeId())) { - qCWarning(dcThingManager()) << "Input thing" << inputThing->name() << "does not have a state with id" << connection.inputStateTypeId(); + qCWarning(dcThingManager()) << "Input thing" << inputThing << "does not have a state with id" << connection.inputStateTypeId(); result.error = Thing::ThingErrorStateTypeNotFound; return result; } @@ -1059,19 +1061,19 @@ IOConnectionResult ThingManagerImplementation::connectIO(const IOConnection &con // Check if this is actually an input if (inputStateType.ioType() != Types::IOTypeDigitalInput && inputStateType.ioType() != Types::IOTypeAnalogInput) { - qCWarning(dcThingManager()) << "The given input state is neither a digital nor an analog input."; + qCWarning(dcThingManager()) << "The given input state" << inputStateType.name() << "from" << inputThing << "is neither a digital nor an analog input."; result.error = Thing::ThingErrorInvalidParameter; return result; } Thing *outputThing = m_configuredThings.value(connection.outputThingId()); if (!outputThing) { - qCWarning(dcThingManager()) << "Could not find outputThing" << connection.outputThingId() << "in configured things. Not adding IO connection."; + qCWarning(dcThingManager()) << "Could not find outputThing with ID" << connection.outputThingId() << "in configured things. Not adding IO connection."; result.error = Thing::ThingErrorThingNotFound; return result; } if (!outputThing->thingClass().stateTypes().contains(connection.outputStateTypeId())) { - qCWarning(dcThingManager()) << "Output thing" << outputThing->name() << "does not have a state with id" << connection.outputStateTypeId(); + qCWarning(dcThingManager()) << "Output thing" << outputThing << "does not have a state with id" << connection.outputStateTypeId(); result.error = Thing::ThingErrorStateTypeNotFound; return result; } @@ -1079,7 +1081,7 @@ IOConnectionResult ThingManagerImplementation::connectIO(const IOConnection &con // Check if this is actually an output if (outputStateType.ioType() != Types::IOTypeDigitalOutput && outputStateType.ioType() != Types::IOTypeAnalogOutput) { - qCWarning(dcThingManager()) << "The given output state is neither a digital nor an analog output."; + qCWarning(dcThingManager()) << "The given output state " << outputStateType.name() << "from" << outputThing << "is neither a digital nor an analog output."; result.error = Thing::ThingErrorInvalidParameter; return result; } @@ -1099,12 +1101,12 @@ IOConnectionResult ThingManagerImplementation::connectIO(const IOConnection &con // Check if either input or output is already connected foreach (const IOConnectionId &id, m_ioConnections.keys()) { if (m_ioConnections.value(id).inputThingId() == connection.inputThingId() && m_ioConnections.value(id).inputStateTypeId() == connection.inputStateTypeId()) { - qCDebug(dcThingManager()).nospace() << "Thing " << inputThing->name() << " already has an IO connection on " << inputStateType.displayName() << ". Replacing old connection."; + qCDebug(dcThingManager()).nospace() << inputThing << "already has an IO connection on " << inputStateType.displayName() << ". Replacing old connection."; disconnectIO(id); continue; } if (m_ioConnections.value(id).outputThingId() == connection.outputThingId() && m_ioConnections.value(id).outputStateTypeId() == connection.outputStateTypeId()) { - qCDebug(dcThingManager()).nospace() << "Thing " << inputThing->name() << " already has an IO connection on " << inputStateType.displayName() << ". Replacing old connection."; + qCDebug(dcThingManager()).nospace() << inputThing << "already has an IO connection on " << inputStateType.displayName() << ". Replacing old connection."; disconnectIO(id); } } @@ -1292,14 +1294,14 @@ ThingActionInfo *ThingManagerImplementation::executeAction(const Action &action) Action finalAction = action; Thing *thing = m_configuredThings.value(action.thingId()); if (!thing) { - qCWarning(dcThingManager()) << "Cannot execute action. No such thing:" << action.thingId(); + qCWarning(dcThingManager()) << "Cannot execute action. No thing with ID:" << action.thingId(); ThingActionInfo *info = new ThingActionInfo(nullptr, action, this); info->finish(Thing::ThingErrorThingNotFound); return info; } if (!thing->setupComplete()) { - qCWarning(dcThingManager()) << "Cannot execute action. Thing" << thing->name() << "hasn't completed setup."; + qCWarning(dcThingManager()) << "Cannot execute action. Thing" << thing << "hasn't completed setup."; ThingActionInfo *info = new ThingActionInfo(nullptr, action, this); info->finish(Thing::ThingErrorSetupFailed); return info; @@ -1309,12 +1311,20 @@ ThingActionInfo *ThingManagerImplementation::executeAction(const Action &action) ThingClass thingClass = findThingClass(thing->thingClassId()); ActionType actionType = thingClass.actionTypes().findById(action.actionTypeId()); if (actionType.id().isNull()) { - qCWarning(dcThingManager()) << "Cannot execute action. No such action type" << action.actionTypeId(); + qCWarning(dcThingManager()) << "Cannot execute action on" << thing << "No ActionType with ID" << action.actionTypeId(); ThingActionInfo *info = new ThingActionInfo(thing, action, this); info->finish(Thing::ThingErrorActionTypeNotFound); return info; } + IntegrationPlugin *plugin = m_integrationPlugins.value(thing->pluginId()); + if (!plugin) { + qCWarning(dcThingManager()) << "Cannot execute action" << actionType << "on" << thing << ". Plugin not found fot this thing."; + ThingActionInfo *info = new ThingActionInfo(thing, action, this); + info->finish(Thing::ThingErrorPluginNotFound); + return info; + } + // If there's a stateType with the same id, we'll need to take min/max values from the state as // they might change at runtime ParamTypes paramTypes = actionType.paramTypes(); @@ -1328,7 +1338,7 @@ ThingActionInfo *ThingManagerImplementation::executeAction(const Action &action) Thing::ThingError paramCheck = ThingUtils::verifyParams(paramTypes, action.params()); if (paramCheck != Thing::ThingErrorNoError) { - qCWarning(dcThingManager()) << "Cannot execute action. Parameter verification failed."; + qCWarning(dcThingManager()) << "Cannot execute action" << actionType << "on" << thing << "from" << plugin << "because the param verification failed with error" << paramCheck; ThingActionInfo *info = new ThingActionInfo(thing, action, this); info->finish(paramCheck); return info; @@ -1337,14 +1347,6 @@ ThingActionInfo *ThingManagerImplementation::executeAction(const Action &action) finalAction.setParams(finalParams); ThingActionInfo *info = new ThingActionInfo(thing, finalAction, this, 15000); - - IntegrationPlugin *plugin = m_integrationPlugins.value(thing->pluginId()); - if (!plugin) { - qCWarning(dcThingManager()) << "Cannot execute action. Plugin not found for device" << thing->name(); - info->finish(Thing::ThingErrorPluginNotFound); - return info; - } - connect(info, &ThingActionInfo::finished, this, [=](){ emit actionExecuted(action, info->status()); }); @@ -1449,7 +1451,7 @@ void ThingManagerImplementation::loadPlugin(IntegrationPlugin *pluginIface) qCDebug(dcThingManager) << "**** Loaded plugin" << pluginIface->pluginName(); foreach (const Vendor &vendor, pluginIface->supportedVendors()) { - qCDebug(dcThingManager) << "* Loaded vendor:" << vendor.name() << vendor.id(); + qCDebug(dcThingManager) << "* Loaded vendor:" << vendor.name() << vendor.id().toString(); if (m_supportedVendors.contains(vendor.id())) continue; @@ -1458,7 +1460,7 @@ void ThingManagerImplementation::loadPlugin(IntegrationPlugin *pluginIface) foreach (const ThingClass &thingClass, pluginIface->supportedThings()) { if (!m_supportedVendors.contains(thingClass.vendorId())) { - qCWarning(dcThingManager) << "Vendor not found. Ignoring thing. VendorId:" << thingClass.vendorId() << "ThingClass:" << thingClass.name() << thingClass.id(); + qCWarning(dcThingManager) << "Vendor not found. Ignoring thing. VendorId:" << thingClass.vendorId().toString() << "ThingClass:" << thingClass.name() << thingClass.id().toString(); continue; } m_vendorThingMap[thingClass.vendorId()].append(thingClass.id()); @@ -1492,7 +1494,7 @@ void ThingManagerImplementation::loadPlugin(IntegrationPlugin *pluginIface) if (params.count() > 0) { Thing::ThingError status = pluginIface->setConfiguration(params); if (status != Thing::ThingErrorNoError) { - qCWarning(dcThingManager) << "Error setting params to plugin. Broken configuration?"; + qCWarning(dcThingManager) << "Error setting params to plugin" << pluginIface->pluginId().toString() << pluginIface->pluginDisplayName() << ". Broken configuration?"; } } @@ -1722,7 +1724,7 @@ void ThingManagerImplementation::onAutoThingsAppeared(const ThingDescriptors &th } if (!thingDescriptor.parentId().isNull() && !m_configuredThings.contains(thingDescriptor.parentId())) { - qCWarning(dcThingManager()) << "Invalid parent thing id. Not adding thing to the system."; + qCWarning(dcThingManager()) << "Invalid parent thing id" << thingDescriptor.parentId() << "in" << thingClass << "Not adding thing to the system."; continue; } @@ -1732,7 +1734,7 @@ void ThingManagerImplementation::onAutoThingsAppeared(const ThingDescriptors &th if (!thingDescriptor.thingId().isNull()) { thing = findConfiguredThing(thingDescriptor.thingId()); if (!thing) { - qCWarning(dcThingManager()) << "Could not find thing for auto thing descriptor" << thingDescriptor.thingId(); + qCWarning(dcThingManager()) << "Could not find thing for auto thing descriptor" << thingDescriptor.thingId().toString(); continue; } qCDebug(dcThingManager()) << "Start reconfiguring auto thing" << thing; @@ -1751,13 +1753,13 @@ void ThingManagerImplementation::onAutoThingsAppeared(const ThingDescriptors &th initThing(thing); - qCDebug(dcThingManager()) << "Setting up auto thing:" << thing->name() << thing->id().toString(); + qCDebug(dcThingManager()) << "Setting up auto thing:" << thing; ThingSetupInfo *info = setupThing(thing); connect(info, &ThingSetupInfo::finished, thing, [this, info](){ if (info->status() != Thing::ThingErrorNoError) { - qCWarning(dcThingManager) << "Thing setup failed. Not adding auto thing to system."; + qCWarning(dcThingManager) << "Setting up" << info->thing() << "failed:" << info->status() << "Not adding auto thing to system."; info->thing()->deleteLater(); return; } @@ -1777,19 +1779,19 @@ void ThingManagerImplementation::onAutoThingDisappeared(const ThingId &thingId) Thing *thing = m_configuredThings.value(thingId); if (!thing) { - qCWarning(dcThingManager) << "Received an autoThingDisappeared signal but this thing is unknown:" << thingId; + qCWarning(dcThingManager) << "Received an autoThingDisappeared signal from plugin" << plugin->pluginDisplayName() << plugin->pluginId().toString() << "but this thing is unknown:" << thingId.toString(); return; } ThingClass thingClass = m_supportedThings.value(thing->thingClassId()); if (thingClass.pluginId() != plugin->pluginId()) { - qCWarning(dcThingManager) << "Received a autoThingDisappeared signal but emitting plugin does not own the thing"; + qCWarning(dcThingManager) << "Received a autoThingDisappeared signal from plugin" << plugin->pluginDisplayName() << plugin->pluginId().toString() << "but emitting plugin does not own the thing"; return; } if (!thing->autoCreated()) { - qCWarning(dcThingManager) << "Received an autoThingDisappeared signal but thing creationMethod is not CreateMothodAuto"; + qCWarning(dcThingManager) << "Received an autoThingDisappeared signal from plugin" << plugin->pluginDisplayName() << plugin->pluginId().toString() << "but thing creationMethod is not CreateMothodAuto"; return; } @@ -1811,7 +1813,7 @@ void ThingManagerImplementation::cleanupThingStateCache() foreach (const QFileInfo &entry, dir.entryList()) { ThingId thingId(entry.baseName()); if (!m_configuredThings.contains(thingId)) { - qCDebug(dcThingManager()) << "Thing ID" << thingId << "not found in configured things. Cleaning up stale thing state cache."; + qCDebug(dcThingManager()) << "Thing ID" << thingId.toString() << "not found in configured things. Cleaning up stale thing state cache."; QFile::remove(entry.absoluteFilePath()); } } @@ -1827,7 +1829,7 @@ void ThingManagerImplementation::onEventTriggered(Event event) } EventType eventType = thing->thingClass().eventTypes().findById(event.eventTypeId()); if (!eventType.isValid()) { - qCWarning(dcThingManager()) << "The given thing does not have an event type of id " + event.eventTypeId().toString() + ". Not forwarding event."; + qCWarning(dcThingManager()) << "The given thing" << thing << "does not have an event type of id " + event.eventTypeId().toString() + ". Not forwarding event."; return; } // configure logging @@ -2035,7 +2037,7 @@ void ThingManagerImplementation::pairThingInternal(ThingPairingInfo *info) IntegrationPlugin *plugin = m_integrationPlugins.value(thingClass.pluginId()); if (!plugin) { - qCWarning(dcThingManager) << "Cannot pair thing class" << thingClass.name() << "because no plugin for it is loaded."; + qCWarning(dcThingManager) << "Cannot pair thing class" << thingClass << "because no plugin for it is loaded."; info->finish(Thing::ThingErrorPluginNotFound); return; } @@ -2230,7 +2232,7 @@ void ThingManagerImplementation::trySetupThing(Thing *thing) connect(info, &ThingSetupInfo::finished, thing, [this, info, thing](){ if (info->status() != Thing::ThingErrorNoError) { - qCWarning(dcThingManager()) << "Error setting up thing" << info->thing()->name() << info->thing()->id().toString() << info->status() << info->displayMessage(); + qCWarning(dcThingManager()) << "Error setting up" << info->thing() << info->status() << info->displayMessage(); info->thing()->setSetupStatus(Thing::ThingSetupStatusFailed, info->status(), info->displayMessage()); emit thingChanged(info->thing()); @@ -2244,7 +2246,7 @@ void ThingManagerImplementation::trySetupThing(Thing *thing) return; } - qCDebug(dcThingManager()) << "Setup complete for thing" << info->thing(); + qCDebug(dcThingManager()) << "Setup complete for" << info->thing(); info->thing()->setSetupStatus(Thing::ThingSetupStatusComplete, Thing::ThingErrorNoError); emit thingChanged(info->thing()); postSetupThing(info->thing()); diff --git a/libnymea-core/logging/logentry.cpp b/libnymea-core/logging/logentry.cpp index d1d2bbce..8c892828 100644 --- a/libnymea-core/logging/logentry.cpp +++ b/libnymea-core/logging/logentry.cpp @@ -170,6 +170,7 @@ int LogEntry::errorCode() const QDebug operator<<(QDebug dbg, const LogEntry &entry) { + QDebugStateSaver saver(dbg); QMetaEnum metaEnum; dbg.nospace() << "LogEntry (" << entry.timestamp().toString() << ")" << endl; dbg.nospace() << " time stamp: " << entry.timestamp().toTime_t() << endl; @@ -184,7 +185,7 @@ QDebug operator<<(QDebug dbg, const LogEntry &entry) dbg.nospace() << " error code: " << entry.errorCode() << endl; dbg.nospace() << " active: " << entry.active() << endl; dbg.nospace() << " value: " << entry.value() << endl; - return dbg.space(); + return dbg; } LogEntries::LogEntries() diff --git a/libnymea-core/nymeacore.cpp b/libnymea-core/nymeacore.cpp index c8fe4316..8ca707f9 100644 --- a/libnymea-core/nymeacore.cpp +++ b/libnymea-core/nymeacore.cpp @@ -704,7 +704,7 @@ void NymeaCore::evaluateRules(const Event &event) QList eventBasedActions; foreach (const Rule &rule, m_ruleEngine->evaluateEvent(event)) { if (m_executingRules.contains(rule.id())) { - qCWarning(dcRuleEngine()) << "WARNING: Loop detected in rule execution for rule" << rule.id() << rule.name(); + qCWarning(dcRuleEngine()) << "WARNING: Loop detected in rule execution for rule" << rule.id().toString() << rule.name(); break; } m_executingRules.append(rule.id()); diff --git a/libnymea-core/ruleengine/rule.cpp b/libnymea-core/ruleengine/rule.cpp index 7705c88b..b7a97aa4 100644 --- a/libnymea-core/ruleengine/rule.cpp +++ b/libnymea-core/ruleengine/rule.cpp @@ -245,6 +245,7 @@ void Rule::setActive(const bool &active) * It is useful to debug, but be cautionous with using this in production code. */ QDebug operator<<(QDebug dbg, const Rule &rule) { + QDebugStateSaver saver(dbg); dbg.nospace() << endl << "=== Rule begin ===" << endl; dbg.nospace() << "ID:" << rule.id().toString() << endl; dbg.nospace() << "Name:" << rule.name() << endl; @@ -256,7 +257,7 @@ QDebug operator<<(QDebug dbg, const Rule &rule) dbg.nospace() << "Actions:" << rule.actions(); dbg.nospace() << "ExitActions:" << rule.exitActions(); dbg.nospace() << "=== Rule end ==="; - return dbg.space(); + return dbg; } Rules::Rules() diff --git a/libnymea-core/ruleengine/ruleaction.cpp b/libnymea-core/ruleengine/ruleaction.cpp index 168ff4ca..61c5b313 100644 --- a/libnymea-core/ruleengine/ruleaction.cpp +++ b/libnymea-core/ruleengine/ruleaction.cpp @@ -210,6 +210,7 @@ void RuleAction::operator=(const RuleAction &other) QDebug operator<<(QDebug dbg, const RuleAction &ruleAction) { + QDebugStateSaver saver(dbg); dbg.nospace() << "RuleAction(ActionTypeId:" << ruleAction.actionTypeId().toString() << ", ThingId:" << ruleAction.thingId().toString() << ", Interface:" << ruleAction.interface() << ", InterfaceAction:" << ruleAction.interfaceAction() << ", BrowserItemId:" << ruleAction.browserItemId() << ")" << endl; for (int i = 0; i < ruleAction.ruleActionParams().count(); i++) { dbg.nospace() << " " << i << ": " << ruleAction.ruleActionParams().at(i) << endl; @@ -219,6 +220,7 @@ QDebug operator<<(QDebug dbg, const RuleAction &ruleAction) QDebug operator<<(QDebug dbg, const QList &ruleActionList) { + QDebugStateSaver saver(dbg); dbg.nospace() << "RuleActionList (count:" << ruleActionList.count() << "):" << endl; for (int i = 0; i < ruleActionList.count(); i++ ) { dbg.nospace() << " " << i << ": " << ruleActionList.at(i); diff --git a/libnymea-core/ruleengine/ruleactionparam.cpp b/libnymea-core/ruleengine/ruleactionparam.cpp index a459b352..fadca87a 100644 --- a/libnymea-core/ruleengine/ruleactionparam.cpp +++ b/libnymea-core/ruleengine/ruleactionparam.cpp @@ -177,6 +177,7 @@ bool RuleActionParam::isStateBased() const QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam) { + QDebugStateSaver saver(dbg); dbg.nospace() << "RuleActionParam(ParamTypeId: " << ruleActionParam.paramTypeId().toString() << ", Name:" << ruleActionParam.paramName() << ", Value:" << ruleActionParam.value(); if (ruleActionParam.eventTypeId() != EventTypeId()) { dbg.nospace() << ", EventTypeId:" << ruleActionParam.eventTypeId().toString() << ", EventParamTypeId:" << ruleActionParam.eventParamTypeId().toString() << ")"; @@ -233,12 +234,13 @@ RuleActionParams RuleActionParams::operator<<(const RuleActionParam &ruleActionP QDebug operator<<(QDebug dbg, const RuleActionParams &ruleActionParams) { + QDebugStateSaver saver(dbg); dbg.nospace() << "RuleActionParamList (count:" << ruleActionParams.count() << ")" << endl; for (int i = 0; i < ruleActionParams.count(); i++ ) { dbg.nospace() << " " << i << ": " << ruleActionParams.at(i) << endl; } - return dbg.space(); + return dbg; } QVariant RuleActionParams::get(int index) const diff --git a/libnymea-core/ruleengine/ruleengine.cpp b/libnymea-core/ruleengine/ruleengine.cpp index 9d0f1680..da27fed1 100644 --- a/libnymea-core/ruleengine/ruleengine.cpp +++ b/libnymea-core/ruleengine/ruleengine.cpp @@ -537,7 +537,7 @@ RuleEngine::RuleError RuleEngine::enableRule(const RuleId &ruleId) emit ruleConfigurationChanged(rule); NymeaCore::instance()->logEngine()->logRuleEnabledChanged(rule, true); - qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "enabled."; + qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id().toString() << "enabled."; return RuleErrorNoError; } @@ -563,7 +563,7 @@ RuleEngine::RuleError RuleEngine::disableRule(const RuleId &ruleId) emit ruleConfigurationChanged(rule); NymeaCore::instance()->logEngine()->logRuleEnabledChanged(rule, false); - qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "disabled."; + qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id().toString() << "disabled."; return RuleErrorNoError; } @@ -596,7 +596,7 @@ RuleEngine::RuleError RuleEngine::executeActions(const RuleId &ruleId) } } - qCDebug(dcRuleEngine) << "Executing rule actions of rule" << rule.name() << rule.id(); + qCDebug(dcRuleEngine) << "Executing rule actions of rule" << rule.name() << rule.id().toString(); NymeaCore::instance()->logEngine()->logRuleActionsExecuted(rule); NymeaCore::instance()->executeRuleActions(rule.actions()); return RuleErrorNoError; @@ -628,7 +628,7 @@ RuleEngine::RuleError RuleEngine::executeExitActions(const RuleId &ruleId) return RuleErrorNoExitActions; } - qCDebug(dcRuleEngine) << "Executing rule exit actions of rule" << rule.name() << rule.id(); + qCDebug(dcRuleEngine) << "Executing rule exit actions of rule" << rule.name() << rule.id().toString(); NymeaCore::instance()->logEngine()->logRuleExitActionsExecuted(rule); NymeaCore::instance()->executeRuleActions(rule.exitActions()); return RuleErrorNoError; diff --git a/libnymea-core/ruleengine/stateevaluator.cpp b/libnymea-core/ruleengine/stateevaluator.cpp index 07d2fea1..0b14bb30 100644 --- a/libnymea-core/ruleengine/stateevaluator.cpp +++ b/libnymea-core/ruleengine/stateevaluator.cpp @@ -429,6 +429,7 @@ bool StateEvaluator::evaluateDescriptor(const StateDescriptor &descriptor) const QDebug operator<<(QDebug dbg, const StateEvaluator &stateEvaluator) { + QDebugStateSaver saver(dbg); dbg.nospace() << "StateEvaluator: Operator:" << stateEvaluator.operatorType() << endl << " " << stateEvaluator.stateDescriptor() << endl; for (int i = 0; i < stateEvaluator.childEvaluators().count(); i++) { dbg.nospace() << " " << i << ": " << stateEvaluator.childEvaluators().at(i); diff --git a/libnymea-core/servers/httpreply.cpp b/libnymea-core/servers/httpreply.cpp index 2e1b6224..e7988854 100644 --- a/libnymea-core/servers/httpreply.cpp +++ b/libnymea-core/servers/httpreply.cpp @@ -490,10 +490,11 @@ void HttpReply::timeout() QDebug operator<<(QDebug debug, HttpReply *httpReply) { + QDebugStateSaver saver(debug); debug.nospace() << "HttpReply(" << httpReply->clientId().toString() << ")" << endl; debug << qUtf8Printable(httpReply->rawHeader()); debug << qUtf8Printable(httpReply->payload()); - return debug.space(); + return debug; } } diff --git a/libnymea-core/servers/httprequest.cpp b/libnymea-core/servers/httprequest.cpp index 29999813..9958530a 100644 --- a/libnymea-core/servers/httprequest.cpp +++ b/libnymea-core/servers/httprequest.cpp @@ -277,6 +277,7 @@ HttpRequest::RequestMethod HttpRequest::getRequestMethodType(const QString &meth QDebug operator<<(QDebug debug, const HttpRequest &httpRequest) { + QDebugStateSaver saver(debug); debug << "HttpRequest:" << endl; debug << qUtf8Printable(httpRequest.rawHeader()); debug << qUtf8Printable(httpRequest.payload()); diff --git a/libnymea-core/tagging/tag.cpp b/libnymea-core/tagging/tag.cpp index 7502bfa2..1a89a59a 100644 --- a/libnymea-core/tagging/tag.cpp +++ b/libnymea-core/tagging/tag.cpp @@ -118,6 +118,7 @@ bool Tag::operator==(const Tag &other) const QDebug operator<<(QDebug dbg, const Tag &tag) { + QDebugStateSaver saver(dbg); if (!tag.thingId().isNull()) { dbg.nospace() << "Tag (ThingId:" << tag.thingId(); } else { diff --git a/libnymea-core/zigbee/zigbeeadapter.cpp b/libnymea-core/zigbee/zigbeeadapter.cpp index 6c5b1884..221a1ac3 100644 --- a/libnymea-core/zigbee/zigbeeadapter.cpp +++ b/libnymea-core/zigbee/zigbeeadapter.cpp @@ -133,6 +133,7 @@ QHash ZigbeeAdapter::backendNames() QDebug operator<<(QDebug debug, const ZigbeeAdapter &adapter) { + QDebugStateSaver saver(debug); debug.nospace() << "ZigbeeAdapter(" << adapter.name() << " - " << adapter.description(); debug.nospace() << ", " << adapter.serialPort(); if (adapter.hardwareRecognized()) { @@ -141,7 +142,7 @@ QDebug operator<<(QDebug debug, const ZigbeeAdapter &adapter) } debug.nospace() << ")"; - return debug.space(); + return debug; } } diff --git a/libnymea/coap/coapoption.cpp b/libnymea/coap/coapoption.cpp index 15cd7ac2..83aa26f4 100644 --- a/libnymea/coap/coapoption.cpp +++ b/libnymea/coap/coapoption.cpp @@ -113,6 +113,7 @@ QByteArray CoapOption::data() const */ QDebug operator<<(QDebug debug, const CoapOption &coapOption) { + QDebugStateSaver saver(debug); const QMetaObject &metaObject = CoapOption::staticMetaObject; QMetaEnum optionEnum = metaObject.enumerator(metaObject.indexOfEnumerator("Option")); @@ -161,5 +162,5 @@ QDebug operator<<(QDebug debug, const CoapOption &coapOption) break; } - return debug.space(); + return debug; } diff --git a/libnymea/coap/coappdu.cpp b/libnymea/coap/coappdu.cpp index 025d61b8..01bd4ace 100644 --- a/libnymea/coap/coappdu.cpp +++ b/libnymea/coap/coappdu.cpp @@ -618,6 +618,7 @@ void CoapPdu::unpack(const QByteArray &data) */ QDebug operator<<(QDebug debug, const CoapPdu &coapPdu) { + QDebugStateSaver saver(debug); const QMetaObject &metaObject = CoapPdu::staticMetaObject; QMetaEnum messageTypeEnum = metaObject.enumerator(metaObject.indexOfEnumerator("MessageType")); debug.nospace() << "CoapPdu(" << messageTypeEnum.valueToKey(coapPdu.messageType()) << ")" << endl; @@ -633,5 +634,5 @@ QDebug operator<<(QDebug debug, const CoapPdu &coapPdu) if (!coapPdu.payload().isEmpty()) debug.nospace() << endl << coapPdu.payload() << endl; - return debug.space(); + return debug; } diff --git a/libnymea/coap/coapreply.cpp b/libnymea/coap/coapreply.cpp index 4d772926..c7698ee0 100644 --- a/libnymea/coap/coapreply.cpp +++ b/libnymea/coap/coapreply.cpp @@ -348,6 +348,7 @@ void CoapReply::setRequestData(const QByteArray &requestData) */ QDebug operator<<(QDebug debug, CoapReply *reply) { + QDebugStateSaver saver(debug); const QMetaObject &metaObject = CoapPdu::staticMetaObject; QMetaEnum messageTypeEnum = metaObject.enumerator(metaObject.indexOfEnumerator("MessageType")); QMetaEnum contentTypeEnum = metaObject.enumerator(metaObject.indexOfEnumerator("ContentType")); @@ -359,5 +360,5 @@ QDebug operator<<(QDebug debug, CoapReply *reply) if (!reply->payload().isEmpty()) debug.nospace() << endl << reply->payload() << endl; - return debug.space(); + return debug; } diff --git a/libnymea/coap/corelink.cpp b/libnymea/coap/corelink.cpp index 3dc5911d..16d05476 100644 --- a/libnymea/coap/corelink.cpp +++ b/libnymea/coap/corelink.cpp @@ -143,6 +143,7 @@ void CoreLink::setObservable(const bool &observable) */ QDebug operator<<(QDebug debug, const CoreLink &link) { + QDebugStateSaver saver(debug); const QMetaObject &metaObject = CoapPdu::staticMetaObject; QMetaEnum contentTypeEnum = metaObject.enumerator(metaObject.indexOfEnumerator("ContentType")); debug.nospace() << "CoapLink(" << link.path() << ")" << endl; @@ -162,5 +163,5 @@ QDebug operator<<(QDebug debug, const CoreLink &link) if (link.maximumSize() >= 0) debug.nospace() << " Maximum size: " << link.maximumSize() << endl; - return debug.space(); + return debug; } diff --git a/libnymea/hardware/i2c/i2cdevice.cpp b/libnymea/hardware/i2c/i2cdevice.cpp index f68fd7c7..89d9813b 100644 --- a/libnymea/hardware/i2c/i2cdevice.cpp +++ b/libnymea/hardware/i2c/i2cdevice.cpp @@ -113,6 +113,7 @@ bool I2CDevice::writeData(int fileDescriptor, const QByteArray &data) QDebug operator<<(QDebug debug, const I2CDevice *i2cDevice) { + QDebugStateSaver saver(debug); debug.nospace() << "I2CDevice(Port: " << i2cDevice->portName() << ", Address: 0x" << QString::number(i2cDevice->address(), 16) << ")"; - return debug.space(); + return debug; } diff --git a/libnymea/hardware/pwm.cpp b/libnymea/hardware/pwm.cpp index e1aa8ea0..7c8de9c7 100644 --- a/libnymea/hardware/pwm.cpp +++ b/libnymea/hardware/pwm.cpp @@ -340,6 +340,7 @@ bool Pwm::unexportPwm() QDebug operator<<(QDebug d, Pwm *pwm) { + QDebugStateSaver saver(d); d << "-----------------------------------"; d << "\n--> pwm0 on pwmChip" << pwm->chipNumber() << ":"; d << "\n------------------"; diff --git a/libnymea/hardware/zwave/zwavenode.cpp b/libnymea/hardware/zwave/zwavenode.cpp index 81d38bd5..1b7c0739 100644 --- a/libnymea/hardware/zwave/zwavenode.cpp +++ b/libnymea/hardware/zwave/zwavenode.cpp @@ -40,6 +40,7 @@ ZWaveNode::ZWaveNode(QObject *parent): QDebug operator<<(QDebug debug, ZWaveNode *node) { + QDebugStateSaver saver(debug); debug.nospace().noquote() << "\nNode ID: " << node->nodeId() << (node->name().isEmpty() ? "" : ", " + node->name()) << " Z-Wave Version: " << node->version() << (node->isZWavePlusDevice() ? "+" : "") << "\n" << "├ Type: " << node->nodeType() << "\n" << "├ Role: " << node->role() << "\n" diff --git a/libnymea/hardware/zwave/zwavevalue.cpp b/libnymea/hardware/zwave/zwavevalue.cpp index a1f4c8c5..42a8fca6 100644 --- a/libnymea/hardware/zwave/zwavevalue.cpp +++ b/libnymea/hardware/zwave/zwavevalue.cpp @@ -112,6 +112,7 @@ bool ZWaveValue::isValid() const QDebug operator<<(QDebug debug, ZWaveValue value) { + QDebugStateSaver saver(debug); debug.nospace() << "Value(ID: " << value.id() << ", " << "Ins: " << value.instance() << ", " << value.genre() << ", " diff --git a/libnymea/integrations/integrationplugin.cpp b/libnymea/integrations/integrationplugin.cpp index fe80b1f3..5ab5ee77 100644 --- a/libnymea/integrations/integrationplugin.cpp +++ b/libnymea/integrations/integrationplugin.cpp @@ -450,9 +450,10 @@ Thing::ThingError IntegrationPlugin::setConfigValue(const ParamTypeId ¶mType if (paramType.id() == paramTypeId) { found = true; Thing::ThingError result = ThingUtils::verifyParam(paramType, Param(paramTypeId, value)); - if (result != Thing::ThingErrorNoError) + if (result != Thing::ThingErrorNoError) { + qCWarning(dcThingManager()) << "Cannot set plugin config from" << this << "because the param verification failed with error" << result; return result; - + } break; } } @@ -521,6 +522,14 @@ void IntegrationPlugin::setMetaData(const PluginMetadata &metaData) m_metaData = metaData; } +QDebug operator<<(QDebug debug, IntegrationPlugin *plugin) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "IntegrationPlugin(" << plugin->pluginDisplayName(); + debug.nospace() << ", id: " << plugin->pluginId().toString() << ")"; + return debug; +} + IntegrationPlugins::IntegrationPlugins() { diff --git a/libnymea/integrations/integrationplugin.h b/libnymea/integrations/integrationplugin.h index 271818c2..b28128ca 100644 --- a/libnymea/integrations/integrationplugin.h +++ b/libnymea/integrations/integrationplugin.h @@ -154,6 +154,7 @@ private: Q_DECLARE_INTERFACE(IntegrationPlugin, "io.nymea.IntegrationPlugin") Q_DECLARE_METATYPE(IntegrationPlugin*) +QDebug operator<<(QDebug debug, IntegrationPlugin *plugin); class LIBNYMEA_EXPORT IntegrationPlugins: public QList { diff --git a/libnymea/integrations/thing.cpp b/libnymea/integrations/thing.cpp index 1435bd38..31a2cc8c 100644 --- a/libnymea/integrations/thing.cpp +++ b/libnymea/integrations/thing.cpp @@ -300,7 +300,7 @@ void Thing::setSettingValue(const ParamTypeId ¶mTypeId, const QVariant &valu settings << param; } if (!found) { - qCWarning(dcThingManager()) << "Thing" << m_name << "(" << m_id.toString() << ") does not have a setting with id" << paramTypeId; + qCWarning(dcThingManager()) << this << "does not have a setting with id" << paramTypeId; return; } if (changed) { @@ -373,27 +373,27 @@ void Thing::setStateValue(const StateTypeId &stateTypeId, const QVariant &value) { StateType stateType = m_thingClass.stateTypes().findById(stateTypeId); if (!stateType.isValid()) { - qCWarning(dcThing()) << "No such state type" << stateTypeId.toString() << "in" << m_name << "(" + thingClass().name() + ")"; + qCWarning(dcThing()) << "No such state type" << stateTypeId.toString() << "in" << this; return; } for (int i = 0; i < m_states.count(); ++i) { if (m_states.at(i).stateTypeId() == stateTypeId) { QVariant newValue = value; if (!newValue.convert(stateType.type())) { - qCWarning(dcThing()).nospace() << m_name << ": Invalid value " << value << " for state " << stateType.name() << ". Type mismatch. Expected type: " << QVariant::typeToName(stateType.type()) << " (Discarding change)"; + qCWarning(dcThing()).nospace() << this << ": Invalid value " << value << " for state " << stateType.name() << ". Type mismatch. Expected type: " << QVariant::typeToName(stateType.type()) << " (Discarding change)"; return; } State state = m_states.at(i); if (state.minValue().isValid() && value < state.minValue()) { - qCWarning(dcThing()).nospace() << m_name << ": Invalid value " << value << " for state " << stateType.name() << ". Out of range: " << state.minValue() << " - " << state.maxValue() << " (Correcting to closest value within range)"; + qCWarning(dcThing()).nospace() << this << ": Invalid value " << value << " for state " << stateType.name() << ". Out of range: " << state.minValue() << " - " << state.maxValue() << " (Correcting to closest value within range)"; newValue = state.minValue(); } if (state.maxValue().isValid() && value > state.maxValue()) { - qCWarning(dcThing()).nospace() << m_name << ": Invalid value " << value << " for state " << stateType.name() << ". Out of range: " << state.minValue() << " - " << state.maxValue() << " (Correcting to closest value within range)"; + qCWarning(dcThing()).nospace() << this << ": Invalid value " << value << " for state " << stateType.name() << ". Out of range: " << state.minValue() << " - " << state.maxValue() << " (Correcting to closest value within range)"; newValue = state.maxValue(); } if (!stateType.possibleValues().isEmpty() && !stateType.possibleValues().contains(value)) { - qCWarning(dcThing()).nospace() << m_name << ": Invalid value " << value << " for state " << stateType.name() << ". Not an accepted value. Possible values: " << stateType.possibleValues() << " (Discarding change)"; + qCWarning(dcThing()).nospace() << this << ": Invalid value " << value << " for state " << stateType.name() << ". Not an accepted value. Possible values: " << stateType.possibleValues() << " (Discarding change)"; return; } @@ -406,18 +406,18 @@ void Thing::setStateValue(const StateTypeId &stateTypeId, const QVariant &value) QVariant oldValue = m_states.at(i).value(); if (oldValue == newValue) { - qCDebug(dcThing()).nospace() << m_name << ": Discarding state change for " << stateType.name() << " as the value did not actually change. Old value:" << oldValue << "New value:" << newValue; + qCDebug(dcThing()).nospace() << this << ": Discarding state change for " << stateType.name() << " as the value did not actually change. Old value:" << oldValue << "New value:" << newValue; return; } - qCDebug(dcThing()).nospace() << m_name << ": State " << stateType.name() << " changed from " << oldValue << " to " << newValue; + qCDebug(dcThing()).nospace() << this << ": State " << stateType.name() << " changed from " << oldValue << " to " << newValue; m_states[i].setValue(newValue); emit stateValueChanged(stateTypeId, newValue, m_states.at(i).minValue(), m_states.at(i).maxValue()); return; } } Q_ASSERT_X(false, m_name.toUtf8(), QString("Failed setting state %1 to %2").arg(stateType.name()).arg(value.toString()).toUtf8()); - qCWarning(dcThing).nospace() << m_name << ": Failed setting state " << stateType.name() << "to" << value; + qCWarning(dcThing).nospace() << this << ": Failed setting state " << stateType.name() << " to " << value; } /*! Sets the value for the \l{State} matching the given \a stateName in this thing to value. */ @@ -452,11 +452,11 @@ void Thing::setStateMinValue(const StateTypeId &stateTypeId, const QVariant &min // Sanity check for max >= min if (m_states.at(i).maxValue() < newMin) { - qCWarning(dcThing()) << "Adjusting state maximum value for" << stateType.name() << "from" << m_states.at(i).maxValue() << "to new minimum value of" << newMin; + qCWarning(dcThing()).nospace() << this << ": Adjusting state maximum value for " << stateType.name() << " from " << m_states.at(i).maxValue() << " to new minimum value of " << newMin; m_states[i].setMaxValue(newMin); } if (m_states.at(i).value() < newMin) { - qCInfo(dcThing()) << "Adjusting state value for" << stateType.name() << "from" << m_states.at(i).value() << "to new minimum value of" << newMin; + qCInfo(dcThing()).nospace() << this << ": Adjusting state value for " << stateType.name() << " from " << m_states.at(i).value() << " to new minimum value of " << newMin; m_states[i].setValue(newMin); } @@ -465,7 +465,7 @@ void Thing::setStateMinValue(const StateTypeId &stateTypeId, const QVariant &min } } Q_ASSERT_X(false, m_name.toUtf8(), QString("Failed setting minimum state value %1 to %2").arg(stateType.name()).arg(minValue.toString()).toUtf8()); - qCWarning(dcThing).nospace() << m_name << ": Failed setting minimum state value " << stateType.name() << " to " << minValue; + qCWarning(dcThing).nospace() << this << ": Failed setting minimum state value " << stateType.name() << " to " << minValue; } /*! Sets the minimum value for the \l{State} matching the given \a stateName in this thing to value. */ @@ -496,12 +496,12 @@ void Thing::setStateMaxValue(const StateTypeId &stateTypeId, const QVariant &max if (newMax.isValid()) { // Sanity check for min <= max if (m_states.at(i).minValue() > newMax) { - qCWarning(dcThing()) << "Adjusting minimum state value for" << stateType.name() << "from" << m_states.at(i).minValue() << "to new maximum value of" << newMax; + qCWarning(dcThing()).nospace() << this << ": Adjusting minimum state value for " << stateType.name() << " from " << m_states.at(i).minValue() << " to new maximum value of " << newMax; m_states[i].setMinValue(newMax); } if (m_states.at(i).value() > newMax) { - qCInfo(dcThing()) << "Adjusting state value for" << stateType.name() << "from" << m_states.at(i).value() << "to new maximum value of" << newMax; + qCInfo(dcThing()).nospace() << this << ": Adjusting state value for " << stateType.name() << " from " << m_states.at(i).value() << " to new maximum value of " << newMax; m_states[i].setValue(maxValue); } } @@ -511,7 +511,7 @@ void Thing::setStateMaxValue(const StateTypeId &stateTypeId, const QVariant &max } } Q_ASSERT_X(false, m_name.toUtf8(), QString("Failed setting maximum state value %1 to %2").arg(stateType.name()).arg(maxValue.toString()).toUtf8()); - qCWarning(dcThing).nospace() << m_name << ": Failed setting maximum state value " << stateType.name() << " t o" << maxValue; + qCWarning(dcThing).nospace() << this << ": Failed setting maximum state value " << stateType.name() << " to " << maxValue; } /*! Sets the maximum value for the \l{State} matching the given \a stateName in this thing to value. */ @@ -543,16 +543,16 @@ void Thing::setStateMinMaxValues(const StateTypeId &stateTypeId, const QVariant if (newMax.isValid() || newMax.isValid()) { // Sanity check for min <= max if (newMin > newMax) { - qCWarning(dcThing()) << "Adjusting maximum state value for" << stateType.name() << "from" << m_states.at(i).maxValue() << "to new minimum value of" << newMax; + qCWarning(dcThing()).nospace() << this << ": Adjusting maximum state value for " << stateType.name() << " from " << m_states.at(i).maxValue() << " to new minimum value of " << newMax; m_states[i].setMaxValue(newMin); } if (m_states.at(i).value() < m_states.at(i).minValue()) { - qCInfo(dcThing()) << "Adjusting state value for" << stateType.name() << "from" << m_states.at(i).value() << "to new minimum value of" << m_states.at(i).minValue(); + qCInfo(dcThing()).nospace() << this << ": Adjusting state value for " << stateType.name() << " from " << m_states.at(i).value() << " to new minimum value of " << m_states.at(i).minValue(); m_states[i].setValue(m_states.at(i).minValue()); } if (m_states.at(i).value() > m_states.at(i).maxValue()) { - qCInfo(dcThing()) << "Adjusting state value for" << stateType.name() << "from" << m_states.at(i).value() << "to new maximum value of" << m_states.at(i).maxValue(); + qCInfo(dcThing()).nospace() << this << ": Adjusting state value for " << stateType.name() << " from " << m_states.at(i).value() << " to new maximum value of " << m_states.at(i).maxValue(); m_states[i].setValue(m_states.at(i).maxValue()); } } @@ -562,7 +562,7 @@ void Thing::setStateMinMaxValues(const StateTypeId &stateTypeId, const QVariant } } Q_ASSERT_X(false, m_name.toUtf8(), QString("Failed setting maximum state value %1 to %2").arg(stateType.name()).arg(maxValue.toString()).toUtf8()); - qCWarning(dcThing).nospace() << m_name << ": Failed setting maximum state value " << stateType.name() << " t o" << maxValue; + qCWarning(dcThing).nospace() << this << ": Failed setting maximum state value " << stateType.name() << " to " << maxValue; } @@ -728,12 +728,13 @@ Thing *Things::findByParams(const ParamList ¶ms) const return nullptr; } -QDebug operator<<(QDebug dbg, Thing *thing) +QDebug operator<<(QDebug debug, Thing *thing) { - dbg.nospace() << "Thing(" << thing->name(); - dbg.nospace() << ", id: " << thing->id().toString(); - dbg.nospace() << ", ThingClassId: " << thing->thingClassId().toString() << ")"; - return dbg.space(); + QDebugStateSaver saver(debug); + debug.nospace().noquote() << "Thing(" << thing->name(); + debug.nospace().noquote() << ", id: " << thing->id().toString(); + debug.nospace().noquote() << ", ThingClassId: " << thing->thingClassId().toString() << ")"; + return debug; } /*! Filter things by a parameter. Only things having a parameter of the given diff --git a/libnymea/integrations/thing.h b/libnymea/integrations/thing.h index 8e3aa879..6a615310 100644 --- a/libnymea/integrations/thing.h +++ b/libnymea/integrations/thing.h @@ -208,7 +208,7 @@ private: QHash m_stateValueFilters; }; -QDebug operator<<(QDebug dbg, Thing *device); +QDebug operator<<(QDebug debug, Thing *device); class LIBNYMEA_EXPORT Things: public QList { diff --git a/libnymea/integrations/thingactioninfo.cpp b/libnymea/integrations/thingactioninfo.cpp index d1c0df42..5f3f62c0 100644 --- a/libnymea/integrations/thingactioninfo.cpp +++ b/libnymea/integrations/thingactioninfo.cpp @@ -101,7 +101,8 @@ QString ThingActionInfo::translatedDisplayMessage(const QLocale &locale) void ThingActionInfo::finish(Thing::ThingError status, const QString &displayMessage) { if (m_finished) { - qCWarning(dcIntegrations()) << "ThingActionInfo::finish() called on an already finished object."; + //qCWarning(dcIntegrations()) << "ThingActionInfo::finish() called on an already finished object:" << m_thing << m_action.actionTypeId().toString(); + qCWarning(dcIntegrations()) << "ThingActionInfo::finish() called on an already finished object.";// << m_thing << m_action.actionTypeId().toString(); return; } m_finished = true; diff --git a/libnymea/integrations/thingdiscoveryinfo.cpp b/libnymea/integrations/thingdiscoveryinfo.cpp index be02c177..098b72e8 100644 --- a/libnymea/integrations/thingdiscoveryinfo.cpp +++ b/libnymea/integrations/thingdiscoveryinfo.cpp @@ -109,8 +109,8 @@ QString ThingDiscoveryInfo::translatedDisplayMessage(const QLocale &locale) if (!m_thingManager) { return m_displayMessage; } - ThingClass deviceClass = m_thingManager->findThingClass(m_thingClassId); - return m_thingManager->translate(deviceClass.pluginId(), m_displayMessage.toUtf8(), locale); + ThingClass thingClass = m_thingManager->findThingClass(m_thingClassId); + return m_thingManager->translate(thingClass.pluginId(), m_displayMessage.toUtf8(), locale); } void ThingDiscoveryInfo::finish(Thing::ThingError status, const QString &displayMessage) diff --git a/libnymea/integrations/thingpairinginfo.cpp b/libnymea/integrations/thingpairinginfo.cpp index 6e3c4b88..f986d46a 100644 --- a/libnymea/integrations/thingpairinginfo.cpp +++ b/libnymea/integrations/thingpairinginfo.cpp @@ -122,8 +122,8 @@ QString ThingPairingInfo::translatedDisplayMessage(const QLocale &locale) const if (!m_thingManager) { return m_displayMessage; } - ThingClass deviceClass = m_thingManager->findThingClass(m_thingClassId); - return m_thingManager->translate(deviceClass.pluginId(), m_displayMessage.toUtf8(), locale); + ThingClass thingClass = m_thingManager->findThingClass(m_thingClassId); + return m_thingManager->translate(thingClass.pluginId(), m_displayMessage.toUtf8(), locale); } void ThingPairingInfo::finish(Thing::ThingError status, const QString &displayMessage) diff --git a/libnymea/integrations/thingsetupinfo.cpp b/libnymea/integrations/thingsetupinfo.cpp index ec2ef439..950d8251 100644 --- a/libnymea/integrations/thingsetupinfo.cpp +++ b/libnymea/integrations/thingsetupinfo.cpp @@ -97,7 +97,7 @@ QString ThingSetupInfo::translatedDisplayMessage(const QLocale &locale) void ThingSetupInfo::finish(Thing::ThingError status, const QString &displayMessage) { if (m_finished) { - qCWarning(dcIntegrations()) << "ThingSetupInfo::finish() called on an already finished object."; + qCWarning(dcIntegrations()) << "ThingSetupInfo::finish() called on an already finished object for" << m_thing << status << displayMessage; return; } m_finished = true; diff --git a/libnymea/network/macaddress.cpp b/libnymea/network/macaddress.cpp index c0d5dcea..1423810a 100644 --- a/libnymea/network/macaddress.cpp +++ b/libnymea/network/macaddress.cpp @@ -157,6 +157,7 @@ bool MacAddress::operator!=(const MacAddress &other) const QDebug operator<<(QDebug debug, const MacAddress &macAddress) { + QDebugStateSaver saver(debug); debug.nospace() << "MacAddress(" << macAddress.toString() << ")"; - return debug.space(); + return debug; } diff --git a/libnymea/network/networkdeviceinfo.cpp b/libnymea/network/networkdeviceinfo.cpp index 0e57e54c..658f98e1 100644 --- a/libnymea/network/networkdeviceinfo.cpp +++ b/libnymea/network/networkdeviceinfo.cpp @@ -140,6 +140,7 @@ bool NetworkDeviceInfo::operator!=(const NetworkDeviceInfo &other) const QDebug operator<<(QDebug dbg, const NetworkDeviceInfo &networkDeviceInfo) { + QDebugStateSaver saver(dbg); dbg.nospace() << "NetworkDeviceInfo(" << networkDeviceInfo.address().toString(); if (!networkDeviceInfo.macAddress().isEmpty()) @@ -155,5 +156,5 @@ QDebug operator<<(QDebug dbg, const NetworkDeviceInfo &networkDeviceInfo) dbg.nospace() << ", " << networkDeviceInfo.networkInterface().name(); dbg.nospace() << ")"; - return dbg.space(); + return dbg; } diff --git a/libnymea/network/networkdevicemonitor.cpp b/libnymea/network/networkdevicemonitor.cpp index 37edc216..41090e94 100644 --- a/libnymea/network/networkdevicemonitor.cpp +++ b/libnymea/network/networkdevicemonitor.cpp @@ -39,6 +39,7 @@ NetworkDeviceMonitor::NetworkDeviceMonitor(QObject *parent) : QDebug operator<<(QDebug dbg, NetworkDeviceMonitor *networkDeviceMonitor) { + QDebugStateSaver saver(dbg); dbg.nospace() << "NetworkDeviceMonitor(" << networkDeviceMonitor->macAddress().toString(); if (!networkDeviceMonitor->networkDeviceInfo().macAddressManufacturer().isEmpty()) @@ -47,6 +48,6 @@ QDebug operator<<(QDebug dbg, NetworkDeviceMonitor *networkDeviceMonitor) dbg.nospace() << ", " << networkDeviceMonitor->networkDeviceInfo().address().toString(); dbg.nospace() << ")"; - return dbg.space(); + return dbg; } diff --git a/libnymea/network/upnp/upnpdevicedescriptor.cpp b/libnymea/network/upnp/upnpdevicedescriptor.cpp index 14be8170..5bc4dbf9 100644 --- a/libnymea/network/upnp/upnpdevicedescriptor.cpp +++ b/libnymea/network/upnp/upnpdevicedescriptor.cpp @@ -222,6 +222,7 @@ QString UpnpDeviceDescriptor::upc() const QDebug operator<<(QDebug debug, const UpnpDeviceDescriptor &upnpDeviceDescriptor) { + QDebugStateSaver saver(debug); debug << "----------------------------------------------\n"; debug << "UPnP device on " << upnpDeviceDescriptor.hostAddress().toString() << upnpDeviceDescriptor.port() << "\n"; debug << "location | " << upnpDeviceDescriptor.location() << "\n"; diff --git a/libnymea/time/calendaritem.cpp b/libnymea/time/calendaritem.cpp index 28c18126..46710291 100644 --- a/libnymea/time/calendaritem.cpp +++ b/libnymea/time/calendaritem.cpp @@ -279,6 +279,7 @@ bool CalendarItem::evaluateYearly(const QDateTime &dateTime) const /*! Print a CalendarItem to QDebug. */ QDebug operator<<(QDebug dbg, const CalendarItem &calendarItem) { + QDebugStateSaver saver(dbg); dbg.nospace() << "CalendarItem (StartTime:" << calendarItem.startTime() << ", DateTime:" << calendarItem.dateTime().toString() << ", " << calendarItem.repeatingOption() << ", Duration:" << calendarItem.duration() << ")"; return dbg; } diff --git a/libnymea/time/repeatingoption.cpp b/libnymea/time/repeatingoption.cpp index 9e03a420..4ac34c25 100644 --- a/libnymea/time/repeatingoption.cpp +++ b/libnymea/time/repeatingoption.cpp @@ -217,6 +217,7 @@ bool RepeatingOption::evaluateMonthDay(const QDateTime &dateTime) const /*! Print a RepeatingOption to QDebug. */ QDebug operator<<(QDebug dbg, const RepeatingOption &repeatingOption) { + QDebugStateSaver saver(dbg); dbg.nospace() << "RepeatingOption(Mode:" << repeatingOption.mode() << ", Monthdays:" << repeatingOption.monthDays() << "Weekdays:" << repeatingOption.weekDays() << ")"; return dbg; } diff --git a/libnymea/time/timedescriptor.cpp b/libnymea/time/timedescriptor.cpp index dc5c62a7..a25a1df9 100644 --- a/libnymea/time/timedescriptor.cpp +++ b/libnymea/time/timedescriptor.cpp @@ -118,6 +118,7 @@ bool TimeDescriptor::evaluate(const QDateTime &lastEvaluationTime, const QDateTi /*! Print a TimeDescriptor including the full lists of CalendarItems and TimeEventItems to QDebug. */ QDebug operator<<(QDebug dbg, const TimeDescriptor &timeDescriptor) { + QDebugStateSaver saver(dbg); dbg.nospace() << "TimeDescriptor (TimeEventItems:" << timeDescriptor.timeEventItems().count() << ", CalendarItems:" << timeDescriptor.calendarItems().count() << ")" << endl; for (int i = 0; i < timeDescriptor.timeEventItems().count(); i++) { dbg.nospace() << " " << i << ": " << timeDescriptor.timeEventItems().at(i); diff --git a/libnymea/time/timeeventitem.cpp b/libnymea/time/timeeventitem.cpp index 431e8c1b..56db1583 100644 --- a/libnymea/time/timeeventitem.cpp +++ b/libnymea/time/timeeventitem.cpp @@ -145,6 +145,7 @@ bool TimeEventItem::evaluate(const QDateTime &lastEvaluationTime, const QDateTim /*! Print a TimeEvent to QDebug. */ QDebug operator<<(QDebug dbg, const TimeEventItem &timeEventItem) { + QDebugStateSaver saver(dbg); dbg.nospace() << "TimeEventItem (Time:" << timeEventItem.time() << ", DateTime:" << timeEventItem.dateTime().toString() << ", " << timeEventItem.repeatingOption() << ")" << endl; return dbg; } diff --git a/libnymea/types/actiontype.cpp b/libnymea/types/actiontype.cpp index fe5f3045..6afbf15f 100644 --- a/libnymea/types/actiontype.cpp +++ b/libnymea/types/actiontype.cpp @@ -194,7 +194,8 @@ ActionType &ActionTypes::operator[](const QString &name) QDebug operator<<(QDebug dbg, const ActionType &actionType) { - dbg.nospace().noquote() << "ActionType: " << actionType.name() << actionType.displayName() << actionType.id(); + QDebugStateSaver saver(dbg); + dbg.nospace().noquote() << "ActionType(" << actionType.name() << ", " << actionType.displayName() << ", " << actionType.id() << ") "; return dbg; } diff --git a/libnymea/types/event.cpp b/libnymea/types/event.cpp index 7e016bd2..02ec341e 100644 --- a/libnymea/types/event.cpp +++ b/libnymea/types/event.cpp @@ -150,17 +150,19 @@ bool Event::operator ==(const Event &other) const /*! Writes the eventTypeId and the deviceId of the given \a event to \a dbg. */ QDebug operator<<(QDebug dbg, const Event &event) { + QDebugStateSaver saver(dbg); dbg.nospace() << "Event(EventTypeId: " << event.eventTypeId().toString() << ", DeviceId" << event.thingId().toString() << ")"; - return dbg.space(); + return dbg; } /*! Writes the each \l{Event} of the given \a events to \a dbg. */ QDebug operator<<(QDebug dbg, const QList &events) { + QDebugStateSaver saver(dbg); dbg.nospace() << "EventList (count:" << events.count() << ")"; for (int i = 0; i < events.count(); i++ ) { dbg.nospace() << " " << i << ": " << events.at(i); } - return dbg.space(); + return dbg; } diff --git a/libnymea/types/eventdescriptor.cpp b/libnymea/types/eventdescriptor.cpp index e384bdab..75fae587 100644 --- a/libnymea/types/eventdescriptor.cpp +++ b/libnymea/types/eventdescriptor.cpp @@ -178,6 +178,7 @@ bool EventDescriptor::operator ==(const EventDescriptor &other) const /*! Print an EventDescriptor including ParamDescriptors to QDebug. */ QDebug operator<<(QDebug dbg, const EventDescriptor &eventDescriptor) { + QDebugStateSaver saver(dbg); dbg.nospace() << "EventDescriptor(EventTypeId: " << eventDescriptor.eventTypeId().toString() << ", ThingId:" << eventDescriptor.thingId().toString() << ", Interface:" << eventDescriptor.interface() << ", InterfaceEvent:" << eventDescriptor.interfaceEvent() << ")" << endl; for (int i = 0; i < eventDescriptor.paramDescriptors().count(); i++) { dbg.nospace() << " " << i << ": " << eventDescriptor.paramDescriptors().at(i); @@ -189,6 +190,7 @@ QDebug operator<<(QDebug dbg, const EventDescriptor &eventDescriptor) /*! Writes each \a eventDescriptors to \a dbg. */ QDebug operator<<(QDebug dbg, const QList &eventDescriptors) { + QDebugStateSaver saver(dbg); dbg.nospace() << "EventDescriptorList (count:" << eventDescriptors.count() << "):" << endl; for (int i = 0; i < eventDescriptors.count(); i++ ) { dbg.nospace() << " " << i << ": " << eventDescriptors.at(i); diff --git a/libnymea/types/param.cpp b/libnymea/types/param.cpp index 25686265..78928601 100644 --- a/libnymea/types/param.cpp +++ b/libnymea/types/param.cpp @@ -81,13 +81,15 @@ bool Param::isValid() const /*! Writes the paramTypeId and value of the given \a param to \a dbg. */ QDebug operator<<(QDebug dbg, const Param ¶m) { - dbg.nospace() << "Param(Id: " << param.paramTypeId().toString() << ", Value:" << param.value() << ")"; - return dbg.space(); + QDebugStateSaver saver(dbg); + dbg.nospace() << "Param(Id: " << param.paramTypeId().toString() << ", Value: " << param.value() << ")"; + return dbg; } /*! Writes the param of the given \a params to \a dbg. */ QDebug operator<<(QDebug dbg, const ParamList ¶ms) { + QDebugStateSaver saver(dbg); dbg.nospace() << "ParamList (count:" << params.count() << ")"; if (params.count() == 0) { dbg.nospace() << endl; @@ -96,7 +98,7 @@ QDebug operator<<(QDebug dbg, const ParamList ¶ms) dbg.nospace() << endl << " " << i << ": " << params.at(i); } - return dbg.space(); + return dbg; } /*! diff --git a/libnymea/types/paramdescriptor.cpp b/libnymea/types/paramdescriptor.cpp index fdca939d..1169ca30 100644 --- a/libnymea/types/paramdescriptor.cpp +++ b/libnymea/types/paramdescriptor.cpp @@ -90,6 +90,7 @@ void ParamDescriptor::setOperatorType(Types::ValueOperator operatorType) /*! Print a ParamDescriptor to QDebug. */ QDebug operator<<(QDebug dbg, const ParamDescriptor ¶mDescriptor) { + QDebugStateSaver saver(dbg); dbg.nospace() << "ParamDescriptor(ParamTypeId: " << paramDescriptor.paramTypeId().toString() << ", Name:" << paramDescriptor.paramName() << ", Value:" << paramDescriptor.value() << ")" << endl; return dbg; } diff --git a/libnymea/types/paramtype.cpp b/libnymea/types/paramtype.cpp index fd0758c4..f78eb6c0 100644 --- a/libnymea/types/paramtype.cpp +++ b/libnymea/types/paramtype.cpp @@ -234,7 +234,8 @@ QStringList ParamType::mandatoryTypeProperties() /*! Writes the name, type, defaultValue, min value, max value and readOnly of the given \a paramType to \a dbg. */ QDebug operator<<(QDebug dbg, const ParamType ¶mType) { - dbg.nospace() << "ParamType(Id" << paramType.id() + QDebugStateSaver saver(dbg); + dbg.nospace() << "ParamType(Id" << paramType.id().toString() << " Name: " << paramType.name() << ", Type:" << QVariant::typeToName(paramType.type()) << ", Default:" << paramType.defaultValue() @@ -244,18 +245,19 @@ QDebug operator<<(QDebug dbg, const ParamType ¶mType) << ", ReadOnly:" << paramType.readOnly() << ")"; - return dbg.space(); + return dbg; } /*! Writes the name, type defaultValue, min and max value of each \a paramTypes to \a dbg. */ QDebug operator<<(QDebug dbg, const QList ¶mTypes) { + QDebugStateSaver saver(dbg); dbg.nospace() << "ParamTypeList (count:" << paramTypes.count() << ")" << endl; for (int i = 0; i < paramTypes.count(); i++ ) { dbg.nospace() << " " << i << ": " << paramTypes.at(i) << endl; } - return dbg.space(); + return dbg; } ParamTypes::ParamTypes(const QList &other): QList(other) diff --git a/libnymea/types/state.cpp b/libnymea/types/state.cpp index a4fd5879..0f99319f 100644 --- a/libnymea/types/state.cpp +++ b/libnymea/types/state.cpp @@ -113,19 +113,21 @@ void State::setFilter(Types::StateValueFilter filter) /*! Writes the stateTypeId, the deviceId and the value of the given \a state to \a dbg. */ QDebug operator<<(QDebug dbg, const State &state) { + QDebugStateSaver saver(dbg); dbg.nospace() << "State(StateTypeId: " << state.stateTypeId().toString() << ", DeviceId:" << state.thingId() << ", value:" << state.value() << ")"; - return dbg.space(); + return dbg; } /*! Writes each stateTypeId, deviceId and value of the given \a states to \a dbg. */ QDebug operator<<(QDebug dbg, const QList &states) { + QDebugStateSaver saver(dbg); dbg.nospace() << "StateList (count:" << states.count() << ")"; for (int i = 0; i < states.count(); i++ ) { dbg.nospace() << " " << i << ": " << states.at(i); } - return dbg.space(); + return dbg; } States::States() diff --git a/libnymea/types/statedescriptor.cpp b/libnymea/types/statedescriptor.cpp index b0040420..151754ec 100644 --- a/libnymea/types/statedescriptor.cpp +++ b/libnymea/types/statedescriptor.cpp @@ -197,6 +197,7 @@ bool StateDescriptor::isValid() const /*! Print a StateDescriptor with all its contents to QDebug. */ QDebug operator<<(QDebug dbg, const StateDescriptor &stateDescriptor) { + QDebugStateSaver saver(dbg); dbg.nospace() << "StateDescriptor(ThingId:" << stateDescriptor.thingId().toString() << ", StateTypeId:" << stateDescriptor.stateTypeId().toString() << ", Interface:" << stateDescriptor.interface() << ", InterfaceState:" << stateDescriptor.interfaceState() << ", Operator:" << stateDescriptor.operatorType() << ", Value:" << stateDescriptor.stateValue() diff --git a/libnymea/types/thingclass.cpp b/libnymea/types/thingclass.cpp index c7cc3ba8..36871dbd 100644 --- a/libnymea/types/thingclass.cpp +++ b/libnymea/types/thingclass.cpp @@ -394,15 +394,16 @@ void ThingClass::setBrowsable(bool browsable) m_browsable = browsable; } -/*! Compare this \a deviceClass to another. This is effectively the same as calling a.id() == b.id(). Returns true if the ids match.*/ -bool ThingClass::operator==(const ThingClass &deviceClass) const +/*! Compare this \a thingClass to another. This is effectively the same as calling a.id() == b.id(). Returns true if the ids match.*/ +bool ThingClass::operator==(const ThingClass &thingClass) const { - return m_id == deviceClass.id(); + return m_id == thingClass.id(); } -QDebug operator<<(QDebug &dbg, const ThingClass &deviceClass) +QDebug operator<<(QDebug dbg, const ThingClass &thingClass) { - dbg << "DeviceClass ID:" << deviceClass.id() << "Name:" << deviceClass.name(); + QDebugStateSaver saver(dbg); + dbg.nospace() << "ThingClass(" << thingClass.id().toString() << "Name: " << thingClass.name() << ")"; return dbg; } @@ -417,9 +418,9 @@ ThingClasses::ThingClasses(const QList &other): QList (o ThingClass ThingClasses::findById(const ThingClassId &id) const { - foreach (const ThingClass &deviceClass, *this) { - if (deviceClass.id() == id) { - return deviceClass; + foreach (const ThingClass &thingClass, *this) { + if (thingClass.id() == id) { + return thingClass; } } return ThingClass(); diff --git a/libnymea/types/thingclass.h b/libnymea/types/thingclass.h index a8301a42..d06679cf 100644 --- a/libnymea/types/thingclass.h +++ b/libnymea/types/thingclass.h @@ -175,7 +175,7 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(ThingClass::CreateMethods) -QDebug operator<<(QDebug &dbg, const ThingClass &deviceClass); +QDebug operator<<(QDebug dbg, const ThingClass &thingClass); class LIBNYMEA_EXPORT ThingClasses: public QList {