3
* ***** BEGIN LICENSE BLOCK *****
4
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
* The contents of this file are subject to the Mozilla Public
7
* License Version 1.1 (the "MPL"); you may not use this file
8
* except in compliance with the MPL. You may obtain a copy of
9
* the MPL at http://www.mozilla.org/MPL/
11
* Software distributed under the MPL is distributed on an "AS
12
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13
* implied. See the MPL for the specific language governing
14
* rights and limitations under the MPL.
16
* The Original Code is Enigmail.
18
* The Initial Developer of the Original Code is Patrick Brunschwig.
19
* Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
20
* Copyright (C) 2005 Patrick Brunschwig. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the MPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** *
38
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
39
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
42
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
44
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
48
<dialog id="enigmailSetCardPingDlg"
49
title="&enigmail.cardPin.title;"
50
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
52
ondialogaccept="return onAccept();"
58
<label value="&enigmail.cardPin.action.label;" control="actionMenu"/>
59
<menulist id="actionMenu" label="&enigmail.cardPin.changePin.label;" value="P">
60
<menupopup id="actionMenuPopup">
61
<menuitem id="changePin"
62
label="&enigmail.cardPin.changePin.label;"
64
oncommand="setDlgContent('P')"/>
65
<menuitem id="changeAPin"
66
label="&enigmail.cardPin.changeAdmPin.label;"
67
oncommand="setDlgContent('A')"/>
68
<menuitem id="unblockPin"
69
label="&enigmail.cardPin.unblockPin.label;"
70
oncommand="setDlgContent('U')"/>
81
<row align="center" id="currAdminPinRow" collapsed="true">
82
<label value="&enigmail.cardPin.currAdmPin.label; :" type="password" control="currAdmPinTxt"/>
83
<textbox id="currAdmPinTxt" value="" type="password"/>
85
<row align="center" id="adminPinRow" collapsed="true">
86
<label value="&enigmail.cardPin.newAdminPin.label; :" control="adminPinTxt"/>
87
<textbox id="adminPinTxt" value="" type="password"/>
89
<row align="center" id="adminPinRepeatRow" collapsed="true">
90
<label value="&enigmail.cardPin.adminPinRepeat.label; :" control="adminPinRepeatTxt"/>
91
<textbox id="adminPinRepeatTxt" value="" type="password"/>
93
<row align="center" id="currPinRow">
94
<label value="&enigmail.cardPin.currPin.label; :" control="currPinTxt"/>
95
<textbox id="currPinTxt" value="" type="password"/>
97
<row align="center" id="pinRow">
98
<label value="&enigmail.cardPin.newPin.label; :" control="pinTxt"/>
99
<textbox id="pinTxt" value="" type="password"/>
101
<row align="center" id="pinRepeatRow">
102
<label value="&enigmail.cardPin.pinRepeat.label; :" control="pinRepeatTxt"/>
103
<textbox id="pinRepeatTxt" value="" type="password"/>
109
<script type="application/x-javascript">
112
Components.utils.import("resource://enigmail/enigmailCommon.jsm");
113
Components.utils.import("resource://enigmail/keyManagement.jsm");
115
const Ec = EnigmailCommon;
116
const nsIEnigmail = Components.interfaces.nsIEnigmail;
117
const Ci = Components.interfaces;
119
const CHANGE_PIN = 'P';
120
const ADMIN_PIN = 'A';
121
const UNBLOCK_PIN = 'U';
126
setDlgContent(CHANGE_PIN);
129
function onAccept() {
130
var enigmailSvc = Ec.getService(window);
142
pinItem2="pinRepeatTxt";
144
action = nsIEnigmail.CARD_PIN_CHANGE;
148
pinItem2="pinRepeatTxt";
150
action = nsIEnigmail.CARD_PIN_UNBLOCK;
153
pinItem1="adminPinTxt";
154
pinItem2="adminPinRepeatTxt";
156
action = nsIEnigmail.CARD_ADMIN_PIN_CHANGE;
163
if (! enigmailSvc.useGpgAgent()) {
164
adminPin = document.getElementById("currAdmPinTxt").value;
165
oldPin = document.getElementById("currPinTxt").value;
166
newPin = document.getElementById(pinItem1).value;
168
if (newPin.length < minLen) {
169
Ec.alert(window, Ec.getString("cardPin.minLength", minLen));
172
if (newPin != document.getElementById(pinItem2).value) {
173
Ec.alert(window, Ec.getString("cardPin.dontMatch"));
178
var pinObserver = new changePinObserver();
180
EnigmailKeyMgmt.cardChangePin(window,
186
function _ChangePinCb(exitCode, errorMsg) {
188
Ec.alert(window, Ec.getString("cardPin.processFailed")+"\n"+pinObserver.result);
197
function dlgEnable(item) {
198
document.getElementById(item).removeAttribute("collapsed");
201
function dlgDisable(item) {
202
document.getElementById(item).setAttribute("collapsed", "true");
205
function setDlgContent(sel) {
206
var enigmailSvc = Ec.getService(window);
212
if (enigmailSvc.useGpgAgent()) {
213
dlgDisable("currAdminPinRow");
214
dlgDisable("adminPinRow");
215
dlgDisable("adminPinRepeatRow");
216
dlgDisable("currPinRow");
217
dlgDisable("pinRow");
218
dlgDisable("pinRepeatRow");
224
dlgDisable("currAdminPinRow");
225
dlgDisable("adminPinRow");
226
dlgDisable("adminPinRepeatRow");
227
dlgEnable("currPinRow");
229
dlgEnable("pinRepeatRow");
232
dlgEnable("currAdminPinRow");
233
dlgEnable("adminPinRow");
234
dlgEnable("adminPinRepeatRow");
235
dlgDisable("currPinRow");
236
dlgDisable("pinRow");
237
dlgDisable("pinRepeatRow");
240
dlgEnable("currAdminPinRow");
241
dlgDisable("adminPinRow");
242
dlgDisable("adminPinRepeatRow");
243
dlgDisable("currPinRow");
245
dlgEnable("pinRepeatRow");
250
function changePinObserver() {
253
changePinObserver.prototype =
258
QueryInterface : function(iid)
260
if (iid.equals(Ci.nsIEnigMimeReadCallback) ||
261
iid.equals(Ci.nsISupports) )
264
throw Components.results.NS_NOINTERFACE;
267
onDataAvailable: function (data) {
269
Ec.DEBUG_LOG("enigmailSetCardPin: changePinObserver.onDataAvailable: data="+data+"\n");
270
if (data.indexOf("[GNUPG:] SC_OP_FAILURE")>=0) {
271
this.result = this._data;
273
else if (data.indexOf("[GNUPG:] BAD_PASSPHRASE")>=0) {
274
this.result = Ec.getString("badPhrase");