Simplified protobuf interface

This commit is contained in:
Uwe Seimet 2021-08-27 19:16:56 +02:00
parent 929ff22980
commit e1e451aee3
3 changed files with 44 additions and 42 deletions

View File

@ -528,8 +528,9 @@ void GetLogLevels(PbServerInfo& serverInfo)
void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
{
PbDeviceTypeProperties *types_properties = serverInfo.add_types_properties();
PbDeviceProperties *properties = types_properties->add_properties();
types_properties->set_type(SAHD);
PbDeviceProperties *properties = new PbDeviceProperties();
types_properties->set_allocated_properties(properties);
properties->set_supports_file(true);
set<int> block_sizes = device_factory.GetSasiSectorSizes();
for (const auto& block_size : block_sizes) {
@ -540,7 +541,8 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
types_properties = serverInfo.add_types_properties();
types_properties->set_type(SCHD);
properties = types_properties->add_properties();
properties = new PbDeviceProperties();
types_properties->set_allocated_properties(properties);
properties->set_protectable(true);
properties->set_supports_file(true);
for (const auto& block_size : block_sizes) {
@ -549,7 +551,8 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
types_properties = serverInfo.add_types_properties();
types_properties->set_type(SCRM);
properties = types_properties->add_properties();
properties = new PbDeviceProperties();
types_properties->set_allocated_properties(properties);
properties->set_protectable(true);
properties->set_removable(true);
properties->set_lockable(true);
@ -560,7 +563,8 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
types_properties = serverInfo.add_types_properties();
types_properties->set_type(SCMO);
properties = types_properties->add_properties();
properties = new PbDeviceProperties();
types_properties->set_allocated_properties(properties);
properties->set_protectable(true);
properties->set_removable(true);
properties->set_lockable(true);
@ -568,7 +572,8 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
types_properties = serverInfo.add_types_properties();
types_properties->set_type(SCCD);
properties = types_properties->add_properties();
properties = new PbDeviceProperties();
types_properties->set_allocated_properties(properties);
properties->set_read_only(true);
properties->set_removable(true);
properties->set_lockable(true);
@ -579,7 +584,8 @@ void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
types_properties = serverInfo.add_types_properties();
types_properties->set_type(SCDP);
properties = types_properties->add_properties();
properties = new PbDeviceProperties();
types_properties->set_allocated_properties(properties);
properties->set_supports_params(true);
}

View File

@ -80,7 +80,7 @@ message PbDeviceStatus {
// Device properties by device type
message PbDeviceTypeProperties {
PbDeviceType type = 1;
repeated PbDeviceProperties properties = 2;
PbDeviceProperties properties = 2;
}
// The image file data

View File

@ -219,43 +219,39 @@ void CommandServerInfo(const string& hostname, int port)
list<int> block_sizes;
cout << " Properties: ";
if (types_properties.properties_size()) {
for (int j = 0; j < types_properties.properties_size(); j++) {
bool has_property = false;
PbDeviceProperties properties = types_properties.properties(j);
if (properties.read_only()) {
cout << "Read-only";
bool has_property = false;
const PbDeviceProperties& properties = types_properties.properties();
if (properties.read_only()) {
cout << "Read-only";
has_property = true;
}
if (properties.protectable()) {
cout << (has_property ? ", " : "") << "Protectable";
has_property = true;
}
if (properties.removable()) {
cout << (has_property ? ", " : "") << "Removable";
has_property = true;
}
if (properties.lockable()) {
cout << (has_property ? ", " : "") << "Lockable";
has_property = true;
}
if (properties.supports_file()) {
cout << (has_property ? ", " : "") << "Image file support";
}
else if (properties.supports_params()) {
cout << (has_property ? ", " : "") << "Parameter support";
}
cout << endl;
for (int k = 0 ; k < properties.block_sizes_size(); k++)
{
block_sizes.push_back(properties.block_sizes(k));
}
}
}
else {
cout << "None" << endl;
if (properties.protectable()) {
cout << (has_property ? ", " : "") << "Protectable";
has_property = true;
}
if (properties.removable()) {
cout << (has_property ? ", " : "") << "Removable";
has_property = true;
}
if (properties.lockable()) {
cout << (has_property ? ", " : "") << "Lockable";
has_property = true;
}
if (properties.supports_file()) {
cout << (has_property ? ", " : "") << "Image file support";
}
else if (properties.supports_params()) {
cout << (has_property ? ", " : "") << "Parameter support";
}
if (!has_property) {
cout << "None";
}
cout << endl;
for (int k = 0 ; k < properties.block_sizes_size(); k++)
{
block_sizes.push_back(properties.block_sizes(k));
}
if (block_sizes.empty()) {