[gnome-bluetooth/wip/hadess/remove-gtk-tree: 17/18] lib: Fix default-adapter-* properties notifications




commit 7956dd42630fd52ba30417fbd4a65894f5fb0d3c
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Dec 2 12:01:11 2021 +0100

    lib: Fix default-adapter-* properties notifications
    
    It doesn't make much sense for those properties to be sent only when the
    default adapter gets powered, the API user should be told straight away.
    
    This also fixes the "default-adapter-address" property never sending a
    notification.

 lib/bluetooth-client.c | 33 +++++++++------------------------
 1 file changed, 9 insertions(+), 24 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 5ab454d1..d475ba47 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -495,14 +495,6 @@ adapter_notify_cb (Adapter1       *adapter,
        } else if (g_strcmp0 (property, "discovering") == 0) {
                g_object_notify (G_OBJECT (client), "default-adapter-setup-mode");
        } else if (g_strcmp0 (property, "powered") == 0) {
-               gboolean powered = adapter1_get_powered (adapter);
-
-               if (powered) {
-                       g_debug ("Default adapter is powered, so invalidating all the default-adapter* 
properties");
-                       g_object_notify (G_OBJECT (client), "default-adapter");
-                       g_object_notify (G_OBJECT (client), "default-adapter-setup-mode");
-                       g_object_notify (G_OBJECT (client), "default-adapter-name");
-               }
                g_object_notify (G_OBJECT (client), "default-adapter-powered");
        }
 }
@@ -524,23 +516,16 @@ default_adapter_changed (GDBusObjectManager   *manager,
 
        add_devices_to_list_store (client);
 
-       powered = adapter1_get_powered (client->default_adapter);
-
-       if (powered) {
-               g_debug ("New default adapter is powered, so invalidating all the default-adapter* 
properties");
-               g_object_notify (G_OBJECT (client), "default-adapter");
-               g_object_notify (G_OBJECT (client), "default-adapter-powered");
-               g_object_notify (G_OBJECT (client), "default-adapter-setup-mode");
-               g_object_notify (G_OBJECT (client), "default-adapter-name");
-               return;
-       }
+       g_debug ("New default adapter so invalidating all the default-adapter* properties");
+       g_object_notify (G_OBJECT (client), "default-adapter");
+       g_object_notify (G_OBJECT (client), "default-adapter-address");
+       g_object_notify (G_OBJECT (client), "default-adapter-powered");
+       g_object_notify (G_OBJECT (client), "default-adapter-setup-mode");
+       g_object_notify (G_OBJECT (client), "default-adapter-name");
 
-       /*
-        * If the adapter is turn off (Powered = False in bluetooth) object
-        * notifications will be sent only when a Powered = True signal arrives
-        * from bluetoothd
-        */
-       adapter_set_powered (client, adapter, TRUE);
+       powered = adapter1_get_powered (client->default_adapter);
+       if (powered)
+               adapter_set_powered (client, adapter, TRUE);
 }
 
 static void


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