aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-07-08 15:54:20 +0200
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-07-08 15:54:20 +0200
commit0f73c7ff3f8a84bcacf077644d6a199301f58945 (patch)
tree272431fb633d18803ac73dbb6aeff881496e5bb2 /src
parentdc3b77a1e3c8b8ff9a9299fd17c13b0428f1fa14 (diff)
downloadRWA.Support.DesktopApp-0f73c7ff3f8a84bcacf077644d6a199301f58945.tar.gz
RWA.Support.DesktopApp-0f73c7ff3f8a84bcacf077644d6a199301f58945.tar.bz2
RWA.Support.DesktopApp-0f73c7ff3f8a84bcacf077644d6a199301f58945.zip
User can decide on host_alias now.
Diffstat (limited to 'src')
-rw-r--r--src/DBusAPI.cpp22
-rw-r--r--src/DBusAPI.h2
-rw-r--r--src/scenes/add_server_wizard/Scene_step_1.qml105
-rw-r--r--src/scenes/add_server_wizard/add_server_wizard.cpp43
-rw-r--r--src/scenes/add_server_wizard/add_server_wizard.h7
5 files changed, 132 insertions, 47 deletions
diff --git a/src/DBusAPI.cpp b/src/DBusAPI.cpp
index 7f14e4f..18c5974 100644
--- a/src/DBusAPI.cpp
+++ b/src/DBusAPI.cpp
@@ -56,6 +56,8 @@ void DBusAPI::_initDBus() {
* \a host RWAHost object which includes all necessary information about a RWA host.
*/
void DBusAPI::start_request(RWAHost *host) {
+ Q_ASSERT(host != nullptr);
+
qDebug() << "Requesting D-Bus service to start a new session on host:" << host->alias();
// Make an asynchrous 'start' call (Response will be sent to 'start_reply')
@@ -101,6 +103,9 @@ void DBusAPI::start_reply(QDBusPendingCallWatcher *call) {
* \a session_id Unique identifier for a session in a specific host.
*/
void DBusAPI::stop_request(RWAHost *host, QString session_id) {
+ Q_ASSERT(host != nullptr);
+ Q_ASSERT(session_id != "");
+
bool ok;
long long session_id_number = session_id.toLongLong(&ok);
@@ -158,6 +163,9 @@ void DBusAPI::stop_reply(QDBusPendingCallWatcher *call) {
* \a session_id Unique identifier for a session in a specific host.
*/
void DBusAPI::status_request(RWAHost *host, QString session_id) {
+ Q_ASSERT(host != nullptr);
+ Q_ASSERT(session_id != "");
+
bool ok;
long long session_id_number = session_id.toLongLong(&ok);
@@ -186,6 +194,9 @@ void DBusAPI::status_request(RWAHost *host, QString session_id) {
* \a session_id Unique identifier for a session in a specific host.
*/
void DBusAPI::refresh_status_request(RWAHost *host, QString session_id) {
+ Q_ASSERT(host != nullptr);
+ Q_ASSERT(session_id != "");
+
bool ok;
long long session_id_number = session_id.toLongLong(&ok);
@@ -257,13 +268,16 @@ void DBusAPI::get_web_app_hosts_request() {
* \a host_url is the remote web app adress which will be used by the session service to coordinate
* sessions, connections, settings and such.
*/
-void DBusAPI::add_web_app_host_request(QString host_url) {
+void DBusAPI::add_web_app_host_request(QString host_url, QString host_alias) {
+ Q_ASSERT(host_url != "");
+ Q_ASSERT(host_alias != "");
+
qDebug().noquote() << QString("Requesting D-Bus service to register new "
- "remote web app host with url '%0'").arg(host_url);
+ "remote web app host '%0' with url '%1'").arg(host_alias).arg(host_url);
// Make an asynchrous 'add_web_app_host' call
// Response will be sent to 'add_web_app_host_reply'
- QDBusPendingCall async = _dbus_rwa->asyncCall("add_web_app_host", host_url);
+ QDBusPendingCall async = _dbus_rwa->asyncCall("add_web_app_host", host_url, host_alias);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
@@ -276,6 +290,8 @@ void DBusAPI::add_web_app_host_request(QString host_url) {
* \a host_uuid Unique identifier which all hosts have.
*/
void DBusAPI::remove_web_app_host_request(QString host_uuid) {
+ Q_ASSERT(host_uuid != "");
+
qDebug().noquote() << QString("Requesting D-Bus service to list "
"all remote web app hosts");
diff --git a/src/DBusAPI.h b/src/DBusAPI.h
index 632a90b..a25fb64 100644
--- a/src/DBusAPI.h
+++ b/src/DBusAPI.h
@@ -73,7 +73,7 @@ public slots:
void get_web_app_hosts_request();
// Add a specific remote web app host using a url to make sure its contactable
- void add_web_app_host_request(QString host_url);
+ void add_web_app_host_request(QString host_url, QString host_alias);
// Removes a specific remote web app host using the uuid of a host
void remove_web_app_host_request(QString host_uuid);
diff --git a/src/scenes/add_server_wizard/Scene_step_1.qml b/src/scenes/add_server_wizard/Scene_step_1.qml
index a80e4f4..abd761d 100644
--- a/src/scenes/add_server_wizard/Scene_step_1.qml
+++ b/src/scenes/add_server_wizard/Scene_step_1.qml
@@ -42,11 +42,11 @@ Item {
anchors.rightMargin: 15
onClicked: {
- add_server_wizard.processStep1(host_url.text)
+ add_server_wizard.processStep1(host_url.text, host_alias.text)
}
}
- Text {
+ /*Text {
color: Material.foreground
id: step_indicator
@@ -61,7 +61,7 @@ Item {
horizontalAlignment: Text.AlignHCenter
anchors.left: parent.left
anchors.margins: 5
- }
+ }*/
Text {
color: Material.foreground
@@ -74,12 +74,12 @@ Item {
"administrator about it please.\nBefore you can "+
"start any remote sessions you will have to "+
"be approved for remote support.")
- font.pointSize: 13
+ font.pointSize: 12
anchors.right: parent.right
anchors.rightMargin: 15
anchors.leftMargin: 15
- anchors.top: step_indicator.bottom
- anchors.topMargin: 30
+ anchors.top: parent.top //step_indicator.bottom
+ anchors.topMargin: 15
wrapMode: Text.WordWrap
anchors.left: parent.left
@@ -160,7 +160,7 @@ Item {
Text {
color: Material.foreground
- text: qsTr("RWA-server address")
+ text: qsTr("RWA host address")
anchors.left: parent.left
anchors.leftMargin: 15
anchors.verticalCenterOffset: - host_url.height / 2
@@ -176,6 +176,97 @@ Item {
}
}
}
+
+ TextField {
+ id: host_alias
+ selectByMouse: true
+ placeholderText: qsTr("My example host")
+
+ font.pixelSize: 16
+ color: Material.foreground
+
+ padding: 15
+ topPadding: 15
+
+ anchors.top: host_url.bottom
+ anchors.topMargin: 30
+ anchors.left: parent.left
+ anchors.leftMargin: 15
+ anchors.right: parent.right
+ anchors.margins: 30
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onHoveredChanged: {
+ if (containsMouse) {
+ host_alias_background.state = "hovered"
+ } else if (!host_alias.focus) {
+ host_alias_background.state = "unhovered"
+ }
+ }
+ onClicked: {
+ host_alias.forceActiveFocus();
+ }
+ }
+
+ onFocusChanged: {
+ host_alias_background.state = host_alias.focus ? "hovered" : "unhovered"
+ }
+
+ background: Rectangle {
+ id: host_alias_background
+ color: Material.background
+ border.color: Material.foreground
+ border.width: 1
+ radius: 4
+
+ states: [
+ State {
+ name: "hovered"
+ PropertyChanges {
+ target: host_alias_background
+ border.color: "#0178EF"
+ }
+ },
+ State {
+ name: "unhovered"
+ PropertyChanges {
+ target: host_alias_background
+ border.color: Material.foreground
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ PropertyAnimation {
+ property: "border.color"
+ duration: 100
+ easing.type: Easing.Linear
+ }
+ }
+ ]
+
+ Text {
+ color: Material.foreground
+ text: qsTr("RWA host alias")
+ anchors.left: parent.left
+ anchors.leftMargin: 15
+ anchors.verticalCenterOffset: - host_alias.height / 2
+ anchors.verticalCenter: parent.verticalCenter
+ leftPadding: 5
+
+ Rectangle {
+ color: Material.background
+ width: parent.width + 5 + 3
+ height: parent.height
+ z: -1
+ }
+ }
+ }
+ }
}
}
diff --git a/src/scenes/add_server_wizard/add_server_wizard.cpp b/src/scenes/add_server_wizard/add_server_wizard.cpp
index d06108c..09db898 100644
--- a/src/scenes/add_server_wizard/add_server_wizard.cpp
+++ b/src/scenes/add_server_wizard/add_server_wizard.cpp
@@ -40,15 +40,17 @@ Add_Server_wizard::Add_Server_wizard(QObject *parent, MainQMLAdaptor *main_gui)
SLOT(add_web_app_host_response(QJsonDocument*)));
}
-void Add_Server_wizard::processStep1(QString host_url) {
- qDebug() << "Processing Step 1 with args: " << host_url;
+void Add_Server_wizard::processStep1(QString host_url, QString host_alias) {
+ qDebug() << "Processing Step 1 with args: " << host_url << host_alias;
- if(host_url == "") {
- emit step1Failed(tr("This field can't be empty!"));
+ if(host_alias == "" || host_url == "") {
+ QString reason = tr("Both textfields can't be empty!");
+ emit step1Failed(reason);
+ qDebug().noquote() << reason;
return;
}
- return add_server(host_url);
+ return add_server(host_url, host_alias);
}
void Add_Server_wizard::processStep2() {
@@ -58,8 +60,8 @@ void Add_Server_wizard::processStep2() {
emit step2Success();
}
-void Add_Server_wizard::add_server(QString host_url) {
- _dbus_api->add_web_app_host_request(host_url);
+void Add_Server_wizard::add_server(QString host_url, QString host_alias) {
+ _dbus_api->add_web_app_host_request(host_url, host_alias);
}
void Add_Server_wizard::add_web_app_host_response(QJsonDocument *doc) {
@@ -70,32 +72,7 @@ void Add_Server_wizard::add_web_app_host_response(QJsonDocument *doc) {
// Status of request
QString request_status = mainMap["status"].toString();
if (request_status == "success") {
- // Building host_object
- QJsonObject host_object = jObject.value(QString("host")).toObject();
-
- QString host_uuid = host_object["uuid"].toString();
- QString host_alias = host_object["alias"].toString();
- QString host_url = host_object["url"].toString();
-
- if (host_url == "" || host_uuid == "") {
- // This two values are required and can't be omitted.
- QString reason = tr("Response of D-Bus service lacks necessary host object.");
- qCritical().noquote() << tr("An error occured while adding a new host:")
- << reason;
- emit step1Failed(reason);
-
- return;
- }
-
- if (host_alias == "") {
- qDebug().noquote() << QString("An alias for the host wasn't delivered "
- "so just use '%0' as alias.").arg(host_url);
- host_alias = host_url;
- }
-
- // Now built RWAHost object.
- QScopedPointer<RWAHost> rwa_host (new RWAHost(host_uuid, host_alias, host_url));
- _main_gui->addRWAHost(rwa_host.data());
+ _dbus_api->get_web_app_hosts_request();
qInfo() << "Successfully added a new RWAHost.";
emit step1Success();
diff --git a/src/scenes/add_server_wizard/add_server_wizard.h b/src/scenes/add_server_wizard/add_server_wizard.h
index e4d62df..03af824 100644
--- a/src/scenes/add_server_wizard/add_server_wizard.h
+++ b/src/scenes/add_server_wizard/add_server_wizard.h
@@ -37,8 +37,9 @@ class Add_Server_wizard : public QObject
Q_OBJECT
public:
explicit Add_Server_wizard(QObject *parent = nullptr,
- MainQMLAdaptor *main_gui = nullptr);
- void add_server(QString host_url);
+ MainQMLAdaptor *main_gui = nullptr,
+ DBusAPI *dbus_api = nullptr);
+ void add_server(QString host_url, QString host_alias);
private:
DBusAPI *_dbus_api;
@@ -51,7 +52,7 @@ signals:
void step2Failed(QString reason);
public slots:
- void processStep1(QString host_url);
+ void processStep1(QString host_url, QString host_alias);
void processStep2();
void add_web_app_host_response(QJsonDocument *doc);