From 17fbe2b702cdc880abd6cbe117e620b6432f42e0 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Tue, 24 Dec 2002 06:37:33 +0000 Subject: 2002-12-24 Havoc Pennington * glib/dbus-gthread.c: fix include * glib/dbus-glib.h: rename DBusMessageHandler for now. I think glib API needs to change, though, as you don't want to use DBusMessageFunction, you want to use the DBusMessageHandler object. Probably dbus_connection_open_with_g_main_loop() and dbus_connection_setup_g_main_loop() or something like that (but think of better names...) that just create a connection that has watch/timeout functions etc. already set up. * dbus/dbus-connection.c (dbus_connection_send_message_with_reply): new function just to show how the message handler helps us deal with replies. * dbus/dbus-list.c (_dbus_list_remove_last): new function * dbus/dbus-string.c (_dbus_string_test): free a string that wasn't * dbus/dbus-hash.c: use memory pools for the hash entries (rebuild_table): be more paranoid about overflow, and shrink table when we can (_dbus_hash_test): reduce number of sprintfs and write valid C89. Add tests for case where we grow and then shrink the hash table. * dbus/dbus-mempool.h, dbus/dbus-mempool.c: memory pools * dbus/dbus-connection.c (dbus_connection_register_handler) (dbus_connection_unregister_handler): new functions * dbus/dbus-message.c (dbus_message_get_name): new * dbus/dbus-list.c: fix docs typo * dbus/dbus-message-handler.h, dbus/dbus-message-handler.c: an object representing a handler for messages. --- dbus/dbus-connection.h | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'dbus/dbus-connection.h') diff --git a/dbus/dbus-connection.h b/dbus/dbus-connection.h index ceb5728f..518295b2 100644 --- a/dbus/dbus-connection.h +++ b/dbus/dbus-connection.h @@ -35,6 +35,13 @@ DBUS_BEGIN_DECLS; typedef struct DBusConnection DBusConnection; typedef struct DBusWatch DBusWatch; +typedef struct DBusMessageHandler DBusMessageHandler; + +typedef enum +{ + DBUS_HANDLER_RESULT_REMOVE_MESSAGE, /**< Remove this message, no further processing. */ + DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS /**< Run any additional handlers that are interested on this message. */ +} DBusHandlerResult; typedef enum { @@ -63,15 +70,21 @@ void dbus_connection_ref (DBusConnection *connection); void dbus_connection_unref (DBusConnection *connection); void dbus_connection_disconnect (DBusConnection *connection); dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection); -dbus_bool_t dbus_connection_send_message (DBusConnection *connection, - DBusMessage *message, - DBusResultCode *result); void dbus_connection_flush (DBusConnection *connection); int dbus_connection_get_n_messages (DBusConnection *connection); DBusMessage* dbus_connection_peek_message (DBusConnection *connection); DBusMessage* dbus_connection_pop_message (DBusConnection *connection); +dbus_bool_t dbus_connection_dispatch_message (DBusConnection *connection); +dbus_bool_t dbus_connection_send_message (DBusConnection *connection, + DBusMessage *message, + DBusResultCode *result); +dbus_bool_t dbus_connection_send_message_with_reply (DBusConnection *connection, + DBusMessage *message, + DBusMessageHandler *reply_handler, + int timeout_milliseconds, + DBusResultCode *result); void dbus_connection_set_error_function (DBusConnection *connection, DBusConnectionErrorFunction error_function, @@ -86,7 +99,6 @@ void dbus_connection_handle_watch (DBusConnection *connectio DBusWatch *watch, unsigned int condition); - int dbus_watch_get_fd (DBusWatch *watch); unsigned int dbus_watch_get_flags (DBusWatch *watch); void* dbus_watch_get_data (DBusWatch *watch); @@ -95,6 +107,21 @@ void dbus_watch_set_data (DBusWatch *watch, DBusFreeFunction free_data_function); +/* Handlers */ +dbus_bool_t dbus_connection_add_filter (DBusConnection *connection, + DBusMessageHandler *handler); +void dbus_connection_remove_filter (DBusConnection *connection, + DBusMessageHandler *handler); + +dbus_bool_t dbus_connection_register_handler (DBusConnection *connection, + DBusMessageHandler *handler, + const char **messages_to_handle, + int n_messages); +void dbus_connection_unregister_handler (DBusConnection *connection, + DBusMessageHandler *handler, + const char **messages_to_handle, + int n_messages); + DBUS_END_DECLS; #endif /* DBUS_CONNECTION_H */ -- cgit