Method
GioDBusConnectionregister_object
since: 2.26
Declaration [src]
guint
g_dbus_connection_register_object (
GDBusConnection* connection,
const gchar* object_path,
GDBusInterfaceInfo* interface_info,
const GDBusInterfaceVTable* vtable,
gpointer user_data,
GDestroyNotify user_data_free_func,
GError** error
)
Description [src]
Registers callbacks for exported objects at object_path
with the
D-Bus interface that is described in interface_info
.
Calls to functions in vtable
(and user_data_free_func
) will happen
in the
[thread-default main context][g-main-context-push-thread-default]
of the thread you are calling this method from.
Note that all GVariant
values passed to functions in vtable
will match
the signature given in interface_info
- if a remote caller passes
incorrect values, the org.freedesktop.DBus.Error.InvalidArgs
is returned to the remote caller.
Additionally, if the remote caller attempts to invoke methods or
access properties not mentioned in interface_info
the
org.freedesktop.DBus.Error.UnknownMethod
resp.
org.freedesktop.DBus.Error.InvalidArgs
errors
are returned to the caller.
It is considered a programming error if the
GDBusInterfaceGetPropertyFunc
function in vtable
returns a
GVariant
of incorrect type.
If an existing callback is already registered at object_path
and
interface_name
, then error
is set to G_IO_ERROR_EXISTS
.
GDBus automatically implements the standard D-Bus interfaces org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable and org.freedesktop.Peer, so you don’t have to implement those for the objects you export. You can implement org.freedesktop.DBus.Properties yourself, e.g. to handle getting and setting of properties asynchronously.
Note that the reference count on interface_info
will be
incremented by 1 (unless allocated statically, e.g. if the
reference count is -1, see g_dbus_interface_info_ref()) for as long
as the object is exported. Also note that vtable
will be copied.
See this [server][gdbus-server] for an example of how to use this method.
Available since: 2.26
The implementation of this method is provided by g_dbus_connection_register_object_with_closures()
in language bindings.
Parameters
object_path
-
Type:
const gchar*
The object path to register at.
The data is owned by the caller of the method. The value is a NUL terminated UTF-8 string. interface_info
-
Type:
GDBusInterfaceInfo
Introspection data for the interface.
The data is owned by the caller of the method. vtable
-
Type:
GDBusInterfaceVTable
A
GDBusInterfaceVTable
to call into orNULL
.The argument can be NULL
.The data is owned by the caller of the method. user_data
-
Type:
gpointer
Data to pass to functions in
vtable
.The argument can be NULL
.The data is owned by the caller of the method. user_data_free_func
-
Type:
GDestroyNotify
Function to call when the object path is unregistered.
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 aNULL
GError*
.The argument will be 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.