From 302bf1b523012e11b60425d6eee1221ebc2724eb Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 3 Nov 2019 00:17:46 -0400 Subject: Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1 --- mailnews/base/search/content/CustomHeaders.js | 203 ++ mailnews/base/search/content/CustomHeaders.xul | 57 + mailnews/base/search/content/FilterEditor.js | 854 ++++++++ mailnews/base/search/content/FilterEditor.xul | 125 ++ mailnews/base/search/content/searchTermOverlay.js | 536 +++++ mailnews/base/search/content/searchTermOverlay.xul | 66 + mailnews/base/search/content/searchWidgets.xml | 738 +++++++ mailnews/base/search/content/viewLog.js | 36 + mailnews/base/search/content/viewLog.xul | 49 + mailnews/base/search/public/moz.build | 38 + mailnews/base/search/public/nsIMsgFilter.idl | 142 ++ .../search/public/nsIMsgFilterCustomAction.idl | 90 + .../base/search/public/nsIMsgFilterHitNotify.idl | 27 + mailnews/base/search/public/nsIMsgFilterList.idl | 108 + mailnews/base/search/public/nsIMsgFilterPlugin.idl | 350 ++++ .../base/search/public/nsIMsgFilterService.idl | 95 + .../base/search/public/nsIMsgOperationListener.idl | 17 + .../base/search/public/nsIMsgSearchAdapter.idl | 42 + .../base/search/public/nsIMsgSearchCustomTerm.idl | 79 + mailnews/base/search/public/nsIMsgSearchNotify.idl | 31 + .../base/search/public/nsIMsgSearchScopeTerm.idl | 20 + .../base/search/public/nsIMsgSearchSession.idl | 147 ++ mailnews/base/search/public/nsIMsgSearchTerm.idl | 156 ++ .../search/public/nsIMsgSearchValidityManager.idl | 26 + .../search/public/nsIMsgSearchValidityTable.idl | 50 + mailnews/base/search/public/nsIMsgSearchValue.idl | 36 + mailnews/base/search/public/nsIMsgTraitService.idl | 174 ++ mailnews/base/search/public/nsMsgBodyHandler.h | 112 ++ mailnews/base/search/public/nsMsgFilterCore.idl | 63 + mailnews/base/search/public/nsMsgResultElement.h | 40 + mailnews/base/search/public/nsMsgSearchAdapter.h | 218 ++ .../base/search/public/nsMsgSearchBoolExpression.h | 107 + mailnews/base/search/public/nsMsgSearchCore.idl | 222 +++ mailnews/base/search/public/nsMsgSearchScopeTerm.h | 45 + mailnews/base/search/public/nsMsgSearchTerm.h | 85 + mailnews/base/search/src/Bogofilter.sfd | 14 + mailnews/base/search/src/DSPAM.sfd | 14 + mailnews/base/search/src/Habeas.sfd | 8 + mailnews/base/search/src/POPFile.sfd | 14 + mailnews/base/search/src/SpamAssassin.sfd | 14 + mailnews/base/search/src/SpamCatcher.sfd | 14 + mailnews/base/search/src/SpamPal.sfd | 14 + mailnews/base/search/src/moz.build | 33 + mailnews/base/search/src/nsMsgBodyHandler.cpp | 487 +++++ mailnews/base/search/src/nsMsgFilter.cpp | 1057 ++++++++++ mailnews/base/search/src/nsMsgFilter.h | 103 + mailnews/base/search/src/nsMsgFilterList.cpp | 1198 +++++++++++ mailnews/base/search/src/nsMsgFilterList.h | 75 + mailnews/base/search/src/nsMsgFilterService.cpp | 1216 ++++++++++++ mailnews/base/search/src/nsMsgFilterService.h | 46 + mailnews/base/search/src/nsMsgImapSearch.cpp | 1004 ++++++++++ mailnews/base/search/src/nsMsgLocalSearch.cpp | 1022 ++++++++++ mailnews/base/search/src/nsMsgLocalSearch.h | 104 + mailnews/base/search/src/nsMsgSearchAdapter.cpp | 1332 +++++++++++++ mailnews/base/search/src/nsMsgSearchImap.h | 37 + mailnews/base/search/src/nsMsgSearchNews.cpp | 511 +++++ mailnews/base/search/src/nsMsgSearchNews.h | 49 + mailnews/base/search/src/nsMsgSearchSession.cpp | 675 +++++++ mailnews/base/search/src/nsMsgSearchSession.h | 98 + mailnews/base/search/src/nsMsgSearchTerm.cpp | 2088 ++++++++++++++++++++ mailnews/base/search/src/nsMsgSearchValue.cpp | 117 ++ mailnews/base/search/src/nsMsgSearchValue.h | 26 + mailnews/base/search/src/nsMsgTraitService.js | 239 +++ .../base/search/src/nsMsgTraitService.manifest | 2 + 64 files changed, 16795 insertions(+) create mode 100644 mailnews/base/search/content/CustomHeaders.js create mode 100644 mailnews/base/search/content/CustomHeaders.xul create mode 100644 mailnews/base/search/content/FilterEditor.js create mode 100644 mailnews/base/search/content/FilterEditor.xul create mode 100644 mailnews/base/search/content/searchTermOverlay.js create mode 100644 mailnews/base/search/content/searchTermOverlay.xul create mode 100644 mailnews/base/search/content/searchWidgets.xml create mode 100644 mailnews/base/search/content/viewLog.js create mode 100644 mailnews/base/search/content/viewLog.xul create mode 100644 mailnews/base/search/public/moz.build create mode 100644 mailnews/base/search/public/nsIMsgFilter.idl create mode 100644 mailnews/base/search/public/nsIMsgFilterCustomAction.idl create mode 100644 mailnews/base/search/public/nsIMsgFilterHitNotify.idl create mode 100644 mailnews/base/search/public/nsIMsgFilterList.idl create mode 100644 mailnews/base/search/public/nsIMsgFilterPlugin.idl create mode 100644 mailnews/base/search/public/nsIMsgFilterService.idl create mode 100644 mailnews/base/search/public/nsIMsgOperationListener.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchAdapter.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchCustomTerm.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchNotify.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchScopeTerm.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchSession.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchTerm.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchValidityManager.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchValidityTable.idl create mode 100644 mailnews/base/search/public/nsIMsgSearchValue.idl create mode 100644 mailnews/base/search/public/nsIMsgTraitService.idl create mode 100644 mailnews/base/search/public/nsMsgBodyHandler.h create mode 100644 mailnews/base/search/public/nsMsgFilterCore.idl create mode 100644 mailnews/base/search/public/nsMsgResultElement.h create mode 100644 mailnews/base/search/public/nsMsgSearchAdapter.h create mode 100644 mailnews/base/search/public/nsMsgSearchBoolExpression.h create mode 100644 mailnews/base/search/public/nsMsgSearchCore.idl create mode 100644 mailnews/base/search/public/nsMsgSearchScopeTerm.h create mode 100644 mailnews/base/search/public/nsMsgSearchTerm.h create mode 100644 mailnews/base/search/src/Bogofilter.sfd create mode 100644 mailnews/base/search/src/DSPAM.sfd create mode 100644 mailnews/base/search/src/Habeas.sfd create mode 100644 mailnews/base/search/src/POPFile.sfd create mode 100644 mailnews/base/search/src/SpamAssassin.sfd create mode 100644 mailnews/base/search/src/SpamCatcher.sfd create mode 100644 mailnews/base/search/src/SpamPal.sfd create mode 100644 mailnews/base/search/src/moz.build create mode 100644 mailnews/base/search/src/nsMsgBodyHandler.cpp create mode 100644 mailnews/base/search/src/nsMsgFilter.cpp create mode 100644 mailnews/base/search/src/nsMsgFilter.h create mode 100644 mailnews/base/search/src/nsMsgFilterList.cpp create mode 100644 mailnews/base/search/src/nsMsgFilterList.h create mode 100644 mailnews/base/search/src/nsMsgFilterService.cpp create mode 100644 mailnews/base/search/src/nsMsgFilterService.h create mode 100644 mailnews/base/search/src/nsMsgImapSearch.cpp create mode 100644 mailnews/base/search/src/nsMsgLocalSearch.cpp create mode 100644 mailnews/base/search/src/nsMsgLocalSearch.h create mode 100644 mailnews/base/search/src/nsMsgSearchAdapter.cpp create mode 100644 mailnews/base/search/src/nsMsgSearchImap.h create mode 100644 mailnews/base/search/src/nsMsgSearchNews.cpp create mode 100644 mailnews/base/search/src/nsMsgSearchNews.h create mode 100644 mailnews/base/search/src/nsMsgSearchSession.cpp create mode 100644 mailnews/base/search/src/nsMsgSearchSession.h create mode 100644 mailnews/base/search/src/nsMsgSearchTerm.cpp create mode 100644 mailnews/base/search/src/nsMsgSearchValue.cpp create mode 100644 mailnews/base/search/src/nsMsgSearchValue.h create mode 100644 mailnews/base/search/src/nsMsgTraitService.js create mode 100644 mailnews/base/search/src/nsMsgTraitService.manifest (limited to 'mailnews/base/search') diff --git a/mailnews/base/search/content/CustomHeaders.js b/mailnews/base/search/content/CustomHeaders.js new file mode 100644 index 000000000..174ba100e --- /dev/null +++ b/mailnews/base/search/content/CustomHeaders.js @@ -0,0 +1,203 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +Components.utils.import("resource://gre/modules/Services.jsm"); + +var gAddButton; +var gRemoveButton; +var gHeaderInputElement; +var gArrayHdrs; +var gHdrsList; +var gContainer; +var gFilterBundle=null; +var gCustomBundle=null; + +function onLoad() +{ + let hdrs = Services.prefs.getCharPref("mailnews.customHeaders"); + gHeaderInputElement = document.getElementById("headerInput"); + gHeaderInputElement.focus(); + + gHdrsList = document.getElementById("headerList"); + gArrayHdrs = new Array(); + gAddButton = document.getElementById("addButton"); + gRemoveButton = document.getElementById("removeButton"); + + initializeDialog(hdrs); + updateAddButton(true); + updateRemoveButton(); +} + +function initializeDialog(hdrs) +{ + if (hdrs) + { + hdrs = hdrs.replace(/\s+/g,''); //remove white spaces before splitting + gArrayHdrs = hdrs.split(":"); + for (var i = 0; i < gArrayHdrs.length; i++) + if (!gArrayHdrs[i]) + gArrayHdrs.splice(i,1); //remove any null elements + initializeRows(); + } +} + +function initializeRows() +{ + for (var i = 0; i < gArrayHdrs.length; i++) + addRow(TrimString(gArrayHdrs[i])); +} + +function onTextInput() +{ + // enable the add button if the user has started to type text + updateAddButton( (gHeaderInputElement.value == "") ); +} + +function onOk() +{ + if (gArrayHdrs.length) + { + var hdrs; + if (gArrayHdrs.length == 1) + hdrs = gArrayHdrs; + else + hdrs = gArrayHdrs.join(": "); + Services.prefs.setCharPref("mailnews.customHeaders", hdrs); + // flush prefs to disk, in case we crash, to avoid dataloss and problems with filters that use the custom headers + Services.prefs.savePrefFile(null); + } + else + { + Services.prefs.clearUserPref("mailnews.customHeaders"); //clear the pref, no custom headers + } + + window.arguments[0].selectedVal = gHdrsList.selectedItem ? gHdrsList.selectedItem.label : null; + return true; +} + +function customHeaderOverflow() +{ + var nsMsgSearchAttrib = Components.interfaces.nsMsgSearchAttrib; + if (gArrayHdrs.length >= (nsMsgSearchAttrib.kNumMsgSearchAttributes - nsMsgSearchAttrib.OtherHeader - 1)) + { + if (!gFilterBundle) + gFilterBundle = document.getElementById("bundle_filter"); + + var alertText = gFilterBundle.getString("customHeaderOverflow"); + Services.prompt.alert(window, null, alertText); + return true; + } + return false; +} + +function onAddHeader() +{ + var newHdr = TrimString(gHeaderInputElement.value); + + if (!isRFC2822Header(newHdr)) // if user entered an invalid rfc822 header field name, bail out. + { + if (!gCustomBundle) + gCustomBundle = document.getElementById("bundle_custom"); + + var alertText = gCustomBundle.getString("colonInHeaderName"); + Services.prompt.alert(window, null, alertText); + return; + } + + gHeaderInputElement.value = ""; + if (!newHdr || customHeaderOverflow()) + return; + if (!duplicateHdrExists(newHdr)) + { + gArrayHdrs[gArrayHdrs.length] = newHdr; + var newItem = addRow(newHdr); + gHdrsList.selectItem (newItem); // make sure the new entry is selected in the tree + // now disable the add button + updateAddButton(true); + gHeaderInputElement.focus(); // refocus the input field for the next custom header + } +} + +function isRFC2822Header(hdr) +{ + var charCode; + for (var i = 0; i < hdr.length; i++) + { + charCode = hdr.charCodeAt(i); + //58 is for colon and 33 and 126 are us-ascii bounds that should be used for header field name, as per rfc2822 + + if (charCode < 33 || charCode == 58 || charCode > 126) + return false; + } + return true; +} + +function duplicateHdrExists(hdr) +{ + for (var i = 0;i < gArrayHdrs.length; i++) + { + if (gArrayHdrs[i] == hdr) + return true; + } + return false; +} + +function onRemoveHeader() +{ + var listitem = gHdrsList.selectedItems[0] + if (!listitem) return; + listitem.remove(); + var selectedHdr = GetListItemAttributeStr(listitem); + var j=0; + for (var i = 0; i < gArrayHdrs.length; i++) + { + if (gArrayHdrs[i] == selectedHdr) + { + gArrayHdrs.splice(i,1); + break; + } + } +} + +function GetListItemAttributeStr(listitem) +{ + if (listitem) + return TrimString(listitem.getAttribute("label")); + + return ""; +} + +function addRow(newHdr) +{ + var listitem = document.createElement("listitem"); + listitem.setAttribute("label", newHdr); + gHdrsList.appendChild(listitem); + return listitem; +} + +function updateAddButton(aDisable) +{ + // only update the button if the disabled state changed + if (aDisable == gAddButton.disabled) + return; + + gAddButton.disabled = aDisable; + document.documentElement.defaultButton = aDisable ? "accept" : "extra1"; +} + +function updateRemoveButton() +{ + var headerSelected = (gHdrsList.selectedItems.length > 0); + gRemoveButton.disabled = !headerSelected; + if (gRemoveButton.disabled) + gHeaderInputElement.focus(); +} + +//Remove whitespace from both ends of a string +function TrimString(string) +{ + if (!string) return ""; + return string.trim(); +} diff --git a/mailnews/base/search/content/CustomHeaders.xul b/mailnews/base/search/content/CustomHeaders.xul new file mode 100644 index 000000000..c13a8dba8 --- /dev/null +++ b/mailnews/base/search/content/CustomHeaders.xul @@ -0,0 +1,57 @@ + + + + + + + + + + + + +