Method

GioDBusProxycall_sync

since: 2.26

Declaration

GVariant*
g_dbus_proxy_call_sync (
  GDBusProxy* proxy,
  const gchar* method_name,
  GVariant* parameters,
  GDBusCallFlags flags,
  gint timeout_msec,
  GCancellable* cancellable,
  GError** error
)

Description

Synchronously invokes the method_name method on proxy.

If method_name contains any dots, then name is split into interface and method name parts. This allows using proxy for invoking methods on other interfaces.

If the GDBusConnection associated with proxy is disconnected then the operation will fail with G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will fail with G_IO_ERROR_CANCELLED. If parameters contains a value not compatible with the D-Bus protocol, the operation fails with G_IO_ERROR_INVALID_ARGUMENT.

If the parameters GVariant is floating, it is consumed. This allows convenient ‘inline’ use of g_variant_new(), e.g.:

 g_dbus_proxy_call_sync (proxy,
                         "TwoStrings",
                         g_variant_new ("(ss)",
                                        "Thing One",
                                        "Thing Two"),
                         G_DBUS_CALL_FLAGS_NONE,
                         -1,
                         NULL,
                         &error);

The calling thread is blocked until a reply is received. See g_dbus_proxy_call() for the asynchronous version of this method.

If proxy has an expected interface (see GDBusProxy:g-interface-info) and method_name is referenced by it, then the return value is checked against the return type.

Available since: 2.26

Parameters

method_name

Type: const gchar*

Name of method to invoke.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
parameters

Type: GVariant

A GVariant tuple with parameters for the signal or NULL if not passing parameters.

The argument can be NULL.
The data is owned by the caller of the function.
flags

Type: GDBusCallFlags

Flags from the GDBusCallFlags enumeration.

timeout_msec

Type: gint

The timeout in milliseconds (with G_MAXINT meaning “infinite”) or -1 to use the proxy default timeout.

cancellable

Type: GCancellable

A GCancellable or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will left initialized to NULL by the method if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: GVariant

NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref().

The caller of the method takes ownership of the data, and is responsible for freeing it.