mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-12 06:29:36 +00:00
Export the device state as part of the D-Bus interface
This commit is contained in:
parent
949af578ea
commit
0bc65b5e97
@ -59,6 +59,7 @@ typedef struct {
|
|||||||
FwupdUpdateState update_state;
|
FwupdUpdateState update_state;
|
||||||
gchar *update_error;
|
gchar *update_error;
|
||||||
gchar *update_message;
|
gchar *update_message;
|
||||||
|
FwupdStatus status;
|
||||||
GPtrArray *releases;
|
GPtrArray *releases;
|
||||||
FwupdDevice *parent;
|
FwupdDevice *parent;
|
||||||
} FwupdDevicePrivate;
|
} FwupdDevicePrivate;
|
||||||
@ -68,6 +69,7 @@ enum {
|
|||||||
PROP_VERSION_FORMAT,
|
PROP_VERSION_FORMAT,
|
||||||
PROP_FLAGS,
|
PROP_FLAGS,
|
||||||
PROP_PROTOCOL,
|
PROP_PROTOCOL,
|
||||||
|
PROP_STATUS,
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1397,6 +1399,11 @@ fwupd_device_to_variant_full (FwupdDevice *device, FwupdDeviceFlags flags)
|
|||||||
FWUPD_RESULT_KEY_UPDATE_STATE,
|
FWUPD_RESULT_KEY_UPDATE_STATE,
|
||||||
g_variant_new_uint32 (priv->update_state));
|
g_variant_new_uint32 (priv->update_state));
|
||||||
}
|
}
|
||||||
|
if (priv->status != FWUPD_STATUS_UNKNOWN) {
|
||||||
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
|
FWUPD_RESULT_KEY_STATUS,
|
||||||
|
g_variant_new_uint32 (priv->status));
|
||||||
|
}
|
||||||
if (priv->version_format != FWUPD_VERSION_FORMAT_UNKNOWN) {
|
if (priv->version_format != FWUPD_VERSION_FORMAT_UNKNOWN) {
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
FWUPD_RESULT_KEY_VERSION_FORMAT,
|
FWUPD_RESULT_KEY_VERSION_FORMAT,
|
||||||
@ -1575,6 +1582,10 @@ fwupd_device_from_key_value (FwupdDevice *device, const gchar *key, GVariant *va
|
|||||||
fwupd_device_set_update_state (device, g_variant_get_uint32 (value));
|
fwupd_device_set_update_state (device, g_variant_get_uint32 (value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (g_strcmp0 (key, FWUPD_RESULT_KEY_STATUS) == 0) {
|
||||||
|
fwupd_device_set_status (device, g_variant_get_uint32 (value));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (g_strcmp0 (key, FWUPD_RESULT_KEY_VERSION_FORMAT) == 0) {
|
if (g_strcmp0 (key, FWUPD_RESULT_KEY_VERSION_FORMAT) == 0) {
|
||||||
fwupd_device_set_version_format (device, g_variant_get_uint32 (value));
|
fwupd_device_set_version_format (device, g_variant_get_uint32 (value));
|
||||||
return;
|
return;
|
||||||
@ -1881,6 +1892,43 @@ fwupd_device_add_release (FwupdDevice *device, FwupdRelease *release)
|
|||||||
g_return_if_fail (FWUPD_IS_DEVICE (device));
|
g_return_if_fail (FWUPD_IS_DEVICE (device));
|
||||||
g_ptr_array_add (priv->releases, g_object_ref (release));
|
g_ptr_array_add (priv->releases, g_object_ref (release));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* fwupd_device_get_status:
|
||||||
|
* @self: A #FwupdDevice
|
||||||
|
*
|
||||||
|
* Returns what the device is currently doing.
|
||||||
|
*
|
||||||
|
* Returns: the status value, e.g. %FWUPD_STATUS_DEVICE_WRITE
|
||||||
|
*
|
||||||
|
* Since: 1.4.0
|
||||||
|
**/
|
||||||
|
FwupdStatus
|
||||||
|
fwupd_device_get_status (FwupdDevice *self)
|
||||||
|
{
|
||||||
|
FwupdDevicePrivate *priv = GET_PRIVATE (self);
|
||||||
|
g_return_val_if_fail (FWUPD_IS_DEVICE (self), 0);
|
||||||
|
return priv->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_device_set_status:
|
||||||
|
* @self: A #FwupdDevice
|
||||||
|
* @status: the status value, e.g. %FWUPD_STATUS_DEVICE_WRITE
|
||||||
|
*
|
||||||
|
* Sets what the device is currently doing.
|
||||||
|
*
|
||||||
|
* Since: 1.4.0
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
fwupd_device_set_status (FwupdDevice *self, FwupdStatus status)
|
||||||
|
{
|
||||||
|
FwupdDevicePrivate *priv = GET_PRIVATE (self);
|
||||||
|
g_return_if_fail (FWUPD_IS_DEVICE (self));
|
||||||
|
if (priv->status == status)
|
||||||
|
return;
|
||||||
|
priv->status = status;
|
||||||
|
g_object_notify (G_OBJECT (self), "status");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fwupd_pad_kv_ups (GString *str, const gchar *key, FwupdUpdateState value)
|
fwupd_pad_kv_ups (GString *str, const gchar *key, FwupdUpdateState value)
|
||||||
@ -1991,6 +2039,7 @@ fwupd_device_to_json (FwupdDevice *device, JsonBuilder *builder)
|
|||||||
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_CREATED, priv->created);
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_CREATED, priv->created);
|
||||||
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_MODIFIED, priv->modified);
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_MODIFIED, priv->modified);
|
||||||
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_UPDATE_STATE, priv->update_state);
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_UPDATE_STATE, priv->update_state);
|
||||||
|
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_STATUS, priv->status);
|
||||||
fwupd_device_json_add_string (builder, FWUPD_RESULT_KEY_UPDATE_ERROR, priv->update_error);
|
fwupd_device_json_add_string (builder, FWUPD_RESULT_KEY_UPDATE_ERROR, priv->update_error);
|
||||||
fwupd_device_json_add_string (builder, FWUPD_RESULT_KEY_UPDATE_MESSAGE, priv->update_message);
|
fwupd_device_json_add_string (builder, FWUPD_RESULT_KEY_UPDATE_MESSAGE, priv->update_message);
|
||||||
if (priv->releases->len > 0) {
|
if (priv->releases->len > 0) {
|
||||||
@ -2042,6 +2091,10 @@ fwupd_device_to_string (FwupdDevice *device)
|
|||||||
str = g_string_append (str, "Unknown Device\n");
|
str = g_string_append (str, "Unknown Device\n");
|
||||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_ID, priv->id);
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_ID, priv->id);
|
||||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_PARENT_DEVICE_ID, priv->parent_id);
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_PARENT_DEVICE_ID, priv->parent_id);
|
||||||
|
if (priv->status != FWUPD_STATUS_UNKNOWN) {
|
||||||
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_STATUS,
|
||||||
|
fwupd_status_to_string (priv->status));
|
||||||
|
}
|
||||||
if (priv->guids->len > 0) {
|
if (priv->guids->len > 0) {
|
||||||
g_autoptr(GHashTable) ids = NULL;
|
g_autoptr(GHashTable) ids = NULL;
|
||||||
ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||||
@ -2142,6 +2195,9 @@ fwupd_device_get_property (GObject *object, guint prop_id,
|
|||||||
case PROP_PROTOCOL:
|
case PROP_PROTOCOL:
|
||||||
g_value_set_string (value, priv->protocol);
|
g_value_set_string (value, priv->protocol);
|
||||||
break;
|
break;
|
||||||
|
case PROP_STATUS:
|
||||||
|
g_value_set_uint (value, priv->status);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -2163,6 +2219,9 @@ fwupd_device_set_property (GObject *object, guint prop_id,
|
|||||||
case PROP_PROTOCOL:
|
case PROP_PROTOCOL:
|
||||||
fwupd_device_set_protocol (self, g_value_get_string (value));
|
fwupd_device_set_protocol (self, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_STATUS:
|
||||||
|
fwupd_device_set_status (self, g_value_get_uint (value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -2199,6 +2258,14 @@ fwupd_device_class_init (FwupdDeviceClass *klass)
|
|||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_NAME);
|
G_PARAM_STATIC_NAME);
|
||||||
g_object_class_install_property (object_class, PROP_PROTOCOL, pspec);
|
g_object_class_install_property (object_class, PROP_PROTOCOL, pspec);
|
||||||
|
|
||||||
|
pspec = g_param_spec_uint ("status", NULL, NULL,
|
||||||
|
FWUPD_STATUS_UNKNOWN,
|
||||||
|
FWUPD_STATUS_LAST,
|
||||||
|
FWUPD_STATUS_UNKNOWN,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_STATIC_NAME);
|
||||||
|
g_object_class_install_property (object_class, PROP_STATUS, pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -135,6 +135,9 @@ void fwupd_device_set_update_error (FwupdDevice *device,
|
|||||||
const gchar *fwupd_device_get_update_message (FwupdDevice *device);
|
const gchar *fwupd_device_get_update_message (FwupdDevice *device);
|
||||||
void fwupd_device_set_update_message (FwupdDevice *device,
|
void fwupd_device_set_update_message (FwupdDevice *device,
|
||||||
const gchar *update_message);
|
const gchar *update_message);
|
||||||
|
FwupdStatus fwupd_device_get_status (FwupdDevice *self);
|
||||||
|
void fwupd_device_set_status (FwupdDevice *self,
|
||||||
|
FwupdStatus status);
|
||||||
void fwupd_device_add_release (FwupdDevice *device,
|
void fwupd_device_add_release (FwupdDevice *device,
|
||||||
FwupdRelease *release);
|
FwupdRelease *release);
|
||||||
GPtrArray *fwupd_device_get_releases (FwupdDevice *device);
|
GPtrArray *fwupd_device_get_releases (FwupdDevice *device);
|
||||||
|
@ -41,6 +41,7 @@ G_BEGIN_DECLS
|
|||||||
#define FWUPD_RESULT_KEY_REMOTE_ID "RemoteId" /* s */
|
#define FWUPD_RESULT_KEY_REMOTE_ID "RemoteId" /* s */
|
||||||
#define FWUPD_RESULT_KEY_SERIAL "Serial" /* s */
|
#define FWUPD_RESULT_KEY_SERIAL "Serial" /* s */
|
||||||
#define FWUPD_RESULT_KEY_SIZE "Size" /* t */
|
#define FWUPD_RESULT_KEY_SIZE "Size" /* t */
|
||||||
|
#define FWUPD_RESULT_KEY_STATUS "Status" /* u */
|
||||||
#define FWUPD_RESULT_KEY_SUMMARY "Summary" /* s */
|
#define FWUPD_RESULT_KEY_SUMMARY "Summary" /* s */
|
||||||
#define FWUPD_RESULT_KEY_TRUST_FLAGS "TrustFlags" /* t */
|
#define FWUPD_RESULT_KEY_TRUST_FLAGS "TrustFlags" /* t */
|
||||||
#define FWUPD_RESULT_KEY_UPDATE_MESSAGE "UpdateMessage" /* s */
|
#define FWUPD_RESULT_KEY_UPDATE_MESSAGE "UpdateMessage" /* s */
|
||||||
|
@ -424,8 +424,10 @@ LIBFWUPD_1.3.7 {
|
|||||||
|
|
||||||
LIBFWUPD_1.4.0 {
|
LIBFWUPD_1.4.0 {
|
||||||
global:
|
global:
|
||||||
|
fwupd_device_get_status;
|
||||||
fwupd_device_get_version_bootloader_raw;
|
fwupd_device_get_version_bootloader_raw;
|
||||||
fwupd_device_get_version_lowest_raw;
|
fwupd_device_get_version_lowest_raw;
|
||||||
|
fwupd_device_set_status;
|
||||||
fwupd_device_set_version_bootloader_raw;
|
fwupd_device_set_version_bootloader_raw;
|
||||||
fwupd_device_set_version_lowest_raw;
|
fwupd_device_set_version_lowest_raw;
|
||||||
fwupd_release_get_created;
|
fwupd_release_get_created;
|
||||||
|
@ -45,7 +45,6 @@ typedef struct {
|
|||||||
GRWLock parent_guids_mutex;
|
GRWLock parent_guids_mutex;
|
||||||
GPtrArray *children;
|
GPtrArray *children;
|
||||||
guint remove_delay; /* ms */
|
guint remove_delay; /* ms */
|
||||||
FwupdStatus status;
|
|
||||||
guint progress;
|
guint progress;
|
||||||
guint order;
|
guint order;
|
||||||
guint priority;
|
guint priority;
|
||||||
@ -69,7 +68,6 @@ typedef struct {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_STATUS,
|
|
||||||
PROP_PROGRESS,
|
PROP_PROGRESS,
|
||||||
PROP_PHYSICAL_ID,
|
PROP_PHYSICAL_ID,
|
||||||
PROP_LOGICAL_ID,
|
PROP_LOGICAL_ID,
|
||||||
@ -88,9 +86,6 @@ fu_device_get_property (GObject *object, guint prop_id,
|
|||||||
FuDevice *self = FU_DEVICE (object);
|
FuDevice *self = FU_DEVICE (object);
|
||||||
FuDevicePrivate *priv = GET_PRIVATE (self);
|
FuDevicePrivate *priv = GET_PRIVATE (self);
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_STATUS:
|
|
||||||
g_value_set_uint (value, priv->status);
|
|
||||||
break;
|
|
||||||
case PROP_PROGRESS:
|
case PROP_PROGRESS:
|
||||||
g_value_set_uint (value, priv->progress);
|
g_value_set_uint (value, priv->progress);
|
||||||
break;
|
break;
|
||||||
@ -118,9 +113,6 @@ fu_device_set_property (GObject *object, guint prop_id,
|
|||||||
{
|
{
|
||||||
FuDevice *self = FU_DEVICE (object);
|
FuDevice *self = FU_DEVICE (object);
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_STATUS:
|
|
||||||
fu_device_set_status (self, g_value_get_uint (value));
|
|
||||||
break;
|
|
||||||
case PROP_PROGRESS:
|
case PROP_PROGRESS:
|
||||||
fu_device_set_progress (self, g_value_get_uint (value));
|
fu_device_set_progress (self, g_value_get_uint (value));
|
||||||
break;
|
break;
|
||||||
@ -2027,9 +2019,8 @@ fu_device_set_remove_delay (FuDevice *self, guint remove_delay)
|
|||||||
FwupdStatus
|
FwupdStatus
|
||||||
fu_device_get_status (FuDevice *self)
|
fu_device_get_status (FuDevice *self)
|
||||||
{
|
{
|
||||||
FuDevicePrivate *priv = GET_PRIVATE (self);
|
|
||||||
g_return_val_if_fail (FU_IS_DEVICE (self), 0);
|
g_return_val_if_fail (FU_IS_DEVICE (self), 0);
|
||||||
return priv->status;
|
return fwupd_device_get_status (FWUPD_DEVICE (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2044,12 +2035,8 @@ fu_device_get_status (FuDevice *self)
|
|||||||
void
|
void
|
||||||
fu_device_set_status (FuDevice *self, FwupdStatus status)
|
fu_device_set_status (FuDevice *self, FwupdStatus status)
|
||||||
{
|
{
|
||||||
FuDevicePrivate *priv = GET_PRIVATE (self);
|
|
||||||
g_return_if_fail (FU_IS_DEVICE (self));
|
g_return_if_fail (FU_IS_DEVICE (self));
|
||||||
if (priv->status == status)
|
fwupd_device_set_status (FWUPD_DEVICE (self), status);
|
||||||
return;
|
|
||||||
priv->status = status;
|
|
||||||
g_object_notify (G_OBJECT (self), "status");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2946,14 +2933,6 @@ fu_device_class_init (FuDeviceClass *klass)
|
|||||||
object_class->get_property = fu_device_get_property;
|
object_class->get_property = fu_device_get_property;
|
||||||
object_class->set_property = fu_device_set_property;
|
object_class->set_property = fu_device_set_property;
|
||||||
|
|
||||||
pspec = g_param_spec_uint ("status", NULL, NULL,
|
|
||||||
FWUPD_STATUS_UNKNOWN,
|
|
||||||
FWUPD_STATUS_LAST,
|
|
||||||
FWUPD_STATUS_UNKNOWN,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_STATIC_NAME);
|
|
||||||
g_object_class_install_property (object_class, PROP_STATUS, pspec);
|
|
||||||
|
|
||||||
pspec = g_param_spec_string ("physical-id", NULL, NULL, NULL,
|
pspec = g_param_spec_string ("physical-id", NULL, NULL, NULL,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_STATIC_NAME);
|
G_PARAM_STATIC_NAME);
|
||||||
@ -2988,7 +2967,6 @@ static void
|
|||||||
fu_device_init (FuDevice *self)
|
fu_device_init (FuDevice *self)
|
||||||
{
|
{
|
||||||
FuDevicePrivate *priv = GET_PRIVATE (self);
|
FuDevicePrivate *priv = GET_PRIVATE (self);
|
||||||
priv->status = FWUPD_STATUS_IDLE;
|
|
||||||
priv->children = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
priv->children = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||||
priv->parent_guids = g_ptr_array_new_with_free_func (g_free);
|
priv->parent_guids = g_ptr_array_new_with_free_func (g_free);
|
||||||
priv->possible_plugins = g_ptr_array_new_with_free_func (g_free);
|
priv->possible_plugins = g_ptr_array_new_with_free_func (g_free);
|
||||||
|
Loading…
Reference in New Issue
Block a user