Hiding internal DBUS use inside a library

Lennart Poettering mzqohf at 0pointer.de
Thu Aug 25 15:56:05 PDT 2005


On Thu, 25.08.05 18:00, Colin Walters (walters at verbum.org) wrote:

> > > With GNOME apps, set_timeout_functions() will always be called by the
> > > GLib main loop stuff, and set_max_received_size() would never be called
> > > (it's a specialized function used only by the message bus).
> > 
> > Wrong. Our client library for the avahi mdns/dns-sd responder tries to
> > abstract DBUS from the user. Hence it WILL call
> > set_{timeout,watch}_functions(), even when used by Gnome apps.
> 
> This is confusing to me - what arguments does it give to those
> functions?  Is it using an internal mainloop or something?

No, it doesn't use an internal main loop. It just implements some glue
code to abstract the event loop. 

The user of our library fills a vtable with his own implementations of
functions for creating and modifying time or IO event sources. We use
those functions internally for all housekeeping we need to do and - in
the case of libavahi-client - to drive an internaly used
DBusConnection. For that DBusConnection we set the timeut/watch
functions to some glue code with translates them to our event loop
abstraction layer. The abstraction layer is actually very thin, since
it resambles the DBUS event loop abstraction a bit.

> Why is it useful to call those functions if the application is using a
> GLib mainloop?

Because Avahi doesn't use GLib and the application doesn't know we use
DBUS internally. Thefore we ask the user to provide us with the vtable
I mentioned above and use that for all our internal work (including DBUS).

Lennart

-- 
Lennart Poettering; lennart [at] poettering [dot] de
ICQ# 11060553; GPG 0x1A015CC4; http://0pointer.de/lennart/


More information about the dbus mailing list