!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 38 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/extensions/smime/content/msgHdrViewSMIMEOverlay.js"
2
3 var gSignedUINode = null;
4 var gEncryptedUINode = null;
5 var gSMIMEContainer = null;
6 var gStatusBar = null;
7
8 var gEncryptedURIService = null;
9 var gMyLastEncryptedURI = null;
10
11 var gSMIMEBundle = null;
12 //var gBrandBundle; -- defined in mailWindow.js
13
14 // manipulates some globals from msgReadSMIMEOverlay.js
15
16 const nsICMSMessageErrors = Components.interfaces.nsICMSMessageErrors;
17
18 var smimeHeaderSink =
19 {
maxWantedNesting
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
20 maxWantedNesting: function()
21 {
22 return 1;
23 },
24
signedStatus
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
25 signedStatus: function(aNestingLevel, aSignatureStatus, aSignerCert)
26 {
27 if (aNestingLevel > 1) {
28 // we are not interested
29 return;
30 }
31
32 gSignatureStatus = aSignatureStatus;
33 gSignerCert = aSignerCert;
34
35 gSMIMEContainer.collapsed = false;
36 gSignedUINode.collapsed = false;
37
38 switch (aSignatureStatus) {
39 case nsICMSMessageErrors.SUCCESS:
40 gSignedUINode.setAttribute("signed", "ok");
41 gStatusBar.setAttribute("signed", "ok");
42 break;
43
44 case nsICMSMessageErrors.VERIFY_NOT_YET_ATTEMPTED:
45 gSignedUINode.setAttribute("signed", "unknown");
46 gStatusBar.setAttribute("signed", "unknown");
47 break;
48
49 case nsICMSMessageErrors.VERIFY_CERT_WITHOUT_ADDRESS:
50 case nsICMSMessageErrors.VERIFY_HEADER_MISMATCH:
51 gSignedUINode.setAttribute("signed", "mismatch");
52 gStatusBar.setAttribute("signed", "mismatch");
53 break;
54
55 default:
56 gSignedUINode.setAttribute("signed", "notok");
57 gStatusBar.setAttribute("signed", "notok");
58 break;
59 }
60 },
61
encryptionStatus
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
62 encryptionStatus: function(aNestingLevel, aEncryptionStatus, aRecipientCert)
63 {
64 if (aNestingLevel > 1) {
65 // we are not interested
66 return;
67 }
68
69 gEncryptionStatus = aEncryptionStatus;
70 gEncryptionCert = aRecipientCert;
71
72 gSMIMEContainer.collapsed = false;
73 gEncryptedUINode.collapsed = false;
74
75 if (nsICMSMessageErrors.SUCCESS == aEncryptionStatus)
76 {
77 gEncryptedUINode.setAttribute("encrypted", "ok");
78 gStatusBar.setAttribute("encrypted", "ok");
79 }
80 else
81 {
82 gEncryptedUINode.setAttribute("encrypted", "notok");
83 gStatusBar.setAttribute("encrypted", "notok");
84 }
85
86 if (gEncryptedURIService)
87 {
88 gMyLastEncryptedURI = GetLoadedMessage();
89 gEncryptedURIService.rememberEncrypted(gMyLastEncryptedURI);
90 }
91
92 switch (aEncryptionStatus)
93 {
94 case nsICMSMessageErrors.SUCCESS:
95 case nsICMSMessageErrors.ENCRYPT_INCOMPLETE:
96 break;
97 default:
98 var brand = gBrandBundle.getString("brandShortName");
99 var title = gSMIMEBundle.getString("CantDecryptTitle").replace(/%brand%/g,brand);
100 var body = gSMIMEBundle.getString("CantDecryptBody").replace(/%brand%/g,brand);
101
102 // insert our message
103 msgWindow.displayHTMLInMessagePane(title,
104 "<html>\n"+
105 "<body bgcolor=\"#fafaee\">\n"+
106 "<center><br><br><br>\n"+
107 "<table>\n"+
108 "<tr><td>\n"+
109 "<center><strong><font size=\"+3\">\n"+
110 title+"</font></center><br>\n"+
111 body+"\n"+
112 "</td></tr></table></center></body></html>", false);
113 break;
114 }
115 },
116
QueryInterface
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
117 QueryInterface : function(iid)
118 {
119 if (iid.equals(Components.interfaces.nsIMsgSMIMEHeaderSink) || iid.equals(Components.interfaces.nsISupports))
120 return this;
121 throw Components.results.NS_NOINTERFACE;
122 }
123 };
124
forgetEncryptedURI
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
125 function forgetEncryptedURI()
126 {
127 if (gMyLastEncryptedURI && gEncryptedURIService)
128 {
129 gEncryptedURIService.forgetEncrypted(gMyLastEncryptedURI);
130 gMyLastEncryptedURI = null;
131 }
132 }
133
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
134 function onSMIMEStartHeaders()
135 {
136 gEncryptionStatus = -1;
137 gSignatureStatus = -1;
138
139 gSignerCert = null;
140 gEncryptionCert = null;
141
142 gSMIMEContainer.collapsed = true;
143
144 gSignedUINode.collapsed = true;
145 gSignedUINode.removeAttribute("signed");
146 gStatusBar.removeAttribute("signed");
147
148 gEncryptedUINode.collapsed = true;
149 gEncryptedUINode.removeAttribute("encrypted");
150 gStatusBar.removeAttribute("encrypted");
151
152 forgetEncryptedURI();
153 }
154
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
155 function onSMIMEEndHeaders()
156 {}
157
onSmartCardChange
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
158 function onSmartCardChange()
159 {
160 // only reload encrypted windows
161 if (gMyLastEncryptedURI && gEncryptionStatus != -1) {
162 ReloadMessage();
163 }
164 }
165
msgHdrViewSMIMEOnLoad
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
166 function msgHdrViewSMIMEOnLoad(event)
167 {
168 window.crypto.enableSmartCardEvents = true;
169 document.addEventListener("smartcard-insert", onSmartCardChange, false);
170 document.addEventListener("smartcard-remove", onSmartCardChange, false);
171 if (!gSMIMEBundle)
172 gSMIMEBundle = document.getElementById("bundle_read_smime");
173
174 // we want to register our security header sink as an opaque nsISupports
175 // on the msgHdrSink used by mail.....
176 msgWindow.msgHeaderSink.securityInfo = smimeHeaderSink;
177
178 gSignedUINode = document.getElementById('signedHdrIcon');
179 gEncryptedUINode = document.getElementById('encryptedHdrIcon');
180 gSMIMEContainer = document.getElementById('smimeBox');
181 gStatusBar = document.getElementById('status-bar');
182
183 // add ourself to the list of message display listeners so we get notified when we are about to display a
184 // message.
185 var listener = {};
186 listener.onStartHeaders = onSMIMEStartHeaders;
187 listener.onEndHeaders = onSMIMEEndHeaders;
188 gMessageListeners.push(listener);
189
190 gEncryptedURIService =
191 Components.classes["@mozilla.org/messenger-smime/smime-encrypted-uris-service;1"]
192 .getService(Components.interfaces.nsIEncryptedSMIMEURIsService);
193 }
194
msgHdrViewSMIMEOnUnload
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
195 function msgHdrViewSMIMEOnUnload(event)
196 {
197 window.crypto.enableSmartCardEvents = false;
198 document.removeEventListener("smartcard-insert", onSmartCardChange, false);
199 document.removeEventListener("smartcard-remove", onSmartCardChange, false);
200 forgetEncryptedURI();
201 removeEventListener('messagepane-loaded', msgHdrViewSMIMEOnLoad, true);
202 removeEventListener('messagepane-unloaded', msgHdrViewSMIMEOnUnload, true);
203 removeEventListener('messagepane-hide', msgHdrViewSMIMEOnMessagePaneHide, true);
204 removeEventListener('messagepane-unhide', msgHdrViewSMIMEOnMessagePaneUnhide, true);
205 }
206
msgHdrViewSMIMEOnMessagePaneHide
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
207 function msgHdrViewSMIMEOnMessagePaneHide()
208 {
209 gSMIMEContainer.collapsed = true;
210 gSignedUINode.collapsed = true;
211 gEncryptedUINode.collapsed = true;
212 }
213
msgHdrViewSMIMEOnMessagePaneUnhide
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
214 function msgHdrViewSMIMEOnMessagePaneUnhide()
215 {
216 if (gEncryptionStatus != -1 || gSignatureStatus != -1)
217 {
218 gSMIMEContainer.collapsed = false;
219
220 if (gSignatureStatus != -1)
221 {
222 gSignedUINode.collapsed = false;
223 }
224
225 if (gEncryptionStatus != -1)
226 {
227 gEncryptedUINode.collapsed = false;
228 }
229 }
230 }
231
232 addEventListener('messagepane-loaded', msgHdrViewSMIMEOnLoad, true);
233 addEventListener('messagepane-unloaded', msgHdrViewSMIMEOnUnload, true);
234 addEventListener('messagepane-hide', msgHdrViewSMIMEOnMessagePaneHide, true);
235 addEventListener('messagepane-unhide', msgHdrViewSMIMEOnMessagePaneUnhide, true);