RFC: Libdbus++ - C++ bindings for DBus

staneker at gris.uni-tuebingen.de staneker at gris.uni-tuebingen.de
Wed May 17 09:20:50 PDT 2006


Hello,


> Well done. I'd be particularly interested to see how either of you are
> integrating the application's main loop with the application.
>
> As I understand it, d-bus needs to use a main loop, and it would be nice
> if a generic C++ D-BUS API could use, for instance, either a glib/glibmm
> mainloop or a Qt mainloop.

I am using a modified version of the dbus-mainloop to
support a loop on the serverside. It is not possible for me
to use threads or any other library, so I decided to use the
code from dbus-mainloop.c and do some modifications for C++.
I planed a complete rewrite, but hadn't enough time to do
it...


> It would also be easier to evaluate the APIs with a direct link to example
> code.

Hm, at the moment it is very easy (but supports not all the
features of dbus): write a xml-file with the interfaces for
the c++ classes, use the code generator and derive from the
Interface-class to implement your server-side code. Then the
code on the server-side looks like:

  ...
  dbus::DBusServerConnection cnct("org.test.communication");

  DBusTestServerImpl ts(cnct); // derived from auto-gen. class
  cnct.loop_run();             // mainloop
  ...

"testServer" implements the methods on the server-side,
which can be called from the client. On the client you can
directly use the generated code:

  dbus::ClientConnection cnct(getenv("DBUS_SESSION_BUS_ADDRESS"), "org.test.communication");
  DBusTest s(cnct);
  s.foo();         // calls method ts.foo via dbus on the server
  int x=5;
  int y=s.bar(x);  // calls method ts.bar via dbus on the server


At the moment, it is like a rmi-system, because the
instances on the client and on the server-side do not
directly correspond. It would be nice, to create an instance
on the server-side, if the instance is created on the
client-side, but the problem is, when should the server
destroy the instance, if the client died unexpected? How
does other bindings (qt/glib) solve this problem?


Best regards,
Dirk


More information about the dbus mailing list