DBusConnection.callSync

Synchronously 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.

If the @parameters #GVariant is floating, it is consumed. This allows convenient 'inline' use of g_variant_new(), e.g.: |[<!-- language="C" --> g_dbus_connection_call_sync (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, &error); ]|

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

Parameters

busName string

a unique or well-known bus name or %NULL if @connection is not a message bus connection

objectPath string

path of remote object

interfaceName string

D-Bus interface to invoke method on

methodName string

the name of the method to invoke

parameters Variant

a #GVariant tuple with parameters for the method or %NULL if not passing parameters

replyType VariantType

the expected type of the reply, or %NULL

flags GDBusCallFlags

flags from the #GDBusCallFlags enumeration

timeoutMsec int

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

cancellable Cancellable

a #GCancellable or %NULL

Return Value

Type: Variant

%NULL if @error is set. Otherwise a non-floating #GVariant tuple with return values. Free with g_variant_unref().

Throws

GException on failure.

Meta

Since

2.26