diff --git a/src/raspberrypi/rascsi_interface.proto b/src/raspberrypi/rascsi_interface.proto index 4842eeef..820267e8 100644 --- a/src/raspberrypi/rascsi_interface.proto +++ b/src/raspberrypi/rascsi_interface.proto @@ -173,10 +173,12 @@ message PbOperationParameter { // The list of parameters supported by an operation message PbOperationMetaData { + // The operation name at the time the server-side protobuf code was generated. + string name = 1; // Optional short localized description, key is the lower case locale (e.g. en, de). // Falling back to "en" is recommended if a description for a particular language is missing. - map description = 1; - repeated PbOperationParameter parameters = 2; + map description = 2; + repeated PbOperationParameter parameters = 3; } // Mapping of operations to their ordinals diff --git a/src/raspberrypi/rascsi_response.cpp b/src/raspberrypi/rascsi_response.cpp index ddc96485..3562fca1 100644 --- a/src/raspberrypi/rascsi_response.cpp +++ b/src/raspberrypi/rascsi_response.cpp @@ -467,6 +467,7 @@ PbOperationInfo *RascsiResponse::GetOperationInfo(PbResult& result) void RascsiResponse::CreateOperation(PbOperationInfo *operation_info, PbOperationMetaData *meta_data, const PbOperation& operation, const string& description) { + meta_data->set_name(PbOperation_Name(operation)); (*meta_data->mutable_description())["en"] = description; int ordinal = PbOperation_descriptor()->FindValueByName(PbOperation_Name(operation))->index(); (*operation_info->mutable_operations())[ordinal] = *meta_data; diff --git a/src/raspberrypi/rasctl_display.cpp b/src/raspberrypi/rasctl_display.cpp index 7f8b4917..868292ef 100644 --- a/src/raspberrypi/rasctl_display.cpp +++ b/src/raspberrypi/rasctl_display.cpp @@ -281,36 +281,41 @@ void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info) cout << "Remote operations supported by rascsi and their parameters:" << endl; for (const auto& operation : operations) { - cout << " " << PbOperation_Name(operation.first); - if (!operation.second.description().empty()) { - cout << " (" << operation.second.description().at("en") << ")"; - } - cout << endl; - - for (const auto& parameter : operation.second.parameters()) { - cout << " " << parameter.name() << ": " - << (parameter.default_value().empty() ? "mandatory" : "optional"); - if (!parameter.description().empty()) { - cout << " (" << parameter.description().at("en") << ")"; + if (PbOperation_IsValid(operation.first)) { + cout << " " << PbOperation_Name(static_cast(operation.first)); + if (!operation.second.description().empty()) { + cout << " (" << operation.second.description().at("en") << ")"; } cout << endl; - if (parameter.permitted_values_size()) { - cout << " Permitted values: "; - bool isFirst = true; - for (const auto& permitted_value : parameter.permitted_values()) { - if (!isFirst) { - cout << ", "; - } - isFirst = false; - cout << permitted_value; + for (const auto& parameter : operation.second.parameters()) { + cout << " " << parameter.name() << ": " + << (parameter.default_value().empty() ? "mandatory" : "optional"); + if (!parameter.description().empty()) { + cout << " (" << parameter.description().at("en") << ")"; } cout << endl; - } - if (!parameter.default_value().empty()) { - cout << " Default value: " << parameter.default_value() << endl; + if (parameter.permitted_values_size()) { + cout << " Permitted values: "; + bool isFirst = true; + for (const auto& permitted_value : parameter.permitted_values()) { + if (!isFirst) { + cout << ", "; + } + isFirst = false; + cout << permitted_value; + } + cout << endl; + } + + if (!parameter.default_value().empty()) { + cout << " Default value: " << parameter.default_value() << endl; + } } } + else { + cout << " " << operation.second.name() << " (Unknown server-side operation)" << endl; + } } }