summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Andrieu <oliv__a@users.sourceforge.net>2004-05-21 09:05:20 +0000
committerOlivier Andrieu <oliv__a@users.sourceforge.net>2004-05-21 09:05:20 +0000
commite431887e8476b1897f3eef4a90bfb928abb2f07b (patch)
treed5ee0bbe8c6a1d957534338fcabb3f29e95c098e
parentdf23f08f9b4607660aeee2c3640b80e1b6aad256 (diff)
2004-05-21 Olivier Andrieu <oliv__a@users.sourceforge.net>
* dbus/dbus-object-tree.c (_dbus_object_tree_list_registered_unlock, lookup_subtree): return children even if the requested path isn't registered. (object_tree_test_iteration): test object_tree_list_registered. * configure.in: undefine HAVE_ABSTRACT_SOCKETS instead of defining it to 0.
-rw-r--r--ChangeLog10
-rw-r--r--configure.in5
-rw-r--r--dbus/dbus-object-tree.c63
3 files changed, 71 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c8b58588..1327d89c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-05-21 Olivier Andrieu <oliv__a@users.sourceforge.net>
+
+ * dbus/dbus-object-tree.c
+ (_dbus_object_tree_list_registered_unlock, lookup_subtree): return
+ children even if the requested path isn't registered.
+ (object_tree_test_iteration): test object_tree_list_registered.
+
+ * configure.in: undefine HAVE_ABSTRACT_SOCKETS instead of defining
+ it to 0.
+
2004-05-20 Kristian Høgsberg <krh@redhat.com>
* doc/TODO: Remove resolved items.
diff --git a/configure.in b/configure.in
index 2fe7d181..cec7be6f 100644
--- a/configure.in
+++ b/configure.in
@@ -625,15 +625,12 @@ if test x$enable_abstract_sockets = xno; then
fi
if test x$have_abstract_sockets = xyes ; then
- abstract_sockets=1
DBUS_PATH_OR_ABSTRACT=abstract
+ AC_DEFINE(HAVE_ABSTRACT_SOCKETS,1,[Have abstract socket namespace])
else
- abstract_sockets=0
DBUS_PATH_OR_ABSTRACT=path
fi
-AC_DEFINE_UNQUOTED(HAVE_ABSTRACT_SOCKETS, $abstract_sockets, [Have abstract socket namespace])
-
# this is used in addresses to prefer abstract, e.g.
# unix:path=/foo or unix:abstract=/foo
AC_SUBST(DBUS_PATH_OR_ABSTRACT)
diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c
index 6856033a..adac34ed 100644
--- a/dbus/dbus-object-tree.c
+++ b/dbus/dbus-object-tree.c
@@ -344,6 +344,16 @@ find_subtree (DBusObjectTree *tree,
}
static DBusObjectSubtree*
+lookup_subtree (DBusObjectTree *tree,
+ const char **path)
+{
+#if VERBOSE_FIND
+ _dbus_verbose ("Looking for subtree\n");
+#endif
+ return find_subtree_recurse (tree->root, path, FALSE, FALSE, NULL);
+}
+
+static DBusObjectSubtree*
find_handler (DBusObjectTree *tree,
const char **path)
{
@@ -553,12 +563,10 @@ _dbus_object_tree_list_registered_unlocked (DBusObjectTree *tree,
*child_entries = NULL;
- subtree = find_subtree (tree, parent_path, NULL);
+ subtree = lookup_subtree (tree, parent_path);
if (subtree == NULL)
{
retval = dbus_new0 (char *, 1);
- if (retval == NULL)
- goto out;
}
else
{
@@ -1143,6 +1151,15 @@ do_test_dispatch (DBusObjectTree *tree,
return FALSE;
}
+static size_t
+string_array_length (char **array)
+{
+ size_t i;
+ for (i = 0; array[i]; i++) ;
+ return i;
+}
+
+
static dbus_bool_t
object_tree_test_iteration (void *data)
{
@@ -1287,6 +1304,46 @@ object_tree_test_iteration (void *data)
_dbus_assert (find_handler (tree, path7) != tree->root);
_dbus_assert (find_handler (tree, path8) != tree->root);
+ /* test the list_registered function */
+
+ {
+ const char *root[] = { NULL };
+ char **child_entries;
+ int nb;
+
+ _dbus_object_tree_list_registered_unlocked (tree, path1, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 1);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, path2, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 2);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, path8, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 0);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, root, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 3);
+ dbus_free_string_array (child_entries);
+ }
+ }
+
/* Check that destroying tree calls unregister funcs */
_dbus_object_tree_unref (tree);