Ask for consent to terms and conditions if required

This commit is contained in:
Tobias Fella
2020-12-30 13:17:14 +00:00
committed by Carl Schwan
parent 88cc972edc
commit bd00a73aa9
3 changed files with 34 additions and 0 deletions

View File

@@ -262,6 +262,33 @@ Kirigami.ApplicationWindow {
function onOpenRoom(room) { function onOpenRoom(room) {
roomManager.enterRoom(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 { RoomListModel {

View File

@@ -230,6 +230,12 @@ void Controller::addConnection(Connection *c)
dropConnection(c); dropConnection(c);
}); });
connect(c, &Connection::requestFailed, this, [=] (BaseJob *job) {
if(job->error() == BaseJob::UserConsentRequiredError) {
Q_EMIT userConsentRequired(job->errorUrl());
}
});
setBusy(true); setBusy(true);
c->sync(); c->sync();

View File

@@ -107,6 +107,7 @@ Q_SIGNALS:
void passwordStatus(Controller::PasswordStatus _t1); void passwordStatus(Controller::PasswordStatus _t1);
void showWindow(); void showWindow();
void openRoom(NeoChatRoom *room); void openRoom(NeoChatRoom *room);
void userConsentRequired(QUrl url);
public Q_SLOTS: public Q_SLOTS:
void logout(Quotient::Connection *conn, bool serverSideLogout); void logout(Quotient::Connection *conn, bool serverSideLogout);