DBusConnection.callSync

glib.variant.Variant callSync(string busName, string objectPath, string interfaceName, string methodName, glib.variant.Variant parameters, glib.variant_type.VariantType replyType, gio.types.DBusCallFlags flags, int timeoutMsec, gio.cancellable.Cancellable cancellable = null)

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 gio.types.IOErrorEnum.Closed. If cancellable is canceled, the operation will fail with gio.types.IOErrorEnum.Cancelled. If parameters contains a value not compatible with the D-Bus protocol, the operation fails with gio.types.IOErrorEnum.InvalidArgument.

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 glib.variant.Variant.new_, e.g.:

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 gio.dbus_connection.DBusConnection.call for the asynchronous version of this method.

Parameters

busNamea unique or well-known bus name or null if connection is not a message bus connection
objectPathpath of remote object
interfaceNameD-Bus interface to invoke method on
methodNamethe name of the method to invoke
parametersa #GVariant tuple with parameters for the method or null if not passing parameters
replyTypethe expected type of the reply, or null
flagsflags from the #GDBusCallFlags enumeration
timeoutMsecthe timeout in milliseconds, -1 to use the default timeout or G_MAXINT for no timeout
cancellablea #GCancellable or null

Returns

null if error is set. Otherwise a non-floating

#GVariant tuple with return values. Free with glib.variant.Variant.unref.

Throws