diff options
author | Martin Wolf <ext-martin.2.wolf@nokia.com> | 2010-02-03 10:13:44 +0200 |
---|---|---|
committer | Martin Wolf <ext-martin.2.wolf@nokia.com> | 2010-02-03 10:13:44 +0200 |
commit | 06644af1a621f2afbd42957afc9cfda24056df54 (patch) | |
tree | dac557aab7a7bff21ad7b7c0ccc877bf42f5303e /tests/test-dbus-pong/test-dbus-pong.cpp | |
parent | 8bff62c335842b4c850cc09716e79c2f556247c7 (diff) |
Added debian packaging info and libdbus-qeventloop library
Diffstat (limited to 'tests/test-dbus-pong/test-dbus-pong.cpp')
-rw-r--r-- | tests/test-dbus-pong/test-dbus-pong.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/test-dbus-pong/test-dbus-pong.cpp b/tests/test-dbus-pong/test-dbus-pong.cpp new file mode 100644 index 0000000..f781004 --- /dev/null +++ b/tests/test-dbus-pong/test-dbus-pong.cpp @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <QtCore/QCoreApplication> +#include <QtCore/QTimer> +#include <QtDBus/QtDBus> + +#include "pong.h" + +#define SERVICE_NAME "com.nokia.dbusqeventloop.test" + +QString Pong::ping(const QString &arg) +{ + QMetaObject::invokeMethod(QCoreApplication::instance(), "quit"); + return QString("ping(\"%1\") got called").arg(arg); +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + if( !QDBusConnection::systemBus().isConnected() ) + { + fprintf(stderr, "Cannot connect to the D-Bus system bus.\n" + "To start it, run:\n" + "\teval `dbus-launch --auto-syntax`\n"); + return 1; + } + + if( !QDBusConnection::systemBus().registerService(SERVICE_NAME) ) + { + fprintf(stderr, "%s\n", qPrintable(QDBusConnection::systemBus().lastError().message())); + exit(2); + } + + Pong pong; + QDBusConnection::systemBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots); + + app.exec(); + return 0; +} |