!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is Netscape Communicator.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. 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 *
36 * ***** END LICENSE BLOCK ***** */
37
38 var gEncryptionStatus = -1;
39 var gSignatureStatus = -1;
40 var gSignerCert = null;
41 var gEncryptionCert = null;
42 var gBundle;
43 var gBrandBundle;
44
45 const nsPKIParamBlock = "@mozilla.org/security/pkiparamblock;1";
46 const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
47
setupBundles
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
48 function setupBundles()
49 {
50 if (gBundle && gBrandBundle)
51 return;
52
53 if (!gBundle) {
54 gBundle = document.getElementById("bundle_read_smime");
55 gBrandBundle = document.getElementById("bundle_brand");
56 }
57 }
58
showImapSignatureUnknown
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
59 function showImapSignatureUnknown()
60 {
61 var ifps = Components.interfaces.nsIPromptService;
62
63 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
64 promptService = promptService.QueryInterface(ifps);
65 setupBundles();
66
67 if (promptService && gBundle && gBrandBundle) {
68 if (promptService.confirm(window,
69 gBrandBundle.getString("brandShortName"),
70 gBundle.getString("ImapOnDemand"))) {
71 gDBView.reloadMessageWithAllParts();
72 }
73 }
74 }
75
showMessageReadSecurityInfo
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
76 function showMessageReadSecurityInfo()
77 {
78 var gSignedUINode = document.getElementById('signedHdrIcon');
79 if (gSignedUINode) {
80 if (gSignedUINode.getAttribute("signed") == "unknown") {
81 showImapSignatureUnknown();
82 return;
83 }
84 }
85
86 var pkiParams = Components.classes[nsPKIParamBlock].createInstance(nsIPKIParamBlock);
87
88 // isupport array starts with index 1
89 pkiParams.setISupportAtIndex(1, gSignerCert);
90 pkiParams.setISupportAtIndex(2, gEncryptionCert);
91
92 var params = pkiParams.QueryInterface(Components.interfaces.nsIDialogParamBlock);
93
94 // int array starts with index 0, but that is used for window exit status
95 params.SetInt(1, gSignatureStatus);
96 params.SetInt(2, gEncryptionStatus);
97
98 window.openDialog('chrome://messenger-smime/content/msgReadSecurityInfo.xul',
99 '', 'chrome,resizable=1,modal=1,dialog=1', pkiParams );
100 }
101
102 var SecurityController =
103 {
supportsCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
104 supportsCommand: function(command)
105 {
106 switch ( command )
107 {
108 case "cmd_viewSecurityStatus":
109 return true;
110
111 default:
112 return false;
113 }
114 },
115
isCommandEnabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
116 isCommandEnabled: function(command)
117 {
118 switch ( command )
119 {
120 case "cmd_viewSecurityStatus":
121 {
122 if (document.documentElement.getAttribute('windowtype') == "mail:messageWindow")
123 {
124 return ( gCurrentMessageUri != null);
125 }
126 else
127 {
128 if (GetNumSelectedMessages() > 0 && gDBView)
129 {
130 var enabled = new Object();
131 enabled.value = false;
132 var checkStatus = new Object();
133 gDBView.getCommandStatus(nsMsgViewCommandType.cmdRequiringMsgBody, enabled, checkStatus);
134 return enabled.value;
135 }
136 }
137
138 return false;
139 }
140
141 default:
142 return false;
143 }
144 return false;
145 }
146 };
147
148 top.controllers.appendController(SecurityController);