~ubuntu-branches/ubuntu/precise/enigmail/precise-security

« back to all changes in this revision

Viewing changes to mailnews/extensions/enigmail/ui/content/enigmailManageUidDlg.xul

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2014-01-30 11:42:56 UTC
  • mfrom: (0.12.17)
  • Revision ID: package-import@ubuntu.com-20140130114256-6yvx7ylu1cwrhwp2
Tags: 2:1.7-0ubuntu0.12.04.1
* New upstream release v1.7 to support Thunderbird 31

* No longer requires a Mozilla build system, so we use the upstream
  tarball directly now
  - update debian/rules
  - drop libgtk2.0-dev, libidl-dev, libdbus-glib-1-dev, libnotify-dev,
    libasound2-dev, libxt-dev, autoconf2.13 and mesa-common-dev
    build-depends, as these were only there because we were using a hacked
    Mozilla build system
* Update to source format 3.0
* Drop thunderbird-dev build-depend - the only binary code in enigmail now
  uses ctypes, so we don't need the SDK
* Drop debian/patches/no_libxpcom.patch - it doesn't build a binary component
  now
* Drop debian/patches/use_sdk.patch - there's no dependency on the
  Thunderbird SDK now

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0"?>
2
 
<!--
3
 
 * ***** BEGIN LICENSE BLOCK *****
4
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
 
 *
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/
10
 
 *
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.
15
 
 *
16
 
 * The Original Code is Enigmail.
17
 
 *
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) 2004 Patrick Brunschwig. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
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 ***** *
36
 
-->
37
 
 
38
 
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
39
 
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
40
 
 
41
 
<!DOCTYPE window [
42
 
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
43
 
%brandDTD;
44
 
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
45
 
%enigMailDTD;
46
 
]>
47
 
 
48
 
<dialog id="enigmailManageUidDlg"
49
 
        title="&enigmail.manageUidDlg.title;"
50
 
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
51
 
        buttons="accept"
52
 
        onload="onLoad();">
53
 
 
54
 
  <vbox orient="vertical" flex="1">
55
 
    <hbox align="center">
56
 
      <label value="&enigmail.manageUidDlg.affectedKey.label;"/>
57
 
      <label id="keyId" value="?"/>
58
 
    </hbox>
59
 
    <separator/>
60
 
    <label value="&enigmail.manageUidDlg.availableUid.label;" control="uidList"/>
61
 
    <listbox flex="1" id="uidList" style="height:100px"
62
 
             seltype="single"
63
 
             onselect="uidSelectCb()"
64
 
             ondblclick="handleDblClick()"/>
65
 
    <hbox>
66
 
      <button id="addUid"
67
 
              label="&enigmail.manageUidDlg.addUid.label;"
68
 
              oncommand="addUid()"/>
69
 
      <button id="setPrimary"
70
 
              label="&enigmail.manageUidDlg.setPrimary.label;"
71
 
              oncommand="setPrimaryUid()"/>
72
 
      <button id="deleteUid"
73
 
              label="&enigmail.manageUidDlg.deleteUid.label;"
74
 
              oncommand="deleteUid()"/>
75
 
      <button id="revokeUid"
76
 
              label="&enigmail.manageUidDlg.revokeUid.label;"
77
 
              oncommand="revokeUid()"/>
78
 
    </hbox>
79
 
    <vbox align="end">
80
 
      <button dlgtype="accept" label="&enigmail.keyMan.close.label;"/>
81
 
    </vbox>
82
 
  </vbox>
83
 
 
84
 
  <script type="application/x-javascript">
85
 
  <![CDATA[
86
 
    Components.utils.import("resource://enigmail/commonFuncs.jsm");
87
 
    Components.utils.import("resource://enigmail/enigmailCommon.jsm");
88
 
    Components.utils.import("resource://enigmail/keyManagement.jsm");
89
 
 
90
 
    const Ec = EnigmailCommon;
91
 
 
92
 
    function onLoad() {
93
 
      window.arguments[1].refresh = false;
94
 
      reloadUidList();
95
 
      var keyId = window.enigmailUid +" - 0x"+ window.arguments[0].keyId.substr(-8,8);
96
 
      document.getElementById("keyId").value = keyId;
97
 
 
98
 
      if (! window.arguments[0].ownKey) {
99
 
        document.getElementById("addUid").setAttribute("disabled", "true");
100
 
        document.getElementById("setPrimary").setAttribute("disabled", "true");
101
 
        document.getElementById("revokeUid").setAttribute("disabled", "true");
102
 
      }
103
 
    }
104
 
 
105
 
    function reloadUidList() {
106
 
      var uidList=document.getElementById("uidList");
107
 
      while (uidList.getRowCount()>0) {
108
 
        uidList.removeItemAt(0);
109
 
      }
110
 
 
111
 
      var enigmailSvc = Ec.getService();
112
 
      if (!enigmailSvc)
113
 
        return;
114
 
 
115
 
      var keyData = enigmailSvc.getKeyDetails("0x"+window.arguments[0].keyId, false);
116
 
 
117
 
      var keyList=keyData.split(/[\n\r]+/);
118
 
      var uidNum=0;
119
 
      for (var i=0; i < keyList.length; i++) {
120
 
        var uidStr = keyList[i].split(/:/);
121
 
        switch(uidStr[0]) {
122
 
        case "uid":
123
 
        case "uat":
124
 
          ++uidNum;
125
 
          if (uidStr[0]=="uid") {
126
 
            uidTxt=Ec.convertGpgToUnicode(uidStr[9]).replace(/\\e3A/g, ":");
127
 
            if (!window.enigmailUid) {
128
 
              window.enigmailUid = uidTxt;
129
 
            }
130
 
          }
131
 
          else{
132
 
            if (uidStr[9].indexOf("1 ")==0) {
133
 
              uidTxt=Ec.getString("userAtt.photo");
134
 
            }
135
 
          }
136
 
          if (uidStr[1]=="r") {
137
 
            uidTxt += " - "+Ec.getString("keyValid.revoked");
138
 
            uidStr[0]=uidStr[0].replace(/^./,"r");
139
 
          }
140
 
          item=uidList.appendItem(uidTxt, uidStr[0]+":"+String(uidNum));
141
 
          if (uidStr[1]=="r") {
142
 
            item.setAttribute("class", "enigmailUidInactive");
143
 
          }
144
 
          break;
145
 
        }
146
 
      }
147
 
      uidSelectCb();
148
 
    }
149
 
 
150
 
    function handleDblClick() {
151
 
      var uidList = document.getElementById("uidList")
152
 
      if (uidList.selectedCount > 0) {
153
 
        var selValue=uidList.selectedItem.value;
154
 
        var uidType = selValue.substr(0,3);
155
 
        if (uidType=="uat" || uidType=="rat") {
156
 
          EnigmailFuncs.showPhoto(window, window.arguments[0].keyId, window.enigmailUid);
157
 
        }
158
 
      }
159
 
    }
160
 
 
161
 
    function uidSelectCb() {
162
 
      var uidList = document.getElementById("uidList")
163
 
      if (uidList.selectedCount > 0) {
164
 
        var selValue=uidList.selectedItem.value;
165
 
      }
166
 
      else {
167
 
        selValue="uid:1";
168
 
      }
169
 
      if (window.arguments[0].ownKey) {
170
 
        var uidType = selValue.substr(0,3);
171
 
        if (uidType=="uat" || uidType=="rat" || uidType=="rid" || selValue.substr(4)=="1") {
172
 
          document.getElementById("setPrimary").setAttribute("disabled", "true");
173
 
        }
174
 
        else {
175
 
          document.getElementById("setPrimary").removeAttribute("disabled");
176
 
        }
177
 
        if (selValue.substr(4)=="1") {
178
 
          document.getElementById("deleteUid").setAttribute("disabled", "true");
179
 
          document.getElementById("revokeUid").setAttribute("disabled", "true");
180
 
        }
181
 
        else {
182
 
          document.getElementById("deleteUid").removeAttribute("disabled");
183
 
          if (uidType=="rid" || uidType=="rat") {
184
 
            document.getElementById("revokeUid").setAttribute("disabled", "true");
185
 
          }
186
 
          else {
187
 
            document.getElementById("revokeUid").removeAttribute("disabled");
188
 
          }
189
 
        }
190
 
      }
191
 
      else {
192
 
        if (selValue.substr(4)=="1") {
193
 
          document.getElementById("deleteUid").setAttribute("disabled", "true");
194
 
        }
195
 
        else {
196
 
          document.getElementById("deleteUid").removeAttribute("disabled");
197
 
        }
198
 
      }
199
 
    }
200
 
 
201
 
    function addUid() {
202
 
      var inputObj = {
203
 
        keyId: "0x"+window.arguments[0].keyId,
204
 
        userId: window.enigmailUid
205
 
      };
206
 
      var resultObj = { refresh: false };
207
 
      window.openDialog("chrome://enigmail/content/enigmailAddUidDlg.xul",
208
 
            "", "dialog,modal,centerscreen", inputObj, resultObj);
209
 
      window.arguments[1].refresh = resultObj.refresh;
210
 
      reloadUidList();
211
 
    }
212
 
 
213
 
    function setPrimaryUid() {
214
 
      var enigmailSvc = Ec.getService();
215
 
      if (!enigmailSvc)
216
 
        return;
217
 
      var errorMsgObj = new Object();
218
 
      var uidList = document.getElementById("uidList");
219
 
      if (uidList.selectedItem.value.substr(0,3)=="uid") {
220
 
 
221
 
        EnigmailKeyMgmt.setPrimaryUid(window,
222
 
          "0x"+window.arguments[0].keyId,
223
 
          uidList.selectedItem.value.substr(4),
224
 
          function _cb(exitCode, errorMsg) {
225
 
            if (exitCode == 0) {
226
 
              Ec.alert(window, Ec.getString("changePrimUidOK"));
227
 
              window.arguments[1].refresh = true;
228
 
              reloadUidList();
229
 
            }
230
 
            else
231
 
              Ec.alert(window, Ec.getString("changePrimUidFailed")+"\n\n"+errorMsg);
232
 
          });
233
 
      }
234
 
    }
235
 
 
236
 
    function revokeUid() {
237
 
      var enigmailSvc = Ec.getService();
238
 
      if (!enigmailSvc)
239
 
        return;
240
 
      var uidList = document.getElementById("uidList");
241
 
      if (! Ec.confirmDlg(window, Ec.getString("revokeUidQuestion", uidList.selectedItem.label))) return;
242
 
      if (uidList.selectedItem.value.substr(4)!="1") {
243
 
        EnigmailKeyMgmt.revokeUid(window,
244
 
          "0x"+window.arguments[0].keyId,
245
 
          uidList.selectedItem.value.substr(4),
246
 
          function _cb (exitCode, errorMsg) {
247
 
            if (exitCode == 0) {
248
 
              Ec.alert(window, Ec.getString("revokeUidOK", uidList.selectedItem.label));
249
 
              window.arguments[1].refresh = true;
250
 
              reloadUidList();
251
 
            }
252
 
            else
253
 
              Ec.alert(window, Ec.getString("revokeUidFailed", uidList.selectedItem.label)+"\n\n"+errorMsgObj.value);
254
 
          });
255
 
        if (r != 0) {
256
 
          return;
257
 
        }
258
 
      }
259
 
    }
260
 
 
261
 
    function deleteUid() {
262
 
      var enigmailSvc = Ec.getService();
263
 
      if (!enigmailSvc)
264
 
        return;
265
 
      var uidList = document.getElementById("uidList");
266
 
      if (! Ec.confirmDlg(window, Ec.getString("deleteUidQuestion", uidList.selectedItem.label))) return;
267
 
      if (uidList.selectedItem.value.substr(4) != "1") {
268
 
        EnigmailKeyMgmt.deleteUid(window,
269
 
          "0x"+window.arguments[0].keyId,
270
 
          uidList.selectedItem.value.substr(4),
271
 
          function _cb (exitCode, errorMsg) {
272
 
            if (exitCode == 0) {
273
 
              Ec.alert(window, Ec.getString("deleteUidOK", uidList.selectedItem.label));
274
 
              window.arguments[1].refresh = true;
275
 
              reloadUidList();
276
 
            }
277
 
            else
278
 
              Ec.alert(window, Ec.getString("deleteUidFailed", uidList.selectedItem.label)+"\n\n"+errorMsgObj.value);
279
 
          });
280
 
      }
281
 
    }
282
 
  ]]>
283
 
  </script>
284
 
 
285
 
</dialog>
286