Ensure valid instance number

This commit is contained in:
LordGrey 2024-04-25 23:34:53 +02:00
parent 42e809581e
commit 12499c8cbb
17 changed files with 44 additions and 23 deletions

View File

@ -67,8 +67,7 @@ _http/s Support_
| leddevice | getProperties | Yes | Yes | Yes | | leddevice | getProperties | Yes | Yes | Yes |
| leddevice | identify | Yes | Yes | Yes | | leddevice | identify | Yes | Yes | Yes |
| logging | start | Yes | No | Yes | | logging | start | Yes | No | Yes |
| logging | stop | Yes | Yes | Yes | | logging | stop | Yes | No | Yes |
| logging | update | Yes | Yes | Yes |
| processing | - | Yes | Yes | Yes | | processing | - | Yes | Yes | Yes |
| serverinfo | - | Yes | Yes | Yes | | serverinfo | - | Yes | Yes | Yes |
| serverinfo | getInfo | Yes | Yes | Yes | | serverinfo | getInfo | Yes | Yes | Yes |

View File

@ -119,8 +119,7 @@ public:
ToggleIdle, ToggleIdle,
ToggleSuspend, ToggleSuspend,
TokenRequired, TokenRequired,
Unsubscribe, Unsubscribe
Update
}; };
static QString toString(Type type) { static QString toString(Type type) {
@ -171,7 +170,6 @@ public:
case ToggleSuspend: return "toggleSuspend"; case ToggleSuspend: return "toggleSuspend";
case TokenRequired: return "tokenRequired"; case TokenRequired: return "tokenRequired";
case Unsubscribe: return "unsubscribe"; case Unsubscribe: return "unsubscribe";
case Update: return "update";
default: return "unknown"; default: return "unknown";
} }
} }
@ -301,8 +299,7 @@ public:
{ {"leddevice", "getProperties"}, { Command::LedDevice, SubCommand::GetProperties, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} }, { {"leddevice", "getProperties"}, { Command::LedDevice, SubCommand::GetProperties, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"leddevice", "identify"}, { Command::LedDevice, SubCommand::Identify, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} }, { {"leddevice", "identify"}, { Command::LedDevice, SubCommand::Identify, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"logging", "start"}, { Command::Logging, SubCommand::Start, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} }, { {"logging", "start"}, { Command::Logging, SubCommand::Start, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} },
{ {"logging", "stop"}, { Command::Logging, SubCommand::Stop, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} }, { {"logging", "stop"}, { Command::Logging, SubCommand::Stop, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} },
{ {"logging", "update"}, { Command::Logging, SubCommand::Update, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"processing", ""}, { Command::Processing, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} }, { {"processing", ""}, { Command::Processing, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"serverinfo", ""}, { Command::ServerInfo, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} }, { {"serverinfo", ""}, { Command::ServerInfo, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"serverinfo", "getInfo"}, { Command::ServerInfo, SubCommand::GetInfo, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} }, { {"serverinfo", "getInfo"}, { Command::ServerInfo, SubCommand::GetInfo, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },

View File

@ -8,7 +8,9 @@
"enum" : ["adjustment"] "enum" : ["adjustment"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["clear"] "enum" : ["clear"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["clearall"] "enum" : ["clearall"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["color"] "enum" : ["color"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -10,7 +10,9 @@
"enum" : ["componentstate"] "enum" : ["componentstate"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -13,7 +13,9 @@
"enum" : ["getconfig","getschema","setconfig","restoreconfig","reload"] "enum" : ["getconfig","getschema","setconfig","restoreconfig","reload"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["create-effect"] "enum" : ["create-effect"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -9,7 +9,9 @@
"enum" : ["delete-effect"] "enum" : ["delete-effect"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["effect"] "enum" : ["effect"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["image"] "enum" : ["image"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["ledcolors"] "enum" : ["ledcolors"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -7,9 +7,6 @@
"required" : true, "required" : true,
"enum" : ["logging"] "enum" : ["logging"]
}, },
"instance" : {
"type" : "integer"
},
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"
}, },

View File

@ -8,7 +8,9 @@
"enum" : ["processing"] "enum" : ["processing"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"tan" : { "tan" : {
"type" : "integer" "type" : "integer"

View File

@ -12,7 +12,9 @@
"enum": ["getInfo", "subscribe", "unsubscribe", "getSubscriptions", "getSubscriptionCommands"] "enum": ["getInfo", "subscribe", "unsubscribe", "getSubscriptions", "getSubscriptionCommands"]
}, },
"instance" : { "instance" : {
"type" : "integer" "type" : "integer",
"minimum": 0,
"maximum": 255
}, },
"data": { "data": {
"type": ["null", "array"], "type": ["null", "array"],

View File

@ -233,7 +233,9 @@ void JsonAPI::handleMessage(const QString &messageString, const QString &httpAut
const quint8 instance = static_cast<quint8>(message.value("instance").toInt()); const quint8 instance = static_cast<quint8>(message.value("instance").toInt());
if (!setHyperionInstance(instance)) if (!setHyperionInstance(instance))
{ {
cmd.isInstanceCmd = InstanceCmd::No;
sendErrorReply(QString("Invalid or stopped instance: %1").arg(instance), cmd); sendErrorReply(QString("Invalid or stopped instance: %1").arg(instance), cmd);
return;
} }
} }