aboutsummaryrefslogtreecommitdiff
path: root/src/session.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.cpp')
-rw-r--r--src/session.cpp38
1 files changed, 24 insertions, 14 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());
}