@@ -4634,6 +4634,23 @@ static void acquire_reply(DBusMessage *message, void *user_data)
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
+static void select_reply(DBusMessage *message, void *user_data)
+{
+ DBusError error;
+
+ dbus_error_init(&error);
+
+ if (dbus_set_error_from_message(&error, message) == TRUE) {
+ bt_shell_printf("Failed to select: %s\n", error.name);
+ dbus_error_free(&error);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ bt_shell_printf("Select successful");
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
static void prompt_acquire(const char *input, void *user_data)
{
GDBusProxy *proxy = user_data;
@@ -4855,6 +4872,38 @@ static void cmd_acquire_transport(int argc, char *argv[])
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
+static void transport_select(GDBusProxy *proxy, bool prompt)
+{
+ if (!g_dbus_proxy_method_call(proxy, "Select", NULL,
+ select_reply, proxy, NULL)) {
+ bt_shell_printf("Failed select transport\n");
+ return;
+ }
+}
+
+static void cmd_select_transport(int argc, char *argv[])
+{
+ GDBusProxy *proxy;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ proxy = g_dbus_proxy_lookup(transports, NULL, argv[i],
+ BLUEZ_MEDIA_TRANSPORT_INTERFACE);
+ if (!proxy) {
+ bt_shell_printf("Transport %s not found\n", argv[i]);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ if (find_transport(proxy)) {
+ bt_shell_printf("Transport %s already acquired\n",
+ argv[i]);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ transport_select(proxy, false);
+ }
+}
+
static void release_reply(DBusMessage *message, void *user_data)
{
struct transport *transport = user_data;
@@ -5283,6 +5332,9 @@ static const struct bt_shell_menu transport_menu = {
{ "volume", "<transport> [value]", cmd_volume_transport,
"Get/Set transport volume",
transport_generator },
+ { "select", "<transport>", cmd_select_transport,
+ "Select Transport",
+ transport_generator },
{} },
};