~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

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
 *   Russell Francis <rf358197@ohio.edu>
 
24
 *
 
25
 * Alternatively, the contents of this file may be used under the terms of
 
26
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
27
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
28
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
29
 * of those above. If you wish to allow use of your version of this file only
 
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
31
 * use your version of this file under the terms of the MPL, indicate your
 
32
 * decision by deleting the provisions above and replace them with the notice
 
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
34
 * the provisions above, a recipient may use your version of this file under
 
35
 * the terms of any one of the MPL, the GPL or the LGPL.
 
36
 * ***** END LICENSE BLOCK ***** *
 
37
-->
 
38
 
 
39
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
 
40
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
 
41
 
 
42
<!DOCTYPE window [
 
43
  <!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
 
44
   %brandDTD;
 
45
  <!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
 
46
  %enigMailDTD;
 
47
  <!ENTITY % utilDTD SYSTEM "chrome://communicator/locale/utilityOverlay.dtd">
 
48
   %utilDTD;
 
49
]>
 
50
 
 
51
 
 
52
<dialog id="enigmailViewKeySigDlg"
 
53
        title="&enigmail.viewKeySigDlg.title;"
 
54
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
 
55
        onload="onLoad();"
 
56
        style="width:600px"
 
57
        persist="width height"
 
58
        buttons="accept">
 
59
 
 
60
 
 
61
  <script type="application/x-javascript" src="chrome://enigmail/content/enigmailCommon.js"/>
 
62
 
 
63
  <broadcasterset>
 
64
    <broadcaster id="bcViewDetails" disabled="false"/>
 
65
  </broadcasterset>
 
66
 
 
67
  <popupset>
 
68
    <menupopup id="sigCtxMenu"
 
69
           onpopupshowing="showSigCtxMenu()">
 
70
 
 
71
      <menuitem id="ctxViewSig" observes="bcViewDetails"
 
72
                label="&enigmail.keyMan.ctxViewSig.label;"
 
73
                oncommand="listSig()"/>
 
74
      <menuitem id="ctxDetails" observes="bcViewDetails"
 
75
                label="&enigmail.keyMan.keyProps.label;"
 
76
                                                                oncommand="viewKeyDetails()"/>
 
77
      <menuitem id="ctxImportKey"
 
78
                label="&enigmail.importpublickey.label;"
 
79
                oncommand="importKey()"/>
 
80
    </menupopup>
 
81
  </popupset>
 
82
 
 
83
  <vbox flex="1">
 
84
    <hbox>
 
85
      <label value="&enigmail.viewKeySigDlg.sigForKey.label;"/>
 
86
      <label id="keyIdValue" value="?"/>
 
87
    </hbox>
 
88
    <separator/>
 
89
    <tree id="keySigList" flex="1"
 
90
      enableColumnDrag="true"
 
91
      style="height:200px"
 
92
      hidecolumnpicker="true"
 
93
      ondblclick="handleDblClick(event)">
 
94
 
 
95
      <treecols>
 
96
        <treecol id="enigUserNameCol" flex="1"
 
97
            label="&enigmail.keyUserId.label;"/>
 
98
        <splitter class="tree-splitter"/>
 
99
        <treecol id="keyCol" style="width:90px"
 
100
                 label="&enigmail.keyId.label;"
 
101
                 persist="width"/>
 
102
        <splitter class="tree-splitter"/>
 
103
        <treecol id="typeCol" style="width:70px"
 
104
                 label="&enigmail.viewKeySigDlg.sigType.label;"
 
105
                 persist="width"/>
 
106
        <splitter class="tree-splitter"/>
 
107
        <treecol id="validityCol" style="width:70px"
 
108
                 label="&enigmail.valid.label;"
 
109
                 persist="width"/>
 
110
        <splitter class="tree-splitter"/>
 
111
        <treecol id="createdCol" style="width:70px"
 
112
                 label="&enigmail.created.label;"
 
113
                 persist="width"/>
 
114
      </treecols>
 
115
 
 
116
      <treechildren id="keySigListChildren"
 
117
                    context="sigCtxMenu"/>
 
118
 
 
119
    </tree>
 
120
  </vbox>
 
121
 
 
122
  <script type="application/x-javascript">
 
123
  <![CDATA[
 
124
 
 
125
    EnigInitCommon("enigmailViewKeySigDlg");
 
126
 
 
127
    var gKeyListArr;
 
128
 
 
129
    function onLoad() {
 
130
      gKeyListArr = window.arguments[0].keyListArr;
 
131
      window.arguments[1].refresh = false;
 
132
      loadList();
 
133
    }
 
134
 
 
135
    function setWindowPos(x, y) {
 
136
      window.screenX = x;
 
137
      window.screenY = y;
 
138
    }
 
139
 
 
140
    function loadList() {
 
141
      var enigmailSvc = GetEnigmailSvc();
 
142
      if (!enigmailSvc) {
 
143
        EnigAlert(EnigGetString("accessError"));
 
144
        window.close();
 
145
        return;
 
146
      }
 
147
 
 
148
      var inArg = window.arguments[0];
 
149
      var keyId = inArg.keyId;
 
150
      var keyIdValue = document.getElementById("keyIdValue");
 
151
 
 
152
      if (typeof(inArg.posX)=="number" &&
 
153
          typeof(inArg.posY)=="number") {
 
154
        EnigmailCommon.dispatchEvent(setWindowPos, 0, inArg.posX, inArg.posY);
 
155
      }
 
156
 
 
157
      keyIdValue.value = gKeyListArr[keyId].userId+" - 0x"+ inArg.keyId.substr(-8,8);
 
158
 
 
159
      var exitCodeObj = {};
 
160
      var errorMsgObj = {};
 
161
 
 
162
      var sigList = enigmailSvc.getKeySig("0x"+keyId, exitCodeObj, errorMsgObj);
 
163
 
 
164
      if (exitCodeObj.value != 0) {
 
165
        EnigAlert(errorMsgObj.value);
 
166
        window.close();
 
167
        return;
 
168
      }
 
169
 
 
170
 
 
171
      var keySigList=document.getElementById("keySigList");
 
172
      var treeChildren=keySigList.getElementsByAttribute("id", "keySigListChildren")[0];
 
173
      var aSigList = sigList.split(/\n/);
 
174
      var aRevSig = [];
 
175
      var currUid="";
 
176
 
 
177
      for (var i=0; i<aSigList.length; i++) {
 
178
        var listRow=aSigList[i].split(/:/);
 
179
        if (listRow.length>=0) {
 
180
          if ((listRow[0] == "uid" || listRow[0] == "pub" || listRow[0] == "uat") && (listRow[ENIG_USER_ID].length>0)) {
 
181
            var userRow=document.createElement("treerow");
 
182
            if (typeof(listRow[ENIG_KEY_USE_FOR])!="string") {
 
183
              listRow[ENIG_KEY_USE_FOR]="";
 
184
            }
 
185
            var keyValid = (ENIG_KEY_NOT_VALID.indexOf(listRow[ENIG_KEY_TRUST])<0 &&
 
186
                            listRow[ENIG_KEY_USE_FOR].indexOf("D")<0);
 
187
            if (listRow[0] == "uat") {
 
188
              listRow[ENIG_USER_ID]=EnigGetString("userAtt.photo");
 
189
            }
 
190
 
 
191
            if (listRow[0] == "uid" || listRow[0] == "uat") {
 
192
              currUid=listRow[ENIG_UID_ID];
 
193
            }
 
194
            addCell(userRow, EnigConvertGpgToUnicode(listRow[ENIG_USER_ID]), true, keyValid);
 
195
            var treeItem=document.createElement("treeitem");
 
196
            treeItem.appendChild(userRow);
 
197
            treeChildren.appendChild(treeItem);
 
198
          }
 
199
          else if (listRow[0] == "sig") {
 
200
            if (listRow[ENIG_USER_ID].length == 0) {
 
201
              listRow[ENIG_USER_ID] = "-";
 
202
            }
 
203
            if (listRow[ENIG_SIG_TYPE].substr(0,2).toLowerCase()!="1f") {
 
204
              // ignore "revoker" signatures
 
205
              userRow=document.createElement("treerow");
 
206
              if (typeof(gKeyListArr[listRow[ENIG_KEY_ID]]) == "object") {
 
207
                addCell(userRow, "   "+EnigConvertGpgToUnicode(listRow[ENIG_USER_ID]));
 
208
              }
 
209
              else {
 
210
                addCell(userRow, "   "+EnigGetString("userIdNotFound"));
 
211
              }
 
212
              addCell(userRow, listRow[ENIG_KEY_ID].substr(-8,8));
 
213
              if (listRow[ENIG_SIG_TYPE].substr(2,1) == "x") {
 
214
                addCell(userRow, EnigGetString("keySignatureExportable"));
 
215
              }
 
216
              else {
 
217
                addCell(userRow, EnigGetString("keySignatureLocal"));
 
218
              }
 
219
              if (typeof(gKeyListArr[listRow[ENIG_KEY_ID]]) == "object") {
 
220
                addCell(userRow, EnigGetString("signatureValid"));
 
221
              }
 
222
              else {
 
223
                addCell(userRow, EnigGetString("keySignatureNoKey"));
 
224
                userRow.setAttribute("noKey", "true");
 
225
              }
 
226
 
 
227
              userRow.setAttribute("keyID", listRow[ENIG_KEY_ID]);
 
228
              userRow.setAttribute("sigID", currUid+"-"+listRow[ENIG_KEY_ID]);
 
229
              addCell(userRow, EnigGetDateTime(listRow[ENIG_CREATED], true, false));
 
230
              treeItem=document.createElement("treeitem");
 
231
              treeItem.appendChild(userRow);
 
232
              treeChildren.appendChild(treeItem);
 
233
            }
 
234
          }
 
235
          else if (listRow[0] == "sub") {
 
236
            break;
 
237
          }
 
238
          else if (listRow[0] == "rev") {
 
239
            aRevSig.push(currUid+"-"+listRow[ENIG_KEY_ID]);
 
240
          }
 
241
        }
 
242
      }
 
243
 
 
244
      // mark revoked signatures
 
245
      for (i=0; i<aRevSig.length; i++) {
 
246
        var nodes = document.getElementsByAttribute("sigID", aRevSig[i]);
 
247
        for (var node=0; node < nodes.length; node++) {
 
248
          try {
 
249
            nodes[node].childNodes[3].setAttribute("label", EnigGetString("keyValid.revoked"));
 
250
 
 
251
            var cNode=nodes[node].firstChild;
 
252
            while (cNode) {
 
253
              cNode.setAttribute("properties", "enigKeyInactive");
 
254
              cNode=cNode.nextSibling;
 
255
            }
 
256
          }
 
257
          catch (ex){}
 
258
        }
 
259
      }
 
260
 
 
261
      keySigList.appendChild(treeChildren);
 
262
      return;
 
263
    }
 
264
 
 
265
    function addCell(row, label, subkeyRow, keyActive) {
 
266
      var cell = document.createElement("treecell");
 
267
      cell.setAttribute("label", label);
 
268
      if (subkeyRow) {
 
269
        if (keyActive) {
 
270
          cell.setAttribute("properties", "enigmailSubkeyTitle");
 
271
        }
 
272
        else {
 
273
          cell.setAttribute("properties", "enigmailSubkeyTitle enigKeyInactive");
 
274
        }
 
275
      }
 
276
      row.appendChild(cell);
 
277
      return cell;
 
278
    }
 
279
 
 
280
    function getSelectedRows()
 
281
    {
 
282
      var sigList = document.getElementById( "keySigList" );
 
283
      var numRanges = sigList.view.selection.getRangeCount();
 
284
      var selectedRows = new Array();
 
285
      var start = new Object();
 
286
      var end = new Object();
 
287
 
 
288
      for( var i = 0; i < numRanges; ++i )
 
289
      {
 
290
        sigList.view.selection.getRangeAt( i, start, end );
 
291
        for( var j = start.value; j <= end.value; ++j )
 
292
        {
 
293
          selectedRows.push( j );
 
294
        }
 
295
      }
 
296
 
 
297
      return( selectedRows );
 
298
    }
 
299
 
 
300
    function getRowByIndex( index )
 
301
    {
 
302
      var sigList = document.getElementById( "keySigList" );
 
303
      var item = sigList.view.getItemAtIndex( index );
 
304
      if( item )
 
305
      {
 
306
        return item.firstChild;
 
307
      }
 
308
      return null;
 
309
    }
 
310
 
 
311
    function getCurrRow() {
 
312
      var sigList = document.getElementById("keySigList");
 
313
      var item = sigList.view.getItemAtIndex(sigList.view.selection.currentIndex);
 
314
      if (item) {
 
315
        return item.firstChild;
 
316
      }
 
317
      return null;
 
318
    }
 
319
 
 
320
    function showSigCtxMenu()
 
321
    {
 
322
      var viewDetailsDisabled = "true";
 
323
      var importKeyDisabled = "true";
 
324
      var selectedRows = getSelectedRows();
 
325
 
 
326
      if( selectedRows.length == 1 )
 
327
      {
 
328
        var row = getRowByIndex( selectedRows[0] );
 
329
        if( row.hasAttribute( "keyID" ) )
 
330
        {
 
331
          if( row.hasAttribute( "noKey" ) )
 
332
          {
 
333
            importKeyDisabled = "false";
 
334
          }
 
335
          else
 
336
          {
 
337
            viewDetailsDisabled = "false";
 
338
          }
 
339
        }
 
340
      }
 
341
      else
 
342
      {
 
343
        /* We have more than one row. If any of them are importable, enable
 
344
         * the import menuitem.
 
345
         */
 
346
        for( var i = 0; i < selectedRows.length; ++i )
 
347
        {
 
348
          var row = getRowByIndex( selectedRows[i] );
 
349
          if( row.hasAttribute( "keyID" ) && row.hasAttribute( "noKey" ) )
 
350
          {
 
351
            importKeyDisabled = "false";
 
352
            break;
 
353
          }
 
354
        }
 
355
      }
 
356
      document.getElementById( "bcViewDetails" ).setAttribute( "disabled", viewDetailsDisabled );
 
357
      document.getElementById( "ctxImportKey" ).setAttribute( "disabled", importKeyDisabled );
 
358
    }
 
359
 
 
360
    function listSig() {
 
361
      var row = getCurrRow();
 
362
      var inputObj = {
 
363
        keyId: row.getAttribute("keyID"),
 
364
        keyListArr: gKeyListArr,
 
365
        posX: window.screenX+10,
 
366
        posY: window.screenY+10
 
367
      };
 
368
      var resultObj = {};
 
369
 
 
370
      window.openDialog("chrome://enigmail/content/enigmailViewKeySigDlg.xul",
 
371
             "", "dialog,modal,centerscreen,resizable=yes", inputObj, resultObj);
 
372
      if (resultObj.refresh) {
 
373
        window.arguments[1].refresh=true;
 
374
      }
 
375
    }
 
376
 
 
377
    function viewKeyDetails() {
 
378
      var row = getCurrRow();
 
379
      var keyId = row.getAttribute("keyID")
 
380
 
 
381
      var inputObj = {
 
382
        keyId:  keyId,
 
383
        keyListArr: gKeyListArr,
 
384
        secKey: gKeyListArr[keyId].secretAvailable
 
385
      };
 
386
      var resultObj = { refresh: true };
 
387
      window.openDialog("chrome://enigmail/content/enigmailKeyDetailsDlg.xul",
 
388
            "", "dialog,modal,centerscreen", inputObj, resultObj);
 
389
      if (resultObj.refresh) {
 
390
        window.arguments[1].refresh=true;
 
391
      }
 
392
    }
 
393
 
 
394
    function importKey()
 
395
    {
 
396
      var resultObj = new Object();
 
397
      var inputObj = new Object();
 
398
      inputObj.searchList = new Array();
 
399
      var selectedRows = getSelectedRows();
 
400
      for( var i = 0; i < selectedRows.length; ++i )
 
401
      {
 
402
        var row = getRowByIndex( selectedRows[i] );
 
403
        if( row.hasAttribute( "keyID" ) && row.hasAttribute( "noKey" ) )
 
404
        {
 
405
          inputObj.searchList.push( "0x" + row.getAttribute( "keyID" ).substr(-8,8) );
 
406
        }
 
407
      }
 
408
 
 
409
      EnigDownloadKeys( inputObj, resultObj );
 
410
      if( resultObj.importedKeys > 0 )
 
411
      {
 
412
        var treeChildren = document.getElementById("keySigListChildren");
 
413
        while (treeChildren.firstChild)
 
414
        {
 
415
          treeChildren.removeChild(treeChildren.firstChild);
 
416
        }
 
417
        var keyListObj = {};
 
418
        EnigLoadKeyList(true, keyListObj);
 
419
        gKeyListArr = keyListObj.keyList;
 
420
        window.arguments[1].refresh = true;
 
421
        loadList();
 
422
      }
 
423
    }
 
424
 
 
425
    function handleDblClick(event) {
 
426
      if (event) {
 
427
        if (event.button != 0) return;
 
428
      }
 
429
      var row = getCurrRow();
 
430
      if (row.hasAttribute("keyID")) {
 
431
        if (row.hasAttribute("noKey")) {
 
432
          if (EnigConfirm(EnigGetString("retrieveKeyConfirm"))) {
 
433
            importKey();
 
434
          }
 
435
        }
 
436
        else {
 
437
          listSig();
 
438
        }
 
439
      }
 
440
    }
 
441
  ]]>
 
442
  </script>
 
443
 
 
444
</dialog>
 
445