code source dbus

Nigel Tao nigel.tao.gnome at gmail.com
Wed Oct 10 17:21:21 PDT 2007


> Can anyone send me programs or links wich can help me to solve my problem.

One source of example code is Google Code Search:
http://www.google.com/codesearch?q=dbus_g_proxy_new_for_name

Or, tools/dbus-send.c in the dbus source might help you.


Also, the code you posted is long and complex.  I would suggest to
first of all, write the smallest possible program(s) that speak D-Bus.
 Once you get that, then you can work up.  It is easier to complicate
a simple, working program than it is to fix a complex, broken program.


For example, the simplest possible server's main function will pretty much be
create a new GObject
register it, via dbus_g_connection_register_g_object
request a name for it, via org_freedesktop_DBus_request_name
main loop

and the client main function will be
create a proxy for the server object
issue an IPC method call (synchronous is easiest)
get the reply, and printf it
profit


Again, from the principle of "get simple working first", I would
suggest starting with a method that just takes one i arg with
direction="in", and then work up to direction="out" args and your
crazy array of nested whatnots.

Also, the client might require a main loop as well - mine always use
one, but it might not be necessary for non-GUI clients.  I forget.


More information about the dbus mailing list