How to use Gio::DBus::ObjectManagerServer?

I need to implement the org.freedesktop.DBus.ObjectManager D-Bus interface in my glibmm application (in order to pass it to the org.bluez service). I see that glib(mm) has already the Gio::DBus::ObjectManagerServer class which implements this particular D-Bus interface.

How can I register my application’s D-Bus interfaces with the ObjectManagerServer? It looks like my application needs to pass an instance of DBus::ObjectSkeleton which in turn needs an instance of DBus::InterfaceSkeleton. As InterfaceSkeleton is an abstract base class, it looks like I need to derive from in within my applications classes. Is there an example how to do this? Which constructor of InterfaceSkeleton do I need to call from my derived classes? What data do I need to pass?

I don’t know much about Gio::DBus, but I think you should use the
gdbus-codegen command
to generate one or more subclasses of GDBusInterfaceSkeleton. gdbus-codegen can
only generate C code. You can probably wrap an object of a subclass of GDBusInterfaceSkeleton
in C++ code by calling one of the many overloaded Glib::wrap() functions.
The wrapping C++ object will (hopefully) be a Gio::DBus::InterfaceSkeleton.

but I think you should use the
gdbus-codegen command
to generate one or more subclasses of GDBusInterfaceSkeleton. gdbus-codegen can
only generate C code. You can probably wrap an object of a subclass of GDBusInterfaceSkeleton
in C++ code by calling one of the many overloaded Glib::wrap() functions.
The wrapping C++ object will (hopefully) be a Gio::DBus::InterfaceSkeleton.

This seems to make sense, I’ll try this way (probably next week) and come back with the result.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.