mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 23:29:39 +00:00
Added safeguard against unknown operations
This commit is contained in:
parent
6b14ba6511
commit
b8599ba088
@ -173,10 +173,12 @@ message PbOperationParameter {
|
|||||||
|
|
||||||
// The list of parameters supported by an operation
|
// The list of parameters supported by an operation
|
||||||
message PbOperationMetaData {
|
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).
|
// 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.
|
// Falling back to "en" is recommended if a description for a particular language is missing.
|
||||||
map<string, string> description = 1;
|
map<string, string> description = 2;
|
||||||
repeated PbOperationParameter parameters = 2;
|
repeated PbOperationParameter parameters = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mapping of operations to their ordinals
|
// Mapping of operations to their ordinals
|
||||||
|
@ -467,6 +467,7 @@ PbOperationInfo *RascsiResponse::GetOperationInfo(PbResult& result)
|
|||||||
void RascsiResponse::CreateOperation(PbOperationInfo *operation_info, PbOperationMetaData *meta_data,
|
void RascsiResponse::CreateOperation(PbOperationInfo *operation_info, PbOperationMetaData *meta_data,
|
||||||
const PbOperation& operation, const string& description)
|
const PbOperation& operation, const string& description)
|
||||||
{
|
{
|
||||||
|
meta_data->set_name(PbOperation_Name(operation));
|
||||||
(*meta_data->mutable_description())["en"] = description;
|
(*meta_data->mutable_description())["en"] = description;
|
||||||
int ordinal = PbOperation_descriptor()->FindValueByName(PbOperation_Name(operation))->index();
|
int ordinal = PbOperation_descriptor()->FindValueByName(PbOperation_Name(operation))->index();
|
||||||
(*operation_info->mutable_operations())[ordinal] = *meta_data;
|
(*operation_info->mutable_operations())[ordinal] = *meta_data;
|
||||||
|
@ -281,7 +281,8 @@ void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info)
|
|||||||
|
|
||||||
cout << "Remote operations supported by rascsi and their parameters:" << endl;
|
cout << "Remote operations supported by rascsi and their parameters:" << endl;
|
||||||
for (const auto& operation : operations) {
|
for (const auto& operation : operations) {
|
||||||
cout << " " << PbOperation_Name(operation.first);
|
if (PbOperation_IsValid(operation.first)) {
|
||||||
|
cout << " " << PbOperation_Name(static_cast<PbOperation>(operation.first));
|
||||||
if (!operation.second.description().empty()) {
|
if (!operation.second.description().empty()) {
|
||||||
cout << " (" << operation.second.description().at("en") << ")";
|
cout << " (" << operation.second.description().at("en") << ")";
|
||||||
}
|
}
|
||||||
@ -313,4 +314,8 @@ void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
cout << " " << operation.second.name() << " (Unknown server-side operation)" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user