简体   繁体   English

dbus-将对象注册到接口NULL上的远程

[英]dbus - register object to remote on interface NULL

I have to deal with a binary blob dbus service/server which I need to connect to via dbus (session). 我必须处理需要通过dbus(会话)连接到的二进制blob dbus服务/服务器。

The introspection of the interface is as following (obtained via gdbus-codegen ). 接口的自检如下(通过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 . 我们向遥控器注册了一个函数,因此如果遥控器收到了一条称为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). 这种情况是作为对我通过dbus传递的send_message命令的响应而发生的,但是它有效(因此未显示)。

In a java example it is done via 在一个Java示例中,它是通过

dbus_connection.exportObject("/", new DBusInterfaceDerivedClassFoo());

and shows in bustle as (no interface) message_handler and everything works as expected. 并在节目bustle(no interface) message_handler按预期工作和一切。


喧闹的图形图像


In the bare logs say <none> instead of (no interface) . 在裸日志中,说<none>而不是(no interface)

According to gdbus-monitor - interface `<none>` this is caused by the fact that gdbus-monitor detects interface being NULL 根据gdbus-monitor-接口`<none>`,这是由于gdbus-monitor检测到interfaceNULL所致

How to register/export a object with interface equal NULL using GDBus ? 如何使用GDBus注册/导出接口等于NULL的对象?

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 . 无论我发表什么评论,我都从未输入vtable指定的回调。

Thanks in advance for any tips. 在此先感谢您提供任何提示。

Additional info: The remote uses qtdbus as far as I can say if that does matter. 附加信息:据我所知,遥控器使用qtdbus确实很重要。

It is not about exporting the interface on NULL interface (not covered by the spec), but about the service/server actually handling such a call properly. 这与在NULL接口(规范未涵盖)上导出接口无关,而与服务/服务器实际正确处理此类调用有关。

This was not yet implemented in gdbus, filed a bug (including patch) https://bugzilla.gnome.org/show_bug.cgi?id=706675 这尚未在gdbus中实现,已提交错误(包括补丁) https://bugzilla.gnome.org/show_bug.cgi?id=706675

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM