[gnome-bluetooth/wip/hadess/btd-restart-fixes: 10/13] lib: Update device proxies when they change




commit 8b42f8579b053bce83327d970769f4375e9ef956
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Dec 8 23:59:16 2021 +0100

    lib: Update device proxies when they change
    
    It's possible, when bluetoothd is coming and going, that we'll still
    have a BluetoothDevice around when the service owner changes. Make
    sure to avoid duplicates and update the device already in the store
    instead.

 lib/bluetooth-client.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 732d1ffc..a5389f9f 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -309,6 +309,7 @@ device_added (GDBusObjectManager   *manager,
        g_autoptr (GDBusProxy) adapter = NULL;
        BluetoothDevice *device_obj;
        const char *default_adapter_path;
+       const char *device_path;
        const char *adapter_path, *address, *alias, *name, *icon;
        g_auto(GStrv) uuids = NULL;
        gboolean paired, trusted, connected;
@@ -323,6 +324,16 @@ device_added (GDBusObjectManager   *manager,
        g_signal_connect_object (G_OBJECT (device), "notify",
                                 G_CALLBACK (device_notify_cb), client, 0);
 
+       device_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (device));
+       device_obj = get_device_for_path (client, device_path);
+       if (device_obj) {
+               g_debug ("Updating proxy for device '%s'", device_path);
+               g_object_set (G_OBJECT (device_obj),
+                             "proxy", device,
+                              NULL);
+               return;
+       }
+
        address = device1_get_address (device);
        alias = device1_get_alias (device);
        name = device1_get_name (device);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]