summaryrefslogtreecommitdiffstats
path: root/bus/dispatch.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-08-31 03:25:24 +0000
committerHavoc Pennington <hp@redhat.com>2003-08-31 03:25:24 +0000
commit1dd3f1788f1b4c9af2f4fa744abdb7892d0a14b9 (patch)
tree9f928baa3e6205394044ce5f0c6f1aa3933bdf4f /bus/dispatch.c
parent5fd1e389e1c1c12ad4a55c2af6abdc8e7a2f6d41 (diff)
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/dispatch.c')
-rw-r--r--bus/dispatch.c62
1 files changed, 10 insertions, 52 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