aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-06-24 22:10:32 +0200
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-06-24 22:18:44 +0200
commit66972f70880021f1cc8f9091e09f58b04757dbf8 (patch)
treebd6cbb8c1f42108151896f5d9bd535035b5a298a /src
parent2569aaa4ca068a7c2e885cc53d1eb05bf814190c (diff)
downloadRWA.Support.DesktopApp-66972f70880021f1cc8f9091e09f58b04757dbf8.tar.gz
RWA.Support.DesktopApp-66972f70880021f1cc8f9091e09f58b04757dbf8.tar.bz2
RWA.Support.DesktopApp-66972f70880021f1cc8f9091e09f58b04757dbf8.zip
Complete new more responsive layout; introducing session_id
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp4
-rw-r--r--src/main_qmladaptor.cpp7
-rw-r--r--src/main_qmladaptor.h25
-rw-r--r--src/session.cpp117
-rw-r--r--src/session.h39
5 files changed, 142 insertions, 50 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3d88c0c..381bc9c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -39,7 +39,11 @@
#include "RWADBusAdaptor.cpp"
#include "session.h"
+#define BUILD_TIME __DATE__ " " __TIME__
+
int main(int argc, char *argv[]) {
+ qDebug() << "This app was built on: " << BUILD_TIME;
+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
diff --git a/src/main_qmladaptor.cpp b/src/main_qmladaptor.cpp
index c768623..2416266 100644
--- a/src/main_qmladaptor.cpp
+++ b/src/main_qmladaptor.cpp
@@ -143,12 +143,19 @@ void MainQMLAdaptor::setURL(QString URL) {
_url = URL;
emit urlChanged(URL);
}
+void MainQMLAdaptor::setSessionID(QString session_id) {
+ _session_id = session_id;
+ emit sessionIDChanged(session_id);
+}
QString MainQMLAdaptor::getURL() {
return _url;
}
QString MainQMLAdaptor::getPin() {
return _pin;
}
+QString MainQMLAdaptor::getSessionID() {
+ return _session_id;
+}
void MainQMLAdaptor::onCloseHandler() {
// Do cleanup things here...
diff --git a/src/main_qmladaptor.h b/src/main_qmladaptor.h
index 212c9fa..4619968 100644
--- a/src/main_qmladaptor.h
+++ b/src/main_qmladaptor.h
@@ -36,12 +36,21 @@
class MainQMLAdaptor : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString url READ getURL WRITE setURL NOTIFY urlChanged) // this makes url available as a QML property
- Q_PROPERTY(QString pin READ getPin WRITE setPin NOTIFY pinChanged) // this makes pin available as a QML property
- Q_PROPERTY(bool showMessageDialog READ getShowMessageDialog NOTIFY showMessageDialogChanged) // this makes showMessageDialog available as a QML property
- Q_PROPERTY(QString _messageDialogTitle READ getMessageDialogTitle NOTIFY messageDialogTitleChanged) // this makes showMessageDialogTitle available as a QML property
- Q_PROPERTY(QString _messageDialogText READ getMessageDialogText NOTIFY messageDialogTextChanged) // this makes showMessageDialogText available as a QML property
- Q_PROPERTY(QMessageBox::Icon _messageDialogIcon READ getMessageDialogIcon NOTIFY messageDialogIconChanged) // this makes showMessageDialogIcon available as a QML property
+ // this makes url available as a QML property
+ Q_PROPERTY(QString url READ getURL WRITE setURL NOTIFY urlChanged)
+ // this makes pin available as a QML property
+ Q_PROPERTY(QString pin READ getPin WRITE setPin NOTIFY pinChanged)
+ // this makes session_id available as a QML property
+ Q_PROPERTY(QString session_id READ getSessionID WRITE setSessionID NOTIFY sessionIDChanged)
+ // this makes showMessageDialog available as a QML property
+ Q_PROPERTY(bool showMessageDialog READ getShowMessageDialog NOTIFY showMessageDialogChanged)
+ // this makes showMessageDialogTitle available as a QML property
+ Q_PROPERTY(QString _messageDialogTitle READ getMessageDialogTitle NOTIFY messageDialogTitleChanged)
+ // this makes showMessageDialogText available as a QML property
+ Q_PROPERTY(QString _messageDialogText READ getMessageDialogText NOTIFY messageDialogTextChanged)
+ // this makes showMessageDialogIcon available as a QML property
+ Q_PROPERTY(QMessageBox::Icon _messageDialogIcon READ getMessageDialogIcon NOTIFY messageDialogIconChanged)
+
public:
explicit MainQMLAdaptor(QObject *parent, QQmlApplicationEngine *engine = nullptr);
@@ -71,6 +80,7 @@ signals:
void pinChanged(QString pin);
void urlChanged(QString URL);
+ void sessionIDChanged(QString session_id);
void onCloseSignal();
@@ -79,6 +89,7 @@ signals:
protected:
QString _url;
QString _pin;
+ QString _session_id;
private:
QQmlApplicationEngine* _engine;
@@ -93,8 +104,10 @@ public slots:
void setPin(QString pin);
void setURL(QString URL);
+ void setSessionID(QString session_id);
QString getURL();
QString getPin();
+ QString getSessionID();
void onCloseHandler();
diff --git a/src/session.cpp b/src/session.cpp
index d48de39..e4d3c95 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -47,6 +47,11 @@ Session::Session(QObject *parent, MainQMLAdaptor* main_gui) : QObject(parent) {
SIGNAL(urlChanged(QString)),
main_gui,
SLOT(setURL(QString)));
+ // session::setSessionID --sessionIDChanged--> MainQMLAdaptor::setSessionID --sessionIDChanged--> QML
+ QObject::connect(this,
+ SIGNAL(sessionIDChanged(QString)),
+ main_gui,
+ SLOT(setSessionID(QString)));
// QML -> MainQMLAdaptor::onCloseHandler --onCloseSignal--> session::onCloseHandler
QObject::connect(main_gui,
@@ -64,7 +69,8 @@ void Session::statusTimerEvent() {
void Session::init_vars() {
setPin("-----");
- setId(-1);
+ setSessionID("-----");
+ setId("-----");
setURL(tr("Not available yet"));
setStatus("unknown");
@@ -83,8 +89,12 @@ QString Session::getURL() {
return _url;
}
-int Session::getId() {
- return _id;
+QString Session::getId() {
+ return QString(_id);
+}
+
+QString Session::getSessionID() {
+ return QString(_session_id);
}
QString Session::getPin() {
@@ -187,18 +197,25 @@ void Session::setURL(QString url) {
emit urlChanged(url);
}
-void Session::setId(int id) {
+void Session::setId(QString id) {
_id = id;
emit idChanged(id);
}
+void Session::setSessionID(QString session_id) {
+ _session_id = session_id;
+ emit sessionIDChanged(session_id);
+}
+
void Session::setPin(QString pin) {
_pin = pin;
emit pinChanged(pin);
}
void Session::handleConnectButtonClick(bool checked) {
- qDebug() << "-----Connect button handler-----\nCurrent session #" << this->getId();
+ qDebug() << "-----Connect button handler-----" <<
+ "\nCurrent service-session #" << this->getId() <<
+ "\nCurrent support-session #" << this->getSessionID();
// Stopping even if nothing is running
this->stop_request_dbus(this->getId());
@@ -281,38 +298,68 @@ void Session::start_dbus_replied(QDBusPendingCallWatcher *call) {
return;
}
- // Session ID == PID
- int sessionid = mainMap["id"].toInt();
- this->setId(sessionid);
+ // Service ID == PID
+ bool ok;
+ long long service_id = mainMap["id"].toLongLong(&ok);
+ this->setId(QString::number(service_id));
+ // Sanity Check
+ if(ok == false){
+ qErrnoWarning("Unable to parse <service_id> out of dbus answer!");
+ init_vars();
+ return;
+ }
// URL of remote web app frontend
QString url = mainMap["url"].toString();
this->setURL(url);
// PIN
- QString pin = mainMap["pin"].toString();
- this->setPin(pin);
+ long long pin = mainMap["pin"].toLongLong();
+ this->setPin(QString::number(pin));
+ // Sanity Check
+ if(ok == false){
+ qErrnoWarning("Unable to parse <pin> out of dbus answer!");
+ init_vars();
+ return;
+ }
- qDebug() << "Got session id:" << sessionid;
- qDebug() << "Got url:" << url;
- qDebug() << "Got pin:" << pin;
+ // session_id = remote support id from the rwa-server
+ long long session_id = mainMap["session_id"].toLongLong();
+ this->setSessionID(QString::number(session_id));
+ // Sanity Check
+ if(ok == false){
+ qErrnoWarning("Unable to parse <pin> out of dbus answer!");
+ init_vars();
+ return;
+ }
- emit pinChanged(pin);
+ qDebug() << "Got service_id:" << service_id <<
+ "\nGot session_id:" << session_id <<
+ "\nGot url:" << url <<
+ "\nGot pin:" << pin;
+
+ emit pinChanged(QString::number(pin));
emit urlChanged(url);
- emit idChanged(sessionid);
+ emit idChanged(QString::number(service_id));
+ emit sessionIDChanged(QString::number(session_id));
}
-void Session::stop_request_dbus(int pid) {
- if (pid <= 0 ){
- qDebug() << "Won't send a request to D-Bus service to stop a session when session ID <= 0";
+void Session::stop_request_dbus(QString id) {
+ bool ok;
+ if (id.toLongLong(&ok) == 0 ){
+ qDebug() << "Won't send a request to D-Bus service to stop a session when session ID == 0";
+ return;
+ }
+ if(ok == false){
+ qErrnoWarning("Unable to convert <QString> id to <long long>");
return;
}
// Stopping now.
- qDebug() << "Requesting D-Bus session service to stop session #" << pid;
+ qDebug() << "Requesting D-Bus session service to stop session #" << id;
// Make an asynchrous 'stop' call (Response will be sent to 'stop_dbus_replied')
- QDBusPendingCall async = _dbus_rwa->asyncCall("stop", pid);
+ QDBusPendingCall async = _dbus_rwa->asyncCall("stop", id);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
@@ -359,34 +406,44 @@ void Session::stop_dbus_replied(QDBusPendingCallWatcher *call) {
this->setStatus(new_status);
}
-void Session::status_request_dbus(int pid) {
- if (pid <= 0 ){
- qDebug() << "Won't send a request to D-Bus service of a session's status when session ID <= 0";
+void Session::status_request_dbus(QString id) {
+ bool ok;
+ if (id.toLongLong(&ok) == 0 ){
+ qDebug() << "Won't send a request to D-Bus service of a session's status when session ID == 0";
+ return;
+ }
+ if(ok == false){
+ qErrnoWarning("Unable to convert <QString> id to <long long>");
return;
}
// Requesting status now.
- qDebug() << "Requesting status for session #" << pid;
+ qDebug() << "Requesting status for session #" << id;
// Make an asynchrous 'status' call (Response will be sent to 'status_dbus_replied')
- QDBusPendingCall async = _dbus_rwa->asyncCall("status", pid);
+ QDBusPendingCall async = _dbus_rwa->asyncCall("status", id);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
this, SLOT(stop_dbus_replied(QDBusPendingCallWatcher*)));
}
-void Session::refresh_status_request_dbus(int pid) {
- if (pid <= 0 ){
- qDebug() << "Won't send a request to D-Bus service to refresh the status of a session when session ID <= 0";
+void Session::refresh_status_request_dbus(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";
+ return;
+ }
+ if(ok == false){
+ qErrnoWarning("Unable to convert <QString> id to <long long>");
return;
}
// Refreshing status
- qDebug() << "Requesting status refresh for session #" << pid;
+ 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", pid);
+ QDBusPendingCall async = _dbus_rwa->asyncCall("refresh_status", id);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
diff --git a/src/session.h b/src/session.h
index 07a85d9..ad1b140 100644
--- a/src/session.h
+++ b/src/session.h
@@ -39,31 +39,40 @@
class Session : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString status READ getStatus NOTIFY statusChanged) // this makes status available as a QML property
- Q_PROPERTY(int id READ getId NOTIFY idChanged ) // this makes id available as a QML property
- Q_PROPERTY(QString url READ getURL NOTIFY urlChanged ) // this makes url available as a QML property
- Q_PROPERTY(QString pin READ getPin NOTIFY pinChanged ) // this makes pin available as a QML property
+ // 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)
+ // 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
+ Q_PROPERTY(QString url READ getURL NOTIFY urlChanged)
+ // this makes pin available as a QML property
+ Q_PROPERTY(QString pin READ getPin NOTIFY pinChanged)
+
public:
explicit Session(QObject *parent, MainQMLAdaptor *main_gui = nullptr);
QString getStatus();
QString getURL();
- int getId();
+ QString getId();
+ QString getSessionID();
QString getPin();
void setStatus(QString status);
void setURL(QString url);
- void setId(int id);
+ void setId(QString id);
+ void setSessionID(QString session_id);
void setPin(QString pin);
// Starts a VNC Session
void start_request_dbus();
// Refreshes a VNC Session's status
- void refresh_status_request_dbus(int pid);
+ void refresh_status_request_dbus(QString id);
// Stop the Session
- void stop_request_dbus(int pid);
+ void stop_request_dbus(QString id);
// Gets a VNC Session's status
- void status_request_dbus(int pid);
+ void status_request_dbus(QString id);
// Returns true if Session is somewhat usable (Running, Alive, etc..)
bool isSessionAliveOrRunning(QString status);
@@ -74,7 +83,8 @@ protected:
private:
MainQMLAdaptor* _main_gui;
- int _id;
+ QString _id;
+ QString _session_id;
QString _url;
QString _pin;
OrgArcticaProjectRWAInterface* _dbus_rwa;
@@ -85,10 +95,11 @@ private:
signals:
void finished();
- void statusChanged(QString status);
- void idChanged(int id);
- void urlChanged(QString URL);
- void pinChanged(QString pin);
+ void statusChanged(QString);
+ void idChanged(QString);
+ void sessionIDChanged(QString);
+ void urlChanged(QString);
+ void pinChanged(QString);
public slots:
void handleConnectButtonClick(bool checked);