2020-06-26 16:09:59 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
2020-07-12 12:52:14 +10:00
|
|
|
import "../Base/Buttons"
|
2020-06-26 16:09:59 +10:00
|
|
|
|
|
|
|
HFlickableColumnPopup {
|
|
|
|
id: popup
|
|
|
|
|
|
|
|
property string deviceOwner
|
|
|
|
property string deviceId
|
|
|
|
property string deviceName
|
|
|
|
property string ed25519Key
|
|
|
|
property bool deviceIsCurrent: false
|
|
|
|
property var verifiedCallback: null
|
2020-06-26 16:16:00 +10:00
|
|
|
property var blacklistedCallback: null
|
2020-06-26 16:09:59 +10:00
|
|
|
|
|
|
|
|
2020-07-12 12:52:14 +10:00
|
|
|
page.footer: AutoDirectionLayout {
|
|
|
|
PositiveButton {
|
2020-06-26 16:09:59 +10:00
|
|
|
visible: ! deviceIsCurrent
|
|
|
|
text: qsTr("They match")
|
|
|
|
icon.name: "device-verified"
|
|
|
|
onClicked: {
|
|
|
|
loading = true
|
|
|
|
|
2020-07-10 02:43:21 +10:00
|
|
|
py.callCoro(
|
|
|
|
"verify_device",
|
|
|
|
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
2020-06-26 16:09:59 +10:00
|
|
|
() => {
|
|
|
|
if (verifiedCallback) verifiedCallback()
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 12:52:14 +10:00
|
|
|
NegativeButton {
|
2020-06-26 16:09:59 +10:00
|
|
|
visible: ! popup.deviceIsCurrent
|
|
|
|
text: qsTr("They differ")
|
|
|
|
icon.name: "device-blacklisted"
|
|
|
|
onClicked: {
|
2020-06-26 16:16:00 +10:00
|
|
|
loading = true
|
|
|
|
|
2020-07-10 02:43:21 +10:00
|
|
|
py.callCoro(
|
|
|
|
"blacklist_device",
|
|
|
|
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
2020-06-26 16:16:00 +10:00
|
|
|
() => {
|
|
|
|
if (blacklistedCallback) blacklistedCallback()
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
)
|
2020-06-26 16:09:59 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CancelButton {
|
|
|
|
id: cancelButton
|
|
|
|
onClicked: popup.close()
|
|
|
|
|
|
|
|
Binding on text {
|
|
|
|
value: qsTr("Exit")
|
|
|
|
when: popup.deviceIsCurrent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 06:11:18 +10:00
|
|
|
onOpened: infoArea.forceActiveFocus()
|
|
|
|
|
2020-06-26 16:09:59 +10:00
|
|
|
SummaryLabel {
|
2020-07-12 06:11:18 +10:00
|
|
|
text:
|
|
|
|
deviceIsCurrent ?
|
|
|
|
qsTr("Your session's info:") :
|
|
|
|
qsTr("Do these info match on your other session?")
|
2020-06-26 16:09:59 +10:00
|
|
|
}
|
|
|
|
|
2020-07-12 05:51:31 +10:00
|
|
|
HTextArea {
|
2020-07-12 14:25:57 +10:00
|
|
|
id: infoArea
|
|
|
|
|
2020-06-26 16:09:59 +10:00
|
|
|
function formatInfo(info, value) {
|
|
|
|
return (
|
2020-07-12 05:51:31 +10:00
|
|
|
`<p style="line-height: 115%">` +
|
2020-06-26 16:09:59 +10:00
|
|
|
info +
|
|
|
|
`<span style="font-family: ${theme.fontFamily.mono}">` +
|
2020-07-12 05:51:31 +10:00
|
|
|
" " + value +
|
|
|
|
`</span></p>`
|
2020-06-26 16:09:59 +10:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-07-12 05:51:31 +10:00
|
|
|
readOnly: true
|
|
|
|
wrapMode: HSelectableLabel.Wrap
|
2020-06-26 16:09:59 +10:00
|
|
|
textFormat: Qt.RichText
|
|
|
|
text: (
|
2020-07-12 05:51:31 +10:00
|
|
|
formatInfo(qsTr("Session name:"), popup.deviceName) +
|
|
|
|
formatInfo(qsTr("Session ID:"), popup.deviceId) +
|
|
|
|
formatInfo(qsTr("Session key:"), "<b>"+ popup.ed25519Key+"</b>")
|
2020-06-26 16:09:59 +10:00
|
|
|
)
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
DetailsLabel {
|
|
|
|
text:
|
|
|
|
deviceIsCurrent ?
|
|
|
|
qsTr(
|
2020-07-12 06:11:18 +10:00
|
|
|
"To be verified by one of your other session, compare these " +
|
|
|
|
"info with the ones shown on that session.\n\n" +
|
|
|
|
|
|
|
|
"To be verified by another user, send them these info. " +
|
|
|
|
"If you already know them, use a trusted contact method, " +
|
|
|
|
"such as email or a phone call."
|
2020-06-26 16:09:59 +10:00
|
|
|
) :
|
|
|
|
qsTr(
|
|
|
|
"Compare with the info in your other session's account " +
|
|
|
|
"settings. " +
|
|
|
|
"If they differ, your account's security may be compromised."
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|