Bug 624484: GDBusSubtreeDispatchFunc clarification

Pass NULL rather than "/" for the toplevel of a subtree.

Add clarification to the docs about how trees are flat.
This commit is contained in:
Ryan Lortie 2010-07-15 16:53:43 -04:00
parent ca14ab7ac0
commit 8a2d157d49
3 changed files with 15 additions and 9 deletions

View File

@ -5199,7 +5199,7 @@ handle_subtree_introspect (GDBusConnection *connection,
} }
else else
{ {
requested_node = "/"; requested_node = NULL;
} }
interfaces = es->vtable->introspect (es->connection, interfaces = es->vtable->introspect (es->connection,
@ -5319,7 +5319,7 @@ handle_subtree_method_invocation (GDBusConnection *connection,
} }
else else
{ {
requested_node = "/"; requested_node = NULL;
} }
/* get introspection data for the node */ /* get introspection data for the node */

View File

@ -330,11 +330,14 @@ typedef gchar** (*GDBusSubtreeEnumerateFunc) (GDBusConnection *connection,
* @connection: A #GDBusConnection. * @connection: A #GDBusConnection.
* @sender: The unique bus name of the remote caller. * @sender: The unique bus name of the remote caller.
* @object_path: The object path that was registered with g_dbus_connection_register_subtree(). * @object_path: The object path that was registered with g_dbus_connection_register_subtree().
* @node: A node that is a child of @object_path (relative to @object_path) or <quote>/</quote> for the root of the subtree. * @node: A node that is a child of @object_path (relative to @object_path) or %NULL for the root of the subtree.
* @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree(). * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree().
* *
* The type of the @introspect function in #GDBusSubtreeVTable. * The type of the @introspect function in #GDBusSubtreeVTable.
* *
* Subtrees are flat. @node, if non-%NULL, is always exactly one
* segment of the object path (ie: it never contains a slash).
*
* This function should return %NULL to indicate that there is no object * This function should return %NULL to indicate that there is no object
* at this node. * at this node.
* *
@ -365,12 +368,15 @@ typedef GDBusInterfaceInfo ** (*GDBusSubtreeIntrospectFunc) (GDBusConnection
* @sender: The unique bus name of the remote caller. * @sender: The unique bus name of the remote caller.
* @object_path: The object path that was registered with g_dbus_connection_register_subtree(). * @object_path: The object path that was registered with g_dbus_connection_register_subtree().
* @interface_name: The D-Bus interface name that the method call or property access is for. * @interface_name: The D-Bus interface name that the method call or property access is for.
* @node: A node that is a child of @object_path (relative to @object_path) or <quote>/</quote> for the root of the subtree. * @node: A node that is a child of @object_path (relative to @object_path) or %NULL for the root of the subtree.
* @out_user_data: Return location for user data to pass to functions in the returned #GDBusInterfaceVTable (never %NULL). * @out_user_data: Return location for user data to pass to functions in the returned #GDBusInterfaceVTable (never %NULL).
* @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree(). * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree().
* *
* The type of the @dispatch function in #GDBusSubtreeVTable. * The type of the @dispatch function in #GDBusSubtreeVTable.
* *
* Subtrees are flat. @node, if non-%NULL, is always exactly one
* segment of the object path (ie: it never contains a slash).
*
* Returns: A #GDBusInterfaceVTable or %NULL if you don't want to handle the methods. * Returns: A #GDBusInterfaceVTable or %NULL if you don't want to handle the methods.
* *
* Since: 2.26 * Since: 2.26

View File

@ -628,7 +628,11 @@ subtree_introspect (GDBusConnection *connection,
/* VPs implement the Foo interface, EVPs implement the Bar interface. The root /* VPs implement the Foo interface, EVPs implement the Bar interface. The root
* does not implement any interfaces * does not implement any interfaces
*/ */
if (g_str_has_prefix (node, "vp")) if (node == NULL)
{
return NULL;
}
else if (g_str_has_prefix (node, "vp"))
{ {
interfaces[0] = &foo_interface_info; interfaces[0] = &foo_interface_info;
} }
@ -636,10 +640,6 @@ subtree_introspect (GDBusConnection *connection,
{ {
interfaces[0] = &bar_interface_info; interfaces[0] = &bar_interface_info;
} }
else if (g_strcmp0 (node, "/") == 0)
{
return NULL;
}
else else
{ {
g_assert_not_reached (); g_assert_not_reached ();