I have to deal with a binary blob dbus service/server which I need to connect to via dbus (session).
The introspection of the interface is as following (obtained via gdbus-codegen
).
We register a function to the remote so we get notified if a message has been received by the remote which is called message_handler
. That happens as a response on a send_message
command which I pass via dbus, but that works (and is thus not shown).
In a java example it is done via
dbus_connection.exportObject("/", new DBusInterfaceDerivedClassFoo());
and shows in bustle
as (no interface) message_handler
and everything works as expected.
In the bare logs say <none>
instead of (no interface)
.
According to gdbus-monitor - interface `<none>` this is caused by the fact that gdbus-monitor
detects interface
being NULL
How to register/export a object with interface equal NULL using GDBus
?
Things tried so far marked as comments in the code:
Code chunk:
static gchar iface_xml[] =
"<node name='/'>"
" <interface name='bar.long.long.name.rxobj'>"
" <method name='message_handler' >"
" <arg type='s' direction='in'/>"
" </method>"
" <method name=isRemote' >"
" <arg type='b' direction='out'/>"
" </method>"
" </interface>"
" <interface name='org.freedesktop.DBus.Introspectable'>"
" <method name='Introspect'>"
" <arg type='s' direction='out'/>"
" </method>"
" </interface>"
" <interface name='org.freedesktop.DBus.Peer'>"
" <method name='Ping'>"
" </method>"
" </interface>"
"</node>";
GError *error = NULL;
GDBusConnection *con = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert (!error);
GDBusNodeInfo *node_info = g_dbus_node_info_new_for_xml (iface_xml, &error);
// also tried ...de_info = NULL; // - crash, see below
g_assert (!error);
GDBusInterfaceInfo *interface_info = g_dbus_node_info_lookup_interface (node_info,
"bar.long.long.name.rxobj");
// also tried ...okup_interface (node_info, NULL); - obviously wrong
g_assert (interface_info);
guint id = g_dbus_connection_register_object (con,
(const gchar*)"/",
// also tried node_info->interfaces[0]
// also tried "" - crash
// also tried "\0" - crash
// also tried NULL - assert failure
interface_info,
&vtable, /*we never enter any of the callbacks*/
NULL,/*user_data*/
(GDestroyNotify)NULL,
&error);
g_assert (!error);
GMainLoop *loop = g_main_loop_new (...);
g_main_loop_run (loop);
...
No matter of what I commented out I never even entered the callbacks specified in vtable
.
Thanks in advance for any tips.
Additional info: The remote uses qtdbus as far as I can say if that does matter.