device: Add disconnected property

The property will be FALSE and stay FALSE for all devices, except for
the Linux ones that have a "wireless_status" attribute set to
"disconnected". This will then be used by the backend to hide the device
until the wireless device is turned on again.
This commit is contained in:
Bastien Nocera 2023-02-20 13:56:10 +01:00
parent f7142fe567
commit 20c5e83f12

View file

@ -45,6 +45,11 @@ typedef struct
gint64 last_refresh;
int poll_timeout;
/* This is TRUE if the wireless_status property is present, and
* its value is "disconnected"
* See https://www.kernel.org/doc/html/latest/driver-api/usb/usb.html#c.usb_interface */
gboolean disconnected;
} UpDevicePrivate;
static void up_device_initable_iface_init (GInitableIface *iface);
@ -60,6 +65,7 @@ enum {
PROP_NATIVE,
PROP_LAST_REFRESH,
PROP_POLL_TIMEOUT,
PROP_DISCONNECTED,
N_PROPS
};
@ -761,6 +767,10 @@ up_device_set_property (GObject *object,
priv->poll_timeout = g_value_get_int (value);
break;
case PROP_DISCONNECTED:
priv->disconnected = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -785,6 +795,10 @@ up_device_get_property (GObject *object,
g_value_set_int64 (value, priv->last_refresh);
break;
case PROP_DISCONNECTED:
g_value_set_boolean (value, priv->disconnected);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -834,6 +848,13 @@ up_device_class_init (UpDeviceClass *klass)
0,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
properties[PROP_DISCONNECTED] =
g_param_spec_boolean ("disconnected",
"Disconnected",
"Whethe wireless device is disconnected",
FALSE,
G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_READABLE);
g_object_class_install_properties (object_class, N_PROPS, properties);
}