[PATCH] Fix not setting global mode when SetProperty is used

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

 



From: Luiz Augusto von Dentz <luiz.dentz-von@xxxxxxxxx>

Global mode should be overwrite if user application change the adapter
mode by using SetProperty while there are sessions active, otherwise when
this sessions are released the mode restored will be the global mode from
before the sessions were created and not the mode set with SetProperty.
---
 src/adapter.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index dbae219..2e11832 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -516,8 +516,10 @@ static DBusMessage *set_discoverable(DBusConnection *conn, DBusMessage *msg,
 
 	mode = discoverable ? MODE_DISCOVERABLE : MODE_CONNECTABLE;
 
-	if (mode == adapter->mode)
+	if (mode == adapter->mode) {
+		adapter->global_mode = mode;
 		return dbus_message_new_method_return(msg);
+	}
 
 	err = set_mode(adapter, mode, msg);
 	if (err < 0)
@@ -541,8 +543,10 @@ static DBusMessage *set_powered(DBusConnection *conn, DBusMessage *msg,
 
 	mode = MODE_OFF;
 
-	if (mode == adapter->mode)
+	if (mode == adapter->mode) {
+		adapter->global_mode = mode;
 		return dbus_message_new_method_return(msg);
+	}
 
 	err = set_mode(adapter, mode, msg);
 	if (err < 0)
@@ -2477,8 +2481,12 @@ static void set_mode_complete(struct btd_adapter *adapter)
 
 		if (err < 0)
 			reply = btd_error_failed(msg, strerror(-err));
-		else
+		else {
+			if (strcmp(dbus_message_get_member(msg),
+						"SetProperty") == 0)
+				adapter->global_mode = adapter->mode;
 			reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+		}
 
 		g_dbus_send_message(connection, reply);
 	}
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux