Signals with more than one parameter

Steve Kreyer steve.kreyer at web.de
Fri May 18 07:11:50 PDT 2007


Hi,

I'm new to DBus. I'm using the glib- binding to develop an "IPC-
application". I can send signals with one parameter over DBus, but it
doesn't seem to work with more than one parameter. Is it possible in
general? Also I wonder that there isn't any marshal information for a
particular signal in dbus_glib__object_info, like it is the case for
methods ...

Maybe you  have some hints on how I can extend the following peace of
code to send signals with more than 1 parameter?

The interface definition:
------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>

<node name="/com/example/object_repository">

  <interface name="com.example.Calc">
  <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="calc"/>
    <signal name="kbd_event">
      <arg type="i" name="character" direction="out"/>
    </signal>
  </interface>
</node>
--------------------------------------------------------------------------------------------------------------------------------------

The DBus server:
---------------------------------------------------------------------------------------------------------------------------------------
gpointer
wait_for_event (gpointer user_data)
{
    char input;

    ...
    /* wait for keyboard event and send character: */
    g_signal_emit(obj, g_signal_id, 0, input);
    ...
    return NULL;
}

int
main ()
{
    GObject *calc;
    GThread *thread;

    ...
    calc = g_object_new(G_TYPE_OBJECT, NULL);
    g_signal_id = g_signal_new ("kbd_event",
                        G_TYPE_OBJECT,
                        G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
G_SIGNAL_NO_HOOKS,
                        0,
                        NULL,
                        NULL,
                        g_cclosure_marshal_VOID__INT,
                        G_TYPE_NONE,
                        1,
                        G_TYPE_INT);

    ...
    g_thread_init (NULL);
    thread = g_thread_create (wait_for_event, calc, FALSE, &error);
    g_main_loop_run (loop);
    return 0;
}
--------------------------------------------------------------------------------------------------------------

And last, the Client:
--------------------------------------------------------------------------------------------------------------
void
event_handler (gpointer instance, gint arg1, gpointer user_data)
{
    g_print ("Got signal! Sendet character is: %c\n", arg1);
}

int
main()
{
    ...

    dbus_g_proxy_add_signal (proxy,
            "kbd_event",
            G_TYPE_INT,
            G_TYPE_INVALID);
    dbus_g_proxy_connect_signal (proxy,
            "kbd_event",
            G_CALLBACK(event_handler),
            NULL,
            NULL);
    ...
    return 0;
}
-------------------------------------------------------------------------------------------------------------------

TIA,

Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.freedesktop.org/archives/dbus/attachments/20070518/87caf25a/attachment-0001.bin 


More information about the dbus mailing list