GDBusConnection: allow async property handling

The existing advice in the documentation to "simply" register the
"org.freedesktop.DBus.Properties" interface if you want to handle
properties asynchronously is pretty unreasonable.  If you want to handle
this interface you have to deal with all properties for all interfaces
on the path, and you have to do all of the checking for yourself.  You
also have to provide your own introspection data.

Introduce a new convention for dealing with properties asynchronously.

If the user provides NULL for their get_property() or set_property()
functions in the vtable and has properties registered then the
properties are sent to the method_call() handler.  We get lucky here
that this function takes an "interface_name" parameter that we can set
to "org.freedesktop.DBus.Properties".

We also do the user the favour of setting the GDBusPropertyInfo on the
GDBusMethodInvocation for their convenience (for much the same reasons
as they might want the already-available GDBusMethodInfo).

Add a testcase as well as a bunch of documentation about this new
feature.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
This commit is contained in:
Ryan Lortie
2013-04-17 09:30:15 -04:00
parent c691f7b6ca
commit f754c4e85b
4 changed files with 268 additions and 15 deletions

View File

@@ -166,6 +166,11 @@ g_dbus_method_invocation_get_object_path (GDBusMethodInvocation *invocation)
*
* Gets the name of the D-Bus interface the method was invoked on.
*
* If this method call is a property Get, Set or GetAll call that has
* been redirected to the method call handler then
* "org.freedesktop.DBus.Properties" will be returned. See
* #GDBusInterfaceVTable for more information.
*
* Returns: A string. Do not free, it is owned by @invocation.
*
* Since: 2.26
@@ -183,6 +188,11 @@ g_dbus_method_invocation_get_interface_name (GDBusMethodInvocation *invocation)
*
* Gets information about the method call, if any.
*
* If this method invocation is a property Get, Set or GetAll call that
* has been redirected to the method call handler then %NULL will be
* returned. See g_dbus_method_invocation_get_property_info() and
* #GDBusInterfaceVTable for more information.
*
* Returns: A #GDBusMethodInfo or %NULL. Do not free, it is owned by @invocation.
*
* Since: 2.26
@@ -201,6 +211,15 @@ g_dbus_method_invocation_get_method_info (GDBusMethodInvocation *invocation)
* Gets information about the property that this method call is for, if
* any.
*
* This will only be set in the case of an invocation in response to a
* property Get or Set call that has been directed to the method call
* handler for an object on account of its property_get() or
* property_set() vtable pointers being unset.
*
* See #GDBusInterfaceVTable for more information.
*
* If the call was GetAll, %NULL will be returned.
*
* Returns: (transfer none): a #GDBusPropertyInfo or %NULL
*
* Since: 2.38