本文介绍了DBUS - 注册对象接口远程NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要处理一个二进制数据DBUS服务/服务器,我需要通过DBUS(会话)来连接。

I have to deal with a binary blob dbus service/server which I need to connect to via dbus (session).

接口的自省是如下(通过 gdbus- codeGEN 获得)。
如果消息已被这就是所谓的远程接收我们的注册功能,远程,所以我们得到通知 MESSAGE_HANDLER 。这作为上,我通过DBUS传递 send_message 命令的响应,但工作(并因此未显示)。

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).

在一个java例如,它通过

In a java example it is done via

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

和显示喧嚣(无接口)MESSAGE_HANDLER ,一切都按预期工作。

and shows in bustle as (no interface) message_handler and everything works as expected.

在裸露的日志说<没有方式> 而不是(无接口)

In the bare logs say <none> instead of (no interface).

根据这是怎么引起的事实上, gdbus显示器检测接口 NULL

According to gdbus-monitor - interface `<none>` this is caused by the fact that gdbus-monitor detects interface being NULL

如何注册/使用导出对象,接口等于NULL GDBus

How to register/export a object with interface equal NULL using GDBus?

东西试过到目前为止标记为在code注释:

Things tried so far marked as comments in the code:

code块:

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);
...

什么,我注释掉不管我从来没有进入了虚函数表指定的回调。

先谢谢您的任何提示。

附加信息:遥控器使用qtdbus据我可以说,如果这样做事情

Additional info: The remote uses qtdbus as far as I can say if that does matter.

推荐答案

这是不是出口NULL接口(未涵盖的规范)的接口,但有关服务/服务器实际处理这样的电话正常。

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.

这不是在gdbus尚未实施,提出了错误(包括补丁)

This was not yet implemented in gdbus, filed a bug (including patch) https://bugzilla.gnome.org/show_bug.cgi?id=706675

这篇关于DBUS - 注册对象接口远程NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 12:34