2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-08-07 23:51:09 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import ".."
|
2021-09-16 00:18:21 +03:00
|
|
|
import QtQuick 2.15
|
2021-11-21 06:07:57 +03:00
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2021-08-07 23:51:09 +03:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
2023-08-13 12:30:41 +03:00
|
|
|
Control {
|
2021-08-07 23:51:09 +03:00
|
|
|
id: r
|
|
|
|
|
|
|
|
required property int encryptionError
|
|
|
|
required property string eventId
|
|
|
|
|
2023-08-13 12:30:41 +03:00
|
|
|
padding: Nheko.paddingMedium
|
|
|
|
implicitHeight: contents.implicitHeight + Nheko.paddingMedium * 2
|
|
|
|
Layout.maximumWidth: contents.Layout.maximumWidth + padding * 2
|
|
|
|
Layout.fillWidth: true
|
2021-08-07 23:51:09 +03:00
|
|
|
|
2023-08-13 12:30:41 +03:00
|
|
|
contentItem: RowLayout {
|
2021-11-21 06:07:57 +03:00
|
|
|
id: contents
|
|
|
|
|
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
|
|
|
|
Image {
|
|
|
|
source: "image://colorimage/:/icons/icons/ui/shield-filled-cross.svg?" + Nheko.theme.error
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-08-13 12:30:41 +03:00
|
|
|
Layout.preferredWidth: 24
|
|
|
|
Layout.preferredHeight: 24
|
2021-11-21 06:07:57 +03:00
|
|
|
}
|
|
|
|
|
2023-08-13 12:30:41 +03:00
|
|
|
ColumnLayout {
|
2021-11-21 06:07:57 +03:00
|
|
|
spacing: Nheko.paddingSmall
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-08-13 12:30:41 +03:00
|
|
|
Label {
|
2022-02-09 19:53:02 +03:00
|
|
|
id: encryptedText
|
2021-11-21 06:07:57 +03:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
2023-08-13 12:30:41 +03:00
|
|
|
textFormat: Text.PlainText
|
|
|
|
wrapMode: Label.WordWrap
|
2023-06-02 02:29:05 +03:00
|
|
|
color: palette.text
|
2023-08-13 12:30:41 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: implicitWidth + 1
|
2021-08-07 23:51:09 +03:00
|
|
|
}
|
2021-11-21 06:07:57 +03:00
|
|
|
|
|
|
|
Button {
|
|
|
|
visible: encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex
|
|
|
|
text: qsTr("Request key")
|
|
|
|
onClicked: room.requestKeyForEvent(eventId)
|
|
|
|
}
|
|
|
|
|
2021-08-07 23:51:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-08-13 12:30:41 +03:00
|
|
|
background: Rectangle {
|
|
|
|
color: palette.alternateBase
|
|
|
|
radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingMedium
|
|
|
|
visible: !Settings.bubbles // the bubble in a bubble looks odd
|
|
|
|
}
|
2021-08-07 23:51:09 +03:00
|
|
|
}
|