[glib] Bug 624484: GDBusSubtreeDispatchFunc clarification
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Bug 624484: GDBusSubtreeDispatchFunc clarification
- Date: Thu, 15 Jul 2010 21:33:44 +0000 (UTC)
commit 8a2d157d49c3dceda029bd0e14f8c7367daa2a36
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jul 15 16:53:43 2010 -0400
Bug 624484: GDBusSubtreeDispatchFunc clarification
Pass NULL rather than "/" for the toplevel of a subtree.
Add clarification to the docs about how trees are flat.
gio/gdbusconnection.c | 4 ++--
gio/gdbusconnection.h | 10 ++++++++--
gio/tests/gdbus-export.c | 10 +++++-----
3 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index b7dd83a..b98fe24 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -5199,7 +5199,7 @@ handle_subtree_introspect (GDBusConnection *connection,
}
else
{
- requested_node = "/";
+ requested_node = NULL;
}
interfaces = es->vtable->introspect (es->connection,
@@ -5319,7 +5319,7 @@ handle_subtree_method_invocation (GDBusConnection *connection,
}
else
{
- requested_node = "/";
+ requested_node = NULL;
}
/* get introspection data for the node */
diff --git a/gio/gdbusconnection.h b/gio/gdbusconnection.h
index 7d9642e..8982092 100644
--- a/gio/gdbusconnection.h
+++ b/gio/gdbusconnection.h
@@ -330,11 +330,14 @@ typedef gchar** (*GDBusSubtreeEnumerateFunc) (GDBusConnection *connection,
* @connection: A #GDBusConnection.
* @sender: The unique bus name of the remote caller.
* @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().
*
* 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
* at this node.
*
@@ -365,12 +368,15 @@ typedef GDBusInterfaceInfo ** (*GDBusSubtreeIntrospectFunc) (GDBusConnection
* @sender: The unique bus name of the remote caller.
* @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.
- * @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).
* @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree().
*
* 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.
*
* Since: 2.26
diff --git a/gio/tests/gdbus-export.c b/gio/tests/gdbus-export.c
index cfefe71..7a46d2d 100644
--- a/gio/tests/gdbus-export.c
+++ b/gio/tests/gdbus-export.c
@@ -628,7 +628,11 @@ subtree_introspect (GDBusConnection *connection,
/* VPs implement the Foo interface, EVPs implement the Bar interface. The root
* 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;
}
@@ -636,10 +640,6 @@ subtree_introspect (GDBusConnection *connection,
{
interfaces[0] = &bar_interface_info;
}
- else if (g_strcmp0 (node, "/") == 0)
- {
- return NULL;
- }
else
{
g_assert_not_reached ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]