diff options
author | Bastien Nocera <hadess@hadess.net> | 2022-09-05 16:11:14 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2022-09-05 16:22:11 +0200 |
commit | f035ab12a52c4035b971533c3f7655f3847f8f3c (patch) | |
tree | 4a2aad8ee885b52ae132c4f85e5f40f9be9229a3 /src | |
parent | 6d78c4ab11d6d9ebcb9ca23823184f91ee998889 (diff) | |
download | upower-f035ab12a52c4035b971533c3f7655f3847f8f3c.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/up-device.c | 16 | ||||
-rw-r--r-- | 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 |