summaryrefslogtreecommitdiff
path: root/bus/driver.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/driver.c
parentd4595960e9edc679cb2656d3ff59d2f899b0f16b (diff)
downloaddbus-b5e4d26adec0a9ec37a1bae7aeb5a68344b78ebf.tar.gz
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/driver.c')
-rw-r--r--bus/driver.c67
1 files changed, 66 insertions, 1 deletions
diff --git a/bus/driver.c b/bus/driver.c
index a6c4faff..bc63e7c2 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -470,7 +470,7 @@ bus_driver_handle_acquire_service (DBusConnection *connection,
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 @@ bus_driver_handle_acquire_service (DBusConnection *connection,
}
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 @@ struct
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,