[PATCHv2 40/60] bluetooth: Handle PropertiesChanged for org.bluez.Device1

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

 



On Tue, 2013-08-13 at 01:54 -0300, jprvita at gmail.com wrote:
> From: Jo?o Paulo Rechi Vita <jprvita at openbossa.org>
> 
> ---
>  src/modules/bluetooth/bluez5-util.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
> index 94e3c35..e0a5a69 100644
> --- a/src/modules/bluetooth/bluez5-util.c
> +++ b/src/modules/bluetooth/bluez5-util.c
> @@ -843,6 +843,37 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
>  
>          return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
>  
> +    } else if (dbus_message_is_signal(m, "org.freedesktop.DBus.Properties", "PropertiesChanged")) {
> +        DBusMessageIter arg_i;
> +        const char *iface;
> +
> +        if (!y->objects_listed)
> +            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* No reply received yet from GetManagedObjects */
> +
> +        if (!dbus_message_iter_init(m, &arg_i) || !pa_streq(dbus_message_get_signature(m), "sa{sv}as")) {
> +            pa_log_error("Invalid signature found in PropertiesChanged");
> +            goto fail;
> +        }
> +
> +        dbus_message_iter_get_basic(&arg_i, &iface);
> +
> +        pa_assert_se(dbus_message_iter_next(&arg_i));
> +        pa_assert(dbus_message_iter_get_arg_type(&arg_i) == DBUS_TYPE_ARRAY);
> +
> +        if (pa_streq(iface, BLUEZ_DEVICE_INTERFACE)) {
> +            pa_bluetooth_device *d;
> +
> +            pa_log_debug("Properties changed in device %s", dbus_message_get_path(m));
> +
> +            if (!(d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
> +                pa_log_warn("Properties changed in unknown device");
> +                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
> +            }
> +
> +            parse_device_properties(d, &arg_i, true);

You don't check device_info_valid at all. If it's -1, the properties
shouldn't be parsed, and if it's 0, there should be some notification
about a new device (in addition the notification that I mentioned in the
previous mail: if device_info_valid is 1 and parse_device_properties()
fails, then a notification should be sent about the device becoming
unavailable).

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux