From 4eaa122240d3f019c1a64d61e5335d30b2486f8b Mon Sep 17 00:00:00 2001 From: aceman Date: Fri, 23 Nov 2018 13:47:00 +0100 Subject: [PATCH] Bug 1390337 - Remove some unused functions in nsIMsgDBView and nsIMsgHeaderParser. r=jcranmer,jorgk --- mail/base/content/mailWindowOverlay.js | 2 +- mailnews/base/public/nsIMsgDBView.idl | 2 -- mailnews/base/src/nsMsgDBView.cpp | 16 ------------- mailnews/mime/public/nsIMsgHeaderParser.idl | 23 +------------------ mailnews/mime/src/mimeJSComponents.js | 15 ++---------- .../test/unit/test_nsIMsgHeaderParser2.js | 23 ++++++++++--------- suite/mailnews/mailWindowOverlay.js | 6 ++--- 7 files changed, 19 insertions(+), 68 deletions(-) diff --git a/mail/base/content/mailWindowOverlay.js b/mail/base/content/mailWindowOverlay.js index f13f261df0..4ea096783e 100644 --- a/mail/base/content/mailWindowOverlay.js +++ b/mail/base/content/mailWindowOverlay.js @@ -2942,7 +2942,7 @@ var gMessageNotificationBar = { let mdnAddr = MailServices.headerParser.extractHeaderAddressMailboxes(mdnHdr); let fromAddr = MailServices.headerParser.extractHeaderAddressMailboxes(fromHdr); - let authorName = MailServices.headerParser.extractHeaderAddressName( + let authorName = MailServices.headerParser.extractFirstName( aMsgHeader.mime2DecodedAuthor) || aMsgHeader.author; // If the return receipt doesn't go to the sender address, note that in the diff --git a/mailnews/base/public/nsIMsgDBView.idl b/mailnews/base/public/nsIMsgDBView.idl index 6c68d78cfd..79906a0cee 100644 --- a/mailnews/base/public/nsIMsgDBView.idl +++ b/mailnews/base/public/nsIMsgDBView.idl @@ -318,8 +318,6 @@ interface nsIMsgDBView : nsISupports [retval, array, size_is(count)] out nsIMsgDBHdr headers); - /* @deprecated */ nsIMutableArray getMsgHdrsForSelection(); - void getURIsForSelection(out unsigned long count, [retval, array, size_is(count)] out string uris); void getIndicesForSelection(out unsigned long count, [retval, array, size_is(count)] out nsMsgViewIndex indices); diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index 3ca830a81c..68a8b3cd03 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -2773,22 +2773,6 @@ nsMsgDBView::GetSelectedMsgHdrs(uint32_t *aLength, return NS_OK; } -NS_IMETHODIMP -nsMsgDBView::GetMsgHdrsForSelection(nsIMutableArray **aResult) -{ - nsMsgViewIndexArray selection; - GetSelectedIndices(selection); - uint32_t numIndices = selection.Length(); - - nsresult rv; - nsCOMPtr messages(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - rv = GetHeadersFromSelection(selection.Elements(), numIndices, messages); - NS_ENSURE_SUCCESS(rv, rv); - messages.forget(aResult); - return rv; -} - NS_IMETHODIMP nsMsgDBView::GetURIsForSelection(uint32_t *length, char ***uris) diff --git a/mailnews/mime/public/nsIMsgHeaderParser.idl b/mailnews/mime/public/nsIMsgHeaderParser.idl index 06512ecbaa..54efe8cff2 100644 --- a/mailnews/mime/public/nsIMsgHeaderParser.idl +++ b/mailnews/mime/public/nsIMsgHeaderParser.idl @@ -201,28 +201,7 @@ interface nsIMsgHeaderParser : nsISupports { * @return A comma-separated list of just the mailbox parts * of the email-addresses. */ - /* @deprecated */ ACString extractHeaderAddressMailboxes(in ACString aLine); - - /** - * Given a string which contains a list of Header addresses, returns a - * comma-separated list of just the `user name' portions. If any of - * the addresses doesn't have a name, then the mailbox is used instead. - * - * @param aLine The header line to parse. - * @return A comma-separated list of just the name parts - * of the addresses. - */ - /* @deprecated */ AUTF8String extractHeaderAddressNames(in AUTF8String aLine); - - /* - * Like extractHeaderAddressNames, but only returns the first name in the - * header if there is one. This function will return unquoted strings suitable - * for display. - * - * @param aLine The header line to parse. - * @return The first name found in the list. - */ - /* @deprecated */ AUTF8String extractHeaderAddressName(in AUTF8String aLine); + ACString extractHeaderAddressMailboxes(in ACString aLine); /** * Given a name and email address, produce a string that is suitable for diff --git a/mailnews/mime/src/mimeJSComponents.js b/mailnews/mime/src/mimeJSComponents.js index c22019d71a..9bc8df55dc 100644 --- a/mailnews/mime/src/mimeJSComponents.js +++ b/mailnews/mime/src/mimeJSComponents.js @@ -292,8 +292,8 @@ MimeAddressParser.prototype = { }, extractFirstName: function (aHeader) { - let address = this.parseDecodedHeader(aHeader, false)[0]; - return address.name || address.email; + let addresses = this.parseDecodedHeader(aHeader, false); + return (addresses.length > 0) ? (addresses[0].name || addresses[0].email) : ""; }, removeDuplicateAddresses: function (aAddrs, aOtherAddrs) { @@ -416,17 +416,6 @@ MimeAddressParser.prototype = { return this.parseDecodedHeader(aLine).map(addr => addr.email).join(", "); }, - extractHeaderAddressNames: function (aLine) { - return this.parseDecodedHeader(aLine).map(addr => addr.name || addr.email) - .join(", "); - }, - - extractHeaderAddressName: function (aLine) { - let addrs = this.parseDecodedHeader(aLine).map(addr => - addr.name || addr.email); - return addrs.length == 0 ? "" : addrs[0]; - }, - makeMimeAddress: function (aName, aEmail) { let object = this.makeMailboxObject(aName, aEmail); return this.makeMimeHeader([object]); diff --git a/mailnews/mime/test/unit/test_nsIMsgHeaderParser2.js b/mailnews/mime/test/unit/test_nsIMsgHeaderParser2.js index be844c581d..064eb47495 100644 --- a/mailnews/mime/test/unit/test_nsIMsgHeaderParser2.js +++ b/mailnews/mime/test/unit/test_nsIMsgHeaderParser2.js @@ -2,18 +2,18 @@ /* * Test suite for nsIMsgHeaderParser functions: * extractHeaderAddressMailboxes - * extractHeaderAddressNames - * extractHeaderAddressName + * extractFirstName + * parseDecodedHeader */ ChromeUtils.import("resource:///modules/MailServices.jsm"); function run_test() { // In this array, the sub arrays consist of the following elements: - // 0: input string + // 0: input string (a comma separated list of recipients) // 1: expected output from extractHeaderAddressMailboxes - // 2: expected output from extractHeaderAddressNames - // 3: expected output from extractHeaderAddressName + // 2: list of recipient names in the string + // 3: first recipient name in the string const checks = [ ["abc@foo.invalid", @@ -45,7 +45,7 @@ function run_test() { ["\"Joe Q. Public\" ,Test <\"abc!x.yz\"@foo.invalid>, Test ,\"Giant; \\\"Big\\\" Box\" ", "john.q.public@example.com, \"abc!x.yz\"@foo.invalid, test@[xyz!], sysservices@example.net", "Joe Q. Public, Test, Test, Giant; \"Big\" Box", - // extractHeaderAddressName returns unquoted names, hence the difference. + // extractFirstName returns unquoted names, hence the difference. "Joe Q. Public" ], // Bug 549931 ["Undisclosed recipients:;", @@ -58,18 +58,19 @@ function run_test() { let addresses = {}, names = {}, fullAddresses = {}; MailServices.headerParser.parseHeadersWithArray("\" \"@a a;b", addresses, names, fullAddresses); - // Test - empty strings Assert.equal(MailServices.headerParser.extractHeaderAddressMailboxes(""), ""); - Assert.equal(MailServices.headerParser.extractHeaderAddressNames(""), ""); - Assert.equal(MailServices.headerParser.extractHeaderAddressName(""), ""); + Assert.equal(MailServices.headerParser.extractFirstName(""), ""); // Test - extractHeaderAddressMailboxes for (let i = 0; i < checks.length; ++i) { Assert.equal(MailServices.headerParser.extractHeaderAddressMailboxes(checks[i][0]), checks[i][1]); - Assert.equal(MailServices.headerParser.extractHeaderAddressNames(checks[i][0]), checks[i][2]); - Assert.equal(MailServices.headerParser.extractHeaderAddressName(checks[i][0]), checks[i][3]); + let names = MailServices.headerParser.parseDecodedHeader(checks[i][0]) + .map(addr => addr.name || addr.email) + .join(", "); + Assert.equal(names, checks[i][2]); + Assert.equal(MailServices.headerParser.extractFirstName(checks[i][0]), checks[i][3]); } } diff --git a/suite/mailnews/mailWindowOverlay.js b/suite/mailnews/mailWindowOverlay.js index d4efad04f5..5c0c993c3e 100644 --- a/suite/mailnews/mailWindowOverlay.js +++ b/suite/mailnews/mailWindowOverlay.js @@ -2617,7 +2617,7 @@ var gMessageNotificationBar = // update the allow remote content for sender string var mailbox = headerParser.extractHeaderAddressMailboxes(aMsgHdr.author); var emailAddress = mailbox || aMsgHdr.author; - var displayName = headerParser.extractHeaderAddressName(aMsgHdr.author); + var displayName = headerParser.extractFirstName(aMsgHdr.mime2DecodedAuthor); var brandName = this.mBrandBundle.getString("brandShortName"); var remoteContentMsg = this.mStringBundle .getFormattedString("remoteContentBarMessage", @@ -2685,8 +2685,8 @@ var gMessageNotificationBar = .extractHeaderAddressMailboxes(fromHdr); var authorName = MailServices.headerParser - .extractHeaderAddressName( - aMsgHeader.mime2DecodedAuthor) || aMsgHeader.author; + .extractFirstName(aMsgHeader.mime2DecodedAuthor) + || aMsgHeader.author; var barMsg; // If the return receipt doesn't go to the sender address, note that in the