Most simple C++ API/example for dbus clients ?
Thiago Macieira
thiago at kde.org
Sun Dec 28 14:58:32 PST 2014
On Sunday 28 December 2014 16:36:49 Toerless Eckert wrote:
> > I am looking for pointers to the most simple possible example C++
>
> dbus client code that would allow me to include into a C++ program
> something like what dbus-send(1) does.
>
> Google pointed me to libdbus-cxx, but outside
> of the included client0 example, i couldn't findexisting apps
> including/using it.
>
> Any pointers/suggestions welcome.
This is C++:
#include <QtDBus>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
auto msg = QDBusMessage::createMethodCall("org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"GetConnectionUnixProcessID");
msg.setArguments({"org.freedesktop.DBus"});
QDBusPendingReply<uint> reply =
QDBusConnection::session().asyncCall(msg);
if (reply.isError()) {
/* do something with the error */
} else {
/* do something with msg.value() */
}
}
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
More information about the dbus
mailing list