gdbus: Add support for invalidated properties

If there's a pending property but its exists() callback returns false
the property should be considered invalidated and included in the
relevant list of the PropertiesChanged signal.
This commit is contained in:
Johan Hedberg 2012-10-11 11:53:27 +02:00 committed by Marcel Holtmann
parent c4ec194ede
commit 031189ffea
1 changed files with 14 additions and 1 deletions

View File

@ -1513,6 +1513,7 @@ static void process_properties_from_interface(struct generic_data *data,
GSList *l;
DBusMessage *signal;
DBusMessageIter iter, dict, array;
GSList *invalidated;
if (iface->pending_prop == NULL)
return;
@ -1534,21 +1535,33 @@ static void process_properties_from_interface(struct generic_data *data,
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
invalidated = NULL;
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))
if (p->exists != NULL && !p->exists(p, iface->user_data)) {
invalidated = g_slist_prepend(invalidated, p);
continue;
}
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);
for (l = invalidated; l != NULL; l = g_slist_next(l)) {
GDBusPropertyTable *p = l->data;
dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING,
&p->name);
}
g_slist_free(invalidated);
dbus_message_iter_close_container(&iter, &array);
g_dbus_send_message(data->conn, signal);