Where to start

Tony Houghton h at realh.co.uk
Tue Mar 29 14:09:35 PST 2005

In <1112023847.7387.26.camel at localhost.localdomain>, Havoc Pennington wrote:

> On Mon, 2005-03-28 at 13:36 +0100, Tony Houghton wrote:
> > Are signals associated with a name, or do they go out on the
> > system/session bus? One thing that concerns me about doing it that way
> > is that it smacks a little of polluting a global namespace compared with
> > neatly routed method calls, but if you say it's OK... ;-).
> They _have_ a name which is namespaced, but they aren't addressed to
> anyone special. The recipient has to "subscribe" to the signal name with
> AddMatch. Anyone can subscribe though.

I've had a stab at it (just targetting 0.22 for now), but it isn't
working for me, so I'd be very grateful if you could check my
pseudo-code summary and tell me what I've done wrong. Both halves of my
program start off with:

    optsdbus_g_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
    optsdbus_connection = dbus_g_connection_get_connection

Then the capplet does this:

    dbus_bus_acquire_service (optsdbus_connection, OPTSDBUS_NAME,
                0, &derror);

and each time it sends a signal:

    message = dbus_message_new_signal (OPTSDBUS_OBJECT_PATH,
    dbus_message_append_args (message, ...);
    dbus_connection_send (optsdbus_connection, message, &serial);

The main application, which is supposed to receive the signals, does

    match_rule = g_strdup_printf
    dbus_bus_add_match (optsdbus_connection, match_rule, &derror);
    proxy = dbus_g_proxy_new_for_service (optsdbus_g_connection,
    g_signal_connect (proxy, "received",
            G_CALLBACK (optsdbus_signal_handler), NULL);

The problem is that on sending a signal message the dbus connection gets
destroyed and the main application doesn't get the signal (at least it
doesn't get as far as the glib/GObject signal handler).

TH * http://www.realh.co.uk

More information about the dbus mailing list