Bug 1852922 - Update the encryption status UI via the request. r=kaie
Uses the nsIMsgSMIMEHeaderSink, which can be accessed from nsIMailChannel to forward calls to the UI, instead of saving references to the UI. Differential Revision: https://phabricator.services.mozilla.com/D189074 --HG-- extra : rebase_source : 1a6e405278512cee8b7447270c509bda41d98669 extra : amend_source : 8b29482d2d3cd4cc00fc0192602c68b146bdbc52
This commit is contained in:
Родитель
217ed247b0
Коммит
3961ed8dda
|
@ -177,7 +177,7 @@ MimeDecryptHandler.prototype = {
|
|||
// an in addition, remember that future information for "1" should
|
||||
// be ignored.
|
||||
|
||||
EnigmailSingletons.messageReader.ignoreStatusFrom("1");
|
||||
mimeSvc.mailChannel?.smimeHeaderSink.ignoreStatusFrom("1");
|
||||
}
|
||||
|
||||
if ("messageURI" in mimeSvc) {
|
||||
|
@ -428,7 +428,7 @@ MimeDecryptHandler.prototype = {
|
|||
);
|
||||
|
||||
if (!this.backgroundJob && currUrlSpec.indexOf(manUrlSpec) !== 0) {
|
||||
this.handleManualDecrypt();
|
||||
this.handleManualDecrypt(mimeSvc.mailChannel?.smimeHeaderSink);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ MimeDecryptHandler.prototype = {
|
|||
this.decryptedData = "";
|
||||
}
|
||||
|
||||
this.displayStatus();
|
||||
this.displayStatus(mimeSvc.mailChannel?.smimeHeaderSink);
|
||||
|
||||
// HACK: remove filename from 1st HTML and plaintext parts to make TB display message without attachment
|
||||
this.decryptedData = this.decryptedData.replace(
|
||||
|
@ -641,12 +641,12 @@ MimeDecryptHandler.prototype = {
|
|||
this.decryptedHeaders = LAST_MSG.lastStatus.decryptedHeaders;
|
||||
this.mimePartNumber = LAST_MSG.mimePartNumber;
|
||||
this.exitCode = 0;
|
||||
this.displayStatus();
|
||||
this.displayStatus(mimeSvc.mailChannel?.smimeHeaderSink);
|
||||
this.returnData(mimeSvc, LAST_MSG.lastMessageData);
|
||||
}
|
||||
},
|
||||
|
||||
displayStatus() {
|
||||
displayStatus(headerSink) {
|
||||
lazy.EnigmailLog.DEBUG("mimeDecrypt.jsm: displayStatus()\n");
|
||||
|
||||
if (this.exitCode === null || this.statusDisplayed) {
|
||||
|
@ -662,12 +662,10 @@ MimeDecryptHandler.prototype = {
|
|||
lazy.EnigmailLog.DEBUG(
|
||||
"mimeDecrypt.jsm: displayStatus for uri " + uriSpec + "\n"
|
||||
);
|
||||
let headerSink = EnigmailSingletons.messageReader;
|
||||
|
||||
if (headerSink && this.uri && !this.backgroundJob) {
|
||||
headerSink.processDecryptionResult(
|
||||
headerSink.modifyMessageHeaders(
|
||||
this.uri,
|
||||
"modifyMessageHeaders",
|
||||
JSON.stringify(this.decryptedHeaders),
|
||||
this.mimePartNumber
|
||||
);
|
||||
|
@ -818,10 +816,8 @@ MimeDecryptHandler.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
handleManualDecrypt() {
|
||||
handleManualDecrypt(headerSink) {
|
||||
try {
|
||||
let headerSink = EnigmailSingletons.messageReader;
|
||||
|
||||
if (headerSink && this.uri && !this.backgroundJob) {
|
||||
headerSink.updateSecurityStatus(
|
||||
lazy.EnigmailConstants.POSSIBLE_PGPMIME,
|
||||
|
|
|
@ -626,7 +626,8 @@ MimeVerify.prototype = {
|
|||
this.returnStatus.statusFlags |= EnigmailConstants.PARTIALLY_PGP;
|
||||
}
|
||||
|
||||
this.displayStatus();
|
||||
let mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
|
||||
this.displayStatus(mimeSvc.mailChannel?.smimeHeaderSink);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -660,16 +661,7 @@ MimeVerify.prototype = {
|
|||
this.mimeSvc.outputDecryptedData(data, data.length);
|
||||
},
|
||||
|
||||
setWindow(window, msgUriSpec) {
|
||||
lazy.EnigmailLog.DEBUG("mimeVerify.jsm: setWindow: " + msgUriSpec + "\n");
|
||||
|
||||
if (!this.window) {
|
||||
this.window = window;
|
||||
this.msgUriSpec = msgUriSpec;
|
||||
}
|
||||
},
|
||||
|
||||
displayStatus() {
|
||||
displayStatus(headerSink) {
|
||||
lazy.EnigmailLog.DEBUG("mimeVerify.jsm: displayStatus\n");
|
||||
if (this.exitCode === null || this.statusDisplayed || this.backgroundJob) {
|
||||
return;
|
||||
|
@ -677,12 +669,10 @@ MimeVerify.prototype = {
|
|||
|
||||
try {
|
||||
LOCAL_DEBUG("mimeVerify.jsm: displayStatus displaying result\n");
|
||||
let headerSink = lazy.EnigmailSingletons.messageReader;
|
||||
if (headerSink) {
|
||||
if (this.protectedHeaders) {
|
||||
headerSink.processDecryptionResult(
|
||||
headerSink.modifyMessageHeaders(
|
||||
this.uri,
|
||||
"modifyMessageHeaders",
|
||||
JSON.stringify(this.protectedHeaders.newHeaders),
|
||||
this.mimePartNumber
|
||||
);
|
||||
|
|
|
@ -25,7 +25,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
|
|||
EnigmailLog: "chrome://openpgp/content/modules/log.jsm",
|
||||
EnigmailMime: "chrome://openpgp/content/modules/mime.jsm",
|
||||
EnigmailMimeDecrypt: "chrome://openpgp/content/modules/mimeDecrypt.jsm",
|
||||
EnigmailSingletons: "chrome://openpgp/content/modules/singletons.jsm",
|
||||
EnigmailVerify: "chrome://openpgp/content/modules/mimeVerify.jsm",
|
||||
EnigmailWksMimeHandler: "chrome://openpgp/content/modules/wksMimeHandler.jsm",
|
||||
});
|
||||
|
@ -169,7 +168,7 @@ PgpMimeHandler.prototype = {
|
|||
if (!lazy.EnigmailCore.getService()) {
|
||||
// Ensure Enigmail is initialized
|
||||
if (ct.search(/application\/(x-)?pkcs7-signature/i) > 0) {
|
||||
return this.handleSmime(uri);
|
||||
return this.handleSmime(mimeSvc, uri);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -200,7 +199,7 @@ PgpMimeHandler.prototype = {
|
|||
// S/MIME signed message
|
||||
if (lastUriSpec !== gLastEncryptedUri) {
|
||||
// if message is displayed then handle like S/MIME message
|
||||
return this.handleSmime(uri);
|
||||
return this.handleSmime(mimeSvc, uri);
|
||||
}
|
||||
|
||||
// otherwise just make sure message body is returned
|
||||
|
@ -242,15 +241,14 @@ PgpMimeHandler.prototype = {
|
|||
delete this._onStopRequest;
|
||||
},
|
||||
|
||||
handleSmime(uri) {
|
||||
handleSmime(mimeSvc, uri) {
|
||||
this.contentHandler = throwErrors;
|
||||
|
||||
if (uri) {
|
||||
uri = uri.QueryInterface(Ci.nsIURI);
|
||||
}
|
||||
|
||||
let headerSink = lazy.EnigmailSingletons.messageReader;
|
||||
headerSink?.handleSMimeMessage(uri);
|
||||
mimeSvc.mailChannel?.smimeHeaderSink.handleSMimeMessage(uri);
|
||||
},
|
||||
|
||||
getMessengerWindow() {
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
var EXPORTED_SYMBOLS = ["EnigmailSingletons"];
|
||||
|
||||
var EnigmailSingletons = {
|
||||
// handle to most recent message reader window
|
||||
messageReader: null,
|
||||
|
||||
// information about the last PGP/MIME decrypted message (mimeDecrypt)
|
||||
lastDecryptedMessage: {},
|
||||
lastMessageDecryptTime: 0,
|
||||
|
|
|
@ -16,8 +16,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
|
|||
EnigmailConstants: "chrome://openpgp/content/modules/constants.jsm",
|
||||
EnigmailDecryption: "chrome://openpgp/content/modules/decryption.jsm",
|
||||
EnigmailLog: "chrome://openpgp/content/modules/log.jsm",
|
||||
EnigmailSingletons: "chrome://openpgp/content/modules/singletons.jsm",
|
||||
EnigmailVerify: "chrome://openpgp/content/modules/mimeVerify.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(lazy, "l10n", () => {
|
||||
|
@ -113,7 +111,7 @@ PgpWkdHandler.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
onStopRequest() {
|
||||
onStopRequest(request) {
|
||||
lazy.EnigmailLog.DEBUG("wksMimeHandler.jsm: onStopRequest\n");
|
||||
|
||||
if (this.data.search(/-----BEGIN PGP MESSAGE-----/i) >= 0) {
|
||||
|
@ -132,7 +130,8 @@ PgpWkdHandler.prototype = {
|
|||
});
|
||||
}
|
||||
|
||||
this.displayStatus(jsonStr);
|
||||
let mimeSvc = request.QueryInterface(Ci.nsIPgpMimeProxy);
|
||||
this.displayStatus(mimeSvc.mailChannel?.smimeHeaderSink, jsonStr);
|
||||
},
|
||||
|
||||
decryptChallengeData() {
|
||||
|
@ -214,7 +213,7 @@ PgpWkdHandler.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
displayStatus(jsonStr) {
|
||||
displayStatus(headerSink, jsonStr) {
|
||||
lazy.EnigmailLog.DEBUG("wksMimeHandler.jsm: displayStatus\n");
|
||||
if (this.backgroundJob) {
|
||||
return;
|
||||
|
@ -222,15 +221,8 @@ PgpWkdHandler.prototype = {
|
|||
|
||||
try {
|
||||
LOCAL_DEBUG("wksMimeHandler.jsm: displayStatus displaying result\n");
|
||||
let headerSink = lazy.EnigmailSingletons.messageReader;
|
||||
|
||||
if (headerSink) {
|
||||
headerSink.processDecryptionResult(
|
||||
this.uri,
|
||||
"wksConfirmRequest",
|
||||
jsonStr,
|
||||
this.mimePartNumber
|
||||
);
|
||||
headerSink.wksConfirmRequest(this.uri, jsonStr, this.mimePartNumber);
|
||||
}
|
||||
} catch (ex) {
|
||||
lazy.EnigmailLog.writeException("wksMimeHandler.jsm", ex);
|
||||
|
|
|
@ -555,7 +555,6 @@ Enigmail.hdrView = {
|
|||
}
|
||||
|
||||
Enigmail.hdrView.forgetEncryptedMsgKey();
|
||||
Enigmail.hdrView.setWindowCallback();
|
||||
} catch (ex) {
|
||||
console.debug(ex);
|
||||
}
|
||||
|
@ -787,18 +786,6 @@ Enigmail.hdrView = {
|
|||
}
|
||||
},
|
||||
|
||||
setWindowCallback() {
|
||||
EnigmailLog.DEBUG("enigmailMsgHdrViewOverlay.js: setWindowCallback\n");
|
||||
|
||||
EnigmailSingletons.messageReader = this.headerPane;
|
||||
},
|
||||
|
||||
clearWindowCallback() {
|
||||
if (EnigmailSingletons.messageReader == this.headerPane) {
|
||||
EnigmailSingletons.messageReader = null;
|
||||
}
|
||||
},
|
||||
|
||||
headerPane: {
|
||||
isCurrentMessage(uri) {
|
||||
let uriSpec = uri ? uri.spec : null;
|
||||
|
@ -1075,6 +1062,14 @@ Enigmail.hdrView = {
|
|||
"enigmailMsgHdrViewOverlay.js: EnigMimeHeaderSink.modifyMessageHeaders:\n"
|
||||
);
|
||||
|
||||
let msg = gMessage;
|
||||
if (!msg) {
|
||||
return;
|
||||
}
|
||||
if (!this.isCurrentMessage(uri)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let uriSpec = uri ? uri.spec : null;
|
||||
let hdr;
|
||||
|
||||
|
@ -1094,8 +1089,6 @@ Enigmail.hdrView = {
|
|||
return;
|
||||
}
|
||||
|
||||
let msg = gMessage;
|
||||
|
||||
if ("subject" in hdr) {
|
||||
Enigmail.hdrView.setSubject(hdr.subject);
|
||||
}
|
||||
|
@ -1210,4 +1203,3 @@ window.addEventListener(
|
|||
"load-enigmail",
|
||||
Enigmail.hdrView.hdrViewLoad.bind(Enigmail.hdrView)
|
||||
);
|
||||
window.addEventListener("unload", () => Enigmail.hdrView.clearWindowCallback());
|
||||
|
|
|
@ -365,8 +365,50 @@ var smimeHeaderSink = {
|
|||
);
|
||||
},
|
||||
|
||||
ignoreStatusFrom(aOriginMimePartNumber) {
|
||||
setIgnoreStatusFromMimePart(aOriginMimePartNumber);
|
||||
// Forward these calls to the header pane code.
|
||||
|
||||
ignoreStatusFrom(originMimePartNumber) {
|
||||
return Enigmail.hdrView.headerPane.ignoreStatusFrom(originMimePartNumber);
|
||||
},
|
||||
|
||||
modifyMessageHeaders(uri, headerData, mimePartNumber) {
|
||||
return Enigmail.hdrView.headerPane.modifyMessageHeaders(
|
||||
uri,
|
||||
headerData,
|
||||
mimePartNumber
|
||||
);
|
||||
},
|
||||
|
||||
updateSecurityStatus(
|
||||
exitCode,
|
||||
statusFlags,
|
||||
extStatusFlags,
|
||||
keyId,
|
||||
userId,
|
||||
sigDetails,
|
||||
errorMsg,
|
||||
blockSeparation,
|
||||
uri,
|
||||
extraDetails,
|
||||
mimePartNumber
|
||||
) {
|
||||
return Enigmail.hdrView.headerPane.updateSecurityStatus(
|
||||
exitCode,
|
||||
statusFlags,
|
||||
extStatusFlags,
|
||||
keyId,
|
||||
userId,
|
||||
sigDetails,
|
||||
errorMsg,
|
||||
blockSeparation,
|
||||
uri,
|
||||
extraDetails,
|
||||
mimePartNumber
|
||||
);
|
||||
},
|
||||
|
||||
handleSMimeMessage(uri) {
|
||||
return Enigmail.hdrView.headerPane.handleSMimeMessage(uri);
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIMsgSMIMEHeaderSink"]),
|
||||
|
|
|
@ -27,4 +27,27 @@ interface nsIMsgSMIMEHeaderSink : nsISupports
|
|||
in AUTF8String aMsgNeckoURL,
|
||||
in ACString originMimePartNumber);
|
||||
void ignoreStatusFrom(in ACString originMimePartNumber);
|
||||
void handleSMimeMessage(in ACString uri);
|
||||
|
||||
/**
|
||||
* Although this interface claims it's specific for S/MIME, it was later
|
||||
* reused to dispatch OpenPGP status updates, too. The 2 functions below are
|
||||
* used for OpenPGP messages.
|
||||
* TODO: Clarify this interface, rename it, or split into two separate things.
|
||||
*/
|
||||
|
||||
void modifyMessageHeaders(in ACString uri,
|
||||
in ACString headerData,
|
||||
in ACString mimePartNumber);
|
||||
void updateSecurityStatus(in ACString exitCode,
|
||||
in ACString statusFlags,
|
||||
in ACString extStatusFlags,
|
||||
in ACString keyId,
|
||||
in ACString userId,
|
||||
in ACString sigDetails,
|
||||
in ACString errorMsg,
|
||||
in ACString blockSeparation,
|
||||
in ACString uri,
|
||||
in ACString extraDetails,
|
||||
in ACString mimePartNumber);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче