25 #include "dbus-internals.h"
26 #include "dbus-timeout.h"
27 #include "dbus-list.h"
203 if (timeout_list ==
NULL)
251 if (add_function !=
NULL)
261 if (!(* add_function) (link->
data, data))
267 while (link2 != link)
272 (* remove_function) (link2->
data, data);
372 if (enabled == timeout->
enabled)
459 return timeout->
data;
481 timeout->
data = data;
DBusTimeout * _dbus_timeout_new(int interval, DBusTimeoutHandler handler, void *data, DBusFreeFunction free_data_function)
Creates a new DBusTimeout, enabled by default.
dbus_bool_t _dbus_timeout_needs_restart(DBusTimeout *timeout)
Returns whether a timeout needs restart time counting in the event loop.
DBUS_EXPORT dbus_bool_t dbus_timeout_get_enabled(DBusTimeout *timeout)
Returns whether a timeout is enabled or not.
void _dbus_timeout_list_free(DBusTimeoutList *timeout_list)
Frees a DBusTimeoutList.
void * data
Application data.
dbus_bool_t _dbus_list_remove(DBusList **list, void *data)
Removes a value from the list.
dbus_bool_t _dbus_timeout_list_set_functions(DBusTimeoutList *timeout_list, DBusAddTimeoutFunction add_function, DBusRemoveTimeoutFunction remove_function, DBusTimeoutToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the timeout functions.
DBusTimeoutList implementation details.
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
DBusTimeout * _dbus_timeout_ref(DBusTimeout *timeout)
Increments the reference count of a DBusTimeout object.
DBusTimeoutList * _dbus_timeout_list_new(void)
Creates a new timeout list.
void(* DBusFreeFunction)(void *memory)
DBusTimeoutToggledFunction timeout_toggled_function
Callback when timeout is enabled/disabled or changes interval.
void _dbus_timeout_disable(DBusTimeout *timeout)
Disable the timeout.
DBUS_EXPORT void dbus_timeout_set_data(DBusTimeout *timeout, void *data, DBusFreeFunction free_data_function)
Sets data which can be retrieved with dbus_timeout_get_data().
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
int refcount
Reference count.
void(* DBusRemoveTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus no longer needs a timeout to be monitored by the main loop.
dbus_bool_t(* DBusAddTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus needs a new timeout to be monitored by the main loop.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
void _dbus_timeout_unref(DBusTimeout *timeout)
Decrements the reference count of a DBusTimeout object and finalizes the object if the count reaches ...
void _dbus_timeout_restart(DBusTimeout *timeout, int interval)
Change the timeout interval to be interval milliseconds from now (forgetting when the timeout was ini...
#define _dbus_list_get_next_link(list, link)
DBusFreeFunction timeout_free_data_function
Free function for timeout callback data.
dbus_bool_t _dbus_timeout_list_add_timeout(DBusTimeoutList *timeout_list, DBusTimeout *timeout)
Adds a new timeout to the timeout list, invoking the application DBusAddTimeoutFunction if appropriat...
DBusAddTimeoutFunction add_timeout_function
Callback for adding a timeout.
DBusRemoveTimeoutFunction remove_timeout_function
Callback for removing a timeout.
unsigned int needs_restart
Flag that timeout should be restarted after re-enabling.
Internals of DBusTimeout.
dbus_bool_t _dbus_list_remove_last(DBusList **list, void *data)
Removes a value from the list.
DBusFreeFunction free_handler_data_function
Free the timeout handler data.
void * data
Data stored at this element.
void(* DBusTimeoutToggledFunction)(DBusTimeout *timeout, void *data)
Called when dbus_timeout_get_enabled() may return a different value than it did before.
#define _dbus_assert_not_reached(explanation)
void * timeout_data
Data for timeout callbacks.
void _dbus_timeout_list_toggle_timeout(DBusTimeoutList *timeout_list, DBusTimeout *timeout, dbus_bool_t enabled)
Sets a timeout to the given enabled state, invoking the application's DBusTimeoutToggledFunction if a...
int interval
Timeout interval in milliseconds.
void _dbus_list_foreach(DBusList **list, DBusForeachFunction function, void *data)
Calls the given function for each element in the list.
DBusTimeoutHandler handler
Timeout handler.
DBUS_EXPORT void * dbus_timeout_get_data(DBusTimeout *timeout)
Gets data previously set with dbus_timeout_set_data() or NULL if none.
#define _dbus_assert(condition)
DBUS_EXPORT int dbus_timeout_get_interval(DBusTimeout *timeout)
Gets the timeout interval.
DBusList * timeouts
Timeout objects.
void _dbus_timeout_list_remove_timeout(DBusTimeoutList *timeout_list, DBusTimeout *timeout)
Removes a timeout from the timeout list, invoking the application's DBusRemoveTimeoutFunction if appr...
DBusFreeFunction free_data_function
Free the application data.
void(* DBusForeachFunction)(void *element, void *data)
unsigned int enabled
True if timeout is active.
#define dbus_new0(type, count)
DBUS_EXPORT dbus_bool_t dbus_timeout_handle(DBusTimeout *timeout)
Calls the timeout handler for this timeout.
dbus_bool_t(* DBusTimeoutHandler)(void *data)
function to run when the timeout is handled
void * handler_data
Timeout handler data.
void _dbus_timeout_restarted(DBusTimeout *timeout)
Mark timeout as restarted (setting timestamps is responsibility of the event loop).
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
dbus_uint32_t dbus_bool_t