开发者

Children of a DBus Object

开发者 https://www.devze.com 2023-02-16 16:34 出处:网络
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'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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消