diff options
author | Johann Latocha | 2010-08-28 03:17:08 +0200 |
---|---|---|
committer | Johann Latocha | 2010-08-28 03:17:08 +0200 |
commit | ca61d21c6defb9553234c1fa5b0979c46542c676 (patch) | |
tree | 610c5b1457d968135c1b70dfc8150737263e8922 /src/pvsgui.cpp | |
parent | Some refactoring (diff) | |
download | pvs-ca61d21c6defb9553234c1fa5b0979c46542c676.tar.gz pvs-ca61d21c6defb9553234c1fa5b0979c46542c676.tar.xz pvs-ca61d21c6defb9553234c1fa5b0979c46542c676.zip |
Enhancement #587
Diffstat (limited to 'src/pvsgui.cpp')
-rw-r--r-- | src/pvsgui.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp index b2f0a8f..0d89027 100644 --- a/src/pvsgui.cpp +++ b/src/pvsgui.cpp @@ -51,31 +51,37 @@ PVSGUI::PVSGUI(QWidget *parent) : // connect to D-Bus and get interface QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/", this); - dbus.registerService("org.openslx.pvsgui"); _ifaceDBus = new OrgOpenslxPvsInterface("org.openslx.pvs", "/", dbus, this); - _ifaceDBus->start(); // start pvs if not running + if (dbus.isConnected()) + qDebug("[%s] Connection to DBus successful.", metaObject()->className()); + else + qDebug("[%s] ERROR: Could not connect to DBus!", metaObject()->className()); - // get available hosts - QDBusPendingReply<QStringList> reply0 = _ifaceDBus->getAvailableHosts(); + // start pvs if not running + QDBusPendingReply<bool> reply0 = _ifaceDBus->start(); reply0.waitForFinished(); - QStringList hosts = reply0.value(); - if (reply0.isValid() && !hosts.isEmpty()) + if (reply0.isValid() && reply0.value()) + qDebug("[%s] Connection to PVS daemon successful.", metaObject()->className()); + else + qDebug("[%s] ERROR: Could not connect to PVS daemon!", metaObject()->className()); + + // get available hosts + QDBusPendingReply<QStringList> reply1 = _ifaceDBus->getAvailableHosts(); + reply1.waitForFinished(); + QStringList hosts = reply1.value(); + if (reply1.isValid() && !hosts.isEmpty()) foreach (QString host, hosts) addHost(host); // already connected? - QDBusPendingReply<QString> reply1 = _ifaceDBus->isConnected(); - reply1.waitForFinished(); - QString host = reply1.value(); - if (reply1.isValid() && host != "") + QDBusPendingReply<QString> reply2 = _ifaceDBus->isConnected(); + reply2.waitForFinished(); + QString host = reply2.value(); + if (reply2.isValid() && host != "") connected(host); else disconnected(); - if (dbus.isConnected()) - qDebug("[%s] Connection to DBus successful!", metaObject()->className()); - // listen on port 29481 for incoming file transfers _serverSocket = new QTcpServer(); _serverSocket->listen(QHostAddress::Any, 29481); |