The nsIMsgSearchSession interface allows you to create and manipulate search sessions within Thunderbird.
To create an instance, use:
var searchSession = Components.classes["@mozilla.org/messenger/searchSession;1"]
.createInstance(Components.interfaces.nsIMsgSearchSession);
To use the instance append search terms, set the scope, and then call search().
searchSession.addScopeTerm(Components.interfaces.nsMsgSearchScope.offlineMail, aFolder); var searchTerm = searchSession.createTerm(); var value = searchTerm.value; value.str = aValue; searchTerm.value = value; searchTerm.op = searchSession.BooleanOR; searchTerm.booleanAnd = false; searchSession.appendTerm(searchTerm); searchSession.search(null);
Inherits from: nsISupports
| Attribute | Type | Description |
searchTerms |
nsISupportsArray |
Readonly: |
numSearchTerms |
unsigned long | Readonly: |
runningAdapter |
nsIMsgSearchAdapter |
Readonly: |
searchParam |
voidPtr | Not scriptable and readonly: |
searchType |
nsMsgSearchType |
Readonly: |
numResults |
long | Readonly: |
window |
nsIMsgWindow |
| Name | Value | Description |
BooleanOR |
0 | |
BooleanAND |
1 |
void addSearchTerm(in nsMsgSearchAttribValue attrib,
in nsMsgSearchOpValue op,
in nsIMsgSearchValue value,
in boolean BooleanAND,
in string arbitraryHeader);
attribopvalueBooleanANDtrue if associated boolean operator is AND.arbitraryHeaderattrib = attribOtherHeader.nsIMsgSearchTerm createTerm();
void appendTerm(in nsIMsgSearchTerm term);
termAdds a listener to the search session.
void registerListener(in nsIMsgSearchNotify listener);
listenerRemoves a listener from the search session.
void unregisterListener (in nsIMsgSearchNotify listener);
listener void getNthSearchTerm(in long whichTerm,
in nsMsgSearchAttribValue attrib,
in nsMsgSearchOpValue op,
in nsIMsgSearchValue value);
whichTermattribopvalueout.long countSearchScopes();
void getNthSearchScope(in long which,
out nsMsgSearchScopeValue scopeId,
out nsIMsgFolder folder);
whichscopeIdfolderAdd a scope (e.g. a mail folder) to the search.
void addScopeTerm(in nsMsgSearchScopeValue scope,
in nsIMsgFolder folder);
scopefoldervoid addDirectoryScopeTerm(in nsMsgSearchScopeValue scope);
scopevoid clearScopes();
Call this function everytime the scope changes! It informs the FE if the current scope support custom header use. FEs should not display the custom header dialog if custom headers are not supported.
[noscript] boolean ScopeUsesCustomHeaders(in nsMsgSearchScopeValue scope,
in voidPtr selection,
in boolean forFilters);
scopeselectionforFiltersUse this to determine if your attribute is a string attribute.
boolean IsStringAttribute(in nsMsgSearchAttribValue attrib);
attribAdd all scopes of a given type to the search.
void AddAllScopes(in nsMsgSearchScopeValue attrib);
attribvoid search(in nsIMsgWindow aWindow);
aWindowvoid interruptSearch();
These two methods are used when the search session is using a timer to do local search, and the search adapter needs to run a url (e.g., to reparse a local folder) and wants to pause the timer while running the url. This will fail if the current adapter is not using a timer.
void pauseSearch();
void resumeSearch();
[noscript] nsMsgSearchType SetSearchParam(in nsMsgSearchType type,
in voidPtr param);
typeparam[noscript] void AddResultElement(in nsMsgResultElement element);
element boolean MatchHdr(in nsIMsgDBHdr aMsgHdr,
in nsIMsgDatabase aDatabase);
aMsgHdraDatabase void addSearchHit(in nsIMsgDBHdr header,
in nsIMsgFolder folder);
headerfolder