Bug 310359 - "search all address fields capability (Bcc:s too!)" - First part, implement 'From, To or CC' for local search [r=Standard8 sr=bienvenu]

This commit is contained in:
Kent James 2009-03-05 10:07:44 +00:00
Родитель 7dfdad98d8
Коммит 27afffe50d
11 изменённых файлов: 163 добавлений и 17 удалений

Просмотреть файл

@ -1116,10 +1116,11 @@
this.setAttribute("selectedIndex", "5");
}
// if it's not sender, to, cc, or toorcc, we don't care
// if it's not sender, to, cc, alladdresses, or toorcc, we don't care
if (this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.Sender &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.To &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.ToOrCC &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.AllAddresses &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.CC ) {
this.internalOperator = val;
return val;
@ -1235,6 +1236,7 @@
else if (attrib == nsMsgSearchAttrib.Sender ||
attrib == nsMsgSearchAttrib.To ||
attrib == nsMsgSearchAttrib.CC ||
attrib == nsMsgSearchAttrib.AllAddresses ||
attrib == nsMsgSearchAttrib.ToOrCC)
{
if (this.internalOperator == Components.interfaces.nsMsgSearchOp.IsntInAB ||
@ -1306,6 +1308,7 @@
else if (searchAttribute == nsMsgSearchAttrib.Sender ||
searchAttribute == nsMsgSearchAttrib.To ||
searchAttribute == nsMsgSearchAttrib.CC ||
searchAttribute == nsMsgSearchAttrib.AllAddresses ||
searchAttribute == nsMsgSearchAttrib.ToOrCC)
{
if (this.internalOperator == Components.interfaces.nsMsgSearchOp.IsntInAB ||

Просмотреть файл

@ -47,7 +47,7 @@
40=reserved for AB
41=reserved for AB
42=reserved for AB
43=reserved for AB
43=From, To or CC
44=Junk Score Origin
45=Junk Percent
46=Attachment Status

Просмотреть файл

@ -66,7 +66,7 @@ interface nsMsgSearchScope {
typedef long nsMsgSearchAttribValue;
[scriptable, uuid(4ee04610-cd79-11dc-95ff-0800200c9a66)]
[scriptable, uuid(9ED17774-4748-46a6-9A18-E651E3B791F2)]
interface nsMsgSearchAttrib {
const nsMsgSearchAttribValue Default = -1;
const nsMsgSearchAttribValue Subject = 0; /* mail and news */
@ -106,7 +106,8 @@ interface nsMsgSearchAttrib {
const nsMsgSearchAttribValue Organization = 31;
const nsMsgSearchAttribValue Department = 32;
// 33 - 43, reserved for ab / LDAP;
// 33 - 42, reserved for ab / LDAP;
const nsMsgSearchAttribValue AllAddresses = 43;
const nsMsgSearchAttribValue JunkScoreOrigin = 44;
const nsMsgSearchAttribValue JunkPercent = 45;
const nsMsgSearchAttribValue HasAttachmentStatus = 46;

Просмотреть файл

@ -243,6 +243,19 @@ nsMsgSearchValidityManager::InitOfflineMailTable()
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::ToOrCC, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::ToOrCC, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::Contains, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::Contains, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::DoesntContain, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::DoesntContain, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::BeginsWith, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::BeginsWith, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::EndsWith, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::EndsWith, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsInAB, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsInAB, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::Subject, nsMsgSearchOp::Contains, 1);
m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::Subject, nsMsgSearchOp::Contains, 1);
m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::Subject, nsMsgSearchOp::DoesntContain, 1);
@ -647,6 +660,19 @@ nsMsgSearchValidityManager::InitOfflineMailFilterTable()
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::ToOrCC, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::ToOrCC, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::Contains, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::Contains, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::DoesntContain, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::DoesntContain, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::BeginsWith, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::BeginsWith, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::EndsWith, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::EndsWith, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsInAB, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsInAB, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::AllAddresses, nsMsgSearchOp::IsntInAB, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::Subject, nsMsgSearchOp::Contains, 1);
m_offlineMailFilterTable->SetEnabled (nsMsgSearchAttrib::Subject, nsMsgSearchOp::Contains, 1);
m_offlineMailFilterTable->SetAvailable (nsMsgSearchAttrib::Subject, nsMsgSearchOp::DoesntContain, 1);

Просмотреть файл

@ -494,6 +494,24 @@ nsresult nsMsgSearchOfflineMail::ProcessSearchTerm(nsIMsgDBHdr *msgToMatch,
}
break;
}
case nsMsgSearchAttrib::AllAddresses:
{
PRBool boolKeepGoing;
aTerm->GetMatchAllBeforeDeciding(&boolKeepGoing);
msgToMatch->GetRecipients(getter_Copies(recipients));
err = aTerm->MatchRfc822String (recipients.get(), charset, charsetOverride, &result);
if (boolKeepGoing == result)
{
msgToMatch->GetCcList(getter_Copies(ccList));
err = aTerm->MatchRfc822String (ccList.get(), charset, charsetOverride, &result);
}
if (boolKeepGoing == result)
{
msgToMatch->GetAuthor(getter_Copies(matchString));
err = aTerm->MatchRfc822String (matchString.get(), charset, charsetOverride, &result);
}
break;
}
case nsMsgSearchAttrib::Body:
{
nsMsgKey messageOffset;

Просмотреть файл

@ -103,6 +103,7 @@ nsMsgSearchAttribEntry SearchAttribEntryTable[] =
{nsMsgSearchAttrib::To, "to"},
{nsMsgSearchAttrib::CC, "cc"},
{nsMsgSearchAttrib::ToOrCC, "to or cc"},
{nsMsgSearchAttrib::AllAddresses, "all addresses"},
{nsMsgSearchAttrib::AgeInDays, "age in days"},
{nsMsgSearchAttrib::Label, "label"},
{nsMsgSearchAttrib::Keywords, "tag"},

Просмотреть файл

@ -35,6 +35,7 @@
* ***** END LICENSE BLOCK ***** */
// Testing of to, cc, toorcc in addressbook search features added in bug 187768
// Added testing of AllAddresses from bug 310359
do_import_script("../mailnews/test/resources/searchTestUtils.js");
@ -64,21 +65,25 @@ const Sender = nsMsgSearchAttrib.Sender;
const To = nsMsgSearchAttrib.To;
const CCopy = nsMsgSearchAttrib.CC;
const ToOrCC = nsMsgSearchAttrib.ToOrCC;
const AllAddresses = nsMsgSearchAttrib.AllAddresses;
const Keywords = nsMsgSearchAttrib.Keywords; // control entry that is not enabled
/*
* The address available in the test address book is "PrimaryEmail1@test.invalid"
* Test emails may also include the address "invalid@example.com"
*
*
* Map of test email contents: (P is "Prim...", I is "inva.." address)
*
* Email From To CC
* 1 P I I
* 2 P P P
* 3 I P I
* 4 I I P
* 5 P I P
* 6 I I,P P,I
* 7 I I I
* 8 I P P
*
*/
@ -87,45 +92,55 @@ var Tests =
{ value: ABUri,
attrib: Sender,
op: IsInAB,
count: 2 },
count: 3 },
{ value: ABUri,
attrib: To,
op: IsInAB,
count: 3 },
count: 4 },
{ value: ABUri,
attrib: ToOrCC,
op: IsInAB,
count: 5 },
count: 6 },
{ value: ABUri,
attrib: AllAddresses,
op: IsInAB,
count: 7 },
{ value: ABUri,
attrib: CCopy,
op: IsInAB,
count: 4 },
count: 5 },
{ value: ABUri,
attrib: Sender,
op: IsntInAB,
count: 4 },
count: 5 },
{ value: ABUri,
attrib: To,
op: IsntInAB,
count: 4 },
count: 5 },
{ value: ABUri,
attrib: ToOrCC,
op: IsntInAB,
count: 5 },
count: 6 },
{ value: ABUri,
attrib: AllAddresses,
op: IsntInAB,
count: 7 },
{ value: ABUri,
attrib: CCopy,
op: IsntInAB,
count: 3 },
count: 4 },
];
var Files =
[
"../mailnews/test/data/bugmail1",
"../mailnews/test/data/bugmail2",
"../mailnews/test/data/bugmail3",
"../mailnews/test/data/bugmail4",
"../mailnews/test/data/bugmail5",
"../mailnews/test/data/bugmail6",
"../mailnews/test/data/bugmail7"
"../mailnews/test/data/bugmail7",
"../mailnews/test/data/bugmail8"
]
var messageKey, hdr;
@ -148,16 +163,19 @@ function run_test()
testValidityTable(offlineMail, IsInAB, Sender, true);
testValidityTable(offlineMail, IsInAB, To, true);
testValidityTable(offlineMail, IsInAB, ToOrCC, true);
testValidityTable(offlineMail, IsInAB, AllAddresses, true);
testValidityTable(offlineMail, IsInAB, CCopy, true);
testValidityTable(offlineMail, IsInAB, Keywords, false);
testValidityTable(offlineMail, IsntInAB, Sender, true);
testValidityTable(offlineMail, IsntInAB, To, true);
testValidityTable(offlineMail, IsntInAB, ToOrCC, true);
testValidityTable(offlineMail, IsntInAB, AllAddresses, true);
testValidityTable(offlineMail, IsntInAB, CCopy, true);
testValidityTable(offlineMail, IsntInAB, Keywords, false);
testValidityTable(offlineMail, IsBefore, Sender, false);
testValidityTable(offlineMail, IsBefore, To, false);
testValidityTable(offlineMail, IsBefore, ToOrCC, false);
testValidityTable(offlineMail, IsBefore, AllAddresses, false);
testValidityTable(offlineMail, IsBefore, CCopy, false);
testValidityTable(offlineMail, IsBefore, Keywords, false);
@ -165,16 +183,19 @@ function run_test()
testValidityTable(offlineMailFilter, IsInAB, Sender, true);
testValidityTable(offlineMailFilter, IsInAB, To, true);
testValidityTable(offlineMailFilter, IsInAB, ToOrCC, true);
testValidityTable(offlineMailFilter, IsInAB, AllAddresses, true);
testValidityTable(offlineMailFilter, IsInAB, CCopy, true);
testValidityTable(offlineMailFilter, IsInAB, Keywords, false);
testValidityTable(offlineMailFilter, IsntInAB, Sender, true);
testValidityTable(offlineMailFilter, IsntInAB, To, true);
testValidityTable(offlineMailFilter, IsntInAB, AllAddresses, true);
testValidityTable(offlineMailFilter, IsntInAB, ToOrCC, true);
testValidityTable(offlineMailFilter, IsntInAB, CCopy, true);
testValidityTable(offlineMailFilter, IsntInAB, Keywords, false);
testValidityTable(offlineMailFilter, IsBefore, Sender, false);
testValidityTable(offlineMailFilter, IsBefore, To, false);
testValidityTable(offlineMailFilter, IsBefore, ToOrCC, false);
testValidityTable(offlineMailFilter, IsBefore, AllAddresses, false);
testValidityTable(offlineMailFilter, IsBefore, CCopy, false);
testValidityTable(offlineMailFilter, IsBefore, Keywords, false);

Просмотреть файл

@ -27,8 +27,9 @@ Received: (from root@localhost)
Wed, 7 May 2008 14:55:10 -0700
Date: Wed, 7 May 2008 14:55:10 -0700
Message-Id: <200805072155.m47LtAEf007542@mrapp51.mozilla.org>
From: bugzilla-daemon@mozilla.org
To: kent@example.com
To: invalid@example.com
From: PrimaryEmail1@test.invalid
Cc: invalid@example.com
Subject: [Bug 397009] A filter will let me tag, but not untag
X-Bugzilla-Reason: None
X-Bugzilla-Type: newchanged

Просмотреть файл

@ -0,0 +1,72 @@
From - Tue Oct 02 00:26:47 2007
X-Account-Key: account2
X-UIDL: UID18345-1161858178
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
X-Mozilla-Keys: $label4
Received: from example by host29.example.com with local-bsmtp (Exim 4.68)
(envelope-from <bugzilla-daemon@mozilla.org>)
id 1JtrbR-0001Kc-Nf
for invalid@example.com; Wed, 07 May 2008 15:55:21 -0600
X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on
host29.example.com
X-Spam-Level:
X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham
version=3.2.3
Received: from webapp01.sj.mozilla.com ([10.3.4.5] helo=webapp-out.mozilla.org)
by host29.example.com with esmtps (TLSv1:AES256-SHA:256)
(Exim 4.68)
(envelope-from <bugzilla-daemon@mozilla.org>)
id 1JtrbR-0001KT-FP
for invalid@example.com; Wed, 07 May 2008 15:55:09 -0600
Received: from mrapp51.mozilla.org (mrapp51.mozilla.org [127.0.0.1])
by webapp-out.mozilla.org (8.13.8/8.13.8) with ESMTP id m47LtAFJ007547
for <invalid@example.com>; Wed, 7 May 2008 14:55:10 -0700
Received: (from root@localhost)
by mrapp51.mozilla.org (8.13.8/8.13.8/Submit) id m47LtAEf007542;
Wed, 7 May 2008 14:55:10 -0700
Date: Wed, 7 May 2008 14:55:10 -0700
Message-Id: <bugmail7.m47LtAEf007542@mrapp51.mozilla.org>
From: invalid@example.com
To: PrimaryEmail1@test.invalid
Cc: PrimaryEmail1@test.invalid
Subject: [Bug 397009] A filter will let me tag, but not untag
X-Bugzilla-Reason: None
X-Bugzilla-Type: newchanged
X-Bugzilla-Watch-Reason: QAcontact filters@mail.bugs
X-Bugzilla-Product: Core
X-Bugzilla-Component: MailNews: Filters
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: bugmail@example.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: --
X-Bugzilla-Assigned-To: nobody@mozilla.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields: Blocks
In-Reply-To: <bug-397009-254728@https.bugzilla.mozilla.org/>
References: <bug-397009-254728@https.bugzilla.mozilla.org/>
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-user: ::::10.0.1.2:host29.example.net::::::
DomainKey-Status: no signature
Do not reply to this email. You can add comments to this bug at
https://bugzilla.mozilla.org/show_bug.cgi?id=397009
Some User <bugmail@example.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |432710
--
Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the QA contact of the bug.

Просмотреть файл

@ -47,7 +47,7 @@
40=reserved for AB
41=reserved for AB
42=reserved for AB
43=reserved for AB
43=From, To or CC
44=Junk Score Origin
45=Junk Percent
46=Attachment Status

Просмотреть файл

@ -1091,10 +1091,11 @@
this.setAttribute("selectedIndex", "5");
}
// if it's not sender, to, cc, or toorcc, we don't care
// if it's not sender, to, cc, alladdresses, or toorcc, we don't care
if (this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.Sender &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.To &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.ToOrCC &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.AllAddresses &&
this.searchAttribute != Components.interfaces.nsMsgSearchAttrib.CC ) {
this.internalOperator = val;
return val;
@ -1210,6 +1211,7 @@
else if (attrib == nsMsgSearchAttrib.Sender ||
attrib == nsMsgSearchAttrib.To ||
attrib == nsMsgSearchAttrib.CC ||
attrib == nsMsgSearchAttrib.AllAddresses ||
attrib == nsMsgSearchAttrib.ToOrCC)
{
if (this.internalOperator == Components.interfaces.nsMsgSearchOp.IsntInAB ||
@ -1281,6 +1283,7 @@
else if (searchAttribute == nsMsgSearchAttrib.Sender ||
searchAttribute == nsMsgSearchAttrib.To ||
searchAttribute == nsMsgSearchAttrib.CC ||
searchAttribute == nsMsgSearchAttrib.AllAddresses ||
searchAttribute == nsMsgSearchAttrib.ToOrCC)
{
if (this.internalOperator == Components.interfaces.nsMsgSearchOp.IsntInAB ||