Bug 1677088 - remove EnigmailDialog.promptValue. r=PatrickBrunschwig
Differential Revision: https://phabricator.services.mozilla.com/D127943 --HG-- extra : rebase_source : aa3698d4cbe5941735f82aead00b9d58020a75c6 extra : amend_source : 0d770f6ba6fc283b9bbf209090a74e52f1841147
This commit is contained in:
Родитель
903fe937eb
Коммит
fb268ae384
|
@ -141,26 +141,6 @@ var EnigmailDialog = {
|
|||
return result.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Display a dialog with a message and a text entry field
|
||||
*
|
||||
* @win: nsIWindow - parent window to display modal dialog; can be null
|
||||
* @mesg: String - message text
|
||||
* @valueObj: Object - object to hold the entered text in .value
|
||||
*
|
||||
* @return: Boolean - true if OK was pressed / false otherwise
|
||||
*/
|
||||
promptValue(win, mesg, valueObj) {
|
||||
return Services.prompt.prompt(
|
||||
win,
|
||||
l10n.formatValueSync("enig-prompt"),
|
||||
mesg,
|
||||
valueObj,
|
||||
"",
|
||||
{}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Display an alert message with an OK button and a checkbox to hide
|
||||
* the message in the future.
|
||||
|
|
|
@ -702,10 +702,13 @@ function enigmailSearchKey() {
|
|||
value: "",
|
||||
};
|
||||
if (
|
||||
!EnigmailDialog.promptValue(
|
||||
!Services.prompt.prompt(
|
||||
window,
|
||||
l10n.formatValueSync("enig-prompt"),
|
||||
l10n.formatValueSync("openpgp-key-man-discover-prompt"),
|
||||
result
|
||||
result,
|
||||
"",
|
||||
{}
|
||||
)
|
||||
) {
|
||||
return;
|
||||
|
@ -946,94 +949,97 @@ function enigmailReceiveKeyCb(exitCode, errorMsg, msgBox) {
|
|||
*/
|
||||
|
||||
function enigmailImportKeysFromUrl() {
|
||||
var value = {
|
||||
var result = {
|
||||
value: "",
|
||||
};
|
||||
if (
|
||||
EnigmailDialog.promptValue(
|
||||
!Services.prompt.prompt(
|
||||
window,
|
||||
l10n.formatValueSync("enig-prompt"),
|
||||
l10n.formatValueSync("import-from-url"),
|
||||
value
|
||||
result,
|
||||
"",
|
||||
{}
|
||||
)
|
||||
) {
|
||||
var p = new Promise(function(resolve, reject) {
|
||||
var cbFunc = async function(data) {
|
||||
EnigmailLog.DEBUG("enigmailImportKeysFromUrl: _cbFunc()\n");
|
||||
var errorMsgObj = {};
|
||||
|
||||
var preview = EnigmailKey.getKeyListFromKeyBlock(
|
||||
data,
|
||||
errorMsgObj,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
// should we allow importing secret keys?
|
||||
if (preview && preview.length > 0) {
|
||||
let confirmImport = false;
|
||||
let outParam = {};
|
||||
confirmImport = EnigmailDialog.confirmPubkeyImport(
|
||||
window,
|
||||
preview,
|
||||
outParam
|
||||
);
|
||||
if (confirmImport) {
|
||||
EnigmailKeyRing.importKey(
|
||||
window,
|
||||
false,
|
||||
data,
|
||||
false,
|
||||
"",
|
||||
errorMsgObj,
|
||||
null,
|
||||
false,
|
||||
[],
|
||||
false,
|
||||
true,
|
||||
null,
|
||||
outParam.acceptance
|
||||
);
|
||||
errorMsgObj.preview = preview;
|
||||
resolve(errorMsgObj);
|
||||
}
|
||||
} else {
|
||||
EnigmailDialog.alert(
|
||||
window,
|
||||
await document.l10n.formatValue("preview-failed")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
var bufferListener = EnigmailStreams.newStringStreamListener(cbFunc);
|
||||
var ioServ = Services.io;
|
||||
var msgUri = ioServ.newURI(value.value);
|
||||
|
||||
var channel = EnigmailStreams.createChannel(msgUri);
|
||||
channel.asyncOpen(bufferListener, msgUri);
|
||||
} catch (ex) {
|
||||
var err = {
|
||||
value: ex,
|
||||
};
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
p.then(function(errorMsgObj) {
|
||||
var keyList = errorMsgObj.preview.map(function(a) {
|
||||
return a.id;
|
||||
});
|
||||
EnigmailDialog.keyImportDlg(window, keyList);
|
||||
refreshKeys();
|
||||
}).catch(async function(reason) {
|
||||
EnigmailDialog.alert(
|
||||
window,
|
||||
await document.l10n.formatValue("general-error", {
|
||||
reason: reason.value,
|
||||
})
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
var p = new Promise(function(resolve, reject) {
|
||||
var cbFunc = async function(data) {
|
||||
EnigmailLog.DEBUG("enigmailImportKeysFromUrl: _cbFunc()\n");
|
||||
var errorMsgObj = {};
|
||||
|
||||
var preview = EnigmailKey.getKeyListFromKeyBlock(
|
||||
data,
|
||||
errorMsgObj,
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
// should we allow importing secret keys?
|
||||
if (preview && preview.length > 0) {
|
||||
let confirmImport = false;
|
||||
let outParam = {};
|
||||
confirmImport = EnigmailDialog.confirmPubkeyImport(
|
||||
window,
|
||||
preview,
|
||||
outParam
|
||||
);
|
||||
if (confirmImport) {
|
||||
EnigmailKeyRing.importKey(
|
||||
window,
|
||||
false,
|
||||
data,
|
||||
false,
|
||||
"",
|
||||
errorMsgObj,
|
||||
null,
|
||||
false,
|
||||
[],
|
||||
false,
|
||||
true,
|
||||
null,
|
||||
outParam.acceptance
|
||||
);
|
||||
errorMsgObj.preview = preview;
|
||||
resolve(errorMsgObj);
|
||||
}
|
||||
} else {
|
||||
EnigmailDialog.alert(
|
||||
window,
|
||||
await document.l10n.formatValue("preview-failed")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
var bufferListener = EnigmailStreams.newStringStreamListener(cbFunc);
|
||||
var msgUri = Services.io.newURI(result.value.trim());
|
||||
|
||||
var channel = EnigmailStreams.createChannel(msgUri);
|
||||
channel.asyncOpen(bufferListener, msgUri);
|
||||
} catch (ex) {
|
||||
var err = {
|
||||
value: ex,
|
||||
};
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
p.then(function(errorMsgObj) {
|
||||
var keyList = errorMsgObj.preview.map(function(a) {
|
||||
return a.id;
|
||||
});
|
||||
EnigmailDialog.keyImportDlg(window, keyList);
|
||||
refreshKeys();
|
||||
}).catch(async function(reason) {
|
||||
EnigmailDialog.alert(
|
||||
window,
|
||||
await document.l10n.formatValue("general-error", {
|
||||
reason: reason.value,
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function initiateAcKeyTransfer() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче