diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-03-10 04:10:31 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-03-11 23:08:25 +0100 |
commit | f934a967e3b628ac11839117ce0aa082c9f37803 (patch) | |
tree | 5b8d2fb8e33e302b42666f4a185df3e6e27160a2 | |
parent | 2c34514620c4b79ea4ec71d1db583379138d01ac (diff) | |
download | dbus-f934a967e3b628ac11839117ce0aa082c9f37803.tar.gz |
connection: hook UnknownObject and UnknownInterface up where appropriate
This makes use of UnknownInterface and UnknownObject where appropriate
in the D-Bus core.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34527
Reviewed-By: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | bus/driver.c | 5 | ||||
-rw-r--r-- | dbus/dbus-connection.c | 6 | ||||
-rw-r--r-- | dbus/dbus-object-tree.c | 8 | ||||
-rw-r--r-- | dbus/dbus-object-tree.h | 3 |
4 files changed, 16 insertions, 6 deletions
diff --git a/bus/driver.c b/bus/driver.c index 1e9573ee..425a3d5a 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1921,6 +1921,7 @@ bus_driver_handle_message (DBusConnection *connection, const char *name, *sender, *interface; const InterfaceHandler *ih; const MessageHandler *mh; + dbus_bool_t found_interface = FALSE; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1957,6 +1958,8 @@ bus_driver_handle_message (DBusConnection *connection, if (interface != NULL && strcmp (interface, ih->name) != 0) continue; + found_interface = TRUE; + for (mh = ih->message_handlers; mh->name != NULL; mh++) { if (strcmp (mh->name, name) != 0) @@ -1998,7 +2001,7 @@ bus_driver_handle_message (DBusConnection *connection, _dbus_verbose ("No driver handler for message \"%s\"\n", name); - dbus_set_error (error, DBUS_ERROR_UNKNOWN_METHOD, + dbus_set_error (error, found_interface ? DBUS_ERROR_UNKNOWN_METHOD : DBUS_ERROR_UNKNOWN_INTERFACE, "%s does not understand message %s", DBUS_SERVICE_DBUS, name); diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 526a7162..4a76af77 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -4523,6 +4523,7 @@ dbus_connection_dispatch (DBusConnection *connection) DBusPendingCall *pending; dbus_int32_t reply_serial; DBusDispatchStatus status; + dbus_bool_t found_object; _dbus_return_val_if_fail (connection != NULL, DBUS_DISPATCH_COMPLETE); @@ -4687,7 +4688,8 @@ dbus_connection_dispatch (DBusConnection *connection) HAVE_LOCK_CHECK (connection); result = _dbus_object_tree_dispatch_and_unlock (connection->objects, - message); + message, + &found_object); CONNECTION_LOCK (connection); @@ -4726,7 +4728,7 @@ dbus_connection_dispatch (DBusConnection *connection) } reply = dbus_message_new_error (message, - DBUS_ERROR_UNKNOWN_METHOD, + found_object ? DBUS_ERROR_UNKNOWN_METHOD : DBUS_ERROR_UNKNOWN_OBJECT, _dbus_string_get_const_data (&str)); _dbus_string_free (&str); diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 28cfc8b4..989e5d8b 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -745,7 +745,8 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, */ DBusHandlerResult _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, - DBusMessage *message) + DBusMessage *message, + dbus_bool_t *found_object) { char **path; dbus_bool_t exact_match; @@ -791,6 +792,9 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, /* Find the deepest path that covers the path in the message */ subtree = find_handler (tree, (const char**) path, &exact_match); + if (found_object) + *found_object = !!subtree; + /* Build a list of all paths that cover the path in the message */ list = NULL; @@ -1382,7 +1386,7 @@ do_test_dispatch (DBusObjectTree *tree, ++j; } - result = _dbus_object_tree_dispatch_and_unlock (tree, message); + result = _dbus_object_tree_dispatch_and_unlock (tree, message, NULL); if (result == DBUS_HANDLER_RESULT_NEED_MEMORY) goto oom; diff --git a/dbus/dbus-object-tree.h b/dbus/dbus-object-tree.h index 022dd93f..5576c25d 100644 --- a/dbus/dbus-object-tree.h +++ b/dbus/dbus-object-tree.h @@ -42,7 +42,8 @@ dbus_bool_t _dbus_object_tree_register (DBusObjectTree void _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, const char **path); DBusHandlerResult _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, - DBusMessage *message); + DBusMessage *message, + dbus_bool_t *found_object); void* _dbus_object_tree_get_user_data_unlocked (DBusObjectTree *tree, const char **path); void _dbus_object_tree_free_all_unlocked (DBusObjectTree *tree); |