Gio.DBusMethodInvocation.return_value

### Method

# Gio DBusMethodInvocationreturn_value

since: 2.26

#### Declaration

    void
    g_dbus_method_invocation_return_value (
      GDBusMethodInvocation* invocation,
      GVariant* parameters
    )

#### Description

Finishes handling a D-Bus method call by returning `parameters`. If the `parameters` GVariant is floating, it is consumed.

It is an error if `parameters` is not of the right format: it must be a tuple containing the out-parameters of the D-Bus method. Even if the method has a single out-parameter, it must be contained in a tuple. If the method has no out-parameters, `parameters` may be `NULL` or an empty tuple.

    GDBusMethodInvocation *invocation = some_invocation;
    g_autofree gchar *result_string = NULL;
    g_autoptr (GError) error = NULL;

    result_string = calculate_result (&error);

    if (error != NULL)
      g_dbus_method_invocation_return_gerror (invocation, error);
    else
      g_dbus_method_invocation_return_value (invocation,
                                             g_variant_new ("(s)", result_string));

    // Do not free `invocation` here; returning a value does that

This method will take ownership of `invocation`. See `GDBusInterfaceVTable` for more information about the ownership of `invocation`.

Since 2.48, if the method call requested for a reply not to be sent then this call will sink `parameters` and free `invocation`, but otherwise do nothing (as per the recommendations of the D-Bus specification).

Available since: 2.26

#### Parameters

`parameters`

  Type: `GVariant`

  A `GVariant` tuple with out parameters for the method or `NULL` if not passing any parameters.

  The argument can be `NULL`.
  The data is owned by the caller of the method.