1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public
5
* License Version 1.1 (the "MPL"); you may not use this file
6
* except in compliance with the MPL. You may obtain a copy of
7
* the MPL at http://www.mozilla.org/MPL/
9
* Software distributed under the MPL is distributed on an "AS
10
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
* implied. See the MPL for the specific language governing
12
* rights and limitations under the MPL.
14
* The Original Code is Enigmail.
16
* The Initial Developer of the Original Code is Patrick Brunschwig.
17
* Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
18
* Copyright (C) 2005 Patrick Brunschwig. All Rights Reserved.
22
* Alternatively, the contents of this file may be used under the terms of
23
* either the GNU General Public License Version 2 or later (the "GPL"), or
24
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25
* in which case the provisions of the GPL or the LGPL are applicable instead
26
* of those above. If you wish to allow use of your version of this file only
27
* under the terms of either the GPL or the LGPL, and not to allow others to
28
* use your version of this file under the terms of the MPL, indicate your
29
* decision by deleting the provisions above and replace them with the notice
30
* and other provisions required by the GPL or the LGPL. If you do not delete
31
* the provisions above, a recipient may use your version of this file under
32
* the terms of any one of the MPL, the GPL or the LGPL.
33
* ***** END LICENSE BLOCK ***** */
35
Components.utils.import("resource://enigmail/commonFuncs.jsm");
36
Components.utils.import("resource://enigmail/enigmailCommon.jsm");
37
Components.utils.import("resource://enigmail/keyManagement.jsm");
39
const Ec = EnigmailCommon;
44
var enigmailSvc = Ec.getService(window);
46
Ec.dispatchEvent(failWithError, 0, Ec.getString("accessError"));
49
var exitCodeObj = new Object();
50
var errorMsgObj = new Object();
54
dryRun = Ec.getPref("dryRun");
58
var cardStr = enigmailSvc.getCardStatus(exitCodeObj, errorMsgObj);
59
if (exitCodeObj.value == 0) {
60
var statusList=cardStr.split(/[\r\n]+/);
61
for (var i=0; i<statusList.length; i++) {
62
var l=statusList[i].split(/:/);
65
setValue("firstname", Ec.convertGpgToUnicode(l[1]));
66
setValue(l[0], Ec.convertGpgToUnicode(l[2]));
69
setValue(l[0], Ec.convertGpgToUnicode(l[2].replace(/\\x3a/ig, ":")));
73
var selItem = document.getElementById("card_"+l[0]+"_"+l[1]);
74
document.getElementById("card_"+l[0]).selectedItem = selItem;
75
gCardData[l[0]] = l[1];
79
setValue(l[0], l[1]+" / "+l[2]+" / "+l[3]);
82
setValue("key_fpr_1", EnigmailFuncs.formatFpr(l[1]));
83
setValue("key_fpr_2", EnigmailFuncs.formatFpr(l[2]));
84
setValue("key_fpr_3", EnigmailFuncs.formatFpr(l[3]));
87
setValue("card_key_created_1", Ec.getDateTime(l[1]), true, false);
88
setValue("card_key_created_2", Ec.getDateTime(l[2]), true, false);
89
setValue("card_key_created_3", Ec.getDateTime(l[3]), true, false);
93
setValue(l[0], Ec.convertGpgToUnicode(l[1].replace(/\\x3a/ig, ":")));
100
Ec.dispatchEvent(failWithError, 0, errorMsgObj.value);
106
function failWithError(errorMsg) {
107
Ec.alert(window, errorMsg);
112
function setValue(attrib, value) {
113
var elem = document.getElementById("card_"+attrib);
117
gCardData[attrib] = value;
120
function getValue(attrib) {
121
var elem = document.getElementById("card_"+attrib);
130
function getSelection(attrib) {
131
var elem = document.getElementById("card_"+attrib);
133
return elem.selectedItem.value;
140
function doEditData() {
141
document.getElementById("bcEditMode").removeAttribute("readonly");
142
document.getElementById("bcEnableMode").removeAttribute("disabled");
146
document.getElementById("bcEditMode").setAttribute("readonly", "true");
147
document.getElementById("bcEnableMode").setAttribute("disabled", "true");
151
function doSaveChanges() {
152
document.getElementById("bcEditMode").setAttribute("readonly", "true");
153
document.getElementById("bcEnableMode").setAttribute("disabled", "true");
155
var enigmailSvc = Ec.getService(window);
157
Ec.alert(window, Ec.getString("accessError"));
162
var forcepin = (getSelection("forcepin") == gCardData.forcepin ? 0 : 1);
163
EnigmailKeyMgmt.cardAdminData(window,
164
Ec.convertFromUnicode(getValue("name")),
165
Ec.convertFromUnicode(getValue("firstname")),
168
Ec.convertFromUnicode(getValue("url")),
171
function _cardAdminCb(exitCode, errorMsg) {
173
Ec.alert(window, errorMsg);
180
function engmailGenerateCardKey() {
181
window.openDialog("chrome://enigmail/content/enigmailGenCardKey.xul",
182
"", "dialog,modal,centerscreen");
184
var enigmailSvc = Ec.getService(window);
186
enigmailSvc.invalidateUserIdList();
191
function enigmailAdminPin() {
192
window.openDialog("chrome://enigmail/content/enigmailSetCardPin.xul",
193
"", "dialog,modal,centerscreen");