2019-08-28 17:54:53 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-09-08 09:17:32 +10:00
|
|
|
import Qt.labs.platform 1.1
|
2019-08-28 17:54:53 +10:00
|
|
|
import "../../Base"
|
|
|
|
import "../../utils.js" as Utils
|
|
|
|
|
2019-08-29 01:56:05 +10:00
|
|
|
HBox {
|
2019-09-08 09:17:32 +10:00
|
|
|
property var exportButton: null
|
|
|
|
|
2019-08-29 01:54:25 +10:00
|
|
|
horizontalSpacing: currentSpacing
|
|
|
|
verticalSpacing: currentSpacing
|
|
|
|
|
|
|
|
buttonModel: [
|
2019-09-08 09:17:32 +10:00
|
|
|
{ name: "export", text: qsTr("Export"), iconName: "export-keys"},
|
2019-08-29 01:54:25 +10:00
|
|
|
{ name: "import", text: qsTr("Import"), iconName: "import-keys"},
|
|
|
|
]
|
|
|
|
|
|
|
|
buttonCallbacks: ({
|
2019-09-08 09:17:32 +10:00
|
|
|
export: button => {
|
|
|
|
exportButton = button
|
|
|
|
exportFileDialog.dialog.open()
|
|
|
|
},
|
|
|
|
import: button => { importFileDialog.dialog.open() },
|
2019-08-29 01:54:25 +10:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2019-08-28 17:54:53 +10:00
|
|
|
HLabel {
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
text: qsTr(
|
|
|
|
"The decryption keys for messages you received in encrypted " +
|
2019-09-08 09:17:32 +10:00
|
|
|
"rooms can be exported to a passphrase-protected file.\n" +
|
|
|
|
"You can then import this file on another Matrix account or " +
|
|
|
|
"client, to be able to decrypt these messages again."
|
|
|
|
)
|
2019-08-28 17:54:53 +10:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2019-08-29 01:54:25 +10:00
|
|
|
HFileDialogOpener {
|
2019-09-08 09:17:32 +10:00
|
|
|
id: exportFileDialog
|
|
|
|
fill: false
|
|
|
|
dialog.title: qsTr("Save decryption keys file as...")
|
|
|
|
dialog.fileMode: FileDialog.SaveFile
|
|
|
|
onFileChanged: {
|
|
|
|
exportPasswordPopup.file = file
|
|
|
|
exportPasswordPopup.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HFileDialogOpener {
|
|
|
|
id: importFileDialog
|
2019-08-29 01:54:25 +10:00
|
|
|
fill: false
|
2019-09-08 09:17:32 +10:00
|
|
|
dialog.title: qsTr("Select a decryption keys file to import")
|
2019-08-29 01:54:25 +10:00
|
|
|
onFileChanged: {
|
|
|
|
importPasswordPopup.file = file
|
|
|
|
importPasswordPopup.open()
|
2019-08-28 17:54:53 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-08 09:17:32 +10:00
|
|
|
HPasswordPopup {
|
|
|
|
property url file: ""
|
|
|
|
|
|
|
|
id: exportPasswordPopup
|
|
|
|
label.text: qsTr("Please enter a passphrase to protect this file:")
|
|
|
|
onAcceptedPasswordChanged:
|
|
|
|
encryptionUI.exportKeys(file, acceptedPassword, exportButton)
|
|
|
|
}
|
|
|
|
|
2019-08-28 17:54:53 +10:00
|
|
|
HPasswordPopup {
|
|
|
|
property url file: ""
|
|
|
|
|
|
|
|
function verifyPassword(pass, callback) {
|
2019-09-08 09:17:32 +10:00
|
|
|
py.callCoro(
|
2019-08-28 17:54:53 +10:00
|
|
|
"check_exported_keys_passphrase",
|
|
|
|
[file.toString().replace(/^file:\/\//, ""), pass],
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
id: importPasswordPopup
|
|
|
|
label.text: qsTr(
|
|
|
|
"Please enter the passphrase that was used to protect this file:"
|
|
|
|
)
|
2019-08-29 01:42:52 +10:00
|
|
|
onAcceptedPasswordChanged:
|
2019-08-29 03:13:19 +10:00
|
|
|
encryptionUI.importKeys(file, acceptedPassword)
|
2019-08-28 17:54:53 +10:00
|
|
|
}
|
|
|
|
}
|