From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
To: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ v3 13/15] gdbus: Implement PropertiesChanged signal
Date: Sat, 18 Aug 2012 15:14:29 -0300 [thread overview]
Message-ID: <20120818181429.GA30527@echo> (raw)
In-Reply-To: <1345272662-2850-14-git-send-email-lucas.demarchi@profusion.mobi>
Hi Lucas,
On 03:51 Sat 18 Aug, Lucas De Marchi wrote:
> ---
> gdbus/gdbus.h | 4 +++
> gdbus/object.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 2 files changed, 110 insertions(+), 2 deletions(-)
[snip]
> @@ -1397,3 +1405,99 @@ gboolean g_dbus_emit_signal_valist(DBusConnection *connection,
> return emit_signal_valist(connection, path, interface,
> name, type, args);
> }
> +
> +static void process_properties_from_interface(struct generic_data *data,
> + struct interface_data *iface)
> +{
> + GSList *l;
> + DBusMessage *signal;
> + DBusMessageIter iter, dict, array;
> +
> + if (iface->pending_prop == NULL)
> + return;
> +
> + signal = dbus_message_new_signal(data->path,
> + DBUS_INTERFACE_PROPERTIES, "PropertiesChanged");
> + if (signal == NULL) {
> + error("Unable to allocate new " DBUS_INTERFACE_PROPERTIES
> + ".PropertiesChanged signal");
> + return;
> + }
> +
> + iface->pending_prop = g_slist_reverse(iface->pending_prop);
> +
> + dbus_message_iter_init_append(signal, &iter);
> + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &iface->name);
> + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
> + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
> + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
> + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
> +
> + for (l = iface->pending_prop; l != NULL; l = l->next) {
> + GDBusPropertyTable *p = l->data;
> +
> + if (p->get == NULL)
> + continue;
> +
> + if (p->exists != NULL && !p->exists(p, iface->user_data))
> + continue;
I was thinking about if the following scenario where I want a property that
only gets notified when it changes, but I can't do Get() on it is something
that we want to support. (Yeah, using signals makes more sense for this, but
the question remains ;-))
I was with the impression that that was one of the purposes of the exists()
method.
Anyway, looks good to me.
> +
> + append_property(iface, p, &dict);
> + }
> +
> + dbus_message_iter_close_container(&iter, &dict);
> + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
> + DBUS_TYPE_STRING_AS_STRING, &array);
> + dbus_message_iter_close_container(&iter, &array);
> +
> + g_dbus_send_message(data->conn, signal);
> +
> + g_slist_free(iface->pending_prop);
> + iface->pending_prop = NULL;
> +}
> +
> +static void process_property_changes(struct generic_data *data)
> +{
> + GSList *l;
> +
> + for (l = data->interfaces; l != NULL; l = l->next) {
> + struct interface_data *iface = l->data;
> +
> + process_properties_from_interface(data, iface);
> + }
> +
> + data->pending_prop = FALSE;
> +}
> +
> +void g_dbus_emit_property_changed(DBusConnection *connection,
> + const char *path, const char *interface,
> + const char *name)
> +{
> + const GDBusPropertyTable *property;
> + struct generic_data *data;
> + struct interface_data *iface;
> +
> + if (!dbus_connection_get_object_path_data(connection, path,
> + (void **) &data) || data == NULL)
> + return;
> +
> + iface = find_interface(data->interfaces, interface);
> + if (iface == NULL)
> + return;
> +
> + property = find_property(iface->properties, name);
> + if (property == NULL) {
> + error("Could not find property %s in %p", name,
> + iface->properties);
> + return;
> + }
> +
> + data->pending_prop = TRUE;
> + iface->pending_prop = g_slist_prepend(iface->pending_prop,
> + (void *) property);
> +
> + if (!data->process_id) {
> + data->process_id = g_idle_add(process_changes, data);
> + return;
> + }
> +}
> --
> 1.7.11.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers,
--
Vinicius
next prev parent reply other threads:[~2012-08-18 18:14 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-18 6:50 [PATCH BlueZ v3 00/15] gdbus: DBus.Properties + ObjectManager Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 01/15] gdbus: Move typedefs up Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 02/15] gdbus: Define macros to add annotations Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 03/15] gdbus: Add skeleton of DBus.Properties interface Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 04/15] gdbus: Implement DBus.Properties.Get method Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 05/15] gdbus: Implement DBus.Properties.GetAll method Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 06/15] gdbus: Implement DBus.Properties.Set method Lucas De Marchi
2012-09-06 20:01 ` Marcel Holtmann
2012-09-06 21:31 ` Luiz Augusto von Dentz
2012-09-07 5:49 ` Marcel Holtmann
2012-09-07 8:35 ` Luiz Augusto von Dentz
2012-09-07 20:19 ` Marcel Holtmann
2012-09-10 13:42 ` Luiz Augusto von Dentz
2012-09-12 3:34 ` Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 07/15] gdbus: Add properties into Introspectable interface Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 08/15] gdbus: Add support for org.freedesktop.DBus.ObjectManager interface Lucas De Marchi
2012-08-18 18:25 ` Vinicius Costa Gomes
2012-08-20 7:12 ` Luiz Augusto von Dentz
2012-08-18 6:50 ` [PATCH BlueZ v3 09/15] gdbus: Group interface changes to reduce the amount of signals emitted Lucas De Marchi
2012-08-18 18:28 ` Vinicius Costa Gomes
2012-08-20 7:14 ` Luiz Augusto von Dentz
2012-08-18 6:50 ` [PATCH BlueZ v3 10/15] gdbus: Only export ObjectManager interface on root path Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 11/15] gdbus: Integrates ObjectManager with Properties interface Lucas De Marchi
2012-08-18 6:50 ` [PATCH BlueZ v3 12/15] gdbus: Simplify code for appending properties Lucas De Marchi
2012-08-18 6:51 ` [PATCH BlueZ v3 13/15] gdbus: Implement PropertiesChanged signal Lucas De Marchi
2012-08-18 18:14 ` Vinicius Costa Gomes [this message]
2012-08-20 13:38 ` Lucas De Marchi
2012-08-18 6:51 ` [PATCH BlueZ v3 14/15] control: Use DBus.Properties Lucas De Marchi
2012-08-18 6:51 ` [PATCH BlueZ v3 15/15] audio: device: " Lucas De Marchi
2012-08-20 7:56 ` [PATCH BlueZ v3 00/15] gdbus: DBus.Properties + ObjectManager Luiz Augusto von Dentz
2012-08-20 13:51 ` Lucas De Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120818181429.GA30527@echo \
--to=vinicius.gomes@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=lucas.demarchi@profusion.mobi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).