summary refs log tree commit diff
path: root/resources
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
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')
-rw-r--r--resources/qml/MessageView.qml2
-rw-r--r--resources/qml/TimelineRow.qml3
-rw-r--r--resources/qml/delegates/Encrypted.qml48
-rw-r--r--resources/qml/delegates/MessageDelegate.qml11
-rw-r--r--resources/qml/delegates/Reply.qml2
-rw-r--r--resources/res.qrc9
6 files changed, 71 insertions, 4 deletions
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml

index f3e15d84..79cbd700 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml
@@ -349,6 +349,7 @@ ScrollView { required property string callType required property var reactions required property int trustlevel + required property int encryptionError required property var timestamp required property int status required property int index @@ -456,6 +457,7 @@ ScrollView { callType: wrapper.callType reactions: wrapper.reactions trustlevel: wrapper.trustlevel + encryptionError: wrapper.encryptionError timestamp: wrapper.timestamp status: wrapper.status relatedEventCacheBuster: wrapper.relatedEventCacheBuster diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml
index 6345f44c..c612479a 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml
@@ -38,6 +38,7 @@ Item { required property string callType required property var reactions required property int trustlevel + required property int encryptionError required property var timestamp required property int status required property int relatedEventCacheBuster @@ -110,6 +111,7 @@ Item { roomTopic: r.relatedEventCacheBuster, fromModel(Room.RoomTopic) ?? "" roomName: r.relatedEventCacheBuster, fromModel(Room.RoomName) ?? "" callType: r.relatedEventCacheBuster, fromModel(Room.CallType) ?? "" + encryptionError: r.relatedEventCacheBuster, fromModel(Room.EncryptionError) ?? "" relatedEventCacheBuster: r.relatedEventCacheBuster, fromModel(Room.RelatedEventCacheBuster) ?? 0 } @@ -136,6 +138,7 @@ Item { roomTopic: r.roomTopic roomName: r.roomName callType: r.callType + encryptionError: r.encryptionError relatedEventCacheBuster: r.relatedEventCacheBuster isReply: false } 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 diff --git a/resources/res.qrc b/resources/res.qrc
index d7187f42..f50265ca 100644 --- a/resources/res.qrc +++ b/resources/res.qrc
@@ -143,14 +143,15 @@ <file>qml/emoji/StickerPicker.qml</file> <file>qml/UserProfile.qml</file> <file>qml/delegates/MessageDelegate.qml</file> - <file>qml/delegates/TextMessage.qml</file> - <file>qml/delegates/NoticeMessage.qml</file> - <file>qml/delegates/ImageMessage.qml</file> - <file>qml/delegates/PlayableMediaMessage.qml</file> + <file>qml/delegates/Encrypted.qml</file> <file>qml/delegates/FileMessage.qml</file> + <file>qml/delegates/ImageMessage.qml</file> + <file>qml/delegates/NoticeMessage.qml</file> <file>qml/delegates/Pill.qml</file> <file>qml/delegates/Placeholder.qml</file> + <file>qml/delegates/PlayableMediaMessage.qml</file> <file>qml/delegates/Reply.qml</file> + <file>qml/delegates/TextMessage.qml</file> <file>qml/device-verification/Waiting.qml</file> <file>qml/device-verification/DeviceVerification.qml</file> <file>qml/device-verification/DigitVerification.qml</file>