Query using D-bus

Thiago Macieira thiago at kde.org
Thu Dec 6 07:33:55 PST 2012


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.
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20121206/f3107605/attachment.pgp>


More information about the dbus mailing list