[pulseaudio-discuss] [PATCH 29/56] bluetooth: Implement org.bluez.MediaEndpoint1.SetConfiguration()
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Fri Jul 19 04:12:14 PDT 2013
On Fri, 2013-07-12 at 15:06 -0300, jprvita at gmail.com wrote:
> From: João Paulo Rechi Vita <jprvita at openbossa.org>
>
> ---
> src/modules/bluetooth/bluez5-util.c | 116 +++++++++++++++++++++++++++++++++++-
> src/modules/bluetooth/bluez5-util.h | 3 +
> 2 files changed, 117 insertions(+), 2 deletions(-)
>
> diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
> index 3e6eb1c..a68f8ca 100644
> --- a/src/modules/bluetooth/bluez5-util.c
> +++ b/src/modules/bluetooth/bluez5-util.c
> @@ -350,11 +350,123 @@ fail:
> }
>
> static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage *m, void *userdata) {
> + pa_bluetooth_discovery *y = userdata;
> + pa_bluetooth_device *d;
> + pa_bluetooth_transport *t;
> + const char *sender, *path, *endpoint_path, *dev_path = NULL, *uuid = NULL;
> + uint8_t *config = NULL;
> + int size = 0;
> + pa_bluetooth_profile_t p = PROFILE_OFF;
> + DBusMessageIter args, props;
> DBusMessage *r;
> + bool old_any_connected;
>
> - pa_assert_se(r = dbus_message_new_error(m, BLUEZ_MEDIA_ENDPOINT_INTERFACE ".Error.NotImplemented",
> - "Method not implemented"));
> + if (!dbus_message_iter_init(m, &args) || !pa_streq(dbus_message_get_signature(m), "oa{sv}")) {
> + pa_log_error("Invalid signature for method SetConfiguration()");
> + goto fail2;
> + }
> +
> + dbus_message_iter_get_basic(&args, &path);
> +
> + if (pa_hashmap_get(y->transports, path)) {
> + pa_log_error("Endpoint SetConfiguration(): Transport %s is already configured.", path);
> + goto fail2;
> + }
> +
> + pa_assert_se(dbus_message_iter_next(&args));
> +
> + dbus_message_iter_recurse(&args, &props);
> + if (dbus_message_iter_get_arg_type(&props) != DBUS_TYPE_DICT_ENTRY)
> + goto fail;
> +
> + /* Read transport properties */
> + while (dbus_message_iter_get_arg_type(&props) == DBUS_TYPE_DICT_ENTRY) {
> + const char *key;
> + DBusMessageIter value, entry;
> + int var;
> +
> + dbus_message_iter_recurse(&props, &entry);
> + dbus_message_iter_get_basic(&entry, &key);
> +
> + dbus_message_iter_next(&entry);
> + dbus_message_iter_recurse(&entry, &value);
> +
> + var = dbus_message_iter_get_arg_type(&value);
> +
> + if (strcasecmp(key, "UUID") == 0) {
> + if (var != DBUS_TYPE_STRING)
> + goto fail;
> +
> + dbus_message_iter_get_basic(&value, &uuid);
> + } else if (strcasecmp(key, "Device") == 0) {
> + if (var != DBUS_TYPE_OBJECT_PATH)
> + goto fail;
> +
> + dbus_message_iter_get_basic(&value, &dev_path);
> + } else if (strcasecmp(key, "Configuration") == 0) {
> + DBusMessageIter array;
> + if (var != DBUS_TYPE_ARRAY)
> + goto fail;
> +
> + dbus_message_iter_recurse(&value, &array);
> + dbus_message_iter_get_fixed_array(&array, &config, &size);
I think it would be good to validate the received configuration here,
that is, check that it looks sane before we try to use the
configuration.
--
Tanu
More information about the pulseaudio-discuss
mailing list