Re: Most simple C++ API/example for dbus clients ?

Thiago Macieira <[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <4240490.NtElPKiCQU@tjmaciei-mobl4>
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

_______________________________________________
dbus mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.