mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-17 01:29:21 +00:00
Support unsetting specific device flags
This makes it possible to 'undo' the notification, for example.
This commit is contained in:
parent
e92bb8a2ac
commit
b5a70a70ee
@ -1023,18 +1023,26 @@ fu_engine_modify_device(FuEngine *self,
|
|||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* support adding a subset of device flags */
|
/* support adding and removing a subset of device flags */
|
||||||
if (g_strcmp0(key, "Flags") == 0) {
|
if (g_strcmp0(key, "Flags") == 0) {
|
||||||
FwupdDeviceFlags flag = fwupd_device_flag_from_string(value);
|
if (g_str_has_prefix(value, "~")) {
|
||||||
if (flag == FWUPD_DEVICE_FLAG_UNKNOWN) {
|
FwupdDeviceFlags flag = fwupd_device_flag_from_string(value + 1);
|
||||||
|
if (flag == FWUPD_DEVICE_FLAG_NOTIFIED) {
|
||||||
|
fu_device_remove_flag(device, flag);
|
||||||
|
} else {
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
"key %s not a valid flag",
|
"flag %s cannot be unset from client",
|
||||||
key);
|
key);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (flag != FWUPD_DEVICE_FLAG_REPORTED && flag != FWUPD_DEVICE_FLAG_NOTIFIED) {
|
} else {
|
||||||
|
FwupdDeviceFlags flag = fwupd_device_flag_from_string(value);
|
||||||
|
if (flag == FWUPD_DEVICE_FLAG_REPORTED ||
|
||||||
|
flag == FWUPD_DEVICE_FLAG_NOTIFIED) {
|
||||||
|
fu_device_add_flag(device, flag);
|
||||||
|
} else {
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
@ -1042,7 +1050,7 @@ fu_engine_modify_device(FuEngine *self,
|
|||||||
key);
|
key);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fu_device_add_flag(device, flag);
|
}
|
||||||
return fu_history_modify_device(self->history, device, error);
|
return fu_history_modify_device(self->history, device, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user