summary refs log tree commit diff
path: root/resources/qml/delegates
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-08-07 22:51:09 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-08-07 22:51:09 +0200
commit72bbad7485db6ac1803f81344c29b93d9fa70945 (patch)
tree6fb74f887102affa0d5a6f4fdac0b87c1881c6ad /resources/qml/delegates
parentMerge pull request #664 from govynnus/token-registration (diff)
downloadnheko-72bbad7485db6ac1803f81344c29b93d9fa70945.tar.xz
Show encryption errors in qml and add request keys button
Diffstat (limited to 'resources/qml/delegates')
-rw-r--r--resources/qml/delegates/Encrypted.qml48
-rw-r--r--resources/qml/delegates/MessageDelegate.qml11
-rw-r--r--resources/qml/delegates/Reply.qml2
3 files changed, 61 insertions, 0 deletions
diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml
new file mode 100644

index 00000000..cd00a9d4 --- /dev/null +++ b/resources/qml/delegates/Encrypted.qml
@@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2021 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import ".." +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.2 +import im.nheko 1.0 + +ColumnLayout { + id: r + + required property int encryptionError + required property string eventId + + width: parent ? parent.width : undefined + + MatrixText { + text: { + switch (encryptionError) { + case Olm.MissingSession: + return qsTr("There is no key to unlock this message. We requested the key automatically, but you can try requesting it again if you are impatient."); + case Olm.MissingSessionIndex: + return qsTr("This message couldn't be decrypted, because we only have a key for newer messages. You can try requesting access to this message."); + case Olm.DbError: + return qsTr("There was an internal error reading the decryption key from the database."); + case Olm.DecryptionFailed: + return qsTr("There was an error decrypting this message."); + case Olm.ParsingFailed: + return qsTr("The message couldn't be parsed."); + case Olm.ReplayAttack: + return qsTr("The encryption key was reused! Someone is possibly trying to insert false messages into this chat!"); + default: + return qsTr("Unknown decryption error"); + } + } + color: Nheko.colors.buttonText + width: r ? r.width : undefined + } + + Button { + palette: Nheko.colors + visible: encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex + text: qsTr("Request key") + onClicked: room.requestKeyForEvent(eventId) + } + +} diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml
index a98c2a8b..a8bdf183 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml
@@ -29,6 +29,7 @@ Item { required property string roomTopic required property string roomName required property string callType + required property int encryptionError required property int relatedEventCacheBuster height: chooser.childrenRect.height @@ -190,6 +191,16 @@ Item { } DelegateChoice { + roleValue: MtxEvent.Encrypted + + Encrypted { + encryptionError: d.encryptionError + eventId: d.eventId + } + + } + + DelegateChoice { roleValue: MtxEvent.Name NoticeMessage { diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml
index 3e02a940..8bbce10e 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml
@@ -30,6 +30,7 @@ Item { property string roomTopic property string roomName property string callType + property int encryptionError property int relatedEventCacheBuster width: parent.width @@ -97,6 +98,7 @@ Item { roomName: r.roomName callType: r.callType relatedEventCacheBuster: r.relatedEventCacheBuster + encryptionError: r.encryptionError enabled: false width: parent.width isReply: true