Bug #162563 --> add a search attribute and value for labels so you can search on labels

r=naving
sr=sspitzer
This commit is contained in:
mscott%netscape.com 2002-08-14 21:56:57 +00:00
Родитель 536a42646f
Коммит 41724e14b9
6 изменённых файлов: 35 добавлений и 1 удалений

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

@ -62,6 +62,7 @@ interface nsIMsgSearchTerm : nsISupports {
boolean matchPriority(in nsMsgPriorityValue priority);
boolean matchAge(in PRTime days);
boolean matchSize(in unsigned long size);
boolean matchLabel(in nsMsgLabelValue aLabelValue);
boolean matchBody(in nsIMsgSearchScopeTerm scopeTerm,
in unsigned long offset,

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

@ -55,6 +55,7 @@ interface nsIMsgSearchValue : nsISupports {
attribute nsMsgKey msgKey;
attribute unsigned long age; // in days
attribute nsIMsgFolder folder;
attribute nsMsgLabelValue label;
wstring toString();
};

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

@ -104,9 +104,9 @@ interface nsMsgSearchAttrib {
// 32 - 48, reserved for ab / LDAP;
const nsMsgSearchAttribValue Label = 48; /* mail only...can search by label */
//49 is for showing customize... in ui headers start from 50 onwards up until 99.
const nsMsgSearchAttribValue OtherHeader = 49; /* for mail and news. MUST ALWAYS BE LAST attribute since we can have an arbitrary # of these... */
const nsMsgSearchAttribValue kNumMsgSearchAttributes = 100; /* must be last attribute */
};
@ -193,6 +193,7 @@ typedef struct nsMsgSearchValue
nsMsgKey key;
PRUint32 age; /* in days */
nsIMsgFolder *folder;
nsMsgLabelValue label;
} u;
char *string;
} nsMsgSearchValue;

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

@ -648,6 +648,13 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
err = pTerm->MatchAge (date, &result);
}
break;
case nsMsgSearchAttrib::Label:
{
nsMsgLabelValue label;
msgToMatch->GetLabel(&label);
err = pTerm->MatchLabel(label, &result);
}
break;
default:
// XXX todo
// for the temporary return receipts filters, we use a custom header for Content-Type

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

@ -1143,6 +1143,25 @@ nsresult nsMsgSearchTerm::MatchSize (PRUint32 sizeToMatch, PRBool *pResult)
return NS_OK;
}
nsresult nsMsgSearchTerm::MatchLabel(nsMsgLabelValue aLabelValue, PRBool *pResult)
{
NS_ENSURE_ARG_POINTER(pResult);
PRBool result = PR_FALSE;
switch (m_operator)
{
case nsMsgSearchOp::Is:
if (m_value.u.label == aLabelValue)
result = PR_TRUE;
break;
default:
if (m_value.u.label != aLabelValue)
result = PR_TRUE;
break;
}
*pResult = result;
return NS_OK;
}
nsresult nsMsgSearchTerm::MatchStatus (PRUint32 statusToMatch, PRBool *pResult)
{
@ -1443,6 +1462,9 @@ nsresult nsMsgResultElement::AssignValues (nsIMsgSearchValue *src, nsMsgSearchVa
case nsMsgSearchAttrib::AgeInDays:
err = src->GetAge(&dst->u.age);
break;
case nsMsgSearchAttrib::Label:
err = src->GetLabel(&dst->u.label);
break;
default:
if (dst->attribute < nsMsgSearchAttrib::kNumMsgSearchAttributes)
{

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

@ -66,6 +66,7 @@ NS_IMPL_GETSET(nsMsgSearchValueImpl, MsgKey, nsMsgKey, mValue.u.key);
NS_IMPL_GETSET(nsMsgSearchValueImpl, Age, PRUint32, mValue.u.age);
NS_IMPL_GETSET(nsMsgSearchValueImpl, Date, PRTime, mValue.u.date);
NS_IMPL_GETSET(nsMsgSearchValueImpl, Attrib, nsMsgSearchAttribValue, mValue.attribute);
NS_IMPL_GETSET(nsMsgSearchValueImpl, Label, nsMsgLabelValue, mValue.u.label);
NS_IMETHODIMP
nsMsgSearchValueImpl::GetFolder(nsIMsgFolder* *aResult)
@ -126,6 +127,7 @@ nsMsgSearchValueImpl::ToString(PRUnichar **aResult)
case nsMsgSearchAttrib::Size:
case nsMsgSearchAttrib::AgeInDays:
case nsMsgSearchAttrib::FolderInfo:
case nsMsgSearchAttrib::Label:
resultStr.Append(NS_LITERAL_STRING("type="));
resultStr.AppendInt(mValue.attribute);
break;