我必须处理我需要通过 dbus(会话)连接到的二进制 blob dbus 服务/服务器。
接口的自省如下(通过 获取gdbus-codegen
)。我们向远程注册了一个函数,以便在远程接收到被调用的消息时收到通知message_handler
。这发生在send_message
我通过 dbus 传递的命令的响应中,但这有效(因此未显示)。
在 java 示例中,它是通过
dbus_connection.exportObject("/", new DBusInterfaceDerivedClassFoo());
并显示bustle
为(no interface) message_handler
,一切都按预期工作。
在裸日志中说<none>
而不是(no interface)
.
根据gdbus-monitor - interface `<none>`,这是由于gdbus-monitor
检测到interface
正在NULL
如何使用等于 NULL 的接口注册/导出对象GDBus
?
到目前为止尝试的事情在代码中标记为注释:
代码块:
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);
...
无论我注释了什么,我什至都没有输入vtable
.
提前感谢您的任何提示。
附加信息:据我所知,遥控器使用 qtdbus 是否重要。