gbus messing around

Havoc Pennington hp at redhat.com
Mon Jul 23 12:45:40 PDT 2007


Hi,

At guadec I got the impression Rob was working on something called gbus 
also, so don't let this confuse you, it's not the same.

Before GUADEC I took the hippo-dbus-helper.[hc] convenience functions 
out of the mugshot client and started making them into a library to see 
what it was like. I didn't get particularly far; a bunch of the 
functions don't even have any code in them. Don't try to use the 
library, in short. The only interesting bit is probably the header.

Here is the code:
   git://people.freedesktop.org/~hp/gbus
   http://gitweb.freedesktop.org/?p=users/hp/gbus.git;a=tree

(I figured I'd play with git too)

I probably won't finish this anytime soon. But I do think some of the 
functionality here is needed, so perhaps it can be incorporated into 
what others are doing.

Stuff to notice about gbus.h:

  - I won't reproduce the comments here, there are a couple on
    various topics

  - there's a simple setup for client proxies and object implementation
    that doesn't involve any code generation

  - register_name_tracker() allows you to get a callback as another
    app appears or disappears

  - register_name_owner() allows you to get a callback as you gain or
    lose a particular bus name

  - a NameOwnershipStyle enum replaces the confusing flags to
    dbus_bus_request_name()

  - register_connection_tracker() would be used to support reconnect to
    the bus, by writing your app as follows:
    - in main(), register_connection_tracker() just queues an idle that
      tries to connect to the bus
    - so main() does essentially nothing - you register the connection
      tracker and then enter the main loop
    - you then get a callback indicating that you are connected or
      not connected
    - if you're not connected, exit or whatever, if you are then
      set up your stuff, e.g. with register_name_owner() to try
      and take the single instance, or
      register_interface()/register_object()
    - if you lose the bus connection, you would get the connected
      callback again on reconnect

  - init_single_instance() basically does register_connection_tracker(),
    then on bus connect does register_name_owner() to try and take the
    single instance, and notifies your app if it gets it. So it combines
    the "get bus connection" and "own the single instance name" steps.

  - a further abstraction could add a Launch() method or whatever to
    the picture, as discussed on desktop-devel-list. This would then
    be combined with a GTK function to make single instance work
    right.

There is nothing too glamorous or complicated here but it does reduce 
application lines of code dramatically vs. using libdbus raw.

Havoc


More information about the dbus mailing list