зеркало из https://github.com/mozilla/pjs.git
Bug 358909 ��� Message filter "Age" only allows positive values.
The fix enables searching/filtering out messages with date in the future. r+sr=bienvenu
This commit is contained in:
Родитель
37a103da30
Коммит
ff26bc2426
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
interface nsIMsgFolder;
|
interface nsIMsgFolder;
|
||||||
|
|
||||||
[scriptable, uuid(124C7DEB-5BDE-4367-8CD2-19616FFF8F0D)]
|
[scriptable, uuid(86293830-06e4-4f08-8f2c-e74ef45ceddf)]
|
||||||
interface nsIMsgSearchValue : nsISupports {
|
interface nsIMsgSearchValue : nsISupports {
|
||||||
// type of object
|
// type of object
|
||||||
attribute nsMsgSearchAttribValue attrib;
|
attribute nsMsgSearchAttribValue attrib;
|
||||||
|
@ -53,7 +53,7 @@ interface nsIMsgSearchValue : nsISupports {
|
||||||
attribute unsigned long status; // see MSG_FLAG in msgcom.h
|
attribute unsigned long status; // see MSG_FLAG in msgcom.h
|
||||||
attribute unsigned long size;
|
attribute unsigned long size;
|
||||||
attribute nsMsgKey msgKey;
|
attribute nsMsgKey msgKey;
|
||||||
attribute unsigned long age; // in days
|
attribute long age; // in days
|
||||||
attribute nsIMsgFolder folder;
|
attribute nsIMsgFolder folder;
|
||||||
attribute nsMsgLabelValue label;
|
attribute nsMsgLabelValue label;
|
||||||
attribute nsMsgJunkStatus junkStatus;
|
attribute nsMsgJunkStatus junkStatus;
|
||||||
|
|
|
@ -198,10 +198,10 @@ typedef struct nsMsgSearchValue
|
||||||
PRUint32 msgStatus; /* see MSG_FLAG in msgcom.h */
|
PRUint32 msgStatus; /* see MSG_FLAG in msgcom.h */
|
||||||
PRUint32 size;
|
PRUint32 size;
|
||||||
nsMsgKey key;
|
nsMsgKey key;
|
||||||
PRUint32 age; /* in days */
|
PRInt32 age; /* in days */
|
||||||
nsIMsgFolder *folder;
|
nsIMsgFolder *folder;
|
||||||
nsMsgLabelValue label;
|
nsMsgLabelValue label;
|
||||||
PRUint32 junkStatus;
|
PRUint32 junkStatus;
|
||||||
} u;
|
} u;
|
||||||
char *string;
|
char *string;
|
||||||
} nsMsgSearchValue;
|
} nsMsgSearchValue;
|
||||||
|
|
|
@ -356,20 +356,28 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
|
||||||
case nsMsgSearchAttrib::AgeInDays: // added for searching online for age in days...
|
case nsMsgSearchAttrib::AgeInDays: // added for searching online for age in days...
|
||||||
// for AgeInDays, we are actually going to perform a search by date, so convert the operations for age
|
// for AgeInDays, we are actually going to perform a search by date, so convert the operations for age
|
||||||
// to the IMAP mnemonics that we would use for date!
|
// to the IMAP mnemonics that we would use for date!
|
||||||
switch (op)
|
|
||||||
{
|
{
|
||||||
case nsMsgSearchOp::IsGreaterThan:
|
// If we have a future date, the > and < are reversed.
|
||||||
whichMnemonic = m_kImapBefore;
|
// e.g. ageInDays > 2 means more than 2 days old ("date before X") whereas
|
||||||
break;
|
// ageInDays > -2 should be more than 2 days in the future ("date after X")
|
||||||
case nsMsgSearchOp::IsLessThan:
|
PRInt32 ageInDays;
|
||||||
whichMnemonic = m_kImapSince;
|
searchValue->GetAge(&ageInDays);
|
||||||
break;
|
PRBool dateInFuture = (ageInDays < 0);
|
||||||
case nsMsgSearchOp::Is:
|
switch (op)
|
||||||
whichMnemonic = m_kImapSentOn;
|
{
|
||||||
break;
|
case nsMsgSearchOp::IsGreaterThan:
|
||||||
default:
|
whichMnemonic = (!dateInFuture) ? m_kImapBefore : m_kImapSince;
|
||||||
NS_ASSERTION(PR_FALSE, "invalid search operator");
|
break;
|
||||||
return NS_ERROR_INVALID_ARG;
|
case nsMsgSearchOp::IsLessThan:
|
||||||
|
whichMnemonic = (!dateInFuture) ? m_kImapSince : m_kImapBefore;
|
||||||
|
break;
|
||||||
|
case nsMsgSearchOp::Is:
|
||||||
|
whichMnemonic = m_kImapSentOn;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NS_ASSERTION(PR_FALSE, "invalid search operator");
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case nsMsgSearchAttrib::Size:
|
case nsMsgSearchAttrib::Size:
|
||||||
|
@ -499,7 +507,7 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
|
||||||
{
|
{
|
||||||
// okay, take the current date, subtract off the age in days, then do an appropriate Date search on
|
// okay, take the current date, subtract off the age in days, then do an appropriate Date search on
|
||||||
// the resulting day.
|
// the resulting day.
|
||||||
PRUint32 ageInDays;
|
PRInt32 ageInDays;
|
||||||
|
|
||||||
searchValue->GetAge(&ageInDays);
|
searchValue->GetAge(&ageInDays);
|
||||||
|
|
||||||
|
@ -509,7 +517,7 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
|
||||||
PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDay;
|
PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDay;
|
||||||
|
|
||||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||||
LL_UI2L(secondsInDays, 60 * 60 * 24 * ageInDays);
|
LL_I2L(secondsInDays, 60 * 60 * 24 * ageInDays);
|
||||||
LL_MUL(microSecondsInDay, secondsInDays, microSecondsPerSecond);
|
LL_MUL(microSecondsInDay, secondsInDays, microSecondsPerSecond);
|
||||||
|
|
||||||
LL_SUB(matchDay, now, microSecondsInDay); // = now - term->m_value.u.age * 60 * 60 * 24;
|
LL_SUB(matchDay, now, microSecondsInDay); // = now - term->m_value.u.age * 60 * 60 * 24;
|
||||||
|
@ -1066,8 +1074,6 @@ nsMsgSearchValidityManager::SetOtherHeadersInTable (nsIMsgSearchValidityTable *a
|
||||||
PRUint32 numHeaders=0;
|
PRUint32 numHeaders=0;
|
||||||
if (customHeadersLength)
|
if (customHeadersLength)
|
||||||
{
|
{
|
||||||
char *headersString = strdup(customHeaders);
|
|
||||||
|
|
||||||
nsCAutoString hdrStr(customHeaders);
|
nsCAutoString hdrStr(customHeaders);
|
||||||
hdrStr.StripWhitespace(); //remove whitespace before parsing
|
hdrStr.StripWhitespace(); //remove whitespace before parsing
|
||||||
char *newStr = hdrStr.BeginWriting();
|
char *newStr = hdrStr.BeginWriting();
|
||||||
|
|
|
@ -1138,20 +1138,25 @@ nsresult nsMsgSearchTerm::MatchAge (PRTime msgDate, PRBool *pResult)
|
||||||
PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDays;
|
PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDays;
|
||||||
|
|
||||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||||
LL_UI2L(secondsInDays, 60 * 60 * 24 * m_value.u.age);
|
LL_I2L(secondsInDays, 60 * 60 * 24 * m_value.u.age);
|
||||||
LL_MUL(microSecondsInDays, secondsInDays, microSecondsPerSecond);
|
LL_MUL(microSecondsInDays, secondsInDays, microSecondsPerSecond);
|
||||||
|
|
||||||
LL_SUB(cutOffDay, now, microSecondsInDays); // = now - term->m_value.u.age * 60 * 60 * 24;
|
LL_SUB(cutOffDay, now, microSecondsInDays); // = now - term->m_value.u.age * 60 * 60 * 24;
|
||||||
// so now cutOffDay is the PRTime cut-off point. Any msg with a time less than that will be past the age .
|
|
||||||
|
PRBool cutOffDayInTheFuture = LL_CMP(m_value.u.age, <, 0);
|
||||||
|
|
||||||
|
// So now cutOffDay is the PRTime cut-off point.
|
||||||
|
// Any msg with a time less than that will be past the age.
|
||||||
|
|
||||||
switch (m_operator)
|
switch (m_operator)
|
||||||
{
|
{
|
||||||
case nsMsgSearchOp::IsGreaterThan: // is older than
|
case nsMsgSearchOp::IsGreaterThan: // is older than, or more in the future
|
||||||
if (LL_CMP(msgDate, <, cutOffDay))
|
if ((!cutOffDayInTheFuture && LL_CMP(msgDate, <, cutOffDay)) ||
|
||||||
|
(cutOffDayInTheFuture && LL_CMP(msgDate, >, cutOffDay)))
|
||||||
result = PR_TRUE;
|
result = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
case nsMsgSearchOp::IsLessThan: // is younger than
|
case nsMsgSearchOp::IsLessThan: // is younger than, or less in the future
|
||||||
if (LL_CMP(msgDate, >, cutOffDay))
|
if ((!cutOffDayInTheFuture && LL_CMP(msgDate, >, cutOffDay)) ||
|
||||||
|
(cutOffDayInTheFuture && LL_CMP(msgDate, <, cutOffDay)))
|
||||||
result = PR_TRUE;
|
result = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
case nsMsgSearchOp::Is:
|
case nsMsgSearchOp::Is:
|
||||||
|
|
|
@ -62,7 +62,7 @@ NS_IMPL_GETSET(nsMsgSearchValueImpl, Priority, nsMsgPriorityValue, mValue.u.prio
|
||||||
NS_IMPL_GETSET(nsMsgSearchValueImpl, Status, PRUint32, mValue.u.msgStatus)
|
NS_IMPL_GETSET(nsMsgSearchValueImpl, Status, PRUint32, mValue.u.msgStatus)
|
||||||
NS_IMPL_GETSET(nsMsgSearchValueImpl, Size, PRUint32, mValue.u.size)
|
NS_IMPL_GETSET(nsMsgSearchValueImpl, Size, PRUint32, mValue.u.size)
|
||||||
NS_IMPL_GETSET(nsMsgSearchValueImpl, MsgKey, nsMsgKey, mValue.u.key)
|
NS_IMPL_GETSET(nsMsgSearchValueImpl, MsgKey, nsMsgKey, mValue.u.key)
|
||||||
NS_IMPL_GETSET(nsMsgSearchValueImpl, Age, PRUint32, mValue.u.age)
|
NS_IMPL_GETSET(nsMsgSearchValueImpl, Age, PRInt32, mValue.u.age)
|
||||||
NS_IMPL_GETSET(nsMsgSearchValueImpl, Date, PRTime, mValue.u.date)
|
NS_IMPL_GETSET(nsMsgSearchValueImpl, Date, PRTime, mValue.u.date)
|
||||||
NS_IMPL_GETSET(nsMsgSearchValueImpl, Attrib, nsMsgSearchAttribValue, mValue.attribute)
|
NS_IMPL_GETSET(nsMsgSearchValueImpl, Attrib, nsMsgSearchAttribValue, mValue.attribute)
|
||||||
NS_IMPL_GETSET(nsMsgSearchValueImpl, Label, nsMsgLabelValue, mValue.u.label)
|
NS_IMPL_GETSET(nsMsgSearchValueImpl, Label, nsMsgLabelValue, mValue.u.label)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче