From b5e4d26adec0a9ec37a1bae7aeb5a68344b78ebf Mon Sep 17 00:00:00 2001 From: Robert McQueen Date: Tue, 15 Nov 2005 17:19:19 +0000 Subject: 2005-11-15 Robert McQueen * 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. --- python/dbus_bindings.pyx | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'python/dbus_bindings.pyx') diff --git a/python/dbus_bindings.pyx b/python/dbus_bindings.pyx index 75e448ee..8b1b221b 100644 --- a/python/dbus_bindings.pyx +++ b/python/dbus_bindings.pyx @@ -1710,10 +1710,10 @@ def bus_get_unix_user(Connection connection, service_name): return retval -#These are defines, not enums so they aren't auto generated -DBUS_START_REPLY_SUCCESS = 0 -DBUS_START_REPLY_ALREADY_RUNNING = 1 - +# these are defines, not enums, so they aren't auto generated +DBUS_START_REPLY_SUCCESS = 0 +DBUS_START_REPLY_ALREADY_RUNNING = 1 + def bus_start_service_by_name(Connection connection, service_name, flags=0): cdef DBusError error dbus_error_init(&error) @@ -1771,9 +1771,30 @@ def bus_request_name(Connection connection, service_name, flags=0): errormsg = error.message dbus_error_free(&error) raise DBusException, errormsg - + return retval - + +RELEASE_NAME_REPLY_RELEASED = 1 +RELEASE_NAME_REPLY_NON_EXISTENT = 2 +RELEASE_NAME_REPLY_NOT_OWNER = 3 + +def bus_release_name(Connection connection, service_name): + cdef DBusError error + dbus_error_init(&error) + cdef int retval + cdef DBusConnection *conn + + conn = connection._get_conn() + retval = dbus_bus_release_name(conn, + service_name, + &error) + if dbus_error_is_set(&error): + errormsg = error.message + dbus_error_free(&error) + raise DBusException, errormsg + + return retval + def bus_name_has_owner(Connection connection, service_name): cdef DBusError error dbus_error_init(&error) -- cgit