[PATCH BlueZ 1/2] Change the experimental Adapter1 ConnectDevice api to default to not connecting all profiles, using an optional parameter to restore the current behavior.

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

 



---
 src/adapter.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index c24432125..a3ff97571 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3206,6 +3206,7 @@ struct device_connect_data {
 	struct btd_adapter *adapter;
 	bdaddr_t dst;
 	uint8_t dst_type;
+	dbus_bool_t connect_all_profiles;
 	DBusMessage *msg;
 };
 
@@ -3249,7 +3250,8 @@ static void device_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 	}
 
 	device_discover_services(device);
-	device_wait_for_svc_complete(device, device_browse_cb, NULL);
+	if (data->connect_all_profiles)
+		device_wait_for_svc_complete(device, device_browse_cb, NULL);
 
 	g_io_channel_unref(io);
 	dbus_message_unref(data->msg);
@@ -3264,7 +3266,8 @@ failed:
 }
 
 static void device_connect(struct btd_adapter *adapter, const bdaddr_t *dst,
-					uint8_t dst_type, DBusMessage *msg)
+					uint8_t dst_type, DBusMessage *msg,
+					dbus_bool_t connect_all_profiles)
 {
 	struct device_connect_data *data;
 	GIOChannel *io;
@@ -3273,6 +3276,7 @@ static void device_connect(struct btd_adapter *adapter, const bdaddr_t *dst,
 	data->adapter = adapter;
 	bacpy(&data->dst, dst);
 	data->dst_type = dst_type;
+	data->connect_all_profiles = connect_all_profiles;
 	data->msg = dbus_message_ref(msg);
 
 	if (dst_type == BDADDR_BREDR)
@@ -3309,6 +3313,7 @@ static DBusMessage *connect_device(DBusConnection *conn,
 	DBusMessageIter iter, subiter, dictiter, value;
 	uint8_t addr_type = BDADDR_BREDR;
 	bdaddr_t addr = *BDADDR_ANY;
+	dbus_bool_t connect_all_profiles = FALSE;
 
 	DBG("sender %s", dbus_message_get_sender(msg));
 
@@ -3364,6 +3369,13 @@ static DBusMessage *connect_device(DBusConnection *conn,
 				addr_type = BDADDR_LE_RANDOM;
 			else
 				return btd_error_invalid_args(msg);
+		} else if (!strcmp(key, "ConnectAllProfiles")) {
+			if (dbus_message_iter_get_arg_type(&value) !=
+							DBUS_TYPE_BOOLEAN)
+				return btd_error_invalid_args(msg);
+
+			dbus_message_iter_get_basic(&value,
+						    &connect_all_profiles);
 		} else {
 			return btd_error_invalid_args(msg);
 		}
@@ -3377,7 +3389,7 @@ static DBusMessage *connect_device(DBusConnection *conn,
 	if (btd_adapter_find_device(adapter, &addr, addr_type))
 		return btd_error_already_exists(msg);
 
-	device_connect(adapter, &addr, addr_type, msg);
+	device_connect(adapter, &addr, addr_type, msg, connect_all_profiles);
 	return NULL;
 }
 
-- 
2.17.1





[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