2021-08-07 23:51:09 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2021-08-07 23:51:09 +03:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2022-04-16 03:13:01 +03:00
|
|
|
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
|
2022-04-15 03:58:44 +03:00
|
|
|
import im.nheko
|
2021-08-07 23:51:09 +03:00
|
|
|
|
2021-11-21 06:07:57 +03:00
|
|
|
Rectangle {
|
2021-08-07 23:51:09 +03:00
|
|
|
id: r
|
|
|
|
|
|
|
|
required property int encryptionError
|
|
|
|
required property string eventId
|
|
|
|
|
2022-04-11 05:18:16 +03:00
|
|
|
color: timelineRoot.palette.alternateBase
|
2022-04-16 03:13:01 +03:00
|
|
|
height: contents.implicitHeight + Nheko.paddingMedium * 2
|
|
|
|
implicitWidth: encryptedText.implicitWidth + 24 + Nheko.paddingMedium * 3 // Column doesn't provide a useful implicitWidth, should be replaced by ColumnLayout
|
|
|
|
radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
|
|
|
|
width: parent.width ? parent.width : 0
|
2021-08-07 23:51:09 +03:00
|
|
|
|
2021-11-21 06:07:57 +03:00
|
|
|
RowLayout {
|
|
|
|
id: contents
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
|
|
|
|
Image {
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
height: width
|
2022-04-16 03:13:01 +03:00
|
|
|
source: "image://colorimage/:/icons/icons/ui/shield-filled-cross.svg?" + Nheko.theme.error
|
|
|
|
width: 24
|
2021-11-21 06:07:57 +03:00
|
|
|
}
|
|
|
|
Column {
|
|
|
|
Layout.fillWidth: true
|
2022-04-16 03:13:01 +03:00
|
|
|
spacing: Nheko.paddingSmall
|
2021-11-21 06:07:57 +03:00
|
|
|
|
|
|
|
MatrixText {
|
2022-02-09 19:53:02 +03:00
|
|
|
id: encryptedText
|
2022-04-16 03:13:01 +03:00
|
|
|
color: timelineRoot.palette.text
|
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");
|
|
|
|
}
|
|
|
|
}
|
2021-12-30 21:32:28 +03:00
|
|
|
width: parent.width
|
2021-08-07 23:51:09 +03:00
|
|
|
}
|
2021-11-21 06:07:57 +03:00
|
|
|
Button {
|
2022-04-11 05:18:16 +03:00
|
|
|
palette: timelineRoot.palette
|
2021-11-21 06:07:57 +03:00
|
|
|
text: qsTr("Request key")
|
2022-04-16 03:13:01 +03:00
|
|
|
visible: encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex
|
|
|
|
|
2021-11-21 06:07:57 +03:00
|
|
|
onClicked: room.requestKeyForEvent(eventId)
|
|
|
|
}
|
2021-08-07 23:51:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|