dbus_pending_call_set_notify and threads management with the low-level C API

cscm at meuh.dyndns.org cscm at meuh.dyndns.org
Mon Jul 17 04:39:10 PDT 2006


Hi,

I'd like to make an asynchronous d-bus call with the low-level C API.
I use the dbus_pending_call_set_notify function in order to setup my
callback handler, but it's never called.

/* --- source code -- */
DBusError err;
DBusConnection* conn;
DBusMessageIter iter;

dbus_error_init(&err);
conn = dbus_bus_get(DBUS_BUS_SESSION, &err);

DBusMessage* msg;
DBusPendingCall* pending = NULL;

msg = dbus_message_new_method_call(
             "org.mozilla.TestService", "/",
             "org.mozilla.TestInterface", "HelloAsync");

dbus_message_set_auto_start(msg, TRUE);
dbus_connection_send_with_reply (conn, msg, &pending, -1);
dbus_pending_call_set_notify(pending, callback, NULL, NULL);
dbus_message_unref(msg);

while(42) {
   printf("%d\n", dbus_pending_call_get_completed(pending));
   sleep(1);
}
/* --- /source code -- */

My callback is defined like that:

/* --- callback -- */
void callback(DBusPendingCall *pending, void *user_data) {
    printf("Callback\n");
}
/* --- /callback -- */

My callback, is never called, so I've initialized the d-bus threads system
with the gthreads library  (using the glib's dbus binding function table
from the dbus-gthread.c file). (see the attached file for full source
code).

Can someone give me pointers on threads and callback setup?

Best Regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testClient.c
Type: text/x-csrc
Size: 4889 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20060717/bcdbb20a/testClient.c


More information about the dbus mailing list