summaryrefslogtreecommitdiff
path: root/tests/test-dbus-pong/test-dbus-pong.cpp
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-02-09 12:18:44 +0200
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-02-09 12:18:44 +0200
commit910493fac3e328cef329ade5e8c1a71e136ca246 (patch)
tree1515ef7af8544692f70da623e15cc19b36faf588 /tests/test-dbus-pong/test-dbus-pong.cpp
parent381719b9a0adb8553a041633aed943f5ef48a1ff (diff)
parentae63c568711c128c64b1a94ef50e0af2ca91086b (diff)
Merge commit 'origin/master'
Diffstat (limited to 'tests/test-dbus-pong/test-dbus-pong.cpp')
-rw-r--r--tests/test-dbus-pong/test-dbus-pong.cpp45
1 files changed, 41 insertions, 4 deletions
diff --git a/tests/test-dbus-pong/test-dbus-pong.cpp b/tests/test-dbus-pong/test-dbus-pong.cpp
index 701abb1..c936cc4 100644
--- a/tests/test-dbus-pong/test-dbus-pong.cpp
+++ b/tests/test-dbus-pong/test-dbus-pong.cpp
@@ -31,17 +31,50 @@ unsigned int Pong::timeout()
int main(int argc, char **argv)
{
+ bool useSessionBus = false;
+
QCoreApplication app(argc, argv);
+ if( app.arguments().count() > 1 )
+ {
+ if( app.arguments().at(1) == "--session" )
+ {
+ useSessionBus = true;
+ }
+ }
+
+ QDBusConnection* myBus;
+ if( useSessionBus )
+ {
+ myBus = new QDBusConnection(QDBusConnection::systemBus().sessionBus());
+ qDebug("Using session bus ...");
+ }
+ else
+ {
+ myBus = new QDBusConnection(QDBusConnection::systemBus().systemBus());
+ qDebug("Using system bus ...");
+ }
// Check system bus connection
- if( !QDBusConnection::systemBus().isConnected() )
+ if( !myBus->isConnected() )
{
- qDebug("Cannot connect to the D-Bus system bus.");
+ // Cleanup!!
+ delete myBus;
+ myBus = NULL;
+
+ if( useSessionBus )
+ {
+ qDebug("Cannot connect to the D-Bus session bus.");
+ }
+ else
+ {
+ qDebug("Cannot connect to the D-Bus system bus.");
+ }
+
return 1;
}
// Create listener service
- if( !QDBusConnection::systemBus().registerService("com.nokia.dbusqeventloop.test") )
+ if( !myBus->registerService("com.nokia.dbusqeventloop.test") )
{
qDebug("%s", qPrintable(QDBusConnection::systemBus().lastError().message()));
exit(2);
@@ -49,10 +82,14 @@ int main(int argc, char **argv)
Pong pong;
// Register all slots as dbus methods
- QDBusConnection::systemBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots);
+ myBus->registerObject("/", &pong, QDBusConnection::ExportAllSlots);
// Let's go!
app.exec();
+ // Cleanup!!
+ delete myBus;
+ myBus = NULL;
+
return 0;
}