- activation = bus_context_get_activation (registry->context);
- retval = bus_activation_send_pending_auto_activation_messages (activation,
- service,
- transaction,
- error);
- out:
- return retval;
+ *result = kdbus_request_name(connection, service_name, flags, sender_id);
+ if(*result == -EPERM)
+ {
+ dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
+ "Kdbus not allowed %s to own the service \"%s\"",
+ conn_unique_name, _dbus_string_get_const_data (service_name));
+ goto failed;
+ }
+ else if(*result < 0)
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED , "Name \"%s\" could not be acquired", name);
+ goto failed;
+ }
+
+ if((*result == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) || (*result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER))
+ {
+ service = bus_registry_lookup (registry, service_name);
+ if (service == NULL)
+ {
+ service = bus_registry_ensure (registry, service_name, phantom, flags,
+ transaction, error);
+ if (service == NULL)
+ goto failed2;
+ }
+ else
+ {
+ if (!bus_service_add_owner (service, phantom, flags, transaction, error))
+ goto failed2;
+ }
+
+ activation = bus_context_get_activation (registry->context);
+ retval = bus_activation_send_pending_auto_activation_messages (activation,
+ service,
+ transaction,
+ error);
+ }
+ else
+ retval = TRUE;
+
+ return retval;