gpt4 book ai didi

c - dbus - 在接口(interface) NULL 上将对象注册到远程

转载 作者:行者123 更新时间:2023-11-30 17:48:47 25 4
gpt4 key购买 nike

我必须处理一个二进制 blob dbus 服务/服务器,我需要通过 dbus( session )连接到它。

接口(interface)自省(introspection)如下(通过 gdbus-codegen 获取)。我们向远程注册一个函数,这样如果远程收到一条名为 message_handler 的消息,我们就会收到通知。 。这是对 send_message 的响应。我通过 dbus 传递的命令,但它有效(因此未显示)。

在 java 示例中,它是通过

完成的
dbus_connection.exportObject("/", new DBusInterfaceDerivedClassFoo());

并显示于 bustle(no interface) message_handler一切都按预期进行。

<小时/>

bustle graph image

<小时/>

在裸露的日志中说 <none>而不是(no interface) .

根据gdbus-monitor - interface `<none>`这是由于 gdbus-monitor检测到interfaceNULL

如何使用 GDBus 注册/导出接口(interface)等于 NULL 的对象?

到目前为止尝试过的事情在代码中标记为注释:

代码块:

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 中指定的回调。 .

预先感谢您提供任何提示。

附加信息:据我所知, Remote 使用 qtdbus,这是否重要。

最佳答案

这不是关于在 NULL 接口(interface)上导出接口(interface)(规范未涵盖),而是关于服务/服务器实际正确处理此类调用。

这尚未在 gdbus 中实现,已提交错误(包括补丁)https://bugzilla.gnome.org/show_bug.cgi?id=706675

关于c - dbus - 在接口(interface) NULL 上将对象注册到远程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18357703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com