An example showing dbus signals as glib signals...

मयंक जैन (makuchaku) mayank.gnu at gmail.com
Fri Apr 6 00:48:07 PDT 2007


Hi all,

I finally created a small layer of redirection around the
dbus-signals. An example program (tarball) is attached. Its a very
minimalistic implementation & can be (infact should be) redesigned in
a much better way - but hey, its just a prototype :)

I've added a signal handler to dbus-signal - NameOwnerChanged and from
that signal handler, emitted a glib signal - which is captured by
user's handler-callback (main.c)

Now the problem i'm facing is that my signal handlers are being called
twice - have a look at the output...

----------------------------------
makuchaku at Dreamer$ gcc main.c makuobject.c -o main `pkg-config --libs
--cflags glib-2.0 gobject-2.0 dbus-glib-1`


makuchaku at Dreamer$ ./main
Signals connected...
Maku's age = 100
Got a Signal!
Re-emitting name-owner-changed - as a g-signal!
Signal's Args : [:1.21] [] [:1.21]
Someone... somewhere just changed a name!


Got a Signal!
Re-emitting name-owner-changed - as a g-signal!
Signal's Args : [:1.21] [] [:1.21]
Someone... somewhere just changed a name!


Got a Signal!
Re-emitting name-owner-changed - as a g-signal!
Signal's Args : [:1.21] [:1.21] []
Someone... somewhere just changed a name!


Got a Signal!
Re-emitting name-owner-changed - as a g-signal!
Signal's Args : [:1.21] [:1.21] []
Someone... somewhere just changed a name!
----------------------------------


You can generate a NameOwnerChanged signal using dbus-send as
----------------------------------
makuchaku at Dreamer$ dbus-send --session --type=signal
--dest=org.freedesktop.DBus /org/freedesktop/DBus
org.freedesktop.DBus.NameOwnerChanged string:"abc" string:"def"
string:"ghi"
----------------------------------


I'll be glad if anyone can give me some pointers about what am I doing
wrong so that I'm receiving each signal twice.

The tarball is also uploaded at
http://www.makuchaku.info/code/dbus_signals-as-g_signals.tar.gz just
in case if this attachment does not reaches you...

Thanks alot for your time,

Makuchaku
http://www.makuchaku.info/blog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbus_signals-as-g_signals.tar.gz
Type: application/x-gzip
Size: 7894 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20070406/ad9029ec/dbus_signals-as-g_signals.tar.bin


More information about the dbus mailing list