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

« back to all changes in this revision

Viewing changes to extensions/enigmail/ui/content/enigmailSetCardPin.xul

  • 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
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
 
35
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
 
36
 
 
37
<!DOCTYPE window [
 
38
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
 
39
%brandDTD;
 
40
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
 
41
%enigMailDTD;
 
42
]>
 
43
 
 
44
<dialog id="enigmailSetCardPingDlg"
 
45
        title="&enigmail.cardPin.title;"
 
46
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
 
47
        onload="onLoad();"
 
48
        ondialogaccept="return onAccept();"
 
49
        >
 
50
 
 
51
 
 
52
  <script type="application/x-javascript" src="chrome://enigmail/content/enigmailCommon.js"/>
 
53
 
 
54
 
 
55
  <vbox>
 
56
    <hbox align="center">
 
57
      <label value="&enigmail.cardPin.action.label;" control="actionMenu"/>
 
58
      <menulist id="actionMenu" label="&enigmail.cardPin.changePin.label;" value="P">
 
59
        <menupopup id="actionMenuPopup">
 
60
          <menuitem id="changePin"
 
61
                    label="&enigmail.cardPin.changePin.label;"
 
62
                    selected="true"
 
63
                    oncommand="setDlgContent('P')"/>
 
64
          <menuitem id="changeAPin"
 
65
                    label="&enigmail.cardPin.changeAdmPin.label;"
 
66
                    oncommand="setDlgContent('A')"/>
 
67
          <menuitem id="unblockPin"
 
68
                    label="&enigmail.cardPin.unblockPin.label;"
 
69
                    oncommand="setDlgContent('U')"/>
 
70
        </menupopup>
 
71
      </menulist>
 
72
    </hbox>
 
73
    <separator/>
 
74
    <grid>
 
75
      <columns>
 
76
        <column/>
 
77
        <column flex="1"/>
 
78
      </columns>
 
79
      <rows>
 
80
        <row align="center" id="currAdminPinRow" collapsed="true">
 
81
          <label value="&enigmail.cardPin.currAdmPin.label; :" type="password" control="currAdmPinTxt"/>
 
82
          <textbox id="currAdmPinTxt" value="" type="password"/>
 
83
        </row>
 
84
        <row align="center" id="adminPinRow" collapsed="true">
 
85
          <label value="&enigmail.cardPin.newAdminPin.label; :" control="adminPinTxt"/>
 
86
          <textbox id="adminPinTxt" value="" type="password"/>
 
87
        </row>
 
88
        <row align="center" id="adminPinRepeatRow" collapsed="true">
 
89
          <label value="&enigmail.cardPin.adminPinRepeat.label; :" control="adminPinRepeatTxt"/>
 
90
          <textbox id="adminPinRepeatTxt" value="" type="password"/>
 
91
        </row>
 
92
        <row align="center" id="currPinRow">
 
93
          <label value="&enigmail.cardPin.currPin.label; :" control="currPinTxt"/>
 
94
          <textbox id="currPinTxt" value="" type="password"/>
 
95
        </row>
 
96
        <row align="center" id="pinRow">
 
97
          <label value="&enigmail.cardPin.newPin.label; :" control="pinTxt"/>
 
98
          <textbox id="pinTxt" value="" type="password"/>
 
99
        </row>
 
100
        <row align="center" id="pinRepeatRow">
 
101
          <label value="&enigmail.cardPin.pinRepeat.label; :" control="pinRepeatTxt"/>
 
102
          <textbox id="pinRepeatTxt" value="" type="password"/>
 
103
        </row>
 
104
      </rows>
 
105
    </grid>
 
106
  </vbox>
 
107
 
 
108
  <script type="application/x-javascript">
 
109
  <![CDATA[
 
110
 
 
111
  EnigInitCommon("enigmailSetCardPinDlg");
 
112
  
 
113
  const CHANGE_PIN  = 'P';
 
114
  const ADMIN_PIN   = 'A';
 
115
  const UNBLOCK_PIN = 'U';
 
116
 
 
117
  var gAction = null;
 
118
 
 
119
  function onLoad() {
 
120
    setDlgContent(CHANGE_PIN);
 
121
  }
 
122
 
 
123
  function onAccept() {
 
124
    var enigmailSvc = GetEnigmailSvc();
 
125
    if (!enigmailSvc)
 
126
      return false;
 
127
      
 
128
    var pinItem1;
 
129
    var pinItem2;
 
130
    var minLen=0;
 
131
    var action;
 
132
      
 
133
    switch(gAction) {
 
134
      case CHANGE_PIN:
 
135
        pinItem1="pinTxt";
 
136
        pinItem2="pinRepeatTxt";
 
137
        minLen=6;
 
138
        action = nsIEnigmail.CARD_PIN_CHANGE;
 
139
        break;
 
140
      case UNBLOCK_PIN:
 
141
        pinItem1="pinTxt";
 
142
        pinItem2="pinRepeatTxt";
 
143
        minLen=6;
 
144
        action = nsIEnigmail.CARD_PIN_UNBLOCK;
 
145
        break;
 
146
      case ADMIN_PIN:
 
147
        pinItem1="adminPinTxt";
 
148
        pinItem2="adminPinRepeatTxt";
 
149
        minLen=8;
 
150
        action = nsIEnigmail.CARD_ADMIN_PIN_CHANGE;
 
151
        break;
 
152
    }
 
153
    var adminPin = document.getElementById("currAdmPinTxt").value;
 
154
    var oldPin = document.getElementById("currPinTxt").value;
 
155
    var newPin = document.getElementById(pinItem1).value;
 
156
    if (newPin.length < minLen) {
 
157
      EnigAlert(EnigGetString("cardPin.minLength", minLen));
 
158
      return false;
 
159
    }
 
160
    if (newPin != document.getElementById(pinItem2).value) {
 
161
      EnigAlert(EnigGetString("cardPin.dontMatch"));
 
162
      return false;
 
163
    }
 
164
    
 
165
    var errorMsgObj = new Object();
 
166
    var pinObserver = new changePinObserver();
 
167
    
 
168
    var r = enigmailSvc.cardChangePin(window,
 
169
                                     action,
 
170
                                     oldPin,
 
171
                                     newPin,
 
172
                                     adminPin,
 
173
                                     pinObserver,
 
174
                                     errorMsgObj);
 
175
                                     
 
176
    if (r != 0) {
 
177
      EnigAlert(EnigGetString("cardPin.processFailed")+"\n"+pinObserver.result);
 
178
      return false;
 
179
    }
 
180
    return true;
 
181
  }
 
182
 
 
183
  function dlgEnable(item) {
 
184
    document.getElementById(item).removeAttribute("collapsed");
 
185
  }
 
186
  
 
187
  function dlgDisable(item) {
 
188
    document.getElementById(item).setAttribute("collapsed", "true");
 
189
  }
 
190
  
 
191
  function setDlgContent(sel) {
 
192
    gAction = sel;
 
193
    switch(sel) {
 
194
    case 'P':
 
195
      dlgDisable("currAdminPinRow");
 
196
      dlgDisable("adminPinRow");
 
197
      dlgDisable("adminPinRepeatRow");
 
198
      dlgEnable("currPinRow");
 
199
      dlgEnable("pinRow");
 
200
      dlgEnable("pinRepeatRow");
 
201
      break;
 
202
    case 'A':
 
203
      dlgEnable("currAdminPinRow");
 
204
      dlgEnable("adminPinRow");
 
205
      dlgEnable("adminPinRepeatRow");
 
206
      dlgDisable("currPinRow");
 
207
      dlgDisable("pinRow");
 
208
      dlgDisable("pinRepeatRow");
 
209
      break;
 
210
    case 'U':
 
211
      dlgEnable("currAdminPinRow");
 
212
      dlgDisable("adminPinRow");
 
213
      dlgDisable("adminPinRepeatRow");
 
214
      dlgDisable("currPinRow");
 
215
      dlgEnable("pinRow");
 
216
      dlgEnable("pinRepeatRow");
 
217
      break;
 
218
    }
 
219
  }
 
220
 
 
221
  function changePinObserver() {
 
222
  }
 
223
 
 
224
  changePinObserver.prototype =
 
225
  {
 
226
    _data: "",
 
227
    result: "",
 
228
 
 
229
    QueryInterface : function(iid)
 
230
    {
 
231
      if (iid.equals(Components.interfaces.nsIEnigMimeReadCallback) ||
 
232
          iid.equals(Components.interfaces.nsISupports) )
 
233
        return this;
 
234
 
 
235
      throw Components.results.NS_NOINTERFACE;
 
236
    },
 
237
 
 
238
    onDataAvailable: function (data) {
 
239
      var ret="";
 
240
      DEBUG_LOG("enigmailSetCardPin: changePinObserver.onDataAvailable: data="+data+"\n");
 
241
      if (data.indexOf("[GNUPG:] SC_OP_FAILURE")>=0) {
 
242
        this.result = this._data;
 
243
      }
 
244
      else {
 
245
        this._data = data
 
246
      }
 
247
      return "";
 
248
    }
 
249
  }
 
250
 
 
251
  ]]>
 
252
  </script>
 
253
</dialog>
 
254
 
 
255