dbus/bus driver.c, 1.74, 1.75 services.c, 1.31, 1.32 services.h,
1.13, 1.14
Robert McQueen
robot101 at freedesktop.org
Tue Nov 15 09:19:21 PST 2005
Update of /cvs/dbus/dbus/bus
In directory gabe:/tmp/cvs-serv7289/bus
Modified Files:
driver.c services.c services.h
Log Message:
2005-11-15 Robert McQueen <robot101 at 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.
Index: driver.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/driver.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- driver.c 7 Nov 2005 21:57:13 -0000 1.74
+++ driver.c 15 Nov 2005 17:19:19 -0000 1.75
@@ -470,7 +470,7 @@
DBusMessage *reply;
DBusString service_name;
const char *name;
- int service_reply;
+ dbus_uint32_t service_reply;
dbus_uint32_t flags;
dbus_bool_t retval;
BusRegistry *registry;
@@ -526,6 +526,67 @@
}
static dbus_bool_t
+bus_driver_handle_release_service (DBusConnection *connection,
+ BusTransaction *transaction,
+ DBusMessage *message,
+ DBusError *error)
+{
+ DBusMessage *reply;
+ DBusString service_name;
+ const char *name;
+ dbus_uint32_t service_reply;
+ dbus_bool_t retval;
+ BusRegistry *registry;
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ registry = bus_connection_get_registry (connection);
+
+ if (!dbus_message_get_args (message, error,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INVALID))
+ return FALSE;
+
+ _dbus_verbose ("Trying to release name %s\n", name);
+
+ retval = FALSE;
+ reply = NULL;
+
+ _dbus_string_init_const (&service_name, name);
+
+ if (!bus_registry_release_service (registry, connection,
+ &service_name, &service_reply,
+ transaction, error))
+ goto out;
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, &service_reply, DBUS_TYPE_INVALID))
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ if (!bus_transaction_send_from_driver (transaction, connection, reply))
+ {
+ BUS_SET_OOM (error);
+ goto out;
+ }
+
+ retval = TRUE;
+
+ out:
+ if (reply)
+ dbus_message_unref (reply);
+ return retval;
+}
+
+static dbus_bool_t
bus_driver_handle_service_exists (DBusConnection *connection,
BusTransaction *transaction,
DBusMessage *message,
@@ -1142,6 +1203,10 @@
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING,
DBUS_TYPE_UINT32_AS_STRING,
bus_driver_handle_acquire_service },
+ { "ReleaseName",
+ DBUS_TYPE_STRING_AS_STRING,
+ DBUS_TYPE_UINT32_AS_STRING,
+ bus_driver_handle_release_service },
{ "StartServiceByName",
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING,
DBUS_TYPE_UINT32_AS_STRING,
Index: services.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/services.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- services.c 13 Apr 2005 14:27:11 -0000 1.31
+++ services.c 15 Nov 2005 17:19:19 -0000 1.32
@@ -434,6 +434,70 @@
}
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)
{
Index: services.h
===================================================================
RCS file: /cvs/dbus/dbus/bus/services.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- services.h 7 Nov 2004 17:05:19 -0000 1.13
+++ services.h 15 Nov 2005 17:19:19 -0000 1.14
@@ -56,6 +56,12 @@
dbus_uint32_t *result,
BusTransaction *transaction,
DBusError *error);
+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 bus_registry_set_service_context_table (BusRegistry *registry,
DBusHashTable *table);
More information about the dbus-commit
mailing list