aboutsummaryrefslogtreecommitdiff
path: root/src/scenes/add_server_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'src/scenes/add_server_wizard')
-rw-r--r--src/scenes/add_server_wizard/Scene_step_1.qml185
-rw-r--r--src/scenes/add_server_wizard/Scene_step_2.qml70
-rw-r--r--src/scenes/add_server_wizard/add_server_wizard.cpp100
-rw-r--r--src/scenes/add_server_wizard/add_server_wizard.h35
4 files changed, 0 insertions, 390 deletions
diff --git a/src/scenes/add_server_wizard/Scene_step_1.qml b/src/scenes/add_server_wizard/Scene_step_1.qml
deleted file mode 100644
index e76462a..0000000
--- a/src/scenes/add_server_wizard/Scene_step_1.qml
+++ /dev/null
@@ -1,185 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Window 2.2
-import QtQuick.Extras 1.4
-import QtQuick.Controls 2.2
-import QtQuick.Controls.Material 2.3
-
-/*!
- This .qml file is a Scene which can be loaded through for example a StackView (main_content in main.qml).
- */
-
-Item {
- id: scene_server_wizard_step_1
- objectName: "Scene_step_1"
-
- Connections {
- target: add_server_wizard
- onStep1Success: {
- //main_content_push("scenes/add_server_wizard/Scene_step_2.qml", StackView.Transition)
- main_content_pop(null)
- mainqmladaptor.showToast(qsTr("Successfully added server address."), 5000);
- }
- }
-
- Connections {
- target: add_server_wizard
- onStep1Failed: {
- mainqmladaptor.showToast(reason, 3000);
- }
- }
-
- Rectangle {
- id: rectangle
- anchors.fill: parent
- color: Material.background
-
- Button {
- id: next_step1_button
- text: qsTr("Next Step")
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 15
- anchors.right: parent.right
- anchors.rightMargin: 15
-
- onClicked: {
- add_server_wizard.processStep1(host_url.text)
- }
- }
-
- Text {
- color: Material.foreground
- id: step_indicator
-
- text: qsTr("Step 1")
- anchors.leftMargin: 15
- anchors.top: parent.top
- anchors.topMargin: 15
- font.pointSize: 21
- wrapMode: Text.WordWrap
-
- font.bold: true
- horizontalAlignment: Text.AlignHCenter
- anchors.left: parent.left
- anchors.margins: 5
- }
-
- Text {
- color: Material.foreground
- id: explaining_text
-
- text: qsTr("Please input the address for the "+
- "remote web app server which you want "+
- "to connect to.\nIf you don't know "+
- "what this means, ask your local "+
- "administrator about it please.\nBefore you can "+
- "start any remote sessions you will have to "+
- "be approved for remote support.")
- font.pointSize: 13
- anchors.right: parent.right
- anchors.rightMargin: 15
- anchors.leftMargin: 15
- anchors.top: step_indicator.bottom
- anchors.topMargin: 30
- wrapMode: Text.WordWrap
-
- anchors.left: parent.left
- anchors.margins: 5
- }
-
- TextField {
- id: host_url
- selectByMouse: true
- placeholderText: qsTr("http://example.com:8000")
-
- font.pixelSize: 16
- color: Material.foreground
- anchors.topMargin: 30
-
- padding: 15
- topPadding: 15
-
- anchors.top: explaining_text.bottom
- anchors.left: parent.left
- anchors.leftMargin: 15
- anchors.right: parent.right
- anchors.margins: 30
-
- MouseArea {
- anchors.fill: parent
- hoverEnabled: true
- onHoveredChanged: {
- if (containsMouse) {
- host_url_background.state = "hovered"
- } else if (!host_url.focus) {
- host_url_background.state = "unhovered"
- }
- }
- onClicked: {
- host_url.forceActiveFocus();
- }
- }
-
- onFocusChanged: {
- host_url_background.state = host_url.focus ? "hovered" : "unhovered"
- }
-
- background: Rectangle {
- id: host_url_background
- color: Material.background
- border.color: Material.foreground
- border.width: 1
- radius: 4
-
- states: [
- State {
- name: "hovered"
- PropertyChanges {
- target: host_url_background
- border.color: "#0178EF"
- }
- },
- State {
- name: "unhovered"
- PropertyChanges {
- target: host_url_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-server address")
- anchors.left: parent.left
- anchors.leftMargin: 15
- anchors.verticalCenterOffset: - host_url.height / 2
- anchors.verticalCenter: parent.verticalCenter
- leftPadding: 5
-
- Rectangle {
- color: Material.background
- width: parent.width + 5 + 3
- height: parent.height
- z: -1
- }
- }
- }
- }
- }
-}
-
-/*##^## Designer {
- D{i:0;autoSize:true;height:480;width:640}D{i:4;anchors_width:351;anchors_x:279}
-}
- ##^##*/
diff --git a/src/scenes/add_server_wizard/Scene_step_2.qml b/src/scenes/add_server_wizard/Scene_step_2.qml
deleted file mode 100644
index 5cfbe46..0000000
--- a/src/scenes/add_server_wizard/Scene_step_2.qml
+++ /dev/null
@@ -1,70 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Window 2.2
-import QtQuick.Extras 1.4
-import QtQuick.Controls 2.2
-import QtQuick.Dialogs 1.2
-import QtQuick.Controls.Material 2.3
-
-/*!
- This .qml file is a Scene which can be loaded through for example a StackView (main_content in main.qml).
- */
-
-Item {
- id: scene_server_wizard_step_2
- objectName: "Scene_step_2"
-
- Connections {
- target: add_server_wizard
- onStep2Success: {
- main_content_pop(null, StackView.Transition)
- //main_content_replace("scenes/Scene_placeholder.qml", StackView.Transition)
- }
- }
-
- Connections {
- target: add_server_wizard
- onStep2Failed: {
- mainqmladaptor.showToast(reason, 3000);
- }
- }
-
- Rectangle {
- id: rectangle
- anchors.fill: parent
- color: Material.background
-
- Text {
- color: Material.foreground
- id: title
-
- text: qsTr("Step 2")
- font.pointSize: 18
- wrapMode: Text.WordWrap
-
- font.bold: true
- horizontalAlignment: Text.AlignHCenter
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: 5
- }
-
- Button {
- id: next_step2_button
- text: qsTr("Next Step")
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 10
- anchors.right: parent.right
- anchors.rightMargin: 10
-
- onClicked: {
- add_server_wizard.processStep2()
- }
- }
- }
-}
-
-/*##^## Designer {
- D{i:0;autoSize:true;height:480;width:640}
-}
- ##^##*/
diff --git a/src/scenes/add_server_wizard/add_server_wizard.cpp b/src/scenes/add_server_wizard/add_server_wizard.cpp
deleted file mode 100644
index f8d4b7b..0000000
--- a/src/scenes/add_server_wizard/add_server_wizard.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "add_server_wizard.h"
-#include "../../RWADBusAdaptor.h"
-#include <QDebug>
-#include <QtDBus>
-#include <QDBusPendingCallWatcher>
-
-Add_Server_wizard::Add_Server_wizard(QObject *parent) : QObject(parent) {
- _initDBus();
-
-
-}
-
-bool Add_Server_wizard::processStep1(QString host_url) {
- qDebug() << "Processing Step 1 with args: " << host_url;
-
- if(host_url == "") {
- emit step1Failed(tr("This field can't be empty!"));
- return false;
- }
-
- return _add_server(host_url);
-}
-
-bool Add_Server_wizard::processStep2() {
- qDebug() << "Processing Step 2 with args: No Args.";
- emit step2Failed(tr("The feature you expected here are not yet implemented."));
- // Just show placeholder scene now.
- emit step2Success();
- return false;
-}
-
-bool Add_Server_wizard::_add_server(QString host_url) {
- return _add_web_app_host(host_url);
-}
-
-void Add_Server_wizard::_initDBus() {
- if (!QDBusConnection::sessionBus().isConnected()) {
- qCritical() << "Cannot connect to the D-Bus session bus.";
- }
-
- // Create DBus object
- _dbus_rwa = new OrgArcticaProjectRWASupportSessionServiceInterface("org.ArcticaProject.RWASupportSessionService", "/RWASupportSessionService",
- QDBusConnection::sessionBus(), this->parent());
-
- qDebug("Initialized DBus object!");
-}
-
-bool Add_Server_wizard::_add_web_app_host(QString host_url) {
- qDebug() << "Requesting D-Bus session service to add a new host: " << host_url;
-
- // Make an asynchrous 'add_web_app_host' call (Response will be sent to '_add_web_app_host_dbus_replied')
- QDBusPendingCall async = _dbus_rwa->asyncCall("add_web_app_host", host_url);
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
-
- QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(_add_web_app_host_dbus_replied(QDBusPendingCallWatcher*)));
-
- return true;
-}
-
-void Add_Server_wizard::_add_web_app_host_dbus_replied(QDBusPendingCallWatcher *call) {
- QString result = "";
-
- QDBusPendingReply<QString> reply = *call;
- if (reply.isError()) {
- qDebug() << "D-Bus 'add_web_app_host' request failed, this was the reply:";
- qDebug() << reply.error();
- return;
- } else {
- result = reply.argumentAt<0>();
- }
- call->deleteLater();
-
- qDebug() << "Raw JSON from starting session is:" << result.toUtf8().replace('"', "");
- QJsonDocument doc = QJsonDocument::fromJson(result.toUtf8());
-
- // Get the QJsonObject
- QJsonObject jObject = doc.object();
- QVariantMap mainMap = jObject.toVariantMap();
-
- // Status of request
- QString request_status = mainMap["status"].toString();
- if (request_status == "success") {
- qDebug() << "Successfully started a Session.";
- emit step1Success();
- } else {
- qCritical() << "An error occured while adding a new host!";
-
- QString reason = "An error occured while adding a new host!";
- QString type = mainMap["type"].toString();
- if(type == "connection"){
- reason = tr("Couldn't connect to the specified host!");
- } else if (type == "duplicate") {
- reason = tr("The specified host was already added!");
- } else if (type == "invalid_url") {
- reason = tr("The specified host address is not valid!");
- }
- emit step1Failed(reason);
- }
-}
diff --git a/src/scenes/add_server_wizard/add_server_wizard.h b/src/scenes/add_server_wizard/add_server_wizard.h
deleted file mode 100644
index 1feec9b..0000000
--- a/src/scenes/add_server_wizard/add_server_wizard.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef ADD_SERVER_WIZARD_H
-#define ADD_SERVER_WIZARD_H
-
-#include "../../RWADBusAdaptor.h"
-#include <QObject>
-
-class Add_Server_wizard : public QObject
-{
- Q_OBJECT
-public:
- explicit Add_Server_wizard(QObject *parent = nullptr);
-
-private:
- bool _add_server(QString host_url);
- bool _add_web_app_host(QString host_url);
-
- OrgArcticaProjectRWASupportSessionServiceInterface *_dbus_rwa;
- void _initDBus();
-
-signals:
- void step1Success();
- void step1Failed(QString reason);
- void step2Success();
- void step2Failed(QString reason);
-
-public slots:
- bool processStep1(QString host_url);
- bool processStep2();
-
- void _add_web_app_host_dbus_replied(QDBusPendingCallWatcher *call);
- //void _get_web_app_hosts_dbus_replied(QDBusPendingCallWatcher *call);
- //void _remove_web_app_host_dbus_replied(QDBusPendingCallWatcher *call);
-};
-
-#endif // ADD_SERVER_WIZARD_H