Index: bus/activation.c =================================================================== RCS file: /cvs/dbus/dbus/bus/activation.c,v retrieving revision 1.41 diff -u -a -r1.41 activation.c --- bus/activation.c 22 Nov 2005 20:37:00 -0000 1.41 +++ bus/activation.c 18 Jun 2006 19:11:06 -0000 @@ -1565,6 +1565,54 @@ return TRUE; } +dbus_bool_t +bus_get_activatable_services(BusActivation *activation, char ***listp, int *array_len) +{ + DBusHashIter iter; + int len, i, j; + char **activatable_list; + + _dbus_assert (activation); + + len = _dbus_hash_table_get_n_entries(activation->entries); + activatable_list = dbus_new (char *, len + 1); + + if (!activatable_list) + return FALSE; + + i = 0; + _dbus_hash_iter_init (activation->entries, &iter); + while (_dbus_hash_iter_next (&iter)) + { + BusActivationEntry *entry; + entry = _dbus_hash_iter_get_value (&iter); + + activatable_list[i] = _dbus_strdup(entry->name); + if (activatable_list[i] == NULL) + goto error; + + i++; + } + + activatable_list[i] = NULL; + + if (array_len) + *array_len = len; + + *listp = activatable_list; + + return TRUE; + + error: + for (j = 0; j < i; j++) + dbus_free (activatable_list[i]); + + dbus_free(activatable_list); + + return FALSE; +} + + #ifdef DBUS_BUILD_TESTS #include Index: bus/activation.h =================================================================== RCS file: /cvs/dbus/dbus/bus/activation.h,v retrieving revision 1.13 diff -u -a -r1.13 activation.h --- bus/activation.h 10 Aug 2004 03:06:59 -0000 1.13 +++ bus/activation.h 18 Jun 2006 19:11:06 -0000 @@ -26,6 +26,7 @@ #include #include +#include #include "bus.h" BusActivation* bus_activation_new (BusContext *context, @@ -45,7 +46,9 @@ const char *service_name, BusTransaction *transaction, DBusError *error); - +dbus_bool_t bus_get_activatable_services (BusActivation *activation, + char ***listp, + int *array_len); dbus_bool_t bus_activation_send_pending_auto_activation_messages (BusActivation *activation, BusService *service, BusTransaction *transaction, Index: bus/dispatch.c =================================================================== RCS file: /cvs/dbus/dbus/bus/dispatch.c,v retrieving revision 1.74 diff -u -a -r1.74 dispatch.c --- bus/dispatch.c 22 Nov 2005 20:37:00 -0000 1.74 +++ bus/dispatch.c 18 Jun 2006 19:53:27 -0000 @@ -1051,6 +1051,79 @@ * but the correct thing may include OOM errors. */ static dbus_bool_t +check_ListActivatableNames_message (BusContext *context, + DBusConnection *connection) +{ + DBusMessage *message; + DBusMessage *reply; + DBusPendingCall *pending_call; + DBusMessageIter iter; + DBusMessageIter array_iter; + DBusError error; + int array_type; + + dbus_error_init (&error); + + _dbus_verbose ("check_ListActivatableNames_message for %p\n", connection); + + message = dbus_message_new_method_call (DBUS_SERVICE_ORG_FREEDESKTOP_DBUS, + DBUS_PATH_ORG_FREEDESKTOP_DBUS, + DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, + "ListActivatableNames"); + + if (message == NULL) + return TRUE; + + if (!dbus_connection_send_with_reply (connection, message, &pending_call, -1)) + { + dbus_message_unref (message); + _dbus_verbose ("did not send ListActivatableNames"); + return TRUE; + } + + + if (pending_call == NULL) + { + _dbus_verbose ("did not get pending_call for ListActivatableNames"); + return TRUE; + } + + dbus_pending_call_block(pending_call); + + reply = dbus_pending_call_get_reply(pending_call); + if (reply == NULL) + { + _dbus_verbose ("did not get reply for ListActivatableNames"); + return FALSE; + } + + _dbus_verbose ("got reply for ListActivatableNames"); + dbus_message_iter_init(reply, &iter); + if ((dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) && + (dbus_message_iter_get_array_type(&iter) != DBUS_TYPE_STRING)) + { + _dbus_verbose ("malformed reply"); + return FALSE; + } + + dbus_message_iter_init_array_iterator(&iter, &array_iter, &array_type); + + do { + _dbus_verbose("Found activatable service: %s",dbus_message_iter_get_string(&array_iter)); + } while (dbus_message_iter_next(&array_iter)); + + dbus_message_unref (message); + dbus_message_unref (reply); + dbus_pending_call_unref(pending_call); + dbus_error_free(&error); + _dbus_verbose ("ListActivatableNames check finished"); + return TRUE; +} + +/* returns TRUE if the correct thing happens, + * but the correct thing may include OOM errors. + */ +static dbus_bool_t check_get_connection_unix_user (BusContext *context, DBusConnection *connection) { @@ -3587,6 +3660,9 @@ if (!check_double_hello_message (context, foo)) _dbus_assert_not_reached ("double hello message failed"); + if (!check_ListActivatableNames_message (context, foo)) + _dbus_assert_not_reached ("ListActivatableNames failed"); + if (!check_add_match_all (context, foo)) _dbus_assert_not_reached ("AddMatch message failed"); @@ -3625,7 +3701,7 @@ if (!check_get_connection_unix_process_id (context, baz)) _dbus_assert_not_reached ("GetConnectionUnixProcessID message failed"); - + if (!check_no_leftovers (context)) { _dbus_warn ("Messages were left over after setting up initial connections"); Index: bus/driver.c =================================================================== RCS file: /cvs/dbus/dbus/bus/driver.c,v retrieving revision 1.76 diff -u -a -r1.76 driver.c --- bus/driver.c 22 Nov 2005 20:37:00 -0000 1.76 +++ bus/driver.c 18 Jun 2006 19:22:37 -0000 @@ -460,6 +460,60 @@ } static dbus_bool_t +bus_driver_handle_list_activatable_services (DBusConnection *connection, + BusTransaction *transaction, + DBusMessage *message, + DBusError *error) +{ + DBusMessage *reply; + int len; + char **services; + BusRegistry *registry; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + registry = bus_connection_get_registry (connection); + + reply = dbus_message_new_method_return (message); + if (reply == NULL) + { + BUS_SET_OOM (error); + return FALSE; + } + + if (!bus_registry_list_activatable_services (registry, &services, &len)) + { + dbus_message_unref (reply); + BUS_SET_OOM (error); + return FALSE; + } + + if (!dbus_message_append_args (reply, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, services, len, + DBUS_TYPE_INVALID)) + { + dbus_free_string_array (services); + dbus_message_unref (reply); + BUS_SET_OOM (error); + return FALSE; + } + + dbus_free_string_array (services); + + if (!bus_transaction_send_from_driver (transaction, connection, reply)) + { + dbus_message_unref (reply); + BUS_SET_OOM (error); + return FALSE; + } + else + { + dbus_message_unref (reply); + return TRUE; + } +} + +static dbus_bool_t bus_driver_handle_acquire_service (DBusConnection *connection, BusTransaction *transaction, DBusMessage *message, @@ -1328,6 +1382,10 @@ "", DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING, bus_driver_handle_list_services }, + { "ListActivatableNames", + "", + DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING, + bus_driver_handle_list_activatable_services }, { "AddMatch", DBUS_TYPE_STRING_AS_STRING, "", Index: bus/services.c =================================================================== RCS file: /cvs/dbus/dbus/bus/services.c,v retrieving revision 1.33 diff -u -a -r1.33 services.c --- bus/services.c 22 Nov 2005 20:37:00 -0000 1.33 +++ bus/services.c 18 Jun 2006 19:11:06 -0000 @@ -373,6 +373,31 @@ } dbus_bool_t +bus_registry_list_activatable_services (BusRegistry *registry, + char ***listp, + int *array_len) +{ + BusActivation *activation; + char **activatable_list; + int activatable_list_len; + + activation = bus_context_get_activation (registry->context); + + if (!activation) + return FALSE; + + if (!bus_get_activatable_services(activation,&activatable_list,&activatable_list_len)) + return FALSE; + + if (array_len) + *array_len = activatable_list_len; + + *listp = activatable_list; + return TRUE; +} + + +dbus_bool_t bus_registry_acquire_service (BusRegistry *registry, DBusConnection *connection, const DBusString *service_name, Index: bus/services.h =================================================================== RCS file: /cvs/dbus/dbus/bus/services.h,v retrieving revision 1.15 diff -u -a -r1.15 services.h --- bus/services.h 22 Nov 2005 20:37:00 -0000 1.15 +++ bus/services.h 18 Jun 2006 19:55:00 -0000 @@ -50,6 +50,9 @@ dbus_bool_t bus_registry_list_services (BusRegistry *registry, char ***listp, int *array_len); +dbus_bool_t bus_registry_list_activatable_services (BusRegistry *registry, + char ***listp, + int *array_len); dbus_bool_t bus_registry_acquire_service (BusRegistry *registry, DBusConnection *connection, const DBusString *service_name, Index: dbus/make-dbus-glib-error-enum.sh =================================================================== RCS file: /cvs/dbus/dbus/dbus/make-dbus-glib-error-enum.sh,v retrieving revision 1.3 diff -u -a -r1.3 make-dbus-glib-error-enum.sh --- dbus/make-dbus-glib-error-enum.sh 26 Jun 2005 17:02:09 -0000 1.3 +++ dbus/make-dbus-glib-error-enum.sh 18 Jun 2006 19:32:19 -0000 @@ -3,7 +3,7 @@ SRC=$1 DEST=$2 -die() +die { echo $1 1>&2 /bin/rm $DEST.tmp Index: doc/dbus-specification.xml =================================================================== RCS file: /cvs/dbus/dbus/doc/dbus-specification.xml,v retrieving revision 1.39 diff -u -a -r1.39 dbus-specification.xml --- doc/dbus-specification.xml 3 May 2006 22:56:35 -0000 1.39 +++ doc/dbus-specification.xml 18 Jun 2006 19:31:11 -0000 @@ -3267,6 +3267,37 @@ Returns a list of all currently-owned names on the bus. + + <literal>org.freedesktop.DBus.ListActivatableNames</literal> + + As a method: + + STRING_ARRAY ListActivatableNames () + + Reply arguments: + + + + + Argument + Type + Description + + + + + 0 + STRING_ARRAY + Array of strings where each string is a bus name + + + + + + + Returns a list of all activatable names on the bus. + + <literal>org.freedesktop.DBus.NameHasOwner</literal> Index: mono/BusDriver.cs =================================================================== RCS file: /cvs/dbus/dbus/mono/BusDriver.cs,v retrieving revision 1.4 diff -u -a -r1.4 BusDriver.cs --- mono/BusDriver.cs 13 Mar 2005 02:15:09 -0000 1.4 +++ mono/BusDriver.cs 18 Jun 2006 19:46:34 -0000 @@ -14,6 +14,9 @@ public abstract string[] ListNames (); [Method] + public abstract string[] ListActivatableNames (); + + [Method] public abstract string GetNameOwner (string name); [Method] Index: qt/src/qdbusbus.cpp =================================================================== RCS file: /cvs/dbus/dbus/qt/src/qdbusbus.cpp,v retrieving revision 1.2 diff -u -a -r1.2 qdbusbus.cpp --- qt/src/qdbusbus.cpp 5 Jun 2006 18:13:07 -0000 1.2 +++ qt/src/qdbusbus.cpp 18 Jun 2006 19:42:58 -0000 @@ -151,6 +151,15 @@ } /*! + \fn QDBusBusService::listACtivatableNames() + Lists all activatables names currently existing on the bus. +*/ +QDBusReply QDBusBusService::ListActivatableNames() +{ + return call(QLatin1String("ListActivatableNames")); +} + +/*! \fn QDBusBusService::listQueuedOwners(const QString &serviceName) Returns a list of all unique connection names in queue for the service name \a service. */ Index: qt/src/qdbusbus.h =================================================================== RCS file: /cvs/dbus/dbus/qt/src/qdbusbus.h,v retrieving revision 1.3 diff -u -a -r1.3 qdbusbus.h --- qt/src/qdbusbus.h 12 Jun 2006 09:18:45 -0000 1.3 +++ qt/src/qdbusbus.h 18 Jun 2006 19:45:13 -0000 @@ -90,6 +90,7 @@ QDBusReply ReloadConfig(); QDBusReply ListNames(); + QDBusReply ListActivatableNames(); QDBusReply NameHasOwner(const QString &service); QDBusReply GetNameOwner(const QString &name); @@ -121,6 +122,8 @@ QDBusReply listNames() { return ListNames(); } + QDBusReply listActivatableNames() + { return ListActivatableNames(); } QDBusReply nameHasOwner(const QString &serviceName) { return NameHasOwner(serviceName); }