From 1820f3bd0a5a4b0ab14dbcc80ba1b68d2c48e01d Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 24 Apr 2003 21:26:25 +0000 Subject: 2003-04-24 Havoc Pennington * bus/dispatch.c: somehow missed some name_is * dbus/dbus-timeout.c (_dbus_timeout_set_enabled) (_dbus_timeout_set_interval): new * bus/connection.c (bus_connections_setup_connection): record time when each connection is first set up, and expire them after the auth timeout passes. --- dbus/dbus-timeout.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'dbus/dbus-timeout.c') diff --git a/dbus/dbus-timeout.c b/dbus/dbus-timeout.c index a77363be..74210f9a 100644 --- a/dbus/dbus-timeout.c +++ b/dbus/dbus-timeout.c @@ -48,7 +48,7 @@ struct DBusTimeout }; /** - * Creates a new DBusTimeout. + * Creates a new DBusTimeout, enabled by default. * @param interval the timeout interval in milliseconds. * @param handler function to call when the timeout occurs. * @param data data to pass to the handler @@ -111,6 +111,40 @@ _dbus_timeout_unref (DBusTimeout *timeout) } } +/** + * Changes the timeout interval. Note that you have to disable and + * re-enable the timeout using the timeout toggle function + * (_dbus_connection_toggle_timeout() etc.) to notify the application + * of this change. + * + * @param timeout the timeout + * @param interval the new interval + */ +void +_dbus_timeout_set_interval (DBusTimeout *timeout, + int interval) +{ + timeout->interval = interval; +} + +/** + * Changes the timeout's enabled-ness. Note that you should use + * _dbus_connection_toggle_timeout() etc. instead, if + * the timeout is passed out to an application main loop. + * i.e. you can't use this function in the D-BUS library, it's + * only used in the message bus daemon implementation. + * + * @param timeout the timeout + * @param interval the new interval + */ +void +_dbus_timeout_set_enabled (DBusTimeout *timeout, + dbus_bool_t enabled) +{ + timeout->enabled = enabled != FALSE; +} + + /** * @typedef DBusTimeoutList * @@ -133,7 +167,7 @@ struct DBusTimeoutList DBusAddTimeoutFunction add_timeout_function; /**< Callback for adding a timeout. */ DBusRemoveTimeoutFunction remove_timeout_function; /**< Callback for removing a timeout. */ - DBusTimeoutToggledFunction timeout_toggled_function; /**< Callback when timeout is enabled/disabled */ + DBusTimeoutToggledFunction timeout_toggled_function; /**< Callback when timeout is enabled/disabled or changes interval */ void *timeout_data; /**< Data for timeout callbacks */ DBusFreeFunction timeout_free_data_function; /**< Free function for timeout callback data */ }; @@ -355,6 +389,11 @@ _dbus_timeout_list_toggle_timeout (DBusTimeoutList *timeout_list, * should be called each time this interval elapses, * starting after it elapses once. * + * The interval may change during the life of the + * timeout; if so, the timeout will be disabled and + * re-enabled (calling the "timeout toggled function") + * to notify you of the change. + * * @param timeout the DBusTimeout object. * @returns the interval in milliseconds. */ -- cgit