dbus_bus_get VS dbus_connection_open

Havoc Pennington hp at redhat.com
Tue Sep 5 06:48:27 PDT 2006


frederic heem wrote:
>> The bus is only one possible remote process; you can also just open a
>> connection to some random app, if you like. dbus_bus_get pretty much
>> _is_ dbus_connection_open + dbus_bus_register.
>>
> No difference shall be be made between a standard bus such as the system and 
> sesssion bus (dbus_bus_get()), and a user defined bus 
> (dbus_connection_open()). They are both factory function that returns 
> a "ready to use" connection, only the key to get the connection changes, a 
> number or a string. The dbus-send and dbus-monitor clearly shows that at the 
> moment, the code has to make an extra check if the bus is a user defined bus, 
> this is not symmetrical and very error prone. 
> Moreover, for the glib binding, dbus_g_register() doesn't exist, 
> dbus_register() is not documented and anyway shall not be use in glib code 
> because  it would break encapsulation.
> Let's rename dbus_connection_open() to dbus_connection_create() and add  
> dbus_connection_open() that does dbus_connection_create() + dbus_register().

The issue here is not a user-defined bus; user-defined buses work the 
same as the regular bus, except dbus_bus_get() doesn't know how to get 
their address.

The issue is that you can connect to things that are not a bus at all. 
That's what dbus_connection_open is generally for. The bus protocol is 
built on a more general non-bus-specific protocol. The stuff in 
dbus-bus.h knows about buses, but the stuff in dbus-connection.h does not.

dbus_g_register doesn't exist because the glib bindings aren't really 
particularly finished, and the idea would be to have a DBusGProxy for 
the org.freedesktop.DBus object I suppose.

>>   - rather than == FALSE should use !
> Is it a real mistake or just synthetic sugar ? 

Just a style thing

>>   - I believe the code crashes if --address has no '=' after it?
> Yes, there is a mistake. But the why a standard function to parse parameter is 
> not used ? get_opt() ? 

getopt_long unfortunately isn't portable.

Havoc



More information about the dbus mailing list