25#include "dbus-internals.h"
26#include "dbus-timeout.h"
203 if (timeout_list ==
NULL)
249 if (add_function !=
NULL)
259 if (!(* add_function) (link->
data, data))
265 while (link2 != link)
270 (* remove_function) (link2->
data, data);
370 if (enabled == timeout->
enabled)
457 return timeout->
data;
479 timeout->
data = data;
void(* DBusTimeoutToggledFunction)(DBusTimeout *timeout, void *data)
Called when dbus_timeout_get_enabled() may return a different value than it did before.
dbus_bool_t(* DBusAddTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus needs a new timeout to be monitored by the main loop.
void(* DBusRemoveTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus no longer needs a timeout to be monitored by the main loop.
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
void(* DBusForeachFunction)(void *element, void *data)
Used to iterate over each item in a collection, such as a DBusList.
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
dbus_bool_t _dbus_list_remove(DBusList **list, void *data)
Removes a value from the list.
void _dbus_list_clear_full(DBusList **list, DBusFreeFunction function)
Free every link and every element in the list.
void _dbus_list_foreach(DBusList **list, DBusForeachFunction function, void *data)
Calls the given function for each element in the list.
dbus_bool_t _dbus_list_remove_last(DBusList **list, void *data)
Removes a value from the list.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
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...
void _dbus_timeout_list_free(DBusTimeoutList *timeout_list)
Frees a DBusTimeoutList.
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...
DBusTimeoutList * _dbus_timeout_list_new(void)
Creates a new timeout list.
void _dbus_timeout_unref(DBusTimeout *timeout)
Decrements the reference count of a DBusTimeout object and finalizes the object if the count reaches ...
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.
void _dbus_timeout_disable(DBusTimeout *timeout)
Disable the timeout.
DBusTimeout * _dbus_timeout_new(int interval, DBusTimeoutHandler handler, void *data, DBusFreeFunction free_data_function)
Creates a new DBusTimeout, enabled by default.
void _dbus_timeout_restart(DBusTimeout *timeout, int interval)
Change the timeout interval to be interval milliseconds from now (forgetting when the timeout was ini...
dbus_bool_t(* DBusTimeoutHandler)(void *data)
function to run when the timeout is handled
DBusTimeout * _dbus_timeout_ref(DBusTimeout *timeout)
Increments the reference count of a DBusTimeout object.
void _dbus_timeout_restarted(DBusTimeout *timeout)
Mark timeout as restarted (setting timestamps is responsibility of the event loop).
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...
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_handle(DBusTimeout *timeout)
Calls the timeout handler for this timeout.
DBUS_EXPORT dbus_bool_t dbus_timeout_get_enabled(DBusTimeout *timeout)
Returns whether a timeout is enabled or not.
DBUS_EXPORT int dbus_timeout_get_interval(DBusTimeout *timeout)
Gets the timeout interval.
DBUS_EXPORT void * dbus_timeout_get_data(DBusTimeout *timeout)
Gets data previously set with dbus_timeout_set_data() or NULL if none.
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_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
void * data
Data stored at this element.
DBusTimeoutList implementation details.
DBusTimeoutToggledFunction timeout_toggled_function
Callback when timeout is enabled/disabled or changes interval.
DBusRemoveTimeoutFunction remove_timeout_function
Callback for removing a timeout.
DBusList * timeouts
Timeout objects.
DBusAddTimeoutFunction add_timeout_function
Callback for adding a timeout.
DBusFreeFunction timeout_free_data_function
Free function for timeout callback data.
void * timeout_data
Data for timeout callbacks.
Internals of DBusTimeout.
void * data
Application data.
int refcount
Reference count.
unsigned int enabled
True if timeout is active.
DBusTimeoutHandler handler
Timeout handler.
void * handler_data
Timeout handler data.
int interval
Timeout interval in milliseconds.
unsigned int needs_restart
Flag that timeout should be restarted after re-enabling.
DBusFreeFunction free_handler_data_function
Free the timeout handler data.
DBusFreeFunction free_data_function
Free the application data.