mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-25 21:35:33 +00:00
Implement proper SMART on/off switch support detection.
This commit is contained in:
@@ -681,6 +681,17 @@ StorageDevice::Status StorageDevice::get_smart_status() const
|
||||
|
||||
|
||||
|
||||
bool StorageDevice::get_smart_switch_supported() const
|
||||
{
|
||||
const bool supported = get_smart_status() != Status::Unsupported;
|
||||
// NVMe does not support on/off
|
||||
const bool is_nvme = get_detected_type() == StorageDeviceDetectedType::Nvme;
|
||||
|
||||
return !get_is_virtual() && supported && !is_nvme;
|
||||
}
|
||||
|
||||
|
||||
|
||||
StorageDevice::Status StorageDevice::get_aodc_status() const
|
||||
{
|
||||
// smart-disabled drives are known to print some garbage, so
|
||||
|
||||
@@ -129,6 +129,9 @@ class StorageDevice {
|
||||
/// Get SMART status
|
||||
[[nodiscard]] Status get_smart_status() const;
|
||||
|
||||
/// Get if SMART on/off is supported
|
||||
[[nodiscard]] bool get_smart_switch_supported() const;
|
||||
|
||||
/// Get AODC status
|
||||
[[nodiscard]] Status get_aodc_status() const;
|
||||
|
||||
|
||||
@@ -638,6 +638,9 @@ void GscMainWindow::on_action_enable_smart_toggled(Gtk::ToggleAction* action)
|
||||
if (!drive || drive->get_is_virtual() || drive->get_test_is_active())
|
||||
return;
|
||||
|
||||
if (!drive->get_smart_switch_supported())
|
||||
return;
|
||||
|
||||
StorageDevice::Status status = drive->get_smart_status();
|
||||
if (status == StorageDevice::Status::Unsupported) // this shouldn't happen
|
||||
return;
|
||||
@@ -848,7 +851,7 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_remove_virtual_device))))
|
||||
action->set_visible(drive && is_virtual);
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_smart)))) {
|
||||
action->set_sensitive(smart_status != StorageDevice::Status::Unsupported);
|
||||
action->set_sensitive(drive && drive->get_smart_switch_supported());
|
||||
}
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_aodc))))
|
||||
action->set_sensitive(aodc_status != StorageDevice::Status::Unsupported);
|
||||
|
||||
Reference in New Issue
Block a user