@@ -333,7 +333,7 @@ void JsonAPI::handleInstanceCommand(const JsonApiCommand& cmd, const QJsonObject
333333 // Execute the command for each valid instance
334334 for (const auto &instanceId : std::as_const (instanceIds))
335335 {
336- if (isRunningInstanceRequired == InstanceCmd::MustRun_Yes || _currInstanceIndex == GLOABL_INSTANCE_ID )
336+ if (isRunningInstanceRequired == InstanceCmd::MustRun_Yes || _currInstanceIndex == NO_INSTANCE_ID )
337337 {
338338 if (handleInstanceSwitch (instanceId))
339339 {
@@ -911,8 +911,8 @@ void JsonAPI::handleConfigSetCommand(const QJsonObject &message, const JsonApiCo
911911 const QJsonObject globalSettings = config[" global" ].toObject ().value (" settings" ).toObject ();
912912 if (!globalSettings.isEmpty ())
913913 {
914- const QJsonObject instanceZeroConfig = instancesNewConfigs.value (GLOABL_INSTANCE_ID );
915- instancesNewConfigs.insert (GLOABL_INSTANCE_ID , JsonUtils::mergeJsonObjects (instanceZeroConfig, globalSettings));
914+ const QJsonObject instanceZeroConfig = instancesNewConfigs.value (NO_INSTANCE_ID );
915+ instancesNewConfigs.insert (NO_INSTANCE_ID , JsonUtils::mergeJsonObjects (instanceZeroConfig, globalSettings));
916916 }
917917
918918 QMapIterator<quint8, QJsonObject> iter (instancesNewConfigs);
@@ -959,10 +959,18 @@ void JsonAPI::handleConfigGetCommand(const QJsonObject &message, const JsonApiCo
959959 const QJsonObject globalConfig = filter[" global" ].toObject ();
960960 if (!globalConfig.isEmpty ())
961961 {
962- const QJsonArray globalTypes = globalConfig[" types" ].toArray ();
963- for (const auto &type : globalTypes) {
964- if (type.isString ()) {
965- globalFilterTypes.append (type.toString ());
962+ QJsonValue const globalTypes = globalConfig[" types" ];
963+ if (globalTypes.isNull ())
964+ {
965+ globalFilterTypes.append (" __none__" );
966+ }
967+ else
968+ {
969+ QJsonArray const globalTypesList = globalTypes.toArray ();
970+ for (const auto &type : globalTypesList) {
971+ if (type.isString ()) {
972+ globalFilterTypes.append (type.toString ());
973+ }
966974 }
967975 }
968976 }
@@ -974,25 +982,41 @@ void JsonAPI::handleConfigGetCommand(const QJsonObject &message, const JsonApiCo
974982 if (!instances.isEmpty ())
975983 {
976984 QSet<quint8> const configuredInstanceIds = _instanceManager->getInstanceIds ();
977- const QJsonArray instanceIds = instances[" ids" ].toArray ();
978- for (const auto &idx : instanceIds) {
979- if (idx.isDouble ()) {
980- quint8 const instanceId = static_cast <quint8>(idx.toInt ());
981- if (configuredInstanceIds.contains (instanceId))
982- {
983- instanceListFilter.append (instanceId);
984- }
985- else
986- {
987- errorDetails.append (QString (" Given instance number '%1' does not exist." ).arg (instanceId));
985+ QJsonValue const instanceIds = instances[" ids" ];
986+ if (instanceIds.isNull ())
987+ {
988+ instanceListFilter.append (NO_INSTANCE_ID);
989+ }
990+ else
991+ {
992+ QJsonArray const instaceIdsList = instanceIds.toArray ();
993+ for (const auto &idx : instaceIdsList) {
994+ if (idx.isDouble ()) {
995+ quint8 const instanceId = static_cast <quint8>(idx.toInt ());
996+ if (configuredInstanceIds.contains (instanceId))
997+ {
998+ instanceListFilter.append (instanceId);
999+ }
1000+ else
1001+ {
1002+ errorDetails.append (QString (" Given instance number '%1' does not exist." ).arg (instanceId));
1003+ }
9881004 }
9891005 }
990- }
9911006
992- const QJsonArray instanceTypes = instances[" types" ].toArray ();
993- for (const auto &type : instanceTypes) {
994- if (type.isString ()) {
995- instanceFilterTypes.append (type.toString ());
1007+ QJsonValue const instanceTypes = instances[" types" ];
1008+ if (instanceTypes.isNull ())
1009+ {
1010+ instanceFilterTypes.append (" __none__" );
1011+ }
1012+ else
1013+ {
1014+ QJsonArray const instaceTypesList = instanceTypes.toArray ();
1015+ for (const auto &type : instaceTypesList) {
1016+ if (type.isString ()) {
1017+ instanceFilterTypes.append (type.toString ());
1018+ }
1019+ }
9961020 }
9971021 }
9981022 }
@@ -1005,14 +1029,7 @@ void JsonAPI::handleConfigGetCommand(const QJsonObject &message, const JsonApiCo
10051029 settings = JsonInfo::getConfiguration ();
10061030 }
10071031
1008- if (!settings.empty ())
1009- {
1010- sendSuccessDataReplyWithError (settings, cmd, errorDetails);
1011- }
1012- else
1013- {
1014- sendErrorReply (" Generating full config failed" , cmd);
1015- }
1032+ sendSuccessDataReplyWithError (settings, cmd, errorDetails);
10161033}
10171034
10181035void JsonAPI::handleConfigRestoreCommand (const QJsonObject &message, const JsonApiCommand& cmd)
@@ -1670,7 +1687,7 @@ QJsonObject JsonAPI::getBasicCommandReply(bool success, const QString &command,
16701687 reply[" command" ] = command;
16711688 reply[" tan" ] = tan;
16721689
1673- if ((_currInstanceIndex != GLOABL_INSTANCE_ID ) && instanceCmdType != InstanceCmd::No)
1690+ if ((_currInstanceIndex != NO_INSTANCE_ID ) && instanceCmdType != InstanceCmd::No)
16741691 {
16751692 reply[" instance" ] = _currInstanceIndex;
16761693 }
@@ -1793,7 +1810,7 @@ void JsonAPI::handleInstanceStateChange(InstanceState state, quint8 instanceID,
17931810 if (!_hyperion.isNull () && _hyperion->getInstanceIndex () == instanceID)
17941811 {
17951812 _hyperion.reset (nullptr );
1796- _jsonCB->setSubscriptionsTo (GLOABL_INSTANCE_ID );
1813+ _jsonCB->setSubscriptionsTo (NO_INSTANCE_ID );
17971814 }
17981815 }
17991816 break ;
0 commit comments