From e76855a8f6f695b8cf508a6f159f8edd50668767 Mon Sep 17 00:00:00 2001 From: "kaie%netscape.com" Date: Wed, 19 Jun 2002 13:46:10 +0000 Subject: [PATCH] b=137071 [UE] Replies to or forwarding S/MIME encrypted mail should default to encrypt r=ducarroz sr=mscott --- .../extensions/smime/build/nsMsgSMIMECID.h | 8 +++++ .../smime/build/nsMsgSMIMEFactory.cpp | 8 ++++- .../extensions/smime/macbuild/msgsmimeIDL.xml | 30 +++++++++++++++++++ mailnews/extensions/smime/macbuild/smime.xml | 30 +++++++++++++++++++ mailnews/extensions/smime/public/MANIFEST_IDL | 1 + mailnews/extensions/smime/public/Makefile.in | 1 + mailnews/extensions/smime/public/makefile.win | 1 + .../resources/content/msgCompSMIMEOverlay.js | 17 +++++++++++ .../content/msgHdrViewSMIMEOverlay.js | 30 +++++++++++++++++++ mailnews/extensions/smime/src/Makefile.in | 2 ++ mailnews/extensions/smime/src/makefile.win | 2 ++ .../smime/src/nsEncryptedSMIMEURIsService.h | 2 +- 12 files changed, 130 insertions(+), 2 deletions(-) diff --git a/mailnews/extensions/smime/build/nsMsgSMIMECID.h b/mailnews/extensions/smime/build/nsMsgSMIMECID.h index 56c8e91424b1..b137e64ed93b 100644 --- a/mailnews/extensions/smime/build/nsMsgSMIMECID.h +++ b/mailnews/extensions/smime/build/nsMsgSMIMECID.h @@ -64,4 +64,12 @@ 0xd57d928c, 0x60e4, 0x4f81, \ {0x99, 0x9d, 0x5c, 0x76, 0x2e, 0x61, 0x12, 0x05 }} +#define NS_SMIMEENCRYPTURISERVICE_CONTRACTID \ + "@mozilla.org/messenger-smime/smime-encrypted-uris-service;1" + +#define NS_SMIMEENCRYPTURISERVICE_CID \ +{ /* a0134d58-018f-4d40-a099-fa079e5024a6 */ \ + 0xa0134d58, 0x018f, 0x4d40, \ + {0xa0, 0x99, 0xfa, 0x07, 0x9e, 0x50, 0x24, 0xa6 }} + #endif // nsMsgSMIMECID_h__ diff --git a/mailnews/extensions/smime/build/nsMsgSMIMEFactory.cpp b/mailnews/extensions/smime/build/nsMsgSMIMEFactory.cpp index c2fffe334634..563a27fa0ff9 100644 --- a/mailnews/extensions/smime/build/nsMsgSMIMEFactory.cpp +++ b/mailnews/extensions/smime/build/nsMsgSMIMEFactory.cpp @@ -51,10 +51,12 @@ /* Include all of the interfaces our factory can generate components for */ #include "nsMsgComposeSecure.h" #include "nsSMimeJSHelper.h" +#include "nsEncryptedSMIMEURIsService.h" NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgComposeSecure); NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSMIMEComposeFields); NS_GENERIC_FACTORY_CONSTRUCTOR(nsSMimeJSHelper); +NS_GENERIC_FACTORY_CONSTRUCTOR(nsEncryptedSMIMEURIsService); //////////////////////////////////////////////////////////// // @@ -73,7 +75,11 @@ static const nsModuleComponentInfo components[] = { "SMIME JS Helper", NS_SMIMEJSJELPER_CID, NS_SMIMEJSHELPER_CONTRACTID, - nsSMimeJSHelperConstructor } + nsSMimeJSHelperConstructor }, + { "SMIME Encrypted URI Cache Service", + NS_SMIMEENCRYPTURISERVICE_CID, + NS_SMIMEENCRYPTURISERVICE_CONTRACTID, + nsEncryptedSMIMEURIsServiceConstructor } }; diff --git a/mailnews/extensions/smime/macbuild/msgsmimeIDL.xml b/mailnews/extensions/smime/macbuild/msgsmimeIDL.xml index f6b2b32e4c6c..6950ac9e2526 100644 --- a/mailnews/extensions/smime/macbuild/msgsmimeIDL.xml +++ b/mailnews/extensions/smime/macbuild/msgsmimeIDL.xml @@ -710,6 +710,13 @@ + + Name + nsIEncryptedSMIMEURIsSrvc.idl + MacOS + Text + + Name nsIMsgSMIMECompFields.idl @@ -733,6 +740,11 @@ + + Name + nsIEncryptedSMIMEURIsSrvc.idl + MacOS + Name nsIMsgSMIMECompFields.idl @@ -1407,6 +1419,13 @@ + + Name + nsIEncryptedSMIMEURIsSrvc.idl + MacOS + Text + + Name nsIMsgSMIMECompFields.idl @@ -1430,6 +1449,11 @@ + + Name + nsIEncryptedSMIMEURIsSrvc.idl + MacOS + Name nsIMsgSMIMECompFields.idl @@ -1455,6 +1479,12 @@ + + headers + Name + nsIEncryptedSMIMEURIsSrvc.idl + MacOS + headers Name diff --git a/mailnews/extensions/smime/macbuild/smime.xml b/mailnews/extensions/smime/macbuild/smime.xml index 88f824811128..3b50dcc133fc 100644 --- a/mailnews/extensions/smime/macbuild/smime.xml +++ b/mailnews/extensions/smime/macbuild/smime.xml @@ -962,6 +962,13 @@ Library Debug + + Name + nsEncryptedSMIMEURIsService.cpp + MacOS + Text + + Name nsMsgComposeSecure.cpp @@ -1015,6 +1022,11 @@ xpcomDebug.shlb MacOS + + Name + nsEncryptedSMIMEURIsService.cpp + MacOS + Name nsMsgComposeSecure.cpp @@ -1941,6 +1953,13 @@ Library Debug + + Name + nsEncryptedSMIMEURIsService.cpp + MacOS + Text + + Name nsMsgComposeSecure.cpp @@ -1994,6 +2013,11 @@ xpcom.shlb MacOS + + Name + nsEncryptedSMIMEURIsService.cpp + MacOS + Name nsMsgComposeSecure.cpp @@ -2020,6 +2044,12 @@ src + + msgsmimeDebug.shlb + Name + nsEncryptedSMIMEURIsService.cpp + MacOS + msgsmimeDebug.shlb Name diff --git a/mailnews/extensions/smime/public/MANIFEST_IDL b/mailnews/extensions/smime/public/MANIFEST_IDL index 1dc9ce0f478a..e2cc1bd4568b 100644 --- a/mailnews/extensions/smime/public/MANIFEST_IDL +++ b/mailnews/extensions/smime/public/MANIFEST_IDL @@ -3,3 +3,4 @@ # nsIMsgSMIMEHeaderSink.idl +nsIEncryptedSMIMEURIsSrvc.idl diff --git a/mailnews/extensions/smime/public/Makefile.in b/mailnews/extensions/smime/public/Makefile.in index f06481a59a7a..066851c65c2e 100644 --- a/mailnews/extensions/smime/public/Makefile.in +++ b/mailnews/extensions/smime/public/Makefile.in @@ -32,6 +32,7 @@ XPIDLSRCS = \ nsIMsgSMIMECompFields.idl \ nsIMsgSMIMEHeaderSink.idl \ nsISMimeJSHelper.idl \ + nsIEncryptedSMIMEURIsSrvc.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/mailnews/extensions/smime/public/makefile.win b/mailnews/extensions/smime/public/makefile.win index a4f34398c19b..eb860961ab1c 100644 --- a/mailnews/extensions/smime/public/makefile.win +++ b/mailnews/extensions/smime/public/makefile.win @@ -26,6 +26,7 @@ XPIDLSRCS = \ .\nsIMsgSMIMECompFields.idl \ .\nsIMsgSMIMEHeaderSink.idl \ .\nsISMimeJSHelper.idl \ + .\nsIEncryptedSMIMEURIsSrvc.idl \ $(NULL) ################################################################################ diff --git a/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js b/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js index 65da81f5f4dd..b0ae1acba025 100644 --- a/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js +++ b/mailnews/extensions/smime/resources/content/msgCompSMIMEOverlay.js @@ -28,6 +28,7 @@ var gNextSecurityButtonCommand = ""; var gBundle; var gBrandBundle; var gSMFields; +var gEncryptedURIService = null; function onComposerClose() @@ -70,6 +71,15 @@ function onComposerReOpen() gSMFields.signMessage = gCurrentIdentity.getBoolAttribute("sign_mail"); + if (gEncryptedURIService && !gSMFields.requireEncryptMessage) + { + if (gEncryptedURIService.isEncrypted(gMsgCompose.originalMsgURI)) + { + // Override encryption setting if original is known as encrypted. + gSMFields.requireEncryptMessage = true; + } + } + if (gSMFields.requireEncryptMessage) { setEncryptionUI(); @@ -95,6 +105,13 @@ function onComposerReOpen() // but only on first open, not on composer recycling function smimeComposeOnLoad() { + if (!gEncryptedURIService) + { + gEncryptedURIService = + Components.classes["@mozilla.org/messenger-smime/smime-encrypted-uris-service;1"] + .getService(Components.interfaces.nsIEncryptedSMIMEURIsService); + } + onComposerReOpen(); } diff --git a/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js b/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js index 72a7790f7907..c352b110b153 100644 --- a/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js +++ b/mailnews/extensions/smime/resources/content/msgHdrViewSMIMEOverlay.js @@ -26,6 +26,9 @@ var gStatusBar = null; var gSignedStatusPanel = null; var gEncryptedStatusPanel = null; +var gEncryptedURIService = null; +var gMyLastEncryptedURI = null; + // manipulates some globals from msgReadSMIMEOverlay.js const nsICMSMessageErrors = Components.interfaces.nsICMSMessageErrors; @@ -92,6 +95,12 @@ var smimeHeaderSink = gEncryptedUINode.setAttribute("encrypted", "notok"); gStatusBar.setAttribute("encrypted", "notok"); } + + if (gEncryptedURIService) + { + gMyLastEncryptedURI = GetLoadedMessage(); + gEncryptedURIService.rememberEncrypted(gMyLastEncryptedURI); + } }, QueryInterface : function(iid) @@ -102,6 +111,15 @@ var smimeHeaderSink = } }; +function forgetEncryptedURI() +{ + if (gMyLastEncryptedURI && gEncryptedURIService) + { + gEncryptedURIService.forgetEncrypted(gMyLastEncryptedURI); + gMyLastEncryptedURI = null; + } +} + function onSMIMEStartHeaders() { gEncryptionStatus = -1; @@ -121,6 +139,8 @@ function onSMIMEStartHeaders() gEncryptedUINode.collapsed = true; gEncryptedUINode.removeAttribute("encrypted"); gStatusBar.removeAttribute("encrypted"); + + forgetEncryptedURI(); } function onSMIMEEndHeaders() @@ -145,6 +165,16 @@ function msgHdrViewSMIMEOnLoad(event) listener.onStartHeaders = onSMIMEStartHeaders; listener.onEndHeaders = onSMIMEEndHeaders; gMessageListeners.push(listener); + + gEncryptedURIService = + Components.classes["@mozilla.org/messenger-smime/smime-encrypted-uris-service;1"] + .getService(Components.interfaces.nsIEncryptedSMIMEURIsService); +} + +function msgHdrViewSMIMEOnUnload(event) +{ + forgetEncryptedURI(); } addEventListener('messagepane-loaded', msgHdrViewSMIMEOnLoad, true); +addEventListener('messagepane-unloaded', msgHdrViewSMIMEOnUnload, true); diff --git a/mailnews/extensions/smime/src/Makefile.in b/mailnews/extensions/smime/src/Makefile.in index cf0419a34d23..bd96ba860a5c 100644 --- a/mailnews/extensions/smime/src/Makefile.in +++ b/mailnews/extensions/smime/src/Makefile.in @@ -43,11 +43,13 @@ REQUIRES = xpcom \ CPPSRCS = \ nsMsgComposeSecure.cpp \ nsSMimeJSHelper.cpp \ + nsEncryptedSMIMEURIsService.cpp \ $(NULL) EXPORTS = \ nsMsgComposeSecure.h \ nsSMimeJSHelper.h \ + nsEncryptedSMIMEURIsService.h \ $(NULL) EXTRA_COMPONENTS = smime-service.js diff --git a/mailnews/extensions/smime/src/makefile.win b/mailnews/extensions/smime/src/makefile.win index 866c3ce580e5..12e235e130ce 100644 --- a/mailnews/extensions/smime/src/makefile.win +++ b/mailnews/extensions/smime/src/makefile.win @@ -67,6 +67,7 @@ include <$(DEPTH)\config\config.mak> EXPORTS= nsMsgComposeSecure.h \ nsSMimeJSHelper.h \ + nsEncryptedSMIMEURIsService.h \ $(NULL) ################################################################################ @@ -76,6 +77,7 @@ LIBRARY_NAME=msgsmime_s CPP_OBJS= .\$(OBJDIR)\nsMsgComposeSecure.obj \ .\$(OBJDIR)\nsSMimeJSHelper.obj \ + .\$(OBJDIR)\nsEncryptedSMIMEURIsService.obj \ $(NULL) diff --git a/mailnews/extensions/smime/src/nsEncryptedSMIMEURIsService.h b/mailnews/extensions/smime/src/nsEncryptedSMIMEURIsService.h index d35779fa6985..09f1a9a35925 100644 --- a/mailnews/extensions/smime/src/nsEncryptedSMIMEURIsService.h +++ b/mailnews/extensions/smime/src/nsEncryptedSMIMEURIsService.h @@ -37,7 +37,7 @@ #ifndef _nsEncryptedSMIMEURIsService_H_ #define _nsEncryptedSMIMEURIsService_H_ -#include "nsIEncryptedSMIMEURIsService.h" +#include "nsIEncryptedSMIMEURIsSrvc.h" #include "nsVoidArray.h" class nsEncryptedSMIMEURIsService : public nsIEncryptedSMIMEURIsService