summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-04-24 21:26:25 +0000
committerHavoc Pennington <hp@redhat.com>2003-04-24 21:26:25 +0000
commit1820f3bd0a5a4b0ab14dbcc80ba1b68d2c48e01d (patch)
treee52ad1013416c233db9664fc63041cc106e9ac66 /dbus
parent0ed8f3f3f32d9dfb965b88cda5735f4e61978590 (diff)
2003-04-24 Havoc Pennington <hp@redhat.com>
* 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.
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-connection.c10
-rw-r--r--dbus/dbus-timeout.c43
-rw-r--r--dbus/dbus-timeout.h16
3 files changed, 57 insertions, 12 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 4bb0514f..9843d288 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -2394,12 +2394,14 @@ dbus_connection_set_watch_functions (DBusConnection *connection,
* allocation. With Qt, QTimer::start() and QTimer::stop() can be used
* to enable and disable. The toggled function may be NULL if a main
* loop re-queries dbus_timeout_get_enabled() every time anyway.
+ * Whenever a timeout is toggled, its interval may change.
*
* The DBusTimeout can be queried for the timer interval using
- * dbus_timeout_get_interval(). dbus_timeout_handle() should
- * be called repeatedly, each time the interval elapses, starting
- * after it has elapsed once. The timeout stops firing when
- * it is removed with the given remove_function.
+ * dbus_timeout_get_interval(). dbus_timeout_handle() should be called
+ * repeatedly, each time the interval elapses, starting after it has
+ * elapsed once. The timeout stops firing when it is removed with the
+ * given remove_function. The timer interval may change whenever the
+ * timeout is added, removed, or toggled.
*
* @param connection the connection.
* @param add_function function to add a timeout.
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
@@ -112,6 +112,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
*
* Opaque data type representing a list of timeouts
@@ -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.
*/
diff --git a/dbus/dbus-timeout.h b/dbus/dbus-timeout.h
index 2f136ae0..c68f29fa 100644
--- a/dbus/dbus-timeout.h
+++ b/dbus/dbus-timeout.h
@@ -34,12 +34,16 @@ typedef struct DBusTimeoutList DBusTimeoutList;
typedef dbus_bool_t (* DBusTimeoutHandler) (void *data);
-DBusTimeout* _dbus_timeout_new (int interval,
- DBusTimeoutHandler handler,
- void *data,
- DBusFreeFunction free_data_function);
-void _dbus_timeout_ref (DBusTimeout *timeout);
-void _dbus_timeout_unref (DBusTimeout *timeout);
+DBusTimeout* _dbus_timeout_new (int interval,
+ DBusTimeoutHandler handler,
+ void *data,
+ DBusFreeFunction free_data_function);
+void _dbus_timeout_ref (DBusTimeout *timeout);
+void _dbus_timeout_unref (DBusTimeout *timeout);
+void _dbus_timeout_set_interval (DBusTimeout *timeout,
+ int interval);
+void _dbus_timeout_set_enabled (DBusTimeout *timeout,
+ dbus_bool_t enabled);
DBusTimeoutList *_dbus_timeout_list_new (void);
void _dbus_timeout_list_free (DBusTimeoutList *timeout_list);