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 /glib | |
parent | 5fd1e389e1c1c12ad4a55c2af6abdc8e7a2f6d41 (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 'glib')
-rw-r--r-- | glib/test-profile.c | 23 | ||||
-rw-r--r-- | glib/test-thread-server.c | 52 |
2 files changed, 10 insertions, 65 deletions
diff --git a/glib/test-profile.c b/glib/test-profile.c index 3eac1618..6d9d8e7f 100644 --- a/glib/test-profile.c +++ b/glib/test-profile.c @@ -63,8 +63,7 @@ send_echo_message (DBusConnection *connection) } static DBusHandlerResult -client_filter (DBusMessageHandler *handler, - DBusConnection *connection, +client_filter (DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -99,7 +98,6 @@ thread_func (void *data) DBusError error; GMainContext *context; GMainLoop *loop; - DBusMessageHandler *handler; DBusConnection *connection; int iterations; @@ -116,14 +114,9 @@ thread_func (void *data) iterations = 1; - handler = dbus_message_handler_new (client_filter, - &iterations, NULL); - if (!dbus_connection_add_filter (connection, - handler)) + client_filter, &iterations, NULL)) g_error ("no memory"); - - /* FIXME we leak the handler */ context = g_main_context_new (); loop = g_main_loop_new (context, FALSE); @@ -145,8 +138,7 @@ thread_func (void *data) } static DBusHandlerResult -server_filter (DBusMessageHandler *handler, - DBusConnection *connection, +server_filter (DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -172,17 +164,12 @@ static void new_connection_callback (DBusServer *server, DBusConnection *new_connection, void *user_data) -{ - DBusMessageHandler *handler; - +{ dbus_connection_ref (new_connection); dbus_connection_setup_with_g_main (new_connection, NULL); - - handler = dbus_message_handler_new (server_filter, - NULL, NULL); if (!dbus_connection_add_filter (new_connection, - handler)) + server_filter, NULL, NULL)) g_error ("no memory"); diff --git a/glib/test-thread-server.c b/glib/test-thread-server.c index 33652f8c..8898ca7f 100644 --- a/glib/test-thread-server.c +++ b/glib/test-thread-server.c @@ -25,13 +25,8 @@ thread_test_data_free (ThreadTestData *data) g_free (data); } -static DBusMessageHandler *disconnect_handler; -static DBusMessageHandler *filter_handler; -static dbus_int32_t handler_slot = -1; - static DBusHandlerResult -handle_test_message (DBusMessageHandler *handler, - DBusConnection *connection, +filter_test_message (DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -132,17 +127,7 @@ handle_test_message (DBusMessageHandler *handler, } static DBusHandlerResult -handle_filter (DBusMessageHandler *handler, - DBusConnection *connection, - DBusMessage *message, - void *user_data) -{ - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static DBusHandlerResult -handle_disconnect (DBusMessageHandler *handler, - DBusConnection *connection, +filter_disconnect (DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -161,7 +146,6 @@ new_connection_callback (DBusServer *server, DBusConnection *new_connection, void *user_data) { - DBusMessageHandler *test_message_handler; ThreadTestData * data; g_print ("new_connection_callback\n"); @@ -171,26 +155,13 @@ new_connection_callback (DBusServer *server, data = thread_test_data_new (); - test_message_handler = - dbus_message_handler_new (handle_test_message, - data, (DBusFreeFunction)thread_test_data_free); - if (!dbus_connection_add_filter (new_connection, - test_message_handler)) - goto nomem; - - if (!dbus_connection_set_data (new_connection, - handler_slot, - test_message_handler, - (DBusFreeFunction)dbus_message_handler_unref)) + filter_test_message, data, + (DBusFreeFunction) thread_test_data_free)) goto nomem; if (!dbus_connection_add_filter (new_connection, - disconnect_handler)) - goto nomem; - - if (!dbus_connection_add_filter (new_connection, - filter_handler)) + filter_disconnect, NULL, NULL)) goto nomem; return; @@ -224,19 +195,6 @@ main (int argc, char *argv[]) dbus_error_free (&error); return 1; } - - if (!dbus_connection_allocate_data_slot (&handler_slot)) - g_error ("no memory for data slot"); - - filter_handler = - dbus_message_handler_new (handle_filter, NULL, NULL); - if (filter_handler == NULL) - g_error ("no memory for handler"); - - disconnect_handler = - dbus_message_handler_new (handle_disconnect, NULL, NULL); - if (disconnect_handler == NULL) - g_error ("no memory for handler"); dbus_server_set_new_connection_function (server, new_connection_callback, |