Method

GioDBusConnectioncall

since: 2.26

Declaration [src]

void
g_dbus_connection_call (
  GDBusConnection* connection,
  const gchar* bus_name,
  const gchar* object_path,
  const gchar* interface_name,
  const gchar* method_name,
  GVariant* parameters,
  const GVariantType* reply_type,
  GDBusCallFlags flags,
  gint timeout_msec,
  GCancellable* cancellable,
  GAsyncReadyCallback callback,
  gpointer user_data
)

Description [src]

Asynchronously invokes the method_name method on the interface_name D-Bus interface on the remote object at object_path owned by bus_name.

If connection is closed 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 reply_type is non-NULL then the reply will be checked for having this type and an error will be raised if it does not match. Said another way, if you give a reply_type then any non-NULL return value will be of this type. Unless it’s G_VARIANT_TYPE_UNIT, the reply_type will be a tuple containing one or more values.

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

 g_dbus_connection_call (connection,
                         "org.freedesktop.StringThings",
                         "/org/freedesktop/StringThings",
                         "org.freedesktop.StringThings",
                         "TwoStrings",
                         g_variant_new ("(ss)",
                                        "Thing One",
                                        "Thing Two"),
                         NULL,
                         G_DBUS_CALL_FLAGS_NONE,
                         -1,
                         NULL,
                         (GAsyncReadyCallback) two_strings_done,
                         NULL);

This is an asynchronous method. When the operation is finished, callback will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call g_dbus_connection_call_finish() to get the result of the operation. See g_dbus_connection_call_sync() for the synchronous version of this function.

If callback is NULL then the D-Bus method call message will be sent with the G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set.

Available since: 2.26

This method completes asynchronously. Use g_dbus_connection_call_finish() inside the GAsyncReadyCallback to obtain the result of the operation.

Parameters

bus_name

Type: const gchar*

A unique or well-known bus name or NULL if connection is not a message bus connection.

The argument can be NULL.
The data is owned by the caller of the method.
The value is a NUL terminated UTF-8 string.
object_path

Type: const gchar*

Path of remote object.

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

Type: const gchar*

D-Bus interface to invoke method on.

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

Type: const gchar*

The name of the method to invoke.

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

Type: GVariant

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

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

Type: GVariantType

The expected type of the reply (which will be a tuple), or NULL.

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

Type: GDBusCallFlags

Flags from the GDBusCallFlags enumeration.

timeout_msec

Type: gint

The timeout in milliseconds, -1 to use the default timeout or G_MAXINT for no timeout.

cancellable

Type: GCancellable

A GCancellable or NULL.

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

Type: GAsyncReadyCallback

A GAsyncReadyCallback to call when the request is satisfied or NULL if you don’t care about the result of the method invocation.

The argument can be NULL.
user_data

Type: gpointer

The data to pass to callback.

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