-/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Netscape Communicator.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Eric Ballet Baz / BT Global Services / Etat francais - Ministere de la Defense
- * Raphael Fairise / BT Global Services / Etat francais - Ministere de la Defense
- * Copyright (c) 2010 CASSIDIAN - All rights reserved
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-var gEncryptionStatus = -1;
-var gSignatureStatus = -1;
-var gSignerCert = null;
-var gEncryptionCert = null;
-var gSecurityPolicyIdentifier = null;
-var gSecurityClassification = -1;
-var gPrivacyMark = null;
-var gSecurityCategories = null;
-var gSecurityLabelConf = null;
-var gSecureHeaders = "";
-var gSecureHeadersState=-1;
-
-addEventListener("load", smimeReadOnLoad, false);
-
-function smimeReadOnLoad()
-{
- removeEventListener("load", smimeReadOnLoad, false);
-
- top.controllers.appendController(SecurityController);
-
- addEventListener("unload", smimeReadOnUnload, false);
-
- Components.classes["@mozilla.org/observer-service;1"]
- .getService(Components.interfaces.nsIObserverService)
- .addObserver(securityLabelCreateDbObserver, "MsgCreateDBView", false);
-
- if (!gSecurityLabelConf)
- gSecurityLabelConf = new securityLabelConf();
-}
-
-function smimeReadOnUnload()
-{
- removeEventListener("unload", smimeReadOnUnload, false);
-
- top.controllers.removeController(SecurityController);
-
- Components.classes["@mozilla.org/observer-service;1"]
- .getService(Components.interfaces.nsIObserverService)
- .removeObserver(securityLabelCreateDbObserver, "MsgCreateDBView");
-}
-
-function showImapSignatureUnknown()
-{
- let readSmimeBundle = document.getElementById("bundle_read_smime");
- let brandBundle = document.getElementById("bundle_brand");
- if (!readSmimeBundle || !brandBundle)
- return;
-
- let promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- if (promptService &&
- promptService.confirm(window, brandBundle.getString("brandShortName"),
- readSmimeBundle.getString("ImapOnDemand")))
- gDBView.reloadMessageWithAllParts();
-}
-
-function showMessageReadSecurityInfo()
-{
- let gSignedUINode = document.getElementById("signedHdrIcon");
- if (gSignedUINode && gSignedUINode.getAttribute("signed") == "unknown")
- {
- showImapSignatureUnknown();
- return;
- }
-
- let pkiParams = Components.classes["@mozilla.org/security/pkiparamblock;1"]
- .createInstance(Components.interfaces.nsIPKIParamBlock);
-
- // isupport array starts with index 1
- pkiParams.setISupportAtIndex(1, gSignerCert);
- pkiParams.setISupportAtIndex(2, gEncryptionCert);
-
- var params = pkiParams.QueryInterface(Components.interfaces.nsIDialogParamBlock);
- // int array starts with index 0, but that is used for window exit status
- params.SetInt(1, gSignatureStatus);
- params.SetInt(2, gEncryptionStatus);
- params.SetInt(3, gSecurityClassification);
- params.SetInt(4,gSecureHeadersState);
-
- params.SetString(0, gSecurityPolicyIdentifier);
- params.SetString(1, gPrivacyMark);
- params.SetString(2, gSecurityCategories);
- params.SetString(12,gSecureHeaders);
-
- window.openDialog("chrome://messenger-smime/content/msgReadSecurityInfo.xul",
- "", "chrome,resizable=1,modal=1,dialog=1", pkiParams);
-}
-
-var SecurityController =
-{
- supportsCommand: function(command)
- {
- switch (command)
- {
- case "cmd_viewSecurityStatus":
- return true;
-
- default:
- return false;
- }
- },
-
- isCommandEnabled: function(command)
- {
- switch (command)
- {
- case "cmd_viewSecurityStatus":
- if (document.documentElement.getAttribute('windowtype') == "mail:messageWindow")
- return GetNumSelectedMessages() > 0;
-
- if (GetNumSelectedMessages() > 0 && gDBView)
- {
- let enabled = {value: false};
- let checkStatus = {};
- gDBView.getCommandStatus(nsMsgViewCommandType.cmdRequiringMsgBody,
- enabled, checkStatus);
- return enabled.value;
- }
- // else: fall through.
-
- default:
- return false;
- }
- }
-};
-
-/* Add Security Label column */
-var securityLabelCreateDbObserver = {
- observe: function(aMsgFolder, aTopic, aData) {
- try {
- if (gDBView != undefined && gDBView.addColumnHandler)
- gDBView.addColumnHandler("securityLabelSecurityClassificationColumn", securityLabelSecurityClassificationColumnHandler);
- } catch(e) {}
- }
-}
-
-var securityLabelSecurityClassificationColumnHandler = {
- getCellText: function(row, column) {
- var key = gDBView.getKeyAt(row);
- var hdr = gDBView.db.GetMsgHdrForKey(key);
- var securityLabelSecurityPolicyIdentifier = hdr.getStringProperty("securityLabelSecurityPolicyIdentifier");
- var securityLabelSecurityClassification = hdr.getStringProperty("securityLabelSecurityClassification");
-
- if (securityLabelSecurityPolicyIdentifier != "" && securityLabelSecurityClassification != "" && securityLabelSecurityClassification != "-1")
- return gSecurityLabelConf.getSecurityClassificationName(securityLabelSecurityPolicyIdentifier, securityLabelSecurityClassification);
-
- return "";
- },
- getSortStringForRow: function(hdr) {
- var securityLabelSecurityPolicyIdentifier = hdr.getStringProperty("securityLabelSecurityPolicyIdentifier");
- var securityLabelSecurityClassification = hdr.getStringProperty("securityLabelSecurityClassification");
-
- if (securityLabelSecurityPolicyIdentifier != "") {
- if (securityLabelSecurityClassification != "" && securityLabelSecurityClassification != "-1") {
- if (securityLabelSecurityClassification < 10)
- return "00" + securityLabelSecurityClassification;
- else if (securityLabelSecurityClassification < 100)
- return "0" + securityLabelSecurityClassification;
- else
- return securityLabelSecurityClassification;
- }
- }
- return "";
- },
- isString: function() {return true;},
- getCellProperties: function(row, col, props){ },
- getRowProperties: function(row, props){ },
- getImageSrc: function(row, col) {return null;},
- getSortLongForRow: function(hdr) {return 0;}
-}
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\r
+/* ***** BEGIN LICENSE BLOCK *****\r
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1\r
+ *\r
+ * The contents of this file are subject to the Mozilla Public License Version\r
+ * 1.1 (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ * http://www.mozilla.org/MPL/\r
+ *\r
+ * Software distributed under the License is distributed on an "AS IS" basis,\r
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
+ * for the specific language governing rights and limitations under the\r
+ * License.\r
+ *\r
+ * The Original Code is Netscape Communicator.\r
+ *\r
+ * The Initial Developer of the Original Code is\r
+ * Netscape Communications Corporation.\r
+ * Portions created by the Initial Developer are Copyright (C) 2002\r
+ * the Initial Developer. All Rights Reserved.\r
+ *\r
+ * Contributor(s):\r
+ * Eric Ballet Baz / BT Global Services / Etat francais - Ministere de la Defense\r
+ * Raphael Fairise / BT Global Services / Etat francais - Ministere de la Defense\r
+ * Copyright (c) 2010 CASSIDIAN - All rights reserved\r
+ *\r
+ * Alternatively, the contents of this file may be used under the terms of\r
+ * either the GNU General Public License Version 2 or later (the "GPL"), or\r
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
+ * in which case the provisions of the GPL or the LGPL are applicable instead\r
+ * of those above. If you wish to allow use of your version of this file only\r
+ * under the terms of either the GPL or the LGPL, and not to allow others to\r
+ * use your version of this file under the terms of the MPL, indicate your\r
+ * decision by deleting the provisions above and replace them with the notice\r
+ * and other provisions required by the GPL or the LGPL. If you do not delete\r
+ * the provisions above, a recipient may use your version of this file under\r
+ * the terms of any one of the MPL, the GPL or the LGPL.\r
+ *\r
+ * ***** END LICENSE BLOCK ***** */\r
+\r
+var gEncryptionStatus = -1;\r
+var gSignatureStatus = -1;\r
+var gSignerCert = null;\r
+var gEncryptionCert = null;\r
+var gSecurityPolicyIdentifier = null;\r
+var gSecurityClassification = -1;\r
+var gPrivacyMark = null;\r
+var gSecurityCategories = null;\r
+var gSecurityLabelConf = null;\r
+var gSecureHeaders = "";\r
+var gSecureHeadersState=-1;\r
+/*\r
+gSecureHeadersArray[o.hdrName]={\r
+ o.hdrName = sHeader.headerName; // signed header\r
+ o.hdrSecureValue = sHeader.headerValue; // value in the signature\r
+ o.hdrMimeValue = ""; // value in the MIME message\r
+ o.hdrSignedStatus = sHeader.headerStatus;\r
+ o.hdrCanonAlgo = aCanonAlgo;\r
+ o.hdrEncryptStatus = "";\r
+ o.hdrSignedRes = "valid";}\r
+*/\r
+const SECURE_HEADER_SEPARATOR = "###HEADER_SEPARATOR###";\r
+const HEADER_VAL_SEPARATOR = "###HEADER_VAL###";\r
+var gSecureHeadersArray={};\r
+addEventListener("load", smimeReadOnLoad, false);\r
+\r
+function smimeReadOnLoad()\r
+{\r
+ removeEventListener("load", smimeReadOnLoad, false);\r
+\r
+ top.controllers.appendController(SecurityController);\r
+\r
+ addEventListener("unload", smimeReadOnUnload, false);\r
+\r
+ Components.classes["@mozilla.org/observer-service;1"]\r
+ .getService(Components.interfaces.nsIObserverService)\r
+ .addObserver(securityLabelCreateDbObserver, "MsgCreateDBView", false);\r
+\r
+ if (!gSecurityLabelConf)\r
+ gSecurityLabelConf = new securityLabelConf();\r
+}\r
+\r
+function smimeReadOnUnload()\r
+{\r
+ removeEventListener("unload", smimeReadOnUnload, false);\r
+\r
+ top.controllers.removeController(SecurityController);\r
+\r
+ Components.classes["@mozilla.org/observer-service;1"]\r
+ .getService(Components.interfaces.nsIObserverService)\r
+ .removeObserver(securityLabelCreateDbObserver, "MsgCreateDBView");\r
+}\r
+\r
+function showImapSignatureUnknown()\r
+{\r
+ let readSmimeBundle = document.getElementById("bundle_read_smime");\r
+ let brandBundle = document.getElementById("bundle_brand");\r
+ if (!readSmimeBundle || !brandBundle)\r
+ return;\r
+\r
+ let promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]\r
+ .getService(Components.interfaces.nsIPromptService);\r
+ if (promptService &&\r
+ promptService.confirm(window, brandBundle.getString("brandShortName"),\r
+ readSmimeBundle.getString("ImapOnDemand")))\r
+ gDBView.reloadMessageWithAllParts();\r
+}\r
+\r
+function showMessageReadSecurityInfo()\r
+{\r
+ let gSignedUINode = document.getElementById("signedHdrIcon");\r
+ if (gSignedUINode && gSignedUINode.getAttribute("signed") == "unknown")\r
+ {\r
+ showImapSignatureUnknown();\r
+ return;\r
+ }\r
+\r
+ let pkiParams = Components.classes["@mozilla.org/security/pkiparamblock;1"]\r
+ .createInstance(Components.interfaces.nsIPKIParamBlock);\r
+\r
+ // isupport array starts with index 1\r
+ pkiParams.setISupportAtIndex(1, gSignerCert);\r
+ pkiParams.setISupportAtIndex(2, gEncryptionCert);\r
+\r
+ var params = pkiParams.QueryInterface(Components.interfaces.nsIDialogParamBlock);\r
+ // int array starts with index 0, but that is used for window exit status\r
+ params.SetInt(1, gSignatureStatus);\r
+ params.SetInt(2, gEncryptionStatus);\r
+ params.SetInt(3, gSecurityClassification);\r
+ params.SetInt(4,gSecureHeadersState);\r
+\r
+ params.SetString(0, gSecurityPolicyIdentifier);\r
+ params.SetString(1, gPrivacyMark);\r
+ params.SetString(2, gSecurityCategories);\r
+ params.SetString(12,gSecureHeaders);\r
+ \r
+ //create string with gSecureHeadersArray\r
+ var arraySecureHeadersString = "";\r
+ for (headerName in gSecureHeadersArray) { \r
+ arraySecureHeadersString+=gSecureHeadersArray[headerName].hdrName+HEADER_VAL_SEPARATOR;\r
+ arraySecureHeadersString+=gSecureHeadersArray[headerName].hdrSecureValue+HEADER_VAL_SEPARATOR; //put the value decoded instead of the value in the signature (encoded RFC2047) for the diplay\r
+ arraySecureHeadersString+=gSecureHeadersArray[headerName].hdrMimeValue+HEADER_VAL_SEPARATOR;\r
+ arraySecureHeadersString+=""+gSecureHeadersArray[headerName].hdrSignedStatus+HEADER_VAL_SEPARATOR; \r
+ arraySecureHeadersString+=gSecureHeadersArray[headerName].hdrCanonAlgo+HEADER_VAL_SEPARATOR;\r
+ //arraySecureHeadersString+=""+gSecureHeadersArray[headerName].hdrEncryptStatus+HEADER_VAL_SEPARATOR;\r
+ arraySecureHeadersString+=""+gSecureHeadersArray[headerName].hdrSignedRes+HEADER_VAL_SEPARATOR;\r
+ arraySecureHeadersString+=SECURE_HEADER_SEPARATOR;\r
+ } \r
+ params.SetString(13,arraySecureHeadersString); \r
+\r
+\r
+ window.openDialog("chrome://messenger-smime/content/msgReadSecurityInfo.xul",\r
+ "", "chrome,resizable=1,modal=1,dialog=1", pkiParams);\r
+}\r
+\r
+var SecurityController =\r
+{\r
+ supportsCommand: function(command)\r
+ {\r
+ switch (command)\r
+ {\r
+ case "cmd_viewSecurityStatus":\r
+ return true;\r
+\r
+ default:\r
+ return false;\r
+ }\r
+ },\r
+\r
+ isCommandEnabled: function(command)\r
+ {\r
+ switch (command)\r
+ {\r
+ case "cmd_viewSecurityStatus":\r
+ if (document.documentElement.getAttribute('windowtype') == "mail:messageWindow")\r
+ return GetNumSelectedMessages() > 0;\r
+\r
+ if (GetNumSelectedMessages() > 0 && gDBView)\r
+ {\r
+ let enabled = {value: false};\r
+ let checkStatus = {};\r
+ gDBView.getCommandStatus(nsMsgViewCommandType.cmdRequiringMsgBody,\r
+ enabled, checkStatus);\r
+ return enabled.value;\r
+ }\r
+ // else: fall through.\r
+\r
+ default:\r
+ return false;\r
+ }\r
+ }\r
+};\r
+\r
+/* Add Security Label column */\r
+var securityLabelCreateDbObserver = {\r
+ observe: function(aMsgFolder, aTopic, aData) {\r
+ try {\r
+ if (gDBView != undefined && gDBView.addColumnHandler)\r
+ gDBView.addColumnHandler("securityLabelSecurityClassificationColumn", securityLabelSecurityClassificationColumnHandler);\r
+ } catch(e) {}\r
+ }\r
+}\r
+\r
+var securityLabelSecurityClassificationColumnHandler = {\r
+ getCellText: function(row, column) {\r
+ var key = gDBView.getKeyAt(row);\r
+ var hdr = gDBView.db.GetMsgHdrForKey(key);\r
+ var securityLabelSecurityPolicyIdentifier = hdr.getStringProperty("securityLabelSecurityPolicyIdentifier");\r
+ var securityLabelSecurityClassification = hdr.getStringProperty("securityLabelSecurityClassification");\r
+\r
+ if (securityLabelSecurityPolicyIdentifier != "" && securityLabelSecurityClassification != "" && securityLabelSecurityClassification != "-1")\r
+ return gSecurityLabelConf.getSecurityClassificationName(securityLabelSecurityPolicyIdentifier, securityLabelSecurityClassification);\r
+\r
+ return "";\r
+ },\r
+ getSortStringForRow: function(hdr) {\r
+ var securityLabelSecurityPolicyIdentifier = hdr.getStringProperty("securityLabelSecurityPolicyIdentifier");\r
+ var securityLabelSecurityClassification = hdr.getStringProperty("securityLabelSecurityClassification");\r
+\r
+ if (securityLabelSecurityPolicyIdentifier != "") {\r
+ if (securityLabelSecurityClassification != "" && securityLabelSecurityClassification != "-1") {\r
+ if (securityLabelSecurityClassification < 10)\r
+ return "00" + securityLabelSecurityClassification;\r
+ else if (securityLabelSecurityClassification < 100)\r
+ return "0" + securityLabelSecurityClassification;\r
+ else\r
+ return securityLabelSecurityClassification;\r
+ }\r
+ }\r
+ return "";\r
+ },\r
+ isString: function() {return true;},\r
+ getCellProperties: function(row, col, props){ },\r
+ getRowProperties: function(row, props){ },\r
+ getImageSrc: function(row, col) {return null;},\r
+ getSortLongForRow: function(hdr) {return 0;}\r
+}\r