How to chek the presence of an object on dbus

Luiz Augusto von Dentz luiz.dentz at gmail.com
Sun Sep 12 13:36:59 PDT 2010


Hi,

On Tue, Aug 31, 2010 at 9:23 AM, tomw <tomw at ubilix.com> wrote:
> Thanks, sometimes it's the most obvious things that help...
>
> cheers,
>
> tomw
>
>
> On Tue, 2010-08-31 at 08:01 +0200, Thiago Macieira wrote:
>> On Tuesday 31. August 2010 07.32.07 Rémi Denis-Courmont wrote:
>> > Le mardi 31 août 2010, tomw a écrit :
>> > > I was wondering how to check the presence of an object on the dbus
>> > > the most elegant way. Of course, one could create a proxy object on
>> > > the path and call the Introspect method. If this returns proper
>> > > introspect data the object is available. However, are there any
>> > > better ways?
>> >
>> > Objects are not present "on the bus". They are instantiated in ways
>> > specific to DBus client process, or at least its DBus implementation.
>> >
>> > Not all DBus clients implement introspection. And even when they do
>> > implement it (correctly), there is no race-free nor poll-free way to be
>> > notified of objects tree changes.
>> >
>> >
>> > In my opinion, the most "elegant" way to check that an object exists is
>> > to query it. This is interface-specific, but you should know what you
>> > are talking with anyway.
>>
>> Rémi is correct.
>>
>> The most elegant way to check if an object exists is to use it as if it
>> existed. If it exists, your operation will work. If it doesn't exist, you'll
>> get an error indicating that it doesn't.

I guess you can use org.freedesktop.DBus.Peer.Ping for this purpose:

"On receipt of the METHOD_CALL message org.freedesktop.DBus.Peer.Ping,
an application should do nothing other than reply with a METHOD_RETURN
as usual. It does not matter which object path a ping is sent to. The
reference implementation handles this method automatically."

-- 
Luiz Augusto von Dentz
Computer Engineer


More information about the dbus mailing list