gpt4 book ai didi

c++ - 如何定义一个可以自省(introspection)的新 d-bus 接口(interface)?

转载 作者:太空宇宙 更新时间:2023-11-04 10:49:06 33 4
gpt4 key购买 nike

我已经创建了一个自定义的 d-bus 服务,它似乎已注册并且可以通过 dbus 调用激活,但是它没有接口(interface)定义并且不能通过 d-feet 等工具进行自省(introspection)。

我正在尝试弄清楚如何做到这一点,我已经创建了以下接口(interface)文件:

<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" >
<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<interface name="com.me.test.Manager">
<method name="Start">
<arg name="name" direction="in" type="s">
<doc:doc><doc:summary>Name of new contact</doc:summary></doc:doc>
</arg>
<arg name="email" direction="in" type="s">
<doc:doc><doc:summary>E-mail address of new contact</doc:summary></doc:doc>
</arg>
<arg name="id" direction="out" type="u">
<doc:doc><doc:summary>ID of newly added contact</doc:summary></doc:doc>
</arg>
<doc:doc>
<doc:description>
<doc:para>
Adds a new contact to the address book with their name and
e-mail address.
</doc:para>
</doc:description>
</doc:doc>
</method>
</interface>
</node>

我将文件命名为:

/usr/share/dbus-1/interfaces/com.me.test.Manager.xml

但是,当我使用 d-feet 浏览器搜索“com.me.test”时,我仍然没有在 session 总线上看到任何对象。这个接口(interface)实际上是如何被dbus注册的,dbus是否监控这个目录?我试过重新启动 dbus,但没有帮助

最佳答案

您的服务需要调用org.freedesktop.DBus.RequestName在特定名称下可见,然后回复 org.freedesktop.DBus.Introspectable.Introspect要求

这是我如何在我的 dbus 库中实现它的示例 - https://github.com/sidorares/node-dbus/blob/master/lib/stdifaces.js#L24-L92

关于c++ - 如何定义一个可以自省(introspection)的新 d-bus 接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31815101/

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