Package ch.bailu.gtk.gio
Class DBusMethodInvocation
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gio.DBusMethodInvocation
- All Implemented Interfaces:
PointerInterface
Instances of the #GDBusMethodInvocation class are used when
handling D-Bus method calls. It provides a way to asynchronously
return results and errors.
The normal way to obtain a #GDBusMethodInvocation object is to receive
it as an argument to the handle_method_call() function in a
#GDBusInterfaceVTable that was passed to g_dbus_connection_register_object().
handling D-Bus method calls. It provides a way to asynchronously
return results and errors.
The normal way to obtain a #GDBusMethodInvocation object is to receive
it as an argument to the handle_method_call() function in a
#GDBusInterfaceVTable that was passed to g_dbus_connection_register_object().
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassHandler
Gets the #GDBusConnection the method was invoked on.static int
Gets the name of the D-Bus interface the method was invoked on.Gets the #GDBusMessage for the method invocation.Gets information about the method call, if any.Gets the name of the method that was invoked.Gets the object path the method was invoked on.Gets the parameters of the method invocation.static long
static TypeSystem.TypeSize
Gets information about the property that this method call is for, if
any.Gets the bus name that invoked the method.static long
static TypeSystem.TypeSize
Gets the @user_data #gpointer passed to g_dbus_connection_register_object().void
returnDbusError
(Str error_name, Str error_message) Finishes handling a D-Bus method call by returning an error.void
returnDbusError
(String error_name, String error_message) Finishes handling a D-Bus method call by returning an error.void
returnError
(int domain, int code, Str format, Object... _elipse) Finishes handling a D-Bus method call by returning an error.void
returnError
(int domain, int code, String format, Object... _elipse) Finishes handling a D-Bus method call by returning an error.void
returnErrorLiteral
(int domain, int code, Str message) Like g_dbus_method_invocation_return_error() but without printf()-style formatting.void
returnErrorLiteral
(int domain, int code, String message) Like g_dbus_method_invocation_return_error() but without printf()-style formatting.void
returnGerror
(Error error) Like g_dbus_method_invocation_return_error() but takes a #GError
instead of the error domain, error code and message.void
returnValue
(Variant parameters) Finishes handling a D-Bus method call by returning @parameters.void
returnValueWithUnixFdList
(Variant parameters, UnixFDList fd_list) Like g_dbus_method_invocation_return_value() but also takes a #GUnixFDList.void
Like g_dbus_method_invocation_return_gerror() but takes ownership
of @error so the caller does not need to free it.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
DBusMethodInvocation
-
-
Method Details
-
getClassHandler
-
getConnection
Gets the #GDBusConnection the method was invoked on.- Returns:
- A #GDBusConnection. Do not free, it is owned by @invocation.
-
getInterfaceName
Gets the name of the D-Bus interface the method was invoked on.
If this method call is a property Get, Set or GetAll call that has
been redirected to the method call handler then
"org.freedesktop.DBus.Properties" will be returned. See
#GDBusInterfaceVTable for more information.- Returns:
- A string. Do not free, it is owned by @invocation.
-
getMessage
Gets the #GDBusMessage for the method invocation. This is useful if
you need to use low-level protocol features, such as UNIX file
descriptor passing, that cannot be properly expressed in the
#GVariant API.
See this [server][gdbus-server] and [client][gdbus-unix-fd-client]
for an example of how to use this low-level API to send and receive
UNIX file descriptors.- Returns:
- #GDBusMessage. Do not free, it is owned by @invocation.
-
getMethodInfo
Gets information about the method call, if any.
If this method invocation is a property Get, Set or GetAll call that
has been redirected to the method call handler then %NULL will be
returned. See g_dbus_method_invocation_get_property_info() and
#GDBusInterfaceVTable for more information.- Returns:
- A #GDBusMethodInfo or %NULL. Do not free, it is owned by @invocation.
-
getMethodName
Gets the name of the method that was invoked.- Returns:
- A string. Do not free, it is owned by @invocation.
-
getObjectPath
Gets the object path the method was invoked on.- Returns:
- A string. Do not free, it is owned by @invocation.
-
getParameters
Gets the parameters of the method invocation. If there are no input
parameters then this will return a GVariant with 0 children rather than NULL.- Returns:
- A #GVariant tuple. Do not unref this because it is owned by @invocation.
-
getPropertyInfo
Gets information about the property that this method call is for, if
any.
This will only be set in the case of an invocation in response to a
property Get or Set call that has been directed to the method call
handler for an object on account of its property_get() or
property_set() vtable pointers being unset.
See #GDBusInterfaceVTable for more information.
If the call was GetAll, %NULL will be returned.- Returns:
- a #GDBusPropertyInfo or %NULL
-
getSender
Gets the bus name that invoked the method.- Returns:
- A string. Do not free, it is owned by @invocation.
-
getUserData
Gets the @user_data #gpointer passed to g_dbus_connection_register_object().- Returns:
- A #gpointer.
-
returnDbusError
Finishes handling a D-Bus method call by returning an error.
This method will take ownership of @invocation. See
#GDBusInterfaceVTable for more information about the ownership of
@invocation.- Parameters:
error_name
- A valid D-Bus error name.error_message
- A valid D-Bus error message.
-
returnDbusError
Finishes handling a D-Bus method call by returning an error.
This method will take ownership of @invocation. See
#GDBusInterfaceVTable for more information about the ownership of
@invocation.- Parameters:
error_name
- A valid D-Bus error name.error_message
- A valid D-Bus error message.
-
returnError
Finishes handling a D-Bus method call by returning an error.
See g_dbus_error_encode_gerror() for details about what error name
will be returned on the wire. In a nutshell, if the given error is
registered using g_dbus_error_register_error() the name given
during registration is used. Otherwise, a name of the form
`org.gtk.GDBus.UnmappedGError.Quark...` is used. This provides
transparent mapping of #GError between applications using GDBus.
If you are writing an application intended to be portable,
always register errors with g_dbus_error_register_error()
or use g_dbus_method_invocation_return_dbus_error().
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 free @invocation but otherwise do nothing (as per
the recommendations of the D-Bus specification).- Parameters:
domain
- A #GQuark for the #GError error domain.code
- The error code.format
- printf()-style format._elipse
- Parameters for @format.
-
returnError
Finishes handling a D-Bus method call by returning an error.
See g_dbus_error_encode_gerror() for details about what error name
will be returned on the wire. In a nutshell, if the given error is
registered using g_dbus_error_register_error() the name given
during registration is used. Otherwise, a name of the form
`org.gtk.GDBus.UnmappedGError.Quark...` is used. This provides
transparent mapping of #GError between applications using GDBus.
If you are writing an application intended to be portable,
always register errors with g_dbus_error_register_error()
or use g_dbus_method_invocation_return_dbus_error().
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 free @invocation but otherwise do nothing (as per
the recommendations of the D-Bus specification).- Parameters:
domain
- A #GQuark for the #GError error domain.code
- The error code.format
- printf()-style format._elipse
- Parameters for @format.
-
returnErrorLiteral
Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
This method will take ownership of @invocation. See
#GDBusInterfaceVTable for more information about the ownership of
@invocation.- Parameters:
domain
- A #GQuark for the #GError error domain.code
- The error code.message
- The error message.
-
returnErrorLiteral
Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
This method will take ownership of @invocation. See
#GDBusInterfaceVTable for more information about the ownership of
@invocation.- Parameters:
domain
- A #GQuark for the #GError error domain.code
- The error code.message
- The error message.
-
returnGerror
Like g_dbus_method_invocation_return_error() but takes a #GError
instead of the error domain, error code and message.
This method will take ownership of @invocation. See
#GDBusInterfaceVTable for more information about the ownership of
@invocation.- Parameters:
error
- A #GError.
-
returnValue
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.
<!-- language="C" --> 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).- Parameters:
parameters
- A #GVariant tuple with out parameters for the method or %NULL if not passing any parameters.
-
returnValueWithUnixFdList
Like g_dbus_method_invocation_return_value() but also takes a #GUnixFDList.
This method is only available on UNIX.
This method will take ownership of @invocation. See
#GDBusInterfaceVTable for more information about the ownership of
@invocation.- Parameters:
parameters
- A #GVariant tuple with out parameters for the method or %NULL if not passing any parameters.fd_list
- A #GUnixFDList or %NULL.
-
takeError
Like g_dbus_method_invocation_return_gerror() but takes ownership
of @error so the caller does not need to free it.
This method will take ownership of @invocation. See
#GDBusInterfaceVTable for more information about the ownership of
@invocation.- Parameters:
error
- A #GError.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-