From 64f3d8f67db09e0c84ed3ff009b86d0127fe82b4 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 24 Apr 2005 14:04:16 +0000 Subject: 2005-04-23 Havoc Pennington * dbus/dbus-message.c (dbus_message_append_args): fix doc comment, reported by Tony Houghton * test/test-service.c (main): test dbus_connection_get_object_path_data() * dbus/dbus-object-tree.c (find_handler): be sure we always init the exact_match (_dbus_object_tree_get_user_data_unlocked): new function used by dbus_connection_get_object_path_data() (do_register): add assertion test for get_user_data_unlocked (object_tree_test_iteration): more tests * dbus/dbus-connection.c (dbus_connection_get_object_path_data): new function from Dan Reed to let you get the user data from dbus_connection_register_object_path() --- dbus/dbus-connection.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'dbus/dbus-connection.c') diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index df8de937..edc57b84 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -4300,6 +4300,43 @@ dbus_connection_unregister_object_path (DBusConnection *connection, return TRUE; } +/** + * Gets the user data passed to dbus_connection_register_object_path() + * or dbus_connection_register_fallback(). If nothing was registered + * at this path, the data is filled in with #NULL. + * + * @param connection the connection + * @param path the path you registered with + * @param data_p location to store the user data, or #NULL + * @returns #FALSE if not enough memory + */ +dbus_bool_t +dbus_connection_get_object_path_data (DBusConnection *connection, + const char *path, + void **data_p) +{ + char **decomposed_path; + + _dbus_return_val_if_fail (connection != NULL, FALSE); + _dbus_return_val_if_fail (path != NULL, FALSE); + _dbus_return_val_if_fail (data_p != NULL, FALSE); + + *data_p = NULL; + + if (!_dbus_decompose_path (path, strlen (path), &decomposed_path, NULL)) + return FALSE; + + CONNECTION_LOCK (connection); + + *data_p = _dbus_object_tree_get_user_data_unlocked (connection->objects, (const char**) decomposed_path); + + CONNECTION_UNLOCK (connection); + + dbus_free_string_array (decomposed_path); + + return TRUE; +} + /** * Lists the registered fallback handlers and object path handlers at * the given parent_path. The returned array should be freed with -- cgit