diff --git a/addon/_locales/de/messages.json b/addon/_locales/de/messages.json index 504aa2d..32cb173 100644 --- a/addon/_locales/de/messages.json +++ b/addon/_locales/de/messages.json @@ -288,7 +288,7 @@ "message": "Schlüssel-Import nicht möglich solange das Gerät Mitglied einer Gerätegruppe ist." }, "optionsImportSuccessPublicKey": { - "message": "Öffentlicher Schlüssel erfolgreich importiert. Bitten geben Sie die E-Mail-Adresse des Kommunikationspartners an:" + "message": "Öffentlicher Schlüssel erfolgreich importiert. Der Fingerabdruck des ausgewählten Schlüssel ist:{0}Bitten geben Sie die E-Mail-Adresse des Kommunikationspartners an:" }, "optionsImportFingerprint": { "message": "Privater Schlüssel erfolgreich importiert. Der Fingerabdruck des ausgewählten Schlüssel ist:" diff --git a/addon/_locales/en/messages.json b/addon/_locales/en/messages.json index 81d8042..a7bbc98 100644 --- a/addon/_locales/en/messages.json +++ b/addon/_locales/en/messages.json @@ -288,7 +288,7 @@ "message": "Key import not possible while the device is in a device group." }, "optionsImportSuccessPublicKey": { - "message": "Public key successfully imported. Please specify communication partner's email address:" + "message": "Public key successfully imported. The fingerprint of the selected key is:{0}Please specify communication partner's email address:" }, "optionsImportFingerprint": { "message": "Private key successfully imported. The fingerprint of the selected key is:" diff --git a/addon/content/dialogs/options.js b/addon/content/dialogs/options.js index ffc0010..a5328b0 100644 --- a/addon/content/dialogs/options.js +++ b/addon/content/dialogs/options.js @@ -372,6 +372,8 @@ var pEpOptions = { }, async importKey() { + this.cancelKey(); + // Workaround for ENGINE-808. if (Services.prefs.getBoolPref("extensions.pEp.grouped", false)) { Services.prompt.alert( @@ -411,8 +413,9 @@ var pEpOptions = { // Send to the engine. let result; + let fprs; try { - result = await pEpController.import_key(btoa(streamData)); + [result, fprs] = await pEpController.import_key_with_fpr_return(btoa(streamData)); } catch (err) { pEpController.log.error(`Key import error: ${err.message}`); Services.prompt.alert( @@ -433,11 +436,15 @@ var pEpOptions = { pEpController.log.info("Public key import"); msg = pEpOptions.getLocaleMessage("optionsImportSuccessPublicKey"); + const fpr = fprs[0].replace(/(....)/g, "$1 ").trim(); + msg = msg.replace("{0}", `\n${fpr}\n`); + let importResult = document.getElementById("importResult"); importResult.textContent = msg; importResult.removeAttribute("hidden"); - // E-Mail entry missing here. + let commPartnerAddress = document.getElementById("commPartnerAddress"); + commPartnerAddress.removeAttribute("hidden"); let button1 = document.getElementById("useForAddress"); button1.removeAttribute("hidden"); @@ -468,11 +475,31 @@ var pEpOptions = { gImportResult = result; }, + commPartnerKeyPress(event, element) { + if (event.key != "Enter" && event.key != "Tab") { + return; + } + let email = element.value; + if (!email.includes("@", 1) || email.endsWith("@")) { + // Invalid. + event.preventDefault(); + return; + } + + // Make Enter move to the next UI element as Tab already does. + if (event.key == "Enter") { + let button = document.getElementById("useForAddress"); + button.focus(); + } + }, + cancelKey() { let importResult = document.getElementById("importResult"); importResult.textContent = ""; importResult.setAttribute("hidden", "hidden"); + let commPartnerAddress = document.getElementById("commPartnerAddress"); + commPartnerAddress.setAttribute("hidden", "hidden"); let importOptions = document.getElementById("importOptions"); importOptions.setAttribute("hidden", "true"); let button1 = document.getElementById("useKey"); diff --git a/addon/content/dialogs/options.xhtml b/addon/content/dialogs/options.xhtml index a039f76..4cdade1 100644 --- a/addon/content/dialogs/options.xhtml +++ b/addon/content/dialogs/options.xhtml @@ -155,7 +155,17 @@ - +