[gnome-bluetooth/wip/hadess/powered-fixes: 1/4] lib: Simplify adapter_set_powered()
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/hadess/powered-fixes: 1/4] lib: Simplify adapter_set_powered()
- Date: Thu, 16 Dec 2021 14:05:00 +0000 (UTC)
commit 0c9e1c67ada319ad1a65fa66785e062861d6e609
Author: Bastien Nocera <hadess hadess net>
Date: Thu Dec 16 14:10:05 2021 +0100
lib: Simplify adapter_set_powered()
We don't need to pass the adapter we want to power, we only care about
the default adapter.
lib/bluetooth-client.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 644e3bb5..300e9a18 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -403,15 +403,24 @@ adapter_set_powered_cb (GDBusProxy *proxy,
static void
adapter_set_powered (BluetoothClient *client,
- GDBusProxy *adapter,
gboolean powered)
{
GVariant *variant;
g_return_if_fail (BLUETOOTH_IS_CLIENT (client));
+ if (!client->default_adapter) {
+ g_debug ("No default adapter to power");
+ return;
+ }
+
+ if (powered == adapter1_get_powered (client->default_adapter)) {
+ g_debug ("Default adapter is already %spowered", powered ? "" : "un");
+ return;
+ }
+
variant = g_variant_new_boolean (powered);
- g_dbus_proxy_call (adapter,
+ g_dbus_proxy_call (G_DBUS_PROXY (client->default_adapter),
"org.freedesktop.DBus.Properties.Set",
g_variant_new ("(ssv)", "org.bluez.Adapter1", "Powered", variant),
G_DBUS_CALL_FLAGS_NONE,
@@ -571,7 +580,7 @@ default_adapter_changed (GDBusObjectManager *manager,
powered = adapter1_get_powered (client->default_adapter);
if (!powered)
- adapter_set_powered (client, adapter, TRUE);
+ adapter_set_powered (client, TRUE);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]