Query using D-bus

Nicolas Cavallari Nicolas.Cavallari at lri.fr
Fri Dec 7 00:53:39 PST 2012


On 07/12/2012 05:50, Keyur wrote:
> Hi,
> 
> Thanks for help,
> 
> but my client application is in c++ and i am using libdbus-c++ 0.9.0
> 
> any suggestion on that how to get notified that my Qt server application has crashed ?

Then you have to implement the name watcher yourself. Generate a proxy for the
org.freedesktop.DBus object (hint: there's already a xml description for it in
libdbus-c++/data/), implement the NameOwnedChanged signal handler, as explained by Simon
then instantiate your object with path '/'.

However, i suggest to move away from libdbus-c++ as soon as you can, because you will
have to maintain it yourself. There are several forks out there (even one from google),
and if you encounter bugs, you may have to pick patches from these forks until it works
for your use case. If i remember correctly, with 0.9.6, when under a signal handler,
you cannot call any D-Bus method or signal, otherwise a deadlock may occur. That also
includes creating or destroying a proxy or adapter, as these actions makes dbus calls to
add/remove matches.

> 
> On 06/12/2012 9:03 PM, Thiago Macieira wrote:
>> On quinta-feira, 6 de dezembro de 2012 12.01.55, Simon McVittie wrote:
>>> If it adds appropriate match rules, the client will get a
>>> NameOwnerChanged signal from the dbus-daemon, for each of the bus names
>>> that were owned by the Qt application, telling it that the bus name's
>>> owner has changed to "". Something like this:
>>>
>>>      NameOwnerChanged("com.einfochips.keyur.MyService", ":1.42", "")
>>>      NameOwnerChanged(":1.42",                          ":1.42", "")
>>>
>>> (The parameters are the name being owned, the old owner and the new
>>> owner, in that order. Every unique bus name is considered to be its own
>>> owner.)
>>>
>>> The library you're using in your client application (which one are you
>>> using?) should hopefully give you a high-level way to subscribe to
>>> NameOwnerChanged, whose name will probably be something involving
>>> "watching names". In GDBus it's g_bus_watch_name(),
>>> g_bus_watch_name_on_connection() etc.
>>>
>>> If it doesn't have that, the next best thing is if it gives you a way to
>>> subscribe to signals. In GDBus this is g_dbus_connection_signal_subscribe().
>> With QtDBus, you connect to signals in one of two ways:
>>
>> QDBusConnection::connect, a low level mechanism that allows you to specify
>> many items of the connection, including an argument match list.
>>
>> QObject::connect and passing a QDBusInterface object as the sender, which
>> might be more at home for Qt developers.
>>
>> However, specifically for watching for names on the bus, there's a
>> QDBusServiceWatcher class which should be used, as it will do the right thing
>> with the minimal signal subscription on the bus, avoiding unnecessary process
>> wakeups.
>>
>>> In C/C++ code, I recommend using either GDBus (part of GLib) or QtDBus.
>>>
>>>
>>> _______________________________________________
>>> dbus mailing list
>>> dbus at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/dbus
> 
> 
> 
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus



More information about the dbus mailing list