2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "MPL"); you may not use this file
4
* except in compliance with the MPL. You may obtain a copy of
5
* the MPL at http://www.mozilla.org/MPL/
7
* Software distributed under the MPL is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the MPL for the specific language governing
10
* rights and limitations under the MPL.
12
* The Original Code is Enigmail.
14
* The Initial Developer of this code is Patrick Brunschwig.
15
* Portions created by Patrick Brunschwig <patrick.brunschwig@gmx.net>
16
* are Copyright (C) 2005 Patrick Brunschwig.
17
* All Rights Reserved.
21
* Alternatively, the contents of this file may be used under the
22
* terms of the GNU General Public License (the "GPL"), in which case
23
* the provisions of the GPL are applicable instead of
24
* those above. If you wish to allow use of your version of this
25
* file only under the terms of the GPL and not to allow
26
* others to use your version of this file under the MPL, indicate
27
* your decision by deleting the provisions above and replace them
28
* with the notice and other provisions required by the GPL.
29
* If you do not delete the provisions above, a recipient
30
* may use your version of this file under either the MPL or the
39
var gEncryptionChoicesEnabled;
40
var gPgpSignPlainPolicy;
41
var gPgpSignEncPolicy;
42
var gEncryptionPolicy;
43
var gOpenPgpHeaderUrl;
47
var gEnigAdvancedSettings;
49
EnigInitCommon("pref-enigmail");
53
// initialize all of our elements based on the current identity values....
54
EnigCollapseAdvanced(document.getElementById("enigmailPrefsBox"), "hidden");
56
gEnablePgp = document.getElementById("enablePgp");
57
gPgpKeyMode = document.getElementById("pgpKeyMode");
58
gOpenPgpHeaderUrl = document.getElementById("openpgpHeaderMode.url");
59
gPgpkeyId = document.getElementById("identity.pgpkeyId");
60
gPgpSignEncPolicy = document.getElementById("sign_encrypted");
61
gPgpSignPlainPolicy = document.getElementById("sign_notEncrypted");
62
gEncryptionPolicy = document.getElementById("encrypt_ifPossible");
63
gPgpMimeMode = document.getElementById("pgpMimeMode");
66
gEnablePgp.checked = gEnigIdentity.getBoolAttribute("enablePgp");
67
gEncryptionChoicesEnabled = gEnablePgp.checked;
69
var selectedItemId = null;
70
var keyPolicy = gEnigIdentity.getIntAttribute("pgpKeyMode");
74
selectedItemId = 'keymode_usePgpkeyId';
77
selectedItemId = 'keymode_useFromAddress';
80
gPgpKeyMode.selectedItem = document.getElementById(selectedItemId);
82
gPgpkeyId.value = gEnigIdentity.getCharAttribute("pgpkeyId");
83
EnigGetSignMsg(gEnigIdentity);
84
gPgpSignEncPolicy.checked = gEnigIdentity.getBoolAttribute("pgpSignEncrypted");
85
gPgpSignPlainPolicy.checked = gEnigIdentity.getBoolAttribute("pgpSignPlain");
86
gPgpMimeMode.checked = gEnigIdentity.getBoolAttribute("pgpMimeMode");
87
gEncryptionPolicy.checked = (gEnigIdentity.getIntAttribute("defaultEncryptionPolicy")>0);
88
gEnigAdvancedSettings = {
89
openPgpHeaderMode: gEnigIdentity.getIntAttribute("openPgpHeaderMode"),
90
openPgpUrlName: gEnigIdentity.getCharAttribute("openPgpUrlName"),
91
attachPgpKey: gEnigIdentity.getBoolAttribute("attachPgpKey")
96
gEnablePgp.checked=false;
97
gEncryptionChoicesEnabled=false;
98
gEnigAdvancedSettings = {
105
// Disable all locked elements on the panel
106
//onLockPreference();
107
enigEnableAllPrefs();
110
function enigOnLoadEditor() {
111
if (typeof(gAccount) == "object") {
112
gEnigAccount = gAccount;
113
gEnigIdentity = gIdentity;
116
gEnigIdentity = window.arguments[0].identity;
117
gEnigAccount = window.arguments[0].account;
121
var idLabel = EnigGetString("identityName", gEnigIdentity.identityName);
122
document.getElementById("identityName").value = idLabel;
125
var dlg = document.getElementsByTagName("dialog")[0];
126
dlg.setAttribute("ondialogaccept", "return enigOnAcceptEditor();");
131
function enigOnAcceptEditor() {
139
if (typeof(smimeOnAcceptEditor) == "function") {
140
return smimeOnAcceptEditor();
146
function onPreInit(account, accountValues)
148
gEnigIdentity = account.defaultIdentity;
149
gEnigAccount = account;
152
function enigOnSave()
154
if (! gEnigIdentity) {
155
gEnigIdentity = gIdentity;
157
gEnigIdentity.setBoolAttribute("enablePgp", gEnablePgp.checked);
159
if (gEnablePgp.checked) {
161
gEnigIdentity.setIntAttribute("pgpKeyMode", gPgpKeyMode.selectedItem.value);
162
gEnigIdentity.setCharAttribute("pgpkeyId", gPgpkeyId.value);
163
gEnigIdentity.setBoolAttribute("pgpSignEncrypted", gPgpSignEncPolicy.checked);
164
gEnigIdentity.setBoolAttribute("pgpSignPlain", gPgpSignPlainPolicy.checked);
165
gEnigIdentity.setBoolAttribute("pgpMimeMode", gPgpMimeMode.checked);
166
gEnigIdentity.setIntAttribute("defaultEncryptionPolicy", (gEncryptionPolicy.checked ? 1 : 0));
167
gEnigIdentity.setIntAttribute("openPgpHeaderMode", gEnigAdvancedSettings.openPgpHeaderMode);
168
gEnigIdentity.setCharAttribute("openPgpUrlName", gEnigAdvancedSettings.openPgpUrlName);
169
gEnigIdentity.setBoolAttribute("attachPgpKey", gEnigAdvancedSettings.attachPgpKey);
174
function enigToggleEnable() {
175
gEncryptionChoicesEnabled = (! gEncryptionChoicesEnabled);
176
enigEnableAllPrefs();
179
function enigEnableAllPrefs()
181
var elem = document.getElementById("bcEnablePgp");
182
if (gEncryptionChoicesEnabled) {
183
if (elem) elem.removeAttribute("disabled");
186
if (elem) elem.setAttribute("disabled", "true");
189
enigEnableKeySel(gEncryptionChoicesEnabled && (gPgpKeyMode.value == 1));
193
function enigEnableKeySel(enable)
196
document.getElementById("bcUseKeyId").removeAttribute("disabled");
199
document.getElementById("bcUseKeyId").setAttribute("disabled", "true");
203
function enigSelectKeyId()
205
var resultObj = new Object();
206
var inputObj = new Object();
207
inputObj.dialogHeader = EnigGetString("encryptKeyHeader");
208
inputObj.options = "single,hidexpired,private,nosending";
211
window.openDialog("chrome://enigmail/content/enigmailUserSelection.xul","", "dialog,modal,centerscreen", inputObj, resultObj);
213
if (resultObj.cancelled) return;
214
var selKey = resultObj.userList[0];
215
selKey = "0x"+selKey.substring(10,18)
216
gPgpkeyId.value = selKey;
218
// cancel pressed -> don't send mail
223
function enigAdvancedIdentitySettings() {
225
identitySettings: gEnigAdvancedSettings,
226
pgpKeyMode: gPgpKeyMode.selectedItem.value
228
window.openDialog("chrome://enigmail/content/enigmailAdvancedIdentityDlg.xul","", "dialog,modal,centerscreen", inputObj);