diff options
author | Robert McQueen <robot101@debian.org> | 2005-11-15 17:19:19 +0000 |
---|---|---|
committer | Robert McQueen <robot101@debian.org> | 2005-11-15 17:19:19 +0000 |
commit | b5e4d26adec0a9ec37a1bae7aeb5a68344b78ebf (patch) | |
tree | 66eb4e5670d802aee918f8bd3c4674482de0990c /dbus | |
parent | d4595960e9edc679cb2656d3ff59d2f899b0f16b (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 'dbus')
-rw-r--r-- | dbus/dbus-bus.c | 65 | ||||
-rw-r--r-- | dbus/dbus-bus.h | 3 | ||||
-rw-r--r-- | dbus/dbus-shared.h | 5 |
3 files changed, 73 insertions, 0 deletions
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 107fde90..9016f1b1 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -777,6 +777,71 @@ dbus_bus_request_name (DBusConnection *connection, return result; } +int +dbus_bus_release_name (DBusConnection *connection, + const char *name, + DBusError *error) +{ + DBusMessage *message, *reply; + dbus_uint32_t result; + + _dbus_return_val_if_fail (connection != NULL, 0); + _dbus_return_val_if_fail (name != NULL, 0); + _dbus_return_val_if_fail (_dbus_check_is_valid_bus_name (name), 0); + _dbus_return_val_if_error_is_set (error, 0); + + message = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "ReleaseName"); + + if (message == NULL) + { + _DBUS_SET_OOM (error); + return -1; + } + + if (!dbus_message_append_args (message, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID)) + { + dbus_message_unref (message); + _DBUS_SET_OOM (error); + return -1; + } + + reply = dbus_connection_send_with_reply_and_block (connection, message, -1, + error); + + dbus_message_unref (message); + + if (reply == NULL) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + return -1; + } + + if (dbus_set_error_from_message (error, reply)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + dbus_message_unref (reply); + return -1; + } + + if (!dbus_message_get_args (reply, error, + DBUS_TYPE_UINT32, &result, + DBUS_TYPE_INVALID)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + dbus_message_unref (reply); + return -1; + } + + dbus_message_unref (reply); + + return result; +} + /** * Checks whether a certain name has an owner. * diff --git a/dbus/dbus-bus.h b/dbus/dbus-bus.h index 24470672..2329e138 100644 --- a/dbus/dbus-bus.h +++ b/dbus/dbus-bus.h @@ -48,6 +48,9 @@ int dbus_bus_request_name (DBusConnection *connection, const char *name, unsigned int flags, DBusError *error); +int dbus_bus_release_name (DBusConnection *connection, + const char *name, + DBusError *error); dbus_bool_t dbus_bus_name_has_owner (DBusConnection *connection, const char *name, DBusError *error); diff --git a/dbus/dbus-shared.h b/dbus/dbus-shared.h index a1f49a02..a8519c13 100644 --- a/dbus/dbus-shared.h +++ b/dbus/dbus-shared.h @@ -77,6 +77,11 @@ typedef enum #define DBUS_REQUEST_NAME_REPLY_EXISTS 3 #define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4 +/* Replies to releasing a name */ +#define DBUS_RELEASE_NAME_REPLY_RELEASED 1 +#define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 +#define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 + /* Replies to service starts */ #define DBUS_START_REPLY_SUCCESS 1 #define DBUS_START_REPLY_ALREADY_RUNNING 2 |