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.
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;
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);
CONNECTION_UNLOCK (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_assert (connection != NULL);
+
+ CONNECTION_LOCK (connection);
+ connection->builtin_filters_enabled = value;
+ CONNECTION_UNLOCK (connection);
+}
+
/**
*
* Normally #DBusConnection automatically handles all messages to the