[gnome-bluetooth/wip/hadess/btd-restart-fixes: 11/13] lib: Add helper to check for the default adapter




commit 5bd5958e82092bdf2d4780939f568f7f4d5e0847
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Dec 9 00:02:18 2021 +0100

    lib: Add helper to check for the default adapter

 lib/bluetooth-client.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index a5389f9f..64443192 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -555,6 +555,21 @@ default_adapter_changed (GDBusObjectManager   *manager,
                adapter_set_powered (client, adapter, TRUE);
 }
 
+static gboolean
+is_default_adapter (BluetoothClient *client,
+                   Adapter1        *adapter)
+{
+       const char *default_adapter_path = NULL;
+       const char *adapter_path;
+
+       g_return_val_if_fail (client->default_adapter, FALSE);
+       g_return_val_if_fail (adapter, FALSE);
+
+       adapter_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (adapter));
+       default_adapter_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (client->default_adapter));
+       return (g_strcmp0 (adapter_path, default_adapter_path) == 0);
+}
+
 static void
 adapter_added (GDBusObjectManager   *manager,
               Adapter1             *adapter,


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