From f035ab12a52c4035b971533c3f7655f3847f8f3c Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 5 Sep 2022 16:11:14 +0200 Subject: device: Make it possible to remove devices from D-Bus Add up_device_unregister() method to allow backends to hide particular UpDevices from the D-Bus interface. Also rename the private up_device_register_device() function, no need to say "device" twice there, we're registering the only device passed as an argument. --- src/up-device.c | 16 ++++++++++++++-- src/up-device.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/up-device.c b/src/up-device.c index c974529..a2ce914 100644 --- a/src/up-device.c +++ b/src/up-device.c @@ -424,7 +424,7 @@ up_device_compute_object_path (UpDevice *device) } static void -up_device_register_device (UpDevice *device) +up_device_register (UpDevice *device) { char *object_path = up_device_compute_object_path (device); g_debug ("object path = %s", object_path); @@ -432,6 +432,18 @@ up_device_register_device (UpDevice *device) g_free (object_path); } +void +up_device_unregister (UpDevice *device) +{ + g_autofree char *object_path = NULL; + + object_path = g_strdup (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (device))); + if (object_path != NULL) { + g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (device)); + g_debug ("Unexported UpDevice with path %s", object_path); + } +} + /** * up_device_refresh: * @@ -492,7 +504,7 @@ up_device_initable_init (GInitable *initable, register_device: /* put on the bus */ - up_device_register_device (device); + up_device_register (device); return TRUE; } diff --git a/src/up-device.h b/src/up-device.h index 4f7f6bd..f7f1df9 100644 --- a/src/up-device.h +++ b/src/up-device.h @@ -71,6 +71,7 @@ void up_device_sibling_discovered (UpDevice *device, GObject *sibling); gboolean up_device_refresh_internal (UpDevice *device, UpRefreshReason reason); +void up_device_unregister (UpDevice *device); G_END_DECLS -- cgit v1.2.1