2019-07-25 16:43:52 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../../Base"
|
|
|
|
import "../../utils.js" as Utils
|
|
|
|
|
|
|
|
HColumnLayout {
|
|
|
|
function importKeys(file, passphrase) {
|
|
|
|
importButton.loading = true
|
|
|
|
|
2019-08-28 13:51:38 +10:00
|
|
|
let path = file.toString().replace(/^file:\/\//, "")
|
2019-07-25 16:43:52 +10:00
|
|
|
|
|
|
|
py.callClientCoro(
|
|
|
|
editAccount.userId, "import_keys", [path, passphrase], () => {
|
2019-08-28 13:51:38 +10:00
|
|
|
print("import done")
|
2019-07-25 16:43:52 +10:00
|
|
|
importButton.loading = false
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
text: qsTr(
|
2019-08-16 23:47:44 +10:00
|
|
|
"The decryption keys for messages you received in encrypted " +
|
|
|
|
"rooms can be exported to a passphrase-protected file.%1" +
|
2019-07-25 16:43:52 +10:00
|
|
|
"You will then be able to import this file in another " +
|
|
|
|
"Matrix client."
|
2019-08-20 05:37:48 +10:00
|
|
|
).arg(pageLoader.isWide ? "\n" :"\n\n")
|
2019-07-25 16:43:52 +10:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.margins: currentSpacing
|
|
|
|
}
|
|
|
|
|
|
|
|
HRowLayout {
|
2019-08-21 07:41:24 +10:00
|
|
|
HButton {
|
2019-07-25 16:43:52 +10:00
|
|
|
id: exportButton
|
2019-08-22 05:45:13 +10:00
|
|
|
icon.name: "export-keys"
|
2019-07-25 16:43:52 +10:00
|
|
|
text: qsTr("Export")
|
|
|
|
enabled: false
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
}
|
|
|
|
|
2019-08-21 07:41:24 +10:00
|
|
|
HButton {
|
2019-07-25 16:43:52 +10:00
|
|
|
id: importButton
|
2019-08-22 05:45:13 +10:00
|
|
|
icon.name: "import-keys"
|
2019-07-25 16:43:52 +10:00
|
|
|
text: qsTr("Import")
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
|
|
|
HFileDialogOpener {
|
|
|
|
id: fileDialog
|
|
|
|
dialog.title: qsTr("Select a decryption key file to import")
|
|
|
|
onFileChanged: {
|
|
|
|
importPasswordPopup.file = file
|
|
|
|
importPasswordPopup.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HPasswordPopup {
|
|
|
|
property url file: ""
|
|
|
|
|
2019-08-28 13:51:38 +10:00
|
|
|
function verifyPassword(pass, callback) {
|
|
|
|
return py.callCoro(
|
|
|
|
"check_exported_keys_passphrase",
|
|
|
|
[file.toString().replace(/^file:\/\//, ""), pass],
|
|
|
|
callback
|
2019-08-28 12:25:13 +10:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-07-25 16:43:52 +10:00
|
|
|
id: importPasswordPopup
|
|
|
|
label.text: qsTr(
|
2019-08-28 12:25:13 +10:00
|
|
|
"Please enter the passphrase that was used to protect this file:"
|
2019-07-25 16:43:52 +10:00
|
|
|
)
|
2019-08-28 13:51:38 +10:00
|
|
|
onAcceptedPasswordChanged: importKeys(file, acceptedPassword)
|
2019-07-25 16:43:52 +10:00
|
|
|
}
|
|
|
|
}
|