mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-15 00:04:29 +08:00
client/player: Prompt the user to enter the bcode
This adds support for entering the broadcast code on sink side. When the user selects a transport, if the transport is encrypted, the user will be prompted to enter the broadcast code before the process of transport selection can continue.
This commit is contained in:
parent
8d43c209f0
commit
35f2bb9517
@ -5092,8 +5092,67 @@ static void cmd_acquire_transport(int argc, char *argv[])
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void set_bcode_cb(const DBusError *error, void *user_data)
|
||||
{
|
||||
GDBusProxy *proxy = user_data;
|
||||
|
||||
if (dbus_error_is_set(error)) {
|
||||
bt_shell_printf("Failed to set broadcast code: %s\n",
|
||||
error->name);
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Setting broadcast code succeeded\n");
|
||||
|
||||
if (!g_dbus_proxy_method_call(proxy, "Select", NULL,
|
||||
select_reply, proxy, NULL))
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void set_bcode(const char *input, void *user_data)
|
||||
{
|
||||
GDBusProxy *proxy = user_data;
|
||||
char *bcode = g_strdup(input);
|
||||
|
||||
if (g_dbus_proxy_set_property_dict(proxy, "QoS",
|
||||
set_bcode_cb, user_data,
|
||||
NULL, "BCode", DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
|
||||
strlen(bcode), bcode, NULL) == FALSE) {
|
||||
bt_shell_printf("Setting broadcast code failed\n");
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
static void transport_select(GDBusProxy *proxy, bool prompt)
|
||||
{
|
||||
DBusMessageIter iter, array, entry, value;
|
||||
unsigned char encryption;
|
||||
const char *key;
|
||||
|
||||
if (g_dbus_proxy_get_property(proxy, "QoS", &iter) == FALSE)
|
||||
return;
|
||||
|
||||
dbus_message_iter_recurse(&iter, &array);
|
||||
|
||||
while (dbus_message_iter_get_arg_type(&array) !=
|
||||
DBUS_TYPE_INVALID) {
|
||||
dbus_message_iter_recurse(&array, &entry);
|
||||
dbus_message_iter_get_basic(&entry, &key);
|
||||
|
||||
if (!strcasecmp(key, "Encryption")) {
|
||||
dbus_message_iter_next(&entry);
|
||||
dbus_message_iter_recurse(&entry, &value);
|
||||
dbus_message_iter_get_basic(&value, &encryption);
|
||||
if (encryption == 1) {
|
||||
bt_shell_prompt_input("",
|
||||
"Enter broadcast code:", set_bcode, proxy);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
dbus_message_iter_next(&array);
|
||||
}
|
||||
|
||||
if (!g_dbus_proxy_method_call(proxy, "Select", NULL,
|
||||
select_reply, proxy, NULL)) {
|
||||
bt_shell_printf("Failed select transport\n");
|
||||
|
Loading…
Reference in New Issue
Block a user