DBus 对象的子对象

发布于 2024-10-21 12:37:00 字数 334 浏览 6 评论 0原文

我正在尝试编写一个导出用户的 dbus 对象,并在 /path/to/users 创建了我的对象。该对象具有诸如“用户添加”、“用户删除”等信号。

然后我想为用户 a、b 在 /path/to/users/[a, b, c] 处提供对每个用户的访问权限c 将为每个用户提供一些方法。

我的问题是如何“列出”路径 /path/to/users 以返回 a、b、c?

我唯一的选择是从 path.to.users.ListUsers() 返回路径数组,是否有一个我可以继承的标准接口,或者某种形式的内省?

谢谢。

注意。我正在 python 中执行此操作,但我认为问题与语言无关

I'm trying to write a dbus object that exports users and have created my object at /path/to/users. This object has signals such as 'user-added', 'user-removed' etc.

I then want to provide access to each of these users at /path/to/users/[a, b, c] for users a, b and c which will have some methods for each user.

My question though is how do i 'list' the path /path/to/users to return a, b, c?

Is my only option returning an array of paths from path.to.users.ListUsers(), is there a standard interface i can inherit, or some form of introspection?

Thanks.

nb. I'm doing this in python but i think the question is language independent

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

同展鸳鸯锦 2024-10-28 12:37:00

标准 D-Bus Introspectable 接口提供了一种方法内省一个物体; 它返回的数据包括对象列表。

大多数 D-Bus 绑定(包括 dbus-python )都会在服务端为您实现 Introspectable ;因此您的客户端应该能够对 /path/to/users 处的对象调用 Introspect 方法来查看存在哪些用户对象。我不知道 dbus-python 是否为这些数据提供了更好的接口。就我个人而言,我会实现一个 ListUsers() 方法,该方法返回 a{oa{sv}} — 即对象路径列表,以及有关这些路径的一些属性对象(例如,相当于对每个对象调用 Properties.GetAll("uk.co.example.MyService.User"))。

(如果您对未来感兴趣,David Zeuthan 提议标准化像这样的东西。)

The standard D-Bus Introspectable interface provides a method to introspect an object; the data returned by it includes a list of objects.

Most D-Bus bindings, including dbus-python, implement Introspectable on the service-side for you; so your client should be able to call the Introspect method on the object at /path/to/users to see which user objects exist. I don't know offhand if dbus-python provides a nicer interface to this data. Personally, I would implement a ListUsers() method, which returns a{oa{sv}}—that is, a list of object paths, along with some properties about those objects (say, the equivalent of calling Properties.GetAll("uk.co.example.MyService.User") on each object).

(If you're interested in the future, David Zeuthan has proposed standardizing something like this.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文