summaryrefslogtreecommitdiffstats
path: root/bus/services.c
diff options
context:
space:
mode:
authorRobert McQueen <robot101@debian.org>2005-11-15 17:19:19 +0000
committerRobert McQueen <robot101@debian.org>2005-11-15 17:19:19 +0000
commitb5e4d26adec0a9ec37a1bae7aeb5a68344b78ebf (patch)
tree66eb4e5670d802aee918f8bd3c4674482de0990c /bus/services.c
parentd4595960e9edc679cb2656d3ff59d2f899b0f16b (diff)
2005-11-15 Robert McQueen <robot101@debian.org>
* bus/driver.c, bus/services.c, bus/services.h: Add a ReleaseName method to org.freedesktop.DBus to release a bus name or give up waiting in the queue for it. * dbus/dbus-bus.c, dbus/dbus-bus.h, dbus/dbus-shared.h: Add a dbus_bus_release_name method to send the ReleaseName method calls. Add constants for the return values to dbus/dbus-shared.h. * doc/dbus-specification.xml: Document the new ReleaseName method in the specification. * python/dbus_bindings.pyx: Add a low-level python binding for the release name method. * python/exceptions.py, python/service.py: Make freeing BusName objects release the name. Add a NameExistsException, and fix a bug with creating UnknownMethodException. * test/python/test-client.py: Add tests for freeing BusName objects causing names to be released.
Diffstat (limited to 'bus/services.c')
-rw-r--r--bus/services.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/bus/services.c b/bus/services.c
index 7a22dce7..87feab2f 100644
--- a/bus/services.c
+++ b/bus/services.c
@@ -434,6 +434,70 @@ bus_registry_acquire_service (BusRegistry *registry,
}
dbus_bool_t
+bus_registry_release_service (BusRegistry *registry,
+ DBusConnection *connection,
+ const DBusString *service_name,
+ dbus_uint32_t *result,
+ BusTransaction *transaction,
+ DBusError *error)
+{
+ dbus_bool_t retval;
+ BusService *service;
+
+ retval = FALSE;
+
+ if (!_dbus_validate_bus_name (service_name, 0,
+ _dbus_string_get_length (service_name)))
+ {
+ dbus_set_error (error, DBUS_ERROR_INVALID_ARGS,
+ "Given bus name \"%s\" is not valid",
+ _dbus_string_get_const_data (service_name));
+
+ _dbus_verbose ("Attempt to release invalid service name\n");
+
+ goto out;
+ }
+
+ if (_dbus_string_get_byte (service_name, 0) == ':')
+ {
+ /* Not allowed; the base service name cannot be created or released */
+ dbus_set_error (error, DBUS_ERROR_INVALID_ARGS,
+ "Cannot release a service starting with ':' such as \"%s\"",
+ _dbus_string_get_const_data (service_name));
+
+ _dbus_verbose ("Attempt to release invalid base service name \"%s\"",
+ _dbus_string_get_const_data (service_name));
+
+ goto out;
+ }
+
+ service = bus_registry_lookup (registry, service_name);
+
+ if (service == NULL)
+ {
+ *result = DBUS_RELEASE_NAME_REPLY_NON_EXISTENT;
+ }
+ else if (!bus_service_has_owner (service, connection))
+ {
+ *result = DBUS_RELEASE_NAME_REPLY_NOT_OWNER;
+ }
+ else
+ {
+ if (!bus_service_remove_owner (service, connection,
+ transaction, error))
+ goto out;
+
+ _dbus_assert (!bus_service_has_owner (service, connection));
+ *result = DBUS_RELEASE_NAME_REPLY_RELEASED;
+ }
+
+ retval = TRUE;
+
+ out:
+ return retval;
+}
+
+dbus_bool_t
bus_registry_set_service_context_table (BusRegistry *registry,
DBusHashTable *table)
{