diff -u -r1.36 activation.c --- bus/activation.c 10 Aug 2004 03:06:59 -0000 1.36 +++ bus/activation.c 13 Dec 2004 14:24:18 -0000 @@ -1543,6 +1543,54 @@ return TRUE; } +dbus_bool_t +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 diff -u -r1.13 activation.h --- bus/activation.h 10 Aug 2004 03:06:59 -0000 1.13 +++ bus/activation.h 13 Dec 2004 14:24:18 -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 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, diff -u -r1.64 dispatch.c --- bus/dispatch.c 26 Nov 2004 01:53:13 -0000 1.64 +++ bus/dispatch.c 13 Dec 2004 14:24:19 -0000 @@ -1048,6 +1048,79 @@ * but the correct thing may include OOM errors. */ static dbus_bool_t +check_ListActivatableServices_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_ListActivatableServices_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, + "ListActivatableServices"); + + 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 ListActivatableServices"); + return TRUE; + } + + + if (pending_call == NULL) + { + _dbus_verbose ("did not get pending_call for ListActivatableServices"); + 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 ListActivatableServices"); + return FALSE; + } + + _dbus_verbose ("got reply for ListActivatableServices"); + 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 ("ListActivatableServices 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) { @@ -3129,6 +3202,9 @@ if (!check_double_hello_message (context, foo)) _dbus_assert_not_reached ("double hello message failed"); + if (!check_ListActivatableServices_message (context, foo)) + _dbus_assert_not_reached ("ListActivatableServices failed"); + if (!check_add_match_all (context, foo)) _dbus_assert_not_reached ("AddMatch message failed"); @@ -3167,7 +3243,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"); diff -u -r1.57 driver.c --- bus/driver.c 26 Nov 2004 01:53:13 -0000 1.57 +++ bus/driver.c 13 Dec 2004 14:24:19 -0000 @@ -419,6 +419,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, @@ -1014,6 +1068,7 @@ { "Hello", bus_driver_handle_hello }, { "ServiceExists", bus_driver_handle_service_exists }, { "ListServices", bus_driver_handle_list_services }, + { "ListActivatableServices", bus_driver_handle_list_activatable_services }, { "AddMatch", bus_driver_handle_add_match }, { "RemoveMatch", bus_driver_handle_remove_match }, { "GetServiceOwner", bus_driver_handle_get_service_owner }, diff -u -r1.27 services.c --- bus/services.c 9 Nov 2004 06:11:33 -0000 1.27 +++ bus/services.c 13 Dec 2004 14:24:19 -0000 @@ -260,6 +260,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 (!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, diff -u -r1.13 services.h --- bus/services.h 7 Nov 2004 17:05:19 -0000 1.13 +++ bus/services.h 13 Dec 2004 14:24:19 -0000 @@ -49,6 +49,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, diff -u -r1.1 make-dbus-glib-error-enum.sh --- dbus/make-dbus-glib-error-enum.sh 20 Jun 2004 15:28:15 -0000 1.1 +++ dbus/make-dbus-glib-error-enum.sh 13 Dec 2004 14:24:19 -0000 @@ -3,7 +3,7 @@ SRC=$1 DEST=$2 -function die() +function die { echo $1 1>&2 /bin/rm $DEST.tmp diff -u -r1.12 dbus-specification.xml --- doc/dbus-specification.xml 24 Sep 2004 10:43:35 -0000 1.12 +++ doc/dbus-specification.xml 13 Dec 2004 14:24:20 -0000 @@ -2028,6 +2028,37 @@ Returns a list of all existing services registered with the message bus. + + <literal>org.freedesktop.DBus.ListActivatableServices</literal> + + As a method: + + STRING_ARRAY ListActivatableServices () + + Reply arguments: + + + + + Argument + Type + Description + + + + + 0 + STRING_ARRAY + Array of strings where each string is the name of a service + + + + + + + Returns a list of activatable services registered with the message bus. + + <literal>org.freedesktop.DBus.ServiceExists</literal>