0

我必须处理我需要通过 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 是否重要。

4

1 回答 1

0

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

这还没有在 gdbus 中实现,提交了一个错误(包括补丁)https://bugzilla.gnome.org/show_bug.cgi?id=706675

于 2013-08-23T15:37:37.577 回答