dbus_g_bus_get return value

John (J5) Palmieri johnp at redhat.com
Tue Oct 5 15:57:11 UTC 2004


On Tue, 2004-10-05 at 11:17 -0400, Leonardo Boiko wrote:
> This is from the D-BUS tutorial:
>      connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
>      if (connection == NULL) {
> 
> When I run it, I have the following situation:
>      16  connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
>      (gdb)
>      17  if (connection == NULL) {
>      (gdb) p *error
>      $1 = {domain = 46, code = 0,
>      message = 0x804d750 "D-BUS error org.freedesktop.DBus.Error.Failed:
>      Unable to determine the address of the message bus"}
>      (gdb) p connection
>      $2 = (DBusGConnection *) 0x4
> 
> Maybe instead of "connection == NULL" it should check for
> "error != NULL"?

Launch your shell with dbus-launch.   For example:

dbus-launch xterm

This starts a session bus and points an environment variable to it.  You
can then run your programs in that shell. 

Not all distros are starting session buses in their sessions yet.  Those
that don't you need to use the trick above.  In Fedora we use dbus-
launch to launch gnome-session so that the session bus is available to
the whole session.

-- 
John (J5) Palmieri
Associate Software Engineer
Desktop Group
Red Hat, Inc.
Blog: http://martianrock.com



More information about the dbus mailing list