diff options
author | Havoc Pennington <hp@redhat.com> | 2003-08-31 03:25:24 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-08-31 03:25:24 +0000 |
commit | 1dd3f1788f1b4c9af2f4fa744abdb7892d0a14b9 (patch) | |
tree | 9f928baa3e6205394044ce5f0c6f1aa3933bdf4f /bus | |
parent | 5fd1e389e1c1c12ad4a55c2af6abdc8e7a2f6d41 (diff) | |
download | dbus-1dd3f1788f1b4c9af2f4fa744abdb7892d0a14b9.tar.gz |
2003-08-30 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c: purge DBusMessageHandler
* dbus/dbus-message-handler.c: remove DBusMessageHandler, just
use callbacks everywhere
Diffstat (limited to 'bus')
-rw-r--r-- | bus/dispatch.c | 62 | ||||
-rw-r--r-- | bus/test.c | 51 |
2 files changed, 20 insertions, 93 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c index 2f2e9e9d..7bdda0d4 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -32,8 +32,6 @@ #include <dbus/dbus-internals.h> #include <string.h> -static dbus_int32_t message_handler_slot = -1; - typedef struct { BusContext *context; @@ -316,61 +314,21 @@ bus_dispatch (DBusConnection *connection, } static DBusHandlerResult -bus_dispatch_message_handler (DBusMessageHandler *handler, - DBusConnection *connection, - DBusMessage *message, - void *user_data) +bus_dispatch_message_filter (DBusConnection *connection, + DBusMessage *message, + void *user_data) { return bus_dispatch (connection, message); } -static void -free_message_handler (void *data) -{ - DBusMessageHandler *handler = data; - - _dbus_assert (message_handler_slot >= 0); - - dbus_message_handler_unref (handler); - dbus_connection_free_data_slot (&message_handler_slot); -} - dbus_bool_t bus_dispatch_add_connection (DBusConnection *connection) -{ - DBusMessageHandler *handler; - - if (!dbus_connection_allocate_data_slot (&message_handler_slot)) +{ + if (!dbus_connection_add_filter (connection, + bus_dispatch_message_filter, + NULL, NULL)) return FALSE; - handler = dbus_message_handler_new (bus_dispatch_message_handler, NULL, NULL); - if (handler == NULL) - { - dbus_connection_free_data_slot (&message_handler_slot); - return FALSE; - } - - if (!dbus_connection_add_filter (connection, handler)) - { - dbus_message_handler_unref (handler); - dbus_connection_free_data_slot (&message_handler_slot); - - return FALSE; - } - - _dbus_assert (message_handler_slot >= 0); - - if (!dbus_connection_set_data (connection, - message_handler_slot, - handler, - free_message_handler)) - { - dbus_message_handler_unref (handler); - dbus_connection_free_data_slot (&message_handler_slot); - - return FALSE; - } - return TRUE; } @@ -380,9 +338,9 @@ bus_dispatch_remove_connection (DBusConnection *connection) /* Here we tell the bus driver that we want to get off. */ bus_driver_remove_connection (connection); - dbus_connection_set_data (connection, - message_handler_slot, - NULL, NULL); + dbus_connection_remove_filter (connection, + bus_dispatch_message_filter, + NULL); } #ifdef DBUS_BUILD_TESTS @@ -102,10 +102,9 @@ remove_client_timeout (DBusTimeout *timeout, } static DBusHandlerResult -client_disconnect_handler (DBusMessageHandler *handler, - DBusConnection *connection, - DBusMessage *message, - void *user_data) +client_disconnect_filter (DBusConnection *connection, + DBusMessage *message, + void *user_data) { if (!dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL, @@ -128,35 +127,15 @@ client_disconnect_handler (DBusMessageHandler *handler, return DBUS_HANDLER_RESULT_HANDLED; } -static dbus_int32_t handler_slot = -1; - -static void -free_handler (void *data) -{ - DBusMessageHandler *handler = data; - - dbus_message_handler_unref (handler); - dbus_connection_free_data_slot (&handler_slot); -} - dbus_bool_t bus_setup_debug_client (DBusConnection *connection) { - DBusMessageHandler *disconnect_handler; - dbus_bool_t retval; - - disconnect_handler = dbus_message_handler_new (client_disconnect_handler, - NULL, NULL); - - if (disconnect_handler == NULL) - return FALSE; + dbus_bool_t retval; if (!dbus_connection_add_filter (connection, - disconnect_handler)) - { - dbus_message_handler_unref (disconnect_handler); - return FALSE; - } + client_disconnect_filter, + NULL, NULL)) + return FALSE; retval = FALSE; @@ -184,25 +163,15 @@ bus_setup_debug_client (DBusConnection *connection) if (!_dbus_list_append (&clients, connection)) goto out; - - if (!dbus_connection_allocate_data_slot (&handler_slot)) - goto out; - - /* Set up handler to be destroyed */ - if (!dbus_connection_set_data (connection, handler_slot, - disconnect_handler, - free_handler)) - { - dbus_connection_free_data_slot (&handler_slot); - goto out; - } retval = TRUE; out: if (!retval) { - dbus_message_handler_unref (disconnect_handler); /* unregisters it */ + dbus_connection_remove_filter (connection, + client_disconnect_filter, + NULL); dbus_connection_set_watch_functions (connection, NULL, NULL, NULL, NULL, NULL); |