org.freedesktop.DBus.Hello

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Nov 11 02:42:34 PST 2011


On Fri, 11 Nov 2011 at 06:16:10 +0000, bartolome moreno wrote:
> can anybody help me to understand what is the pourpose of the following interface:
> org.freedesktop.DBus.Hello

It's the first message that a new D-Bus connection sends to the dbus-daemon.
The reply is the connection's unique bus name, which lets it start sending
messages to other connections. Until a connection says Hello, it has no name,
so the dbus-daemon can't put the connection's name in messages that it sent.

Pseudocode:

    app: (connects)
    app: Hello?
    dbus-daemon, to app: Hi, I'm going to call you ":1.42"
    app: com.example.Messages.Notify("hello, world!")
    dbus-daemon, to Messages service: ":1.42" says
        "com.example.Messages.Notify("hello, world!")"

If you're using a D-Bus binding or implementation (libdbus, dbus-glib, QtDBus,
GDBus etc.) then the connection object provided by the binding
(DBusConnection, DBusGConnection, GDBusConnection, GDBusConnection etc.)
will usually have already called Hello() during its initialization...

> Whenever I try to use it (only for curious) I see the following error:
> 
> Error: Already handled an Hello message

... which is why you get this error when you call it yourself - the library
already did it for you.

There's often a way to make the library not send Hello, for use with
peer-to-peer connections that don't talk to the dbus-daemon. For instance in
GDBus, g_bus_get() always says Hello, but g_dbus_connection_new()
will only send Hello if you pass in
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION.

In libdbus, dbus_bus_get() always says Hello, but dbus_connection_open()
doesn't, and you can send Hello separately by using dbus_bus_register().

Regards,
    smcv


More information about the dbus mailing list