This commit is contained in:
Uwe Seimet
2021-08-25 08:40:55 +02:00
parent bf5289d30e
commit fff119e9fd
4 changed files with 90 additions and 80 deletions

View File

@@ -290,12 +290,12 @@ const PbDevices GetDevices()
PbDeviceType_Parse(device->GetType(), &type); PbDeviceType_Parse(device->GetType(), &type);
pbDevice->set_type(type); pbDevice->set_type(type);
PbDeviceFeatures *features = new PbDeviceFeatures(); PbDeviceProperties *properties = new PbDeviceProperties();
pbDevice->set_allocated_features(features); pbDevice->set_allocated_properties(properties);
features->set_read_only(device->IsReadOnly()); properties->set_read_only(device->IsReadOnly());
features->set_protectable(device->IsProtectable()); properties->set_protectable(device->IsProtectable());
features->set_removable(device->IsRemovable()); properties->set_removable(device->IsRemovable());
features->set_lockable(device->IsLockable()); properties->set_lockable(device->IsLockable());
PbDeviceStatus *status = new PbDeviceStatus(); PbDeviceStatus *status = new PbDeviceStatus();
pbDevice->set_allocated_status(status); pbDevice->set_allocated_status(status);
@@ -334,7 +334,7 @@ const PbDevices GetDevices()
PbImageFile *image_file = new PbImageFile(); PbImageFile *image_file = new PbImageFile();
GetImageFile(image_file, device->IsRemovable() && !device->IsReady() ? "" : filepath.GetPath()); GetImageFile(image_file, device->IsRemovable() && !device->IsReady() ? "" : filepath.GetPath());
pbDevice->set_allocated_file(image_file); pbDevice->set_allocated_file(image_file);
features->set_supports_file(true); properties->set_supports_file(true);
} }
} }
@@ -546,54 +546,54 @@ void GetLogLevels(PbServerInfo& serverInfo)
void GetDeviceTypeFeatures(PbServerInfo& serverInfo) void GetDeviceTypeFeatures(PbServerInfo& serverInfo)
{ {
PbDeviceTypeFeatures *types_features = serverInfo.add_types_features(); PbDeviceTypeProperties *types_properties = serverInfo.add_types_properties();
PbDeviceFeatures *features = types_features->add_features(); PbDeviceProperties *properties = types_properties->add_properties();
types_features->set_type(SAHD); types_properties->set_type(SAHD);
features->set_supports_file(true); properties->set_supports_file(true);
types_features = serverInfo.add_types_features(); types_properties = serverInfo.add_types_properties();
types_features->add_block_sizes(512); types_properties->add_block_sizes(512);
types_features->add_block_sizes(1024); types_properties->add_block_sizes(1024);
types_features->add_block_sizes(2048); types_properties->add_block_sizes(2048);
types_features->add_block_sizes(4096); types_properties->add_block_sizes(4096);
features = types_features->add_features(); properties = types_properties->add_properties();
types_features->set_type(SCHD); types_properties->set_type(SCHD);
features->set_protectable(true); properties->set_protectable(true);
features->set_supports_file(true); properties->set_supports_file(true);
types_features = serverInfo.add_types_features(); types_properties = serverInfo.add_types_properties();
types_features->add_block_sizes(512); types_properties->add_block_sizes(512);
types_features->add_block_sizes(1024); types_properties->add_block_sizes(1024);
types_features->add_block_sizes(2048); types_properties->add_block_sizes(2048);
types_features->add_block_sizes(4096); types_properties->add_block_sizes(4096);
features = types_features->add_features(); properties = types_properties->add_properties();
types_features->set_type(SCRM); types_properties->set_type(SCRM);
features->set_protectable(true); properties->set_protectable(true);
features->set_removable(true); properties->set_removable(true);
features->set_lockable(true); properties->set_lockable(true);
features->set_supports_file(true); properties->set_supports_file(true);
types_features = serverInfo.add_types_features(); types_properties = serverInfo.add_types_properties();
features = types_features->add_features(); properties = types_properties->add_properties();
types_features->set_type(SCMO); types_properties->set_type(SCMO);
features->set_protectable(true); properties->set_protectable(true);
features->set_removable(true); properties->set_removable(true);
features->set_lockable(true); properties->set_lockable(true);
features->set_supports_file(true); properties->set_supports_file(true);
types_features = serverInfo.add_types_features(); types_properties = serverInfo.add_types_properties();
features = types_features->add_features(); properties = types_properties->add_properties();
types_features->set_type(SCCD); types_properties->set_type(SCCD);
features->set_read_only(true); properties->set_read_only(true);
features->set_removable(true); properties->set_removable(true);
features->set_lockable(true); properties->set_lockable(true);
features->set_supports_file(true); properties->set_supports_file(true);
types_features = serverInfo.add_types_features(); types_properties = serverInfo.add_types_properties();
types_features->set_type(SCBR); types_properties->set_type(SCBR);
types_features = serverInfo.add_types_features(); types_properties = serverInfo.add_types_properties();
types_features->set_type(SCDP); types_properties->set_type(SCDP);
} }
void GetAvailableImages(PbServerInfo& serverInfo) void GetAvailableImages(PbServerInfo& serverInfo)

View File

@@ -49,8 +49,8 @@ enum PbOperation {
UNPROTECT = 9; UNPROTECT = 9;
} }
// The features supported by a device // The properties supported by a device
message PbDeviceFeatures { message PbDeviceProperties {
// Read-only medium (e.g. CD-ROMs) are not protectable but permanently read-only // Read-only medium (e.g. CD-ROMs) are not protectable but permanently read-only
bool read_only = 1; bool read_only = 1;
// Medium can be write-protected // Medium can be write-protected
@@ -73,10 +73,10 @@ message PbDeviceStatus {
bool locked = 3; bool locked = 3;
} }
// Device features by device type // Device properties by device type
message PbDeviceTypeFeatures { message PbDeviceTypeProperties {
PbDeviceType type = 1; PbDeviceType type = 1;
repeated PbDeviceFeatures features = 2; repeated PbDeviceProperties properties = 2;
// List of supported block sizes // List of supported block sizes
repeated uint32 block_sizes = 6; repeated uint32 block_sizes = 6;
} }
@@ -114,7 +114,7 @@ message PbDevice {
int32 id = 1; int32 id = 1;
int32 unit = 2; int32 unit = 2;
PbDeviceType type = 3; PbDeviceType type = 3;
PbDeviceFeatures features = 4; PbDeviceProperties properties = 4;
PbDeviceStatus status = 5; PbDeviceStatus status = 5;
PbImageFile file = 6; PbImageFile file = 6;
string vendor = 7; string vendor = 7;
@@ -151,8 +151,8 @@ message PbServerInfo {
repeated string available_log_levels = 2; repeated string available_log_levels = 2;
string current_log_level = 3; string current_log_level = 3;
string default_image_folder = 4; string default_image_folder = 4;
// Supported device types and their features // Supported device types and their properties
repeated PbDeviceTypeFeatures types_features = 5; repeated PbDeviceTypeProperties types_properties = 5;
// Files in the default folder // Files in the default folder
repeated PbImageFile image_files = 6; repeated PbImageFile image_files = 6;
// The attached devices // The attached devices

View File

@@ -213,43 +213,53 @@ void CommandServerInfo(const string& hostname, int port)
} }
} }
cout << "Device types and their features:" << endl; cout << "Device types and their properties:" << endl;
for (int i = 0; i < serverInfo.types_features_size(); i++) { for (int i = 0; i < serverInfo.types_properties_size(); i++) {
PbDeviceTypeFeatures type_features = serverInfo.types_features(i); PbDeviceTypeProperties types_properties = serverInfo.types_properties(i);
cout << " " << PbDeviceType_Name(type_features.type()); cout << " " << PbDeviceType_Name(types_properties.type());
if (type_features.features_size()) { cout << " Properties: ";
for (int j = 0; j < type_features.features_size(); j++) { if (types_properties.properties_size()) {
PbDeviceFeatures features = type_features.features(j); for (int j = 0; j < types_properties.properties_size(); j++) {
if (features.read_only()) { bool has_feature = false;
PbDeviceProperties properties = types_properties.properties(j);
if (properties.read_only()) {
cout << "Read-only"; cout << "Read-only";
has_feature = true;
} }
if (features.protectable()) { if (properties.protectable()) {
cout << " Protectable"; cout << (has_feature ? ", " : "") << "Protectable";
has_feature = true;
} }
if (features.removable()) { if (properties.removable()) {
cout << " Removable"; cout << (has_feature ? ", " : "") << "Removable";
has_feature = true;
} }
if (features.lockable()) { if (properties.lockable()) {
cout << " Lockable"; cout << (has_feature ? ", " : "") << "Lockable";
has_feature = true;
} }
if (features.supports_file()) { if (properties.supports_file()) {
cout << " Image file support"; cout << (has_feature ? ", " : "") << "Image file support";
} }
cout << endl; cout << endl;
} }
} }
else { else {
cout << endl; cout << "None" << endl;
} }
if (type_features.block_sizes_size()) { if (!types_properties.block_sizes_size()) {
cout << " Supported block sizes: "; cout << " Block size is not configurable" << endl;
for (int j = 0; j < type_features.block_sizes_size(); j++) { }
else {
cout << " Configurable block sizes: ";
for (int j = 0; j < types_properties.block_sizes_size(); j++) {
if (j) { if (j) {
cout << ", "; cout << ", ";
} }
cout << type_features.block_sizes(j); cout << types_properties.block_sizes(j);
} }
cout << endl; cout << endl;
} }

View File

@@ -59,7 +59,7 @@ string ListDevices(const PbDevices& devices)
s << "| " << device.id() << " | " << device.unit() << " | " << PbDeviceType_Name(device.type()) << " | " s << "| " << device.id() << " | " << device.unit() << " | " << PbDeviceType_Name(device.type()) << " | "
<< (filename.empty() ? "NO MEDIA" : filename) << (filename.empty() ? "NO MEDIA" : filename)
<< (!device.status().removed() && (device.features().read_only() || device.status().protected_()) ? " (WRITEPROTECT)" : "") << (!device.status().removed() && (device.properties().read_only() || device.status().protected_()) ? " (WRITEPROTECT)" : "")
<< endl; << endl;
} }