~ubuntu-branches/ubuntu/oneiric/enigmail/oneiric-updates

« back to all changes in this revision

Viewing changes to extensions/enigmail/ui/content/enigmailEditIdentity.js

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2010-04-10 01:42:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100410014224-fbq9ui5x3b0h2t36
Tags: 2:1.0.1-0ubuntu1
* First releaase of enigmail 1.0.1 for tbird/icedove 3
  (LP: #527138)
* redo packaging from scratch 
  + add debian/make-orig target that uses xulrunner provided
    buildsystem + enigmail tarball to produce a proper orig.tar.gz
  + use debhelper 7 with mozilla-devscripts
  + use debian source format 3.0 (quilt)
  + patch enigmail to use frozen API only
    - add debian/patches/frozen_api.diff
  + patch build system to not link against -lxul - which isnt
    available for sdks produced by all-static apps like tbird
    - add debian/patches/build_system_dont_link_libxul.diff
  + add minimal build-depends to control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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/
 
6
 *
 
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.
 
11
 *
 
12
 * The Original Code is Enigmail.
 
13
 *
 
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.
 
18
 *
 
19
 * Contributor(s):
 
20
 *
 
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
 
31
 * GPL.
 
32
 */
 
33
 
 
34
var gEnigIdentity;
 
35
var gEnablePgp;
 
36
var gPgpKeyMode;
 
37
var gPgpkeyId;
 
38
var gEnigPrefbranch;
 
39
var gEncryptionChoicesEnabled;
 
40
var gPgpSignPlainPolicy;
 
41
var gPgpSignEncPolicy;
 
42
var gEncryptionPolicy;
 
43
var gOpenPgpHeaderUrl;
 
44
var gEnigAccount;
 
45
var gEnigDlgOnAccept;
 
46
var gPgpMimeMode;
 
47
var gEnigAdvancedSettings;
 
48
 
 
49
EnigInitCommon("pref-enigmail");
 
50
 
 
51
function enigOnInit()
 
52
{
 
53
  // initialize all of our elements based on the current identity values....
 
54
  EnigCollapseAdvanced(document.getElementById("enigmailPrefsBox"), "hidden");
 
55
 
 
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");
 
64
 
 
65
  if (gEnigIdentity) {
 
66
    gEnablePgp.checked  = gEnigIdentity.getBoolAttribute("enablePgp");
 
67
    gEncryptionChoicesEnabled = gEnablePgp.checked;
 
68
 
 
69
    var selectedItemId = null;
 
70
    var keyPolicy = gEnigIdentity.getIntAttribute("pgpKeyMode");
 
71
    switch (keyPolicy)
 
72
    {
 
73
      case 1:
 
74
        selectedItemId = 'keymode_usePgpkeyId';
 
75
        break;
 
76
      default:
 
77
        selectedItemId = 'keymode_useFromAddress';
 
78
        break;
 
79
    }
 
80
    gPgpKeyMode.selectedItem = document.getElementById(selectedItemId);
 
81
 
 
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")
 
92
    }
 
93
    
 
94
  }
 
95
  else {
 
96
    gEnablePgp.checked=false;
 
97
    gEncryptionChoicesEnabled=false;
 
98
    gEnigAdvancedSettings = {
 
99
      openPgpHeaderMode: 0,
 
100
      openPgpUrlName: "",
 
101
      attachPgpKey: false
 
102
    }
 
103
  }
 
104
 
 
105
  // Disable all locked elements on the panel
 
106
  //onLockPreference();
 
107
  enigEnableAllPrefs();
 
108
}
 
109
 
 
110
function enigOnLoadEditor() {
 
111
  if (typeof(gAccount) == "object") {
 
112
    gEnigAccount  = gAccount;
 
113
    gEnigIdentity = gIdentity;
 
114
  }
 
115
  else {
 
116
    gEnigIdentity = window.arguments[0].identity;
 
117
    gEnigAccount = window.arguments[0].account;
 
118
  }
 
119
 
 
120
  if (gEnigIdentity) {
 
121
    var idLabel = EnigGetString("identityName", gEnigIdentity.identityName);
 
122
    document.getElementById("identityName").value = idLabel;
 
123
  }
 
124
 
 
125
  var dlg = document.getElementsByTagName("dialog")[0];
 
126
  dlg.setAttribute("ondialogaccept", "return enigOnAcceptEditor();");
 
127
 
 
128
  enigOnInit();
 
129
}
 
130
 
 
131
function enigOnAcceptEditor() {
 
132
  try {
 
133
    if (onOk()==false) {
 
134
      return false;
 
135
    }
 
136
  }
 
137
  catch (ex) {}
 
138
  enigOnSave();
 
139
  if (typeof(smimeOnAcceptEditor) == "function") {
 
140
    return smimeOnAcceptEditor();
 
141
  }
 
142
  else 
 
143
    return true;
 
144
}
 
145
 
 
146
function onPreInit(account, accountValues)
 
147
{
 
148
  gEnigIdentity = account.defaultIdentity;
 
149
  gEnigAccount = account;
 
150
}
 
151
 
 
152
function enigOnSave()
 
153
{
 
154
  if (! gEnigIdentity) {
 
155
    gEnigIdentity = gIdentity;
 
156
  }
 
157
  gEnigIdentity.setBoolAttribute("enablePgp", gEnablePgp.checked);
 
158
 
 
159
  if (gEnablePgp.checked) {
 
160
    // PGP is enabled
 
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);
 
170
    
 
171
  }
 
172
}
 
173
 
 
174
function enigToggleEnable() {
 
175
  gEncryptionChoicesEnabled = (! gEncryptionChoicesEnabled);
 
176
  enigEnableAllPrefs();
 
177
}
 
178
 
 
179
function enigEnableAllPrefs()
 
180
{
 
181
  var elem = document.getElementById("bcEnablePgp");
 
182
  if (gEncryptionChoicesEnabled) {
 
183
    if (elem) elem.removeAttribute("disabled");
 
184
  }
 
185
  else {
 
186
    if (elem) elem.setAttribute("disabled", "true");
 
187
  }
 
188
 
 
189
  enigEnableKeySel(gEncryptionChoicesEnabled && (gPgpKeyMode.value == 1));
 
190
 
 
191
}
 
192
 
 
193
function enigEnableKeySel(enable)
 
194
{
 
195
  if (enable) {
 
196
    document.getElementById("bcUseKeyId").removeAttribute("disabled");
 
197
  }
 
198
  else {
 
199
    document.getElementById("bcUseKeyId").setAttribute("disabled", "true");
 
200
  }
 
201
}
 
202
 
 
203
function enigSelectKeyId()
 
204
{
 
205
  var resultObj = new Object();
 
206
  var inputObj = new Object();
 
207
  inputObj.dialogHeader = EnigGetString("encryptKeyHeader");
 
208
  inputObj.options = "single,hidexpired,private,nosending";
 
209
 
 
210
 
 
211
  window.openDialog("chrome://enigmail/content/enigmailUserSelection.xul","", "dialog,modal,centerscreen", inputObj, resultObj);
 
212
  try {
 
213
    if (resultObj.cancelled) return;
 
214
    var selKey = resultObj.userList[0];
 
215
    selKey = "0x"+selKey.substring(10,18)
 
216
    gPgpkeyId.value = selKey;
 
217
  } catch (ex) {
 
218
    // cancel pressed -> don't send mail
 
219
    return;
 
220
  }
 
221
}
 
222
 
 
223
function enigAdvancedIdentitySettings() {
 
224
  var inputObj = {
 
225
    identitySettings: gEnigAdvancedSettings,
 
226
    pgpKeyMode: gPgpKeyMode.selectedItem.value
 
227
  };
 
228
  window.openDialog("chrome://enigmail/content/enigmailAdvancedIdentityDlg.xul","", "dialog,modal,centerscreen", inputObj);
 
229
}