diff options
-rw-r--r-- | src/session.cpp | 38 | ||||
-rw-r--r-- | src/session.h | 15 |
2 files changed, 34 insertions, 19 deletions
diff --git a/src/session.cpp b/src/session.cpp index f327d65..f3aa168 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -64,13 +64,13 @@ Session::Session(QObject *parent, MainQMLAdaptor* main_gui) : QObject(parent) { void Session::statusTimerEvent() { qDebug() << "Status timer event triggered"; - this->refresh_status_request_dbus(this->getId()); + this->refresh_status_request_dbus(this->getHostID(), this->getID()); } void Session::init_vars() { setPin("-----"); setSessionID("-----"); - setId("-----"); + setID("-----"); setURL(tr("Not available yet")); setStatus("unknown"); @@ -89,7 +89,7 @@ QString Session::getURL() { return _url; } -QString Session::getId() { +QString Session::getID() { return QString(_id); } @@ -97,6 +97,10 @@ QString Session::getSessionID() { return QString(_session_id); } +QString Session::getHostID() { + return QString(_host_id); +} + QString Session::getPin() { return _pin; } @@ -197,7 +201,7 @@ void Session::setURL(QString url) { emit urlChanged(url); } -void Session::setId(QString id) { +void Session::setID(QString id) { _id = id; emit idChanged(id); } @@ -214,15 +218,15 @@ void Session::setPin(QString pin) { void Session::handleConnectButtonClick(bool checked) { qDebug() << "-----Connect button handler-----" << - "\nCurrent service-session #" << this->getId() << + "\nCurrent service-session #" << this->getID() << "\nCurrent support-session #" << this->getSessionID(); // Stopping even if nothing is running - this->stop_request_dbus(this->getId()); + this->stop_request_dbus(this->getID()); if (checked) { // Start the Session again - this->start_request_dbus(); + this->start_request_dbus(getHostID()); } qDebug() << "-----\\Connect button handler-----"; } @@ -239,11 +243,17 @@ void Session::_initDBus() { qDebug("Initialized DBus object!"); } -void Session::start_request_dbus() { - qDebug() << "Requesting D-Bus session service to start a new session"; +void Session::start_request_dbus(QString host_id) { + qDebug() << "Requesting D-Bus session service to start a new session on host: " << host_id; + bool ok; + host_id.toLongLong(&ok); + if(ok == false){ + qErrnoWarning("Unable to convert <QString> id to <long long>"); + return; + } // Make an asynchrous 'start' call (Response will be sent to 'start_dbus_replied') - QDBusPendingCall async = _dbus_rwa->asyncCall("start"); + QDBusPendingCall async = _dbus_rwa->asyncCall("start", host_id); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), @@ -301,7 +311,7 @@ void Session::start_dbus_replied(QDBusPendingCallWatcher *call) { // Service ID == PID bool ok; long long service_id = mainMap["id"].toLongLong(&ok); - this->setId(QString::number(service_id)); + this->setID(QString::number(service_id)); // Sanity Check if(ok == false){ qErrnoWarning("Unable to parse <service_id> out of dbus answer!"); @@ -428,7 +438,7 @@ void Session::status_request_dbus(QString id) { this, SLOT(stop_dbus_replied(QDBusPendingCallWatcher*))); } -void Session::refresh_status_request_dbus(QString id) { +void Session::refresh_status_request_dbus(QString host_id, QString id) { bool ok; if (id.toLongLong(&ok) == 0){ qDebug() << "Won't send a request to D-Bus service to refresh the status of a session when session ID == 0"; @@ -443,7 +453,7 @@ void Session::refresh_status_request_dbus(QString id) { qDebug() << "Requesting status refresh for session #" << id; // Make an asynchrous 'refresh_status' call (Response will be sent to 'status_dbus_replied') - QDBusPendingCall async = _dbus_rwa->asyncCall("refresh_status", id); + QDBusPendingCall async = _dbus_rwa->asyncCall("refresh_status", host_id, id); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), @@ -488,5 +498,5 @@ void Session::status_dbus_replied(QDBusPendingCallWatcher *call) { void Session::onCloseHandler() { // To cleanup things here - this->stop_request_dbus(this->getId()); + this->stop_request_dbus(this->getID()); } diff --git a/src/session.h b/src/session.h index 41d414a..1b8b2d6 100644 --- a/src/session.h +++ b/src/session.h @@ -39,10 +39,11 @@ class Session : public QObject { Q_OBJECT + Q_PROPERTY(QString host_id READ getHostID NOTIFY hostIDChanged) // this makes status available as a QML property Q_PROPERTY(QString status READ getStatus NOTIFY statusChanged) // this makes service id available as a QML property - Q_PROPERTY(QString id READ getId NOTIFY idChanged) + Q_PROPERTY(QString id READ getID NOTIFY idChanged) // this makes session_id available as a QML property Q_PROPERTY(QString session_id READ getSessionID NOTIFY sessionIDChanged) // this makes url available as a QML property @@ -55,20 +56,22 @@ public: QString getStatus(); QString getURL(); - QString getId(); + QString getID(); + QString getHostID(); QString getSessionID(); QString getPin(); void setStatus(QString status); void setURL(QString url); - void setId(QString id); + void setID(QString id); + void setHostID(QString host_id); void setSessionID(QString session_id); void setPin(QString pin); // Starts a VNC Session - void start_request_dbus(); + void start_request_dbus(QString host_id); // Refreshes a VNC Session's status - void refresh_status_request_dbus(QString id); + void refresh_status_request_dbus(QString host_id, QString id); // Stop the Session void stop_request_dbus(QString id); // Gets a VNC Session's status @@ -85,6 +88,7 @@ private: MainQMLAdaptor* _main_gui; QString _id; QString _session_id; + QString _host_id; QString _url; QString _pin; OrgArcticaProjectRWASupportSessionServiceInterface* _dbus_rwa; @@ -100,6 +104,7 @@ signals: void sessionIDChanged(QString); void urlChanged(QString); void pinChanged(QString); + void hostIDChanged(QString); public slots: void handleConnectButtonClick(bool checked); |