Bug 278549 – Can't configure used certificate per mail identity in SeaMonkey

p=1ac7b2edaa08e4edd3334c5dc4b966af@fami-braun.de
r=iann_bugzilla (and me), sr=neil


git-svn-id: svn://10.0.0.236/trunk@252276 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkmelin+mozilla%iki.fi 2008-06-12 17:07:26 +00:00
parent f729d1d29b
commit ab16714331
6 changed files with 276 additions and 84 deletions

View File

@ -4,8 +4,11 @@ messenger.jar:
% overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://messenger-smime/content/msgCompSMIMEOverlay.xul
% overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://messenger-smime/content/msgHdrViewSMIMEOverlay.xul
% overlay chrome://messenger/content/mailWindowOverlay.xul chrome://messenger-smime/content/msgReadSMIMEOverlay.xul
% overlay chrome://messenger/content/am-identity-edit.xul chrome://messenger/content/am-smimeIdentityEditOverlay.xul
content/messenger/am-smime.xul (resources/content/am-smime.xul)
content/messenger/am-smime.js (resources/content/am-smime.js)
content/messenger/am-smimeIdentityEditOverlay.xul (resources/content/am-smimeIdentityEditOverlay.xul)
content/messenger/am-smimeOverlay.xul (resources/content/am-smimeOverlay.xul)
content/messenger-smime/msgCompSMIMEOverlay.js (resources/content/msgCompSMIMEOverlay.js)
content/messenger-smime/msgCompSMIMEOverlay.xul (resources/content/msgCompSMIMEOverlay.xul)
content/messenger-smime/msgReadSMIMEOverlay.js (resources/content/msgReadSMIMEOverlay.js)

View File

@ -62,6 +62,11 @@ const kEncryptionCertPref = "identity.encryption_cert_name";
const kSigningCertPref = "identity.signing_cert_name";
function onInit()
{
smimeInitializeFields();
}
function smimeInitializeFields()
{
// initialize all of our elements based on the current identity values....
gEncryptionCertName = document.getElementById(kEncryptionCertPref);
@ -77,27 +82,44 @@ function onInit()
gEncryptionChoicesLocked = false;
gSigningChoicesLocked = false;
gEncryptionCertName.value = gIdentity.getUnicharAttribute("encryption_cert_name");
if (!gIdentity) {
// The user is going to create a new identity.
// Set everything to default values.
// Do not take over the values from gAccount.defaultIdentity
// as the new identity is going to have a different mail address.
gEncryptionCertName.value = "";
gSignCertName.value = "";
gEncryptionChoices.value = gIdentity.getIntAttribute("encryptionpolicy");
if (!gEncryptionCertName.value)
{
gEncryptAlways.setAttribute("disabled", true);
gNeverEncrypt.setAttribute("disabled", true);
}
else {
enableEncryptionControls(true);
}
gSignCertName.value = gIdentity.getUnicharAttribute("signing_cert_name");
gSignMessages.checked = gIdentity.getBoolAttribute("sign_mail");
if (!gSignCertName.value)
{
gSignMessages.setAttribute("disabled", true);
gSignMessages.checked = false;
gEncryptionChoices.value = 0;
}
else {
enableSigningControls(true);
gEncryptionCertName.value = gIdentity.getUnicharAttribute("encryption_cert_name");
gEncryptionChoices.value = gIdentity.getIntAttribute("encryptionpolicy");
if (!gEncryptionCertName.value) {
gEncryptAlways.setAttribute("disabled", true);
gNeverEncrypt.setAttribute("disabled", true);
}
else {
enableEncryptionControls(true);
}
gSignCertName.value = gIdentity.getUnicharAttribute("signing_cert_name");
gSignMessages.checked = gIdentity.getBoolAttribute("sign_mail");
if (!gSignCertName.value)
{
gSignMessages.setAttribute("disabled", true);
}
else {
enableSigningControls(true);
}
}
// Always start with enabling signing and encryption cert select buttons.
@ -106,7 +128,8 @@ function onInit()
enableCertSelectButtons();
// Disable all locked elements on the panel
onLockPreference();
if (gIdentity)
onLockPreference();
}
function onPreInit(account, accountValues)
@ -115,6 +138,11 @@ function onPreInit(account, accountValues)
}
function onSave()
{
smimeSave();
}
function smimeSave()
{
// find out which radio for the encryption radio group is selected and set that on our hidden encryptionChoice pref....
var newValue = gEncryptionChoices.value;
@ -126,6 +154,19 @@ function onSave()
gIdentity.setUnicharAttribute("signing_cert_name", gSignCertName.value);
}
function smimeOnAcceptEditor()
{
try {
if (!onOk())
return false;
}
catch (ex) {}
smimeSave();
return true;
}
function onLockPreference()
{
var initPrefString = "mail.identity";
@ -409,3 +450,11 @@ function smimeClearCert(smime_cert)
enableCertSelectButtons();
}
function smimeOnLoadEditor()
{
smimeInitializeFields();
document.documentElement.setAttribute("ondialogaccept",
"return smimeOnAcceptEditor();");
}

View File

@ -1,7 +1,5 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -42,80 +40,20 @@
<?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
<?xul-overlay href="chrome://messenger/content/am-smimeOverlay.xul"?>
<!DOCTYPE page SYSTEM "chrome://messenger/locale/am-smime.dtd">
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="color-dialog"
onload="parent.onPanelLoaded('am-smime.xul');"
ondialogaccept="smimeOnAcceptEditor();">
orient="vertical">
<stringbundle id="bundle_smime" src="chrome://messenger/locale/am-smime.properties"/>
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
<script type="application/x-javascript" src="chrome://messenger/content/AccountManager.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/am-smime.js"/>
<dialogheader title="&securityTitle.label;"/>
<label hidden="true" wsm_persist="true" id="identity.encryptionpolicy" />
<description>&securityHeading.label;</description>
<groupbox id="signing.titlebox">
<caption label="&signingGroupTitle.label;"/>
<label value="&signingCert.message;" control="identity.signing_cert_name"/>
<hbox align="center">
<textbox id="identity.signing_cert_name" wsm_persist="true" flex="1"
readonly="true" disabled="true"/>
<button id="signingCertSelectButton"
label="&digitalSign.certificate.button;"
accesskey="&digitalSign.certificate.accesskey;"
oncommand="smimeSelectCert('identity.signing_cert_name')"/>
<button id="signingCertClearButton"
label="&digitalSign.certificate_clear.button;"
accesskey="&digitalSign.certificate_clear.accesskey;"
oncommand="smimeClearCert('identity.signing_cert_name')"/>
</hbox>
<separator class="thin"/>
<checkbox id="identity.sign_mail" wsm_persist="true"
label="&signMessage.label;" accesskey="&signMessage.accesskey;"/>
</groupbox>
<groupbox id="encryption.titlebox">
<caption label="&encryptionGroupTitle.label;"/>
<label value="&encryptionCert.message;" control="identity.encryption_cert_name"/>
<hbox align="center">
<textbox id="identity.encryption_cert_name" wsm_persist="true" flex="1"
readonly="true" disabled="true"/>
<button id="encryptionCertSelectButton"
label="&encryption.certificate.button;"
accesskey="&encryption.certificate.accesskey;"
oncommand="smimeSelectCert('identity.encryption_cert_name')"/>
<button id="encryptionCertClearButton"
label="&encryption.certificate_clear.button;"
accesskey="&encryption.certificate_clear.accesskey;"
oncommand="smimeClearCert('identity.encryption_cert_name')"/>
</hbox>
<separator class="thin"/>
<label value="&encryptionChoiceLabel.label;" control="encryptionChoices"/>
<radiogroup id="encryptionChoices">
<radio id="encrypt_mail_never" wsm_persist="true" value="0"
label="&neverEncrypt.label;" accesskey="&neverEncrypt.accesskey;"/>
<radio id="encrypt_mail_always" wsm_persist="true" value="2"
label="&alwaysEncryptMessage.label;" accesskey="&alwaysEncryptMessage.accesskey;"/>
</radiogroup>
</groupbox>
<vbox flex="1" id="smimeEditing"/>
</page>

View File

@ -0,0 +1,75 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is mozilla.org Code.
The Initial Developer of the Original Code is
Netscape Communications Corporation.
Portions created by the Initial Developer are Copyright (C) 1998-2001
the Initial Developer. All Rights Reserved.
Contributor(s):
ddrinan@netscape.com
Scott MacGregor <mscott@netscape.com>
Michael Braun <michael-dev@fami-braun.de>
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://messenger/skin/accountManage.css"
type="text/css"?>
<?xul-overlay href="chrome://messenger/content/am-smimeOverlay.xul"?>
<!DOCTYPE overlay SYSTEM "chrome://messenger/locale/am-smime.dtd">
<!--
This is the overlay that adds the SMIME configurator
to the identity editor of the account manager
-->
<overlay id="smimeAmIdEditOverlay"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript"
src="chrome://messenger/content/AccountManager.js"/>
<script type="application/x-javascript"
src="chrome://messenger/content/am-smime.js"/>
<tabs id="identitySettings">
<tab label="&securityTab.label;"/>
</tabs>
<tabpanels id="identityTabsPanels">
<vbox flex="1" name="smimeEditingContent" id="smimeEditing"/>
</tabpanels>
<script type="application/x-javascript">
<![CDATA[
window.addEventListener("load", smimeOnLoadEditor, false);
]]>
</script>
</overlay>

View File

@ -0,0 +1,126 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is mozilla.org Code.
The Initial Developer of the Original Code is
Netscape Communications Corporation.
Portions created by the Initial Developer are Copyright (C) 1998-2001
the Initial Developer. All Rights Reserved.
Contributor(s):
ddrinan@netscape.com
Scott MacGregor <mscott@netscape.com>
Alternatively, the contents of this file may be used under the terms of
either of the GNU General Public License Version 2 or later (the "GPL"),
or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://messenger/skin/accountManage.css"
type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://messenger/locale/am-smime.dtd">
<overlay xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox id="smimeEditing">
<stringbundleset>
<stringbundle id="bundle_smime" src="chrome://messenger/locale/am-smime.properties"/>
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
</stringbundleset>
<label hidden="true" wsm_persist="true" id="identity.encryptionpolicy"/>
<description>&securityHeading.label;</description>
<groupbox id="signing.titlebox">
<caption label="&signingGroupTitle.label;"/>
<label value="&signingCert.message;" control="identity.signing_cert_name"
prefstring="mail.identity.%identitykey%.encryptionpolicy"/>
<hbox align="center">
<textbox id="identity.signing_cert_name" wsm_persist="true" flex="1"
prefstring="mail.identity.%identitykey%.signing_cert_name"
readonly="true" disabled="true"/>
<button id="signingCertSelectButton"
label="&digitalSign.certificate.button;"
accesskey="&digitalSign.certificate.accesskey;"
oncommand="smimeSelectCert('identity.signing_cert_name')"/>
<button id="signingCertClearButton"
label="&digitalSign.certificate_clear.button;"
accesskey="&digitalSign.certificate_clear.accesskey;"
oncommand="smimeClearCert('identity.signing_cert_name')"/>
</hbox>
<separator class="thin"/>
<checkbox id="identity.sign_mail" wsm_persist="true"
prefstring="mail.identity.%identitykey%.sign_mail"
label="&signMessage.label;" accesskey="&signMessage.accesskey;"/>
</groupbox>
<groupbox id="encryption.titlebox">
<caption label="&encryptionGroupTitle.label;"/>
<label value="&encryptionCert.message;"
control="identity.encryption_cert_name"/>
<hbox align="center">
<textbox id="identity.encryption_cert_name" wsm_persist="true" flex="1"
prefstring="mail.identity.%identitykey%.encryption_cert_name"
readonly="true" disabled="true"/>
<button id="encryptionCertSelectButton"
label="&encryption.certificate.button;"
accesskey="&encryption.certificate.accesskey;"
oncommand="smimeSelectCert('identity.encryption_cert_name')"/>
<button id="encryptionCertClearButton"
label="&encryption.certificate_clear.button;"
accesskey="&encryption.certificate_clear.accesskey;"
oncommand="smimeClearCert('identity.encryption_cert_name')"/>
</hbox>
<separator class="thin"/>
<label value="&encryptionChoiceLabel.label;" control="encryptionChoices"/>
<radiogroup id="encryptionChoices">
<radio id="encrypt_mail_never" wsm_persist="true" value="0"
label="&neverEncrypt.label;"
accesskey="&neverEncrypt.accesskey;"/>
<radio id="encrypt_mail_always" wsm_persist="true" value="2"
label="&alwaysEncryptMessage.label;"
accesskey="&alwaysEncryptMessage.accesskey;"/>
</radiogroup>
</groupbox>
</vbox>
</overlay>

View File

@ -1,4 +1,5 @@
<!ENTITY securityTitle.label "Security">
<!ENTITY securityTab.label "Security">
<!ENTITY securityHeading.label "To send and receive signed or encrypted messages, you should specify both a digital signing certificate and an encryption certificate.">
<!ENTITY encryptionGroupTitle.label "Encryption">
<!ENTITY encryptionChoiceLabel.label "Default encryption setting when sending messages:">