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);
attrib
op
value
BooleanAND
true
if associated boolean operator is AND
.arbitraryHeader
attrib = attribOtherHeader
.nsIMsgSearchTerm createTerm();
void appendTerm(in nsIMsgSearchTerm term);
term
Adds a listener to the search session.
void registerListener(in nsIMsgSearchNotify listener);
listener
Removes 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);
whichTerm
attrib
op
value
out
.long countSearchScopes();
void getNthSearchScope(in long which, out nsMsgSearchScopeValue scopeId, out nsIMsgFolder folder);
which
scopeId
folder
Add a scope (e.g. a mail folder) to the search.
void addScopeTerm(in nsMsgSearchScopeValue scope, in nsIMsgFolder folder);
scope
folder
void addDirectoryScopeTerm(in nsMsgSearchScopeValue scope);
scope
void 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);
scope
selection
forFilters
Use this to determine if your attribute is a string attribute.
boolean IsStringAttribute(in nsMsgSearchAttribValue attrib);
attrib
Add all scopes of a given type to the search.
void AddAllScopes(in nsMsgSearchScopeValue attrib);
attrib
void search(in nsIMsgWindow aWindow);
aWindow
void 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);
type
param
[noscript] void AddResultElement(in nsMsgResultElement element);
element
boolean MatchHdr(in nsIMsgDBHdr aMsgHdr, in nsIMsgDatabase aDatabase);
aMsgHdr
aDatabase
void addSearchHit(in nsIMsgDBHdr header, in nsIMsgFolder folder);
header
folder