mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 06:45:42 +00:00
add new API to search for filters by name
This commit is contained in:
parent
aca30a0c1c
commit
e5206c1545
@ -56,6 +56,7 @@ interface nsIMsgFilterList : nsISupports {
|
||||
|
||||
readonly attribute unsigned long filterCount;
|
||||
nsIMsgFilter GetFilterAt(in unsigned long filterIndex);
|
||||
nsIMsgFilter getFilterNamed(in wstring filterName);
|
||||
/* these methods don't delete filters - they just change the list.
|
||||
* FE still must
|
||||
* call MSG_DestroyFilter to delete a filter.
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "nsFileStream.h"
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsMsgSearchTerm.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
// unicode "%s" format string
|
||||
static const PRUnichar unicodeFormatter[] = {
|
||||
@ -723,6 +724,36 @@ nsresult nsMsgFilterList::GetFilterAt(PRUint32 filterIndex, nsIMsgFilter **filte
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgFilterList::GetFilterNamed(const PRUnichar *aName, nsIMsgFilter **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
PRUint32 count=0;
|
||||
m_filters->Count(&count);
|
||||
|
||||
*aResult = nsnull;
|
||||
PRUint32 i;
|
||||
for (i=0; i<count; i++) {
|
||||
nsCOMPtr<nsISupports> filterSupports;
|
||||
rv = m_filters->GetElementAt(i, getter_AddRefs(filterSupports));
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
// cast is safe because array is private
|
||||
nsIMsgFilter *filter = (nsIMsgFilter *)filterSupports.get();
|
||||
nsXPIDLString filterName;
|
||||
filter->GetFilterName(getter_Copies(filterName));
|
||||
if (nsCRT::strcmp(filterName, aName) == 0) {
|
||||
*aResult = filter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgFilterList::SetFilterAt(PRUint32 filterIndex, nsIMsgFilter *filter)
|
||||
{
|
||||
m_filters->ReplaceElementAt(filter, filterIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user