summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2023-06-23 19:59:38 +0200
committerBastien Nocera <hadess@hadess.net>2023-07-03 16:10:13 +0200
commit570d6cdf271fae19343b85d7d585e3eed23a99c0 (patch)
tree02bd5d6b0dbfe78bba1586126de0a792c132846f
parent20c5e83f12048b993cefa06822a5bd01463da45f (diff)
linux: Track "disconnected" property to hide devices
Hide "disconnected" devices.
-rw-r--r--src/linux/up-backend.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index a7da19b..7f68be8 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -399,10 +399,33 @@ bluez_vanished (GDBusConnection *connection,
}
static void
+up_device_disconnected_cb (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ g_autofree char *path = NULL;
+ gboolean disconnected;
+
+ g_object_get (gobject,
+ "native-path", &path,
+ "disconnected", &disconnected,
+ NULL);
+ if (disconnected) {
+ g_debug("Device %s became disconnected, hiding device", path);
+ up_device_unregister (UP_DEVICE (gobject));
+ } else {
+ g_debug ("Device %s became connected, showing device", path);
+ up_device_register (UP_DEVICE (gobject));
+ }
+}
+
+static void
udev_device_added_cb (UpBackend *backend, UpDevice *device)
{
g_debug ("Got new device from udev enumerator: %p", device);
update_added_duplicate_device (backend, device);
+ g_signal_connect (device, "notify::disconnected",
+ G_CALLBACK (up_device_disconnected_cb), backend);
g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, device);
}