Bug 284369 UI for encrypted messages that can't be decrypted not dramantic.

This patch adds UI information to the user when the message can't be displayed
because the message was encrypted and a key could not be found. It also adds
event handling to redraw the screen if a smartcard is insert.

SR+=mScott a1.8b4=asa
This commit is contained in:
relyea%netscape.com 2005-07-29 22:01:08 +00:00
Родитель 4de7a414e1
Коммит db871aeb76
8 изменённых файлов: 57 добавлений и 7 удалений

Просмотреть файл

@ -44,6 +44,9 @@ var gStatusBar = null;
var gEncryptedURIService = null;
var gMyLastEncryptedURI = null;
var gSMIMEBundle = null;
//var gBrandBundle; -- defined in mailWindow.js
// manipulates some globals from msgReadSMIMEOverlay.js
const nsICMSMessageErrors = Components.interfaces.nsICMSMessageErrors;
@ -121,6 +124,26 @@ var smimeHeaderSink =
gMyLastEncryptedURI = GetLoadedMessage();
gEncryptedURIService.rememberEncrypted(gMyLastEncryptedURI);
}
if (nsICMSMessageErrors.SUCCESS != aEncryptionStatus)
{
var brand = gBrandBundle.getString("brandShortName");
var title = gSMIMEBundle.getString("CantDecryptTitle").replace(/%brand%/g,brand);
var body = gSMIMEBundle.getString("CantDecryptBody").replace(/%brand%/g,brand);
// insert our message
msgWindow.displayHTMLInMessagePane(title,
"<html>\n"+
"<body bgcolor=\"#fafaee\">\n"+
"<center><br><br><br>\n"+
"<table>\n"+
"<tr><td>\n"+
"<center><strong><font size=\"+3\">\n"+
title+"</font></center><br>\n"+
body+"\n"+
"</td></tr></table></center></body></html>", false);
}
},
QueryInterface : function(iid)
@ -164,8 +187,22 @@ function onSMIMEStartHeaders()
function onSMIMEEndHeaders()
{}
function onSmartCardChange()
{
// only reload encrypted windows
if (gMyLastEncryptedURI && gEncryptionStatus != -1) {
ReloadMessage();
}
}
function msgHdrViewSMIMEOnLoad(event)
{
window.crypto.enableSmartCardEvents = true;
document.addEventListener("smartcard-insert", onSmartCardChange, false);
document.addEventListener("smartcard-remove", onSmartCardChange, false);
if (!gSMIMEBundle)
gSMIMEBundle = document.getElementById("bundle_read_smime");
// we want to register our security header sink as an opaque nsISupports
// on the msgHdrSink used by mail.....
msgWindow.msgHeaderSink.securityInfo = smimeHeaderSink;
@ -189,6 +226,9 @@ function msgHdrViewSMIMEOnLoad(event)
function msgHdrViewSMIMEOnUnload(event)
{
window.crypto.enableSmartCardEvents = false;
document.removeEventListener("smartcard-insert", onSmartCardChange, false);
document.removeEventListener("smartcard-remove", onSmartCardChange, false);
forgetEncryptedURI();
}

Просмотреть файл

@ -1 +1,7 @@
ImapOnDemand=The displayed message has been digitally signed, but not all its attachments have been downloaded yet. Therefore, the signature cannot be validated. Click OK to download the complete message and validate the signature.
#
#NOTE To translater, anything between %..% and <..> should not be translated.
# the former will be replaced by java script, and the latter is HTML formatting.
#
CantDecryptTitle=%brand% cannot decrypt this message
CantDecryptBody=The sender encrypted this message to you using one of your digital certificates, however %brand% was not able to find this certificate and corresponding private key. <br> Possible solutions: <br><ul><li>If you have a smartcard, please insert it now. <li>If you are using a new machine, or if you are using a new %brand% profile, you will need to restore your certificate and private key from a backup. Certificate backups usually end in ".p12".</ul>

Просмотреть файл

@ -60,7 +60,7 @@ interface nsIMsgMessagePaneController : nsISupports {
};
[scriptable, uuid(BD85A416-5433-11d3-8AC5-0060B0FC04D2)]
[scriptable, uuid(BCE0AB71-11FF-428E-9EDC-69ABAD73b697)]
interface nsIMsgWindow : nsISupports {
attribute nsIMsgMessagePaneController messagePaneController;
@ -69,7 +69,7 @@ interface nsIMsgWindow : nsISupports {
attribute nsITransactionManager transactionManager;
attribute nsIMsgFolder openFolder;
attribute nsIDocShell rootDocShell;
void displayHTMLInMessagePane(in wstring title, in wstring body);
void displayHTMLInMessagePane(in wstring title, in wstring body, in boolean clearMsgHdr);
readonly attribute nsIPrompt promptDialog;
attribute string mailCharacterSet;

Просмотреть файл

@ -502,11 +502,11 @@ NS_IMETHODIMP nsMsgWindow::GetPromptDialog(nsIPrompt **aPrompt)
}
NS_IMETHODIMP
nsMsgWindow::DisplayHTMLInMessagePane(const PRUnichar *title, const PRUnichar *body)
nsMsgWindow::DisplayHTMLInMessagePane(const PRUnichar *title, const PRUnichar *body, PRBool clearMsgHdr)
{
nsresult rv;
if (mMsgPaneController)
if (clearMsgHdr && mMsgPaneController)
mMsgPaneController->ClearMsgPane();
nsString htmlStr;

Просмотреть файл

@ -1676,7 +1676,7 @@ NS_IMETHODIMP nsMsgIncomingServer::DisplayOfflineMsg(nsIMsgWindow *aMsgWindow)
bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodybody").get(), getter_Copies(errorMsgBody));
bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodytitle").get(), getter_Copies(errorMsgTitle));
if (aMsgWindow)
return aMsgWindow->DisplayHTMLInMessagePane(errorMsgTitle, errorMsgBody);
return aMsgWindow->DisplayHTMLInMessagePane(errorMsgTitle, errorMsgBody, PR_TRUE);
else
return NS_ERROR_FAILURE;

Просмотреть файл

@ -43,6 +43,11 @@
<script language="JavaScript" src="chrome://messenger-smime/content/msgHdrViewSMIMEOverlay.js"/>
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_read_smime" src="chrome://messenger-smime/locale/msgReadSMIMEOverlay.properties"/>
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
</stringbundleset>
<hbox id="expandedHeaderView">
<vbox id="smimeBox" insertafter="expandedHeaders" collapsed="true">
<spacer flex="1"/>

Просмотреть файл

@ -1 +0,0 @@
ImapOnDemand=The displayed message has been digitally signed, but not all its attachments have been downloaded yet. Therefore, the signature cannot be validated. Click OK to download the complete message and validate the signature.

Просмотреть файл

@ -2310,7 +2310,7 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
// call nsDocShell::Stop(STOP_NETWORK), which will eventually
// call nsNNTPProtocol::Cancel(), which will close the socket.
// we need to fix this, since the connection is still valid.
rv = m_msgWindow->DisplayHTMLInMessagePane((const PRUnichar *)titleStr, errorHtml.get());
rv = m_msgWindow->DisplayHTMLInMessagePane((const PRUnichar *)titleStr, errorHtml.get(), PR_TRUE);
NS_ENSURE_SUCCESS(rv,rv);
}
// let's take the opportunity of removing the hdr from the db so we don't try to download