diff --git a/src/raspberrypi/rascsi_interface.proto b/src/raspberrypi/rascsi_interface.proto index e451c11c..925e22e5 100644 --- a/src/raspberrypi/rascsi_interface.proto +++ b/src/raspberrypi/rascsi_interface.proto @@ -173,7 +173,7 @@ message PbOperationParameter { // The list of parameters supported by an operation message PbOperationParameters { - string operation = 1; + string name = 1; // Optional short localized description, key is the lower case locale (e.g. en, de) map description = 2; repeated PbOperationParameter parameters = 3; diff --git a/src/raspberrypi/rascsi_response.cpp b/src/raspberrypi/rascsi_response.cpp index 72cc0518..518ab4a9 100644 --- a/src/raspberrypi/rascsi_response.cpp +++ b/src/raspberrypi/rascsi_response.cpp @@ -343,7 +343,7 @@ PbOperationInfo *RascsiResponse::GetOperationInfo(PbResult& result) PbOperationParameter *parameter; parameters = operation_info->add_operations(); - parameters->set_operation(PbOperation_Name(ATTACH)); + parameters->set_name(PbOperation_Name(ATTACH)); (*parameters->mutable_description())["en"] = "Attach device, one of the parameters below is required"; parameter = parameters->add_parameters(); parameter->set_name("name"); @@ -355,24 +355,42 @@ PbOperationInfo *RascsiResponse::GetOperationInfo(PbResult& result) parameter->set_type("string"); parameters = operation_info->add_operations(); - parameters->set_operation(PbOperation_Name(DETACH)); + parameters->set_name(PbOperation_Name(DETACH)); (*parameters->mutable_description())["en"] = "Detach device"; parameters = operation_info->add_operations(); - parameters->set_operation(PbOperation_Name(DETACH_ALL)); + parameters->set_name(PbOperation_Name(DETACH_ALL)); (*parameters->mutable_description())["en"] = "Detach all devices"; parameters = operation_info->add_operations(); - parameters->set_operation(PbOperation_Name(START)); + parameters->set_name(PbOperation_Name(START)); (*parameters->mutable_description())["en"] = "Start device"; parameters = operation_info->add_operations(); - parameters->set_operation(PbOperation_Name(STOP)); + parameters->set_name(PbOperation_Name(STOP)); (*parameters->mutable_description())["en"] = "Stop device"; + parameters = operation_info->add_operations(); + parameters->set_name(PbOperation_Name(INSERT)); + (*parameters->mutable_description())["en"] = "Insert medium"; + parameter = parameters->add_parameters(); + parameter->set_name("file"); + (*parameter->mutable_description())["en"] = "Image file name"; parameters = operation_info->add_operations(); - parameters->set_operation(PbOperation_Name(OPERATION_INFO)); + parameters->set_name(PbOperation_Name(EJECT)); + (*parameters->mutable_description())["en"] = "Eject medium"; + + parameters = operation_info->add_operations(); + parameters->set_name(PbOperation_Name(PROTECT)); + (*parameters->mutable_description())["en"] = "Protect medium"; + + parameters = operation_info->add_operations(); + parameters->set_name(PbOperation_Name(UNPROTECT)); + (*parameters->mutable_description())["en"] = "Unprotect medium"; + + parameters = operation_info->add_operations(); + parameters->set_name(PbOperation_Name(OPERATION_INFO)); result.set_status(true); diff --git a/src/raspberrypi/rasctl_display.cpp b/src/raspberrypi/rasctl_display.cpp index ef98a90e..8d36f4c6 100644 --- a/src/raspberrypi/rasctl_display.cpp +++ b/src/raspberrypi/rasctl_display.cpp @@ -276,15 +276,19 @@ void RasctlDisplay::DisplayMappingInfo(const PbMappingInfo& mapping_info) void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info) { + // Creates a sorted list + list operations = { operation_info.operations().begin(), operation_info.operations().end() }; + operations.sort([](const auto& a, const auto& b) { return a.name() < b.name(); }); + cout << "Remote operations supported by rascsi and their parameters:" << endl; - for (auto& operation : operation_info.operations()) { - cout << " " << operation.operation(); + for (const auto& operation : operations) { + cout << " " << operation.name(); if (!operation.description().empty()) { cout << " (" << operation.description().at("en") << ")"; } cout << endl; - for (auto& parameter : operation.parameters()) { + for (const auto& parameter : operation.parameters()) { cout << " " << parameter.name() << ": " << parameter.type() << (parameter.is_mandatory() ? ", mandatory" : ", optional"); if (!parameter.description().empty()) {