diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-08-01 02:19:15 +0200 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-08-01 02:19:50 +0200 |
commit | 766a90125df68f065495354c20412faf9e1df77a (patch) | |
tree | cdba9fef32fe0b29a74aa9305b38c362db5a1a4e /src/session.cpp | |
parent | d75db83442a01dcd003ea39a5ec61baad7d344a0 (diff) | |
download | RWA.Support.DesktopApp-766a90125df68f065495354c20412faf9e1df77a.tar.gz RWA.Support.DesktopApp-766a90125df68f065495354c20412faf9e1df77a.tar.bz2 RWA.Support.DesktopApp-766a90125df68f065495354c20412faf9e1df77a.zip |
move scenes/Scene_remote_control.qml into scenes/remote_control/Scene_remote_control.qml
Diffstat (limited to 'src/session.cpp')
-rw-r--r-- | src/session.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/session.cpp b/src/session.cpp index 32aca7d..a524afe 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -310,22 +310,36 @@ void Session::start_response(QJsonDocument *doc) { emit pinChanged(QString::number(pin)); emit urlChanged(url); emit sessionIDChanged(QString::number(session_id)); -} -void Session::stop() { - _dbus_api->stop_request(_host, this->getSessionID()); + started = true; - // Clear current variables - this->init_vars(); + // Ask status every 1000 millisecond - // Disable connect button to reduce spam. - // And don't enable it as long there is no status update. - // (Or something fails) - _main_gui->setConnectButtonEnabled(false); + QTimer *timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, + QOverload<>::of(&Session::statusTimerEvent)); + timer->start(1000); + + qDebug() << "Successfully started a session."; + this->setStatus("start_session_success"); + + emit startSucceeded(); +} + +void Session::stop() { + if (started) + _dbus_api->stop_request(getHost(), getSessionID()); } void Session::stop_response(QJsonDocument *doc) { - Q_ASSERT(doc != nullptr); + // Q_ASSERT lets the program crash immediatly after method call + // when the session service is not started. + // Don't use Q_ASSERT(doc != nullptr); instead use: + if (doc == nullptr) { + emit stopFailed(tr("Can't connect to underlying session service! " + "Is the session service started?")); + return; + } QJsonObject jObject = doc->object(); QVariantMap mainMap = jObject.toVariantMap(); |