On Sun, Apr 29, 2012 at 8:22 AM, Luiz Augusto von Dentz <luiz.dentz@xxxxxxxxx> wrote: > Hi Lucas, > > On Sat, Apr 28, 2012 at 12:25 AM, Lucas De Marchi > <lucas.demarchi@xxxxxxxxxxxxxx> wrote: >> + if (p->exists != NULL && !p->exists(p, iface->user_data)) >> + continue; >> + >> + dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, >> + NULL, &entry); >> + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, >> + p->name); >> + dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, >> + p->type, &value); >> + >> + if (!p->get(connection, message, p, &value, iface->user_data)) { >> + dbus_message_iter_abandon_container(&entry, &value); >> + dbus_message_iter_abandon_container(&dict, &entry); >> + dbus_message_unref(reply); >> + return NULL; >> + } > > I would do this a little different, make the callback return the value > (void *) so you don't even need to create any container if it returns > NULL, if the value is set then you create the container and use the > registered type to add the value to the container, obviously this is > limited to values that doesn't require another container but IMO that > should not be the case of any of our properties. Yeah, I thought about that. But as you said it's limited to the basic types. See the example Henrique sent for "ao". And there's the more difficult one: a property that is a dictionary. To cover these more complicated cases, we would need to check if it's a property with basic signature and act differently based on that. Lucas De Marchi -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html