From 0c449ab4bd7963ae5d7b8be04545060ddccf38af Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Wed, 30 Dec 2020 13:17:14 +0000 Subject: [PATCH] Ask for consent to terms and conditions if required --- qml/main.qml | 31 ++++++++++++++++++++++++++++++- src/controller.cpp | 6 ++++++ src/controller.h | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/qml/main.qml b/qml/main.qml index 35c951152..8cd6d6622 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -224,7 +224,36 @@ Kirigami.ApplicationWindow { onShowWindow: root.showWindow() - onOpenRoom: roomManager.enterRoom(room) + function onOpenRoom(room) { + roomManager.enterRoom(room) + } + + function onUserConsentRequired(url) { + consentSheet.url = url + consentSheet.open() + } + } + + Kirigami.OverlaySheet { + id: consentSheet + + property string url: "" + + header: Kirigami.Heading { + text: i18n("User consent") + } + + QQC2.Label { + id: label + + text: i18n("Your homeserver requires you to agree to its terms and conditions before being able to use it. Please click the button below to read them.") + wrapMode: Text.WordWrap + width: parent.width + } + footer: QQC2.Button { + text: i18n("Open") + onClicked: Qt.openUrlExternally(consentSheet.url) + } } RoomListModel { diff --git a/src/controller.cpp b/src/controller.cpp index f167d0cdb..c4ed8fd71 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -231,6 +231,12 @@ void Controller::addConnection(Connection *c) dropConnection(c); }); + connect(c, &Connection::requestFailed, this, [=] (BaseJob *job) { + if(job->error() == BaseJob::UserConsentRequiredError) { + Q_EMIT userConsentRequired(job->errorUrl()); + } + }); + setBusy(true); c->sync(); diff --git a/src/controller.h b/src/controller.h index b2328bd8e..97b2f0b71 100644 --- a/src/controller.h +++ b/src/controller.h @@ -113,6 +113,7 @@ Q_SIGNALS: void passwordStatus(Controller::PasswordStatus _t1); void showWindow(); void openRoom(NeoChatRoom *room); + void userConsentRequired(QUrl url); public Q_SLOTS: void logout(Quotient::Connection *conn, bool serverSideLogout);