summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-server.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-15 20:47:16 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-15 20:47:16 +0000
commitf587ce7845edb0eb01451368d01b5bc86b5904cd (patch)
treef3a549cd61df701882d818b5fc452b1438097f5b /dbus/dbus-server.c
parentf05f87a825ab8ed5273674a7f65521ffc526f0d2 (diff)
2003-03-15 Havoc Pennington <hp@pobox.com>
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
Diffstat (limited to 'dbus/dbus-server.c')
-rw-r--r--dbus/dbus-server.c45
1 files changed, 45 insertions, 0 deletions
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
@@ -146,6 +146,25 @@ _dbus_server_remove_watch (DBusServer *server,
}
/**
+ * 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
* repeatedly handled with dbus_timeout_handle() at its given interval
@@ -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);
}