From 6b14ba651135db152fe57c6fe469227f71f00969 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Sat, 18 Dec 2021 13:26:21 +0100 Subject: [PATCH] Map operations by ordinal --- src/raspberrypi/rascsi_interface.proto | 5 ++--- src/raspberrypi/rascsi_response.cpp | 3 ++- src/raspberrypi/rasctl_display.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/raspberrypi/rascsi_interface.proto b/src/raspberrypi/rascsi_interface.proto index 515046b7..4842eeef 100644 --- a/src/raspberrypi/rascsi_interface.proto +++ b/src/raspberrypi/rascsi_interface.proto @@ -179,10 +179,9 @@ message PbOperationMetaData { repeated PbOperationParameter parameters = 2; } -// Mapping of operation names to their meta data. -// The names are the names at the time the server-side protobuf data were generated from the .proto interface file. +// Mapping of operations to their ordinals message PbOperationInfo { - map operations = 1; + map operations = 1; } // The supported file extensions mapped to their respective device types diff --git a/src/raspberrypi/rascsi_response.cpp b/src/raspberrypi/rascsi_response.cpp index bab9ec19..ddc96485 100644 --- a/src/raspberrypi/rascsi_response.cpp +++ b/src/raspberrypi/rascsi_response.cpp @@ -468,7 +468,8 @@ void RascsiResponse::CreateOperation(PbOperationInfo *operation_info, PbOperatio const PbOperation& operation, const string& description) { (*meta_data->mutable_description())["en"] = description; - (*operation_info->mutable_operations())[PbOperation_Name(operation)] = *meta_data; + int ordinal = PbOperation_descriptor()->FindValueByName(PbOperation_Name(operation))->index(); + (*operation_info->mutable_operations())[ordinal] = *meta_data; } PbOperationParameter *RascsiResponse::AddOperationParameter(PbOperationMetaData *meta_data, const string& name, diff --git a/src/raspberrypi/rasctl_display.cpp b/src/raspberrypi/rasctl_display.cpp index 1fb5bc5c..7f8b4917 100644 --- a/src/raspberrypi/rasctl_display.cpp +++ b/src/raspberrypi/rasctl_display.cpp @@ -277,11 +277,11 @@ void RasctlDisplay::DisplayMappingInfo(const PbMappingInfo& mapping_info) void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info) { // Creates a sorted map - const map operations = { operation_info.operations().begin(), operation_info.operations().end() }; + const map operations = { operation_info.operations().begin(), operation_info.operations().end() }; cout << "Remote operations supported by rascsi and their parameters:" << endl; for (const auto& operation : operations) { - cout << " " << operation.first; + cout << " " << PbOperation_Name(operation.first); if (!operation.second.description().empty()) { cout << " (" << operation.second.description().at("en") << ")"; }