From f587ce7845edb0eb01451368d01b5bc86b5904cd Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 15 Mar 2003 20:47:16 +0000 Subject: 2003-03-15 Havoc Pennington Make it pass the Hello handling test including all OOM codepaths. Now to do other messages... * bus/services.c (bus_service_remove_owner): fix crash when removing owner from an empty list of owners (bus_registry_ensure): don't leave service in the list of a connection's owned services if we fail to put the service in the hash table. * bus/connection.c (bus_connection_preallocate_oom_error): set error flag on the OOM error. * dbus/dbus-connection.c (_dbus_connection_new_for_transport): handle _dbus_transport_set_connection failure * dbus/dbus-transport-unix.c (_dbus_transport_new_for_fd): modify to create watches up front and simply enable/disable them as needed. (unix_connection_set): this can now fail on OOM * dbus/dbus-timeout.c, dbus/dbus-watch.c: add concept of enabling/disabling a watch or timeout. * bus/loop.c (bus_loop_iterate): don't touch disabled watches/timeouts * glib/dbus-gmain.c: adapt to enable/disable watches and timeouts --- dbus/dbus-server.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'dbus/dbus-server.c') diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index 80ee6fc2..48703e17 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -145,6 +145,25 @@ _dbus_server_remove_watch (DBusServer *server, _dbus_watch_list_remove_watch (server->watches, watch); } +/** + * Toggles a watch and notifies app via server's + * DBusWatchToggledFunction if available. It's an error to call this + * function on a watch that was not previously added. + * + * @param server the server. + * @param timeout the timeout to toggle. + * @param enabled whether to enable or disable + */ +void +_dbus_server_toggle_watch (DBusServer *server, + DBusWatch *watch, + dbus_bool_t enabled) +{ + if (server->watches) /* null during finalize */ + _dbus_watch_list_toggle_watch (server->watches, + watch, enabled); +} + /** * Adds a timeout for this server, chaining out to * application-provided timeout handlers. The timeout should be @@ -174,6 +193,26 @@ _dbus_server_remove_timeout (DBusServer *server, _dbus_timeout_list_remove_timeout (server->timeouts, timeout); } +/** + * Toggles a timeout and notifies app via server's + * DBusTimeoutToggledFunction if available. It's an error to call this + * function on a timeout that was not previously added. + * + * @param server the server. + * @param timeout the timeout to toggle. + * @param enabled whether to enable or disable + */ +void +_dbus_server_toggle_timeout (DBusServer *server, + DBusTimeout *timeout, + dbus_bool_t enabled) +{ + if (server->timeouts) /* null during finalize */ + _dbus_timeout_list_toggle_timeout (server->timeouts, + timeout, enabled); +} + + /** @} */ /** @@ -405,6 +444,7 @@ dbus_server_set_new_connection_function (DBusServer *server, * @param server the server. * @param add_function function to begin monitoring a new descriptor. * @param remove_function function to stop monitoring a descriptor. + * @param toggled_function function to notify when the watch is enabled/disabled * @param data data to pass to add_function and remove_function. * @param free_data_function function to be called to free the data. * @returns #FALSE on failure (no memory) @@ -413,12 +453,14 @@ dbus_bool_t dbus_server_set_watch_functions (DBusServer *server, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, + DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function) { return _dbus_watch_list_set_functions (server->watches, add_function, remove_function, + toggled_function, data, free_data_function); } @@ -433,6 +475,7 @@ dbus_server_set_watch_functions (DBusServer *server, * @param server the server. * @param add_function function to add a timeout. * @param remove_function function to remove a timeout. + * @param toggled_function function to notify when the timeout is enabled/disabled * @param data data to pass to add_function and remove_function. * @param free_data_function function to be called to free the data. * @returns #FALSE on failure (no memory) @@ -441,11 +484,13 @@ dbus_bool_t dbus_server_set_timeout_functions (DBusServer *server, DBusAddTimeoutFunction add_function, DBusRemoveTimeoutFunction remove_function, + DBusTimeoutToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function) { return _dbus_timeout_list_set_functions (server->timeouts, add_function, remove_function, + toggled_function, data, free_data_function); } -- cgit