diff options
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-connection.c | 47 | ||||
-rw-r--r-- | dbus/dbus-connection.h | 3 |
2 files changed, 46 insertions, 4 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 159dbe1b..5841d817 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -316,6 +316,8 @@ struct DBusConnection unsigned int exit_on_disconnect : 1; /**< If #TRUE, exit after handling disconnect signal */ + unsigned int builtin_filters_enabled : 1; /**< If #TRUE, handle org.freedesktop.DBus.Peer messages automatically, whether they have a bus name or not */ + unsigned int route_peer_messages : 1; /**< If #TRUE, if org.freedesktop.DBus.Peer messages have a bus name, don't handle them automatically */ unsigned int disconnected_message_arrived : 1; /**< We popped or are dispatching the disconnected message. @@ -1343,6 +1345,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->objects = objects; connection->exit_on_disconnect = FALSE; connection->shareable = FALSE; + connection->builtin_filters_enabled = TRUE; connection->route_peer_messages = FALSE; connection->disconnected_message_arrived = FALSE; connection->disconnected_message_processed = FALSE; @@ -4657,10 +4660,14 @@ dbus_connection_dispatch (DBusConnection *connection) goto out; } - result = _dbus_connection_run_builtin_filters_unlocked_no_update (connection, message); - if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED) - goto out; - + /* If skipping builtin filters, we are probably a monitor. */ + if (connection->builtin_filters_enabled) + { + result = _dbus_connection_run_builtin_filters_unlocked_no_update (connection, message); + if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED) + goto out; + } + if (!_dbus_list_copy (&connection->filter_list, &filter_list_copy)) { _dbus_connection_release_dispatch (connection); @@ -5533,6 +5540,38 @@ dbus_connection_set_allow_anonymous (DBusConnection *connection, } /** + * Enables the builtin filtering of messages. + * + * Currently the only filtering implemented by libdbus and mandated by the spec + * is that of peer messages. + * + * If #TRUE, #DBusConnection automatically handles all messages to the + * org.freedesktop.DBus.Peer interface. For monitors this can break the + * specification if the response is sending a message. + * + * If #FALSE, the result is similar to calling + * dbus_connection_set_route_peer_messages() with argument TRUE, but + * messages with a NULL destination are also dispatched to the + * application instead of being passed to the built-in filters. + * + * If a normal application disables this flag, it can break things badly. So + * only unset this if you are a monitor. + * + * @param connection the connection + * @param value #TRUE to pass through org.freedesktop.DBus.Peer messages + */ +void +dbus_connection_set_builtin_filters_enabled (DBusConnection *connection, + dbus_bool_t value) +{ + _dbus_return_if_fail (connection != NULL); + + CONNECTION_LOCK (connection); + connection->builtin_filters_enabled = value; + CONNECTION_UNLOCK (connection); +} + +/** * * Normally #DBusConnection automatically handles all messages to the * org.freedesktop.DBus.Peer interface. However, the message bus wants diff --git a/dbus/dbus-connection.h b/dbus/dbus-connection.h index 32d79979..5d9f244d 100644 --- a/dbus/dbus-connection.h +++ b/dbus/dbus-connection.h @@ -286,6 +286,9 @@ DBUS_EXPORT void dbus_connection_set_allow_anonymous (DBusConnection *connection, dbus_bool_t value); DBUS_EXPORT +void dbus_connection_set_builtin_filters_enabled (DBusConnection *connection, + dbus_bool_t value); +DBUS_EXPORT void dbus_connection_set_route_peer_messages (DBusConnection *connection, dbus_bool_t value); |