diff --git a/mailnews/base/resources/content/mailWidgets.xml b/mailnews/base/resources/content/mailWidgets.xml index 70d030f84684..66fcb187aa93 100644 --- a/mailnews/base/resources/content/mailWidgets.xml +++ b/mailnews/base/resources/content/mailWidgets.xml @@ -655,7 +655,7 @@ @@ -706,6 +706,11 @@ + + + + + null @@ -797,6 +802,9 @@ else if (val == Components.interfaces.nsMsgSearchAttrib.JunkStatus) { this.setAttribute("selectedIndex", "6"); } + else if (val == Components.interfaces.nsMsgSearchAttrib.HasAttachmentStatus) { + this.setAttribute("selectedIndex", "7"); + } else { // a normal text field this.setAttribute("selectedIndex", "0"); @@ -853,6 +861,12 @@ if (junkStatus.length > 0) children[6].selectedItem = junkStatus[0]; } + else if (attrib == nsMsgSearchAttrib.HasAttachmentStatus) { + var hasAttachmentStatus = + children[7].getElementsByAttribute("value", val.hasAttachmentStatus); + if (hasAttachmentStatus.length > 0) + children[7].selectedItem = hasAttachmentStatus[0]; + } else children[0].value = val.str; return val; @@ -872,7 +886,7 @@ searchValue.priority = children[1].selectedItem.value; } else if (searchAttribute == nsMsgSearchAttrib.MsgStatus) - searchValue.status = children[2].selectedItem.value; + searchValue.status = children[2].value; else if (searchAttribute == nsMsgSearchAttrib.AgeInDays) searchValue.age = children[0].value; else if (searchAttribute == nsMsgSearchAttrib.Date) @@ -890,6 +904,8 @@ searchValue.junkStatus = children[6].value; else if (searchAttribute == nsMsgSearchAttrib.Size) searchValue.size = children[0].value; + else if (searchAttribute == nsMsgSearchAttrib.HasAttachmentStatus) + searchValue.status = 0x10000000; // 0x10000000 is MSG_FLAG_ATTACHMENT; else searchValue.str = children[0].value; ]]> @@ -976,6 +992,8 @@ // initialize the junk status picker this.initialize(document.getAnonymousNodes(this)[6], bundle); + // initialize the has attachment status picker + this.initialize(document.getAnonymousNodes(this)[7], bundle); ]]> diff --git a/mailnews/base/resources/locale/en-US/messenger.properties b/mailnews/base/resources/locale/en-US/messenger.properties index a6097bed44e1..94fd7695b638 100644 --- a/mailnews/base/resources/locale/en-US/messenger.properties +++ b/mailnews/base/resources/locale/en-US/messenger.properties @@ -183,6 +183,8 @@ unknown=Unknown junk=Junk notjunk=Not Junk +hasAttachments=Has Attachments + # mailnews.js mailnews.send_default_charset=ISO-8859-1 mailnews.view_default_charset=ISO-8859-1 diff --git a/mailnews/base/search/public/nsMsgSearchCore.idl b/mailnews/base/search/public/nsMsgSearchCore.idl index d83a1d20b42b..cc56f92f47c1 100644 --- a/mailnews/base/search/public/nsMsgSearchCore.idl +++ b/mailnews/base/search/public/nsMsgSearchCore.idl @@ -102,8 +102,8 @@ interface nsMsgSearchAttrib { const nsMsgSearchAttribValue Department = 30; const nsMsgSearchAttribValue AdditionalEmail = 31; - // 32 - 46, reserved for ab / LDAP; - + // 32 - 45, reserved for ab / LDAP; + const nsMsgSearchAttribValue HasAttachmentStatus = 46; const nsMsgSearchAttribValue JunkStatus = 47; 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. @@ -211,7 +211,8 @@ typedef struct nsMsgSearchValue _a == nsMsgSearchAttrib::MsgStatus || _a == nsMsgSearchAttrib::MessageKey || \ _a == nsMsgSearchAttrib::Size || _a == nsMsgSearchAttrib::AgeInDays || \ _a == nsMsgSearchAttrib::FolderInfo || _a == nsMsgSearchAttrib::Location || \ - _a == nsMsgSearchAttrib::Label || _a == nsMsgSearchAttrib::JunkStatus)) + _a == nsMsgSearchAttrib::Label || _a == nsMsgSearchAttrib::JunkStatus || \ + _a == nsMsgSearchAttrib::HasAttachmentStatus)) %} [ptr] native nsSearchMenuItem(nsSearchMenuItem); diff --git a/mailnews/base/search/resources/locale/en-US/search-attributes.properties b/mailnews/base/search/resources/locale/en-US/search-attributes.properties index 10800491397d..f3c698742209 100644 --- a/mailnews/base/search/resources/locale/en-US/search-attributes.properties +++ b/mailnews/base/search/resources/locale/en-US/search-attributes.properties @@ -47,7 +47,7 @@ 43=reserved for AB 44=reserved for AB 45=reserved for AB -46=reserved for AB +46=Attachment Status 47=Junk Status 48=Label # don't use above 49 diff --git a/mailnews/base/search/src/nsMsgImapSearch.cpp b/mailnews/base/search/src/nsMsgImapSearch.cpp index 8901f17f829d..048a79e4d742 100644 --- a/mailnews/base/search/src/nsMsgImapSearch.cpp +++ b/mailnews/base/search/src/nsMsgImapSearch.cpp @@ -171,7 +171,6 @@ nsresult nsMsgSearchOnlineMail::Encode (nsCString& pEncoding, return err; } -#define READY_TO_FORK_AND_SPAM_IS_ENABLED 1 nsresult nsMsgSearchValidityManager::InitOfflineMailTable () { @@ -290,14 +289,15 @@ nsresult nsMsgSearchValidityManager::InitOfflineMailTable () m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::AgeInDays, nsMsgSearchOp::Is, 1); m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::AgeInDays, nsMsgSearchOp::Is, 1); - // don't enable this until we are ready to fork rules.dat - // and the bayesian junk filter has landed -#ifdef READY_TO_FORK_AND_SPAM_IS_ENABLED m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::JunkStatus, nsMsgSearchOp::Is, 1); m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::JunkStatus, nsMsgSearchOp::Is, 1); m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::JunkStatus, nsMsgSearchOp::Isnt, 1); m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::JunkStatus, nsMsgSearchOp::Isnt, 1); -#endif + + m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::HasAttachmentStatus, nsMsgSearchOp::Is, 1); + m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::HasAttachmentStatus, nsMsgSearchOp::Is, 1); + m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::HasAttachmentStatus, nsMsgSearchOp::Isnt, 1); + m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::HasAttachmentStatus, nsMsgSearchOp::Isnt, 1); m_offlineMailTable->SetAvailable (nsMsgSearchAttrib::OtherHeader, nsMsgSearchOp::Contains, 1); m_offlineMailTable->SetEnabled (nsMsgSearchAttrib::OtherHeader, nsMsgSearchOp::Contains, 1); diff --git a/mailnews/base/search/src/nsMsgLocalSearch.cpp b/mailnews/base/search/src/nsMsgLocalSearch.cpp index 323ad5d53dd6..40ffd110370d 100644 --- a/mailnews/base/search/src/nsMsgLocalSearch.cpp +++ b/mailnews/base/search/src/nsMsgLocalSearch.cpp @@ -541,6 +541,7 @@ nsresult nsMsgSearchOfflineMail::ProcessSearchTerm(nsIMsgDBHdr *msgToMatch, break; } + case nsMsgSearchAttrib::HasAttachmentStatus: case nsMsgSearchAttrib::MsgStatus: err = aTerm->MatchStatus (msgFlags, &result); break; diff --git a/mailnews/base/search/src/nsMsgSearchTerm.cpp b/mailnews/base/search/src/nsMsgSearchTerm.cpp index 8442c9c19cca..5ba6e55cd1b4 100644 --- a/mailnews/base/search/src/nsMsgSearchTerm.cpp +++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp @@ -99,6 +99,7 @@ nsMsgSearchAttribEntry SearchAttribEntryTable[] = // the old style. see bug #179803 {nsMsgSearchAttrib::Sender, "from in ab"}, {nsMsgSearchAttrib::JunkStatus, "junk status"}, + {nsMsgSearchAttrib::HasAttachmentStatus, "has attachment status"}, }; // Take a string which starts off with an attribute @@ -184,7 +185,6 @@ nsresult NS_MsgGetStringForAttribute(PRInt16 attrib, const char **string) } // we no longer return invalid attribute. If we cannot find the string in the table, // then it is an arbitrary header. Return success regardless if found or not -// return (found) ? SearchError_Success : SearchError_InvalidAttribute; return NS_OK; } @@ -458,6 +458,11 @@ nsresult nsMsgSearchTerm::OutputValue(nsCString &outputStr) outputStr.AppendWithConversion(priority); break; } + case nsMsgSearchAttrib::HasAttachmentStatus: + { + outputStr.Append("true"); // don't need anything here, really + break; + } default: NS_ASSERTION(PR_FALSE, "trying to output invalid attribute"); break; @@ -543,6 +548,9 @@ nsresult nsMsgSearchTerm::ParseValue(char *inStream) case nsMsgSearchAttrib::JunkStatus: m_value.u.junkStatus = atoi(inStream); // only if we read from disk, right? break; + case nsMsgSearchAttrib::HasAttachmentStatus: + m_value.u.msgStatus = MSG_FLAG_ATTACHMENT; + break; // this should always be true. default: NS_ASSERTION(PR_FALSE, "invalid attribute parsing search term value"); break; @@ -1301,7 +1309,7 @@ nsresult nsMsgSearchTerm::MatchStatus(PRUint32 statusToMatch, PRBool *pResult) break; default: rv = NS_ERROR_FAILURE; - NS_ASSERTION(PR_FALSE, "invalid compare op for msg status"); + NS_ERROR("invalid compare op for msg status"); } *pResult = matches; @@ -1572,6 +1580,7 @@ nsresult nsMsgResultElement::AssignValues (nsIMsgSearchValue *src, nsMsgSearchVa case nsMsgSearchAttrib::Date: err = src->GetDate(&dst->u.date); break; + case nsMsgSearchAttrib::HasAttachmentStatus: case nsMsgSearchAttrib::MsgStatus: err = src->GetStatus(&dst->u.msgStatus); break; diff --git a/mailnews/extensions/mailviews/resources/content/mailViews.dat b/mailnews/extensions/mailviews/resources/content/mailViews.dat index 44fd829b5e04..8565d0061230 100644 --- a/mailnews/extensions/mailviews/resources/content/mailViews.dat +++ b/mailnews/extensions/mailviews/resources/content/mailViews.dat @@ -16,3 +16,7 @@ name="Not Junk" enabled="yes" type="1" condition="AND (junk status,isn't,2)" +name="Has Attachments" +enabled="yes" +type="1" +condition="AND (has attachment status,is,true)"