nsCOMPtr<nsISupportsArray>	cmdArray; nsresult			rv; rv = NS_NewISupportsArray(getter_AddRefs(cmdArray)); if (NS_FAILED(rv))	return(rv);   PRBool				haveFilters = PR_FALSE;  if (mLocalstore) { nsCOMPtr<nsISimpleEnumerator>	cursor; PRBool				hasMore = PR_FALSE;   if (NS_SUCCEEDED(rv = mLocalstore->GetTargets(kNC_FilterSearchURLsRoot, kNC_Child, PR_TRUE, getter_AddRefs(cursor)))) { if (NS_SUCCEEDED(cursor->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE)) { haveFilters = PR_TRUE; } } if (haveFilters == PR_FALSE) {  if (NS_SUCCEEDED(rv = mLocalstore->GetTargets(kNC_FilterSearchSitesRoot, kNC_Child, PR_TRUE, getter_AddRefs(cursor)))) { if (NS_SUCCEEDED(cursor->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE)) { haveFilters = PR_TRUE; } } } }  PRBool				isSearchResult = PR_FALSE; if (NS_SUCCEEDED(rv = mInner->HasAssertion(source, kRDF_type, kNC_SearchResult, PR_TRUE, &isSearchResult)) && (isSearchResult == PR_TRUE)) { nsCOMPtr<nsIRDFDataSource>	datasource; if (NS_SUCCEEDED(rv = gRDFService->GetDataSource("rdf:bookmarks", getter_AddRefs(datasource)))) { nsCOMPtr<nsIBookmarksService> bookmarks (do_QueryInterface(datasource)); if (bookmarks) { char *uri = getSearchURI(source); if (uri) { PRBool	isBookmarkedFlag = PR_FALSE; if (NS_SUCCEEDED(rv = bookmarks->IsBookmarked(uri, &isBookmarkedFlag)) && (isBookmarkedFlag == PR_FALSE)) { cmdArray->AppendElement(kNC_SearchCommand_AddToBookmarks); cmdArray->AppendElement(kNC_BookmarkSeparator); } Recycle(uri); } } }   PRBool				isURLFiltered = PR_FALSE; if (NS_SUCCEEDED(rv = mInner->HasAssertion(kNC_FilterSearchURLsRoot, kNC_Child, source, PR_TRUE, &isURLFiltered)) && (isURLFiltered != PR_TRUE)) { cmdArray->AppendElement(kNC_SearchCommand_FilterResult); }    cmdArray->AppendElement(kNC_SearchCommand_FilterSite);  if (haveFilters == PR_TRUE) { cmdArray->AppendElement(kNC_BookmarkSeparator); cmdArray->AppendElement(kNC_SearchCommand_ClearFilters); } } else if (isSearchURI(source) || (source == kNC_LastSearchRoot)) { if (haveFilters == PR_TRUE) { cmdArray->AppendElement(kNC_SearchCommand_ClearFilters); } }   cmdArray->AppendElement(kNC_BookmarkSeparator);  nsISimpleEnumerator		*result = new nsArrayEnumerator(cmdArray); if (!result) return(NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(result); *commands = result; return(NS_OK);
return(NS_NewEmptyEnumerator(commands));
InternetSearchDataSource::GetAllCmds(nsIRDFResource* source,                                     nsISimpleEnumerator/*<nsIRDFResource>*/** commands){	nsCOMPtr<nsISupportsArray>	cmdArray;	nsresult			rv;	rv = NS_NewISupportsArray(getter_AddRefs(cmdArray));	if (NS_FAILED(rv))	return(rv);	// check if we have any filters, enable command to clear them	PRBool				haveFilters = PR_FALSE;	if (mLocalstore)	{		nsCOMPtr<nsISimpleEnumerator>	cursor;		PRBool				hasMore = PR_FALSE;		// check kNC_FilterSearchURLsRoot		if (NS_SUCCEEDED(rv = mLocalstore->GetTargets(kNC_FilterSearchURLsRoot, kNC_Child,			PR_TRUE, getter_AddRefs(cursor))))		{			if (NS_SUCCEEDED(cursor->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE))			{				haveFilters = PR_TRUE;			}		}		if (haveFilters == PR_FALSE)		{			// check kNC_FilterSearchSitesRoot			if (NS_SUCCEEDED(rv = mLocalstore->GetTargets(kNC_FilterSearchSitesRoot, kNC_Child,				PR_TRUE, getter_AddRefs(cursor))))			{				if (NS_SUCCEEDED(cursor->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE))				{					haveFilters = PR_TRUE;				}			}		}	}	PRBool				isSearchResult = PR_FALSE;	if (NS_SUCCEEDED(rv = mInner->HasAssertion(source, kRDF_type, kNC_SearchResult,		PR_TRUE, &isSearchResult)) && (isSearchResult == PR_TRUE))	{		nsCOMPtr<nsIRDFDataSource>	datasource;		if (NS_SUCCEEDED(rv = gRDFService->GetDataSource("rdf:bookmarks", getter_AddRefs(datasource))))		{			nsCOMPtr<nsIBookmarksService> bookmarks (do_QueryInterface(datasource));			if (bookmarks)			{				char *uri = getSearchURI(source);				if (uri)				{					PRBool	isBookmarkedFlag = PR_FALSE;					if (NS_SUCCEEDED(rv = bookmarks->IsBookmarked(uri, &isBookmarkedFlag))						&& (isBookmarkedFlag == PR_FALSE))					{						cmdArray->AppendElement(kNC_SearchCommand_AddToBookmarks);						cmdArray->AppendElement(kNC_BookmarkSeparator);					}					Recycle(uri);				}			}		}		// if this is a search result, and it isn't filtered, enable command to be able to filter it		PRBool				isURLFiltered = PR_FALSE;		if (NS_SUCCEEDED(rv = mInner->HasAssertion(kNC_FilterSearchURLsRoot, kNC_Child, source,			PR_TRUE, &isURLFiltered)) && (isURLFiltered != PR_TRUE))		{			cmdArray->AppendElement(kNC_SearchCommand_FilterResult);		}		// XXX (should check site) if this is a search result site, and the site isn't filtered,		//     enable command to filter it		cmdArray->AppendElement(kNC_SearchCommand_FilterSite);		if (haveFilters == PR_TRUE)		{			cmdArray->AppendElement(kNC_BookmarkSeparator);			cmdArray->AppendElement(kNC_SearchCommand_ClearFilters);		}	}	else if (isSearchURI(source) || (source == kNC_LastSearchRoot))	{		if (haveFilters == PR_TRUE)		{			cmdArray->AppendElement(kNC_SearchCommand_ClearFilters);		}	}	// always append a separator last (due to aggregation of commands from multiple datasources)	cmdArray->AppendElement(kNC_BookmarkSeparator);	nsISimpleEnumerator		*result = new nsArrayEnumerator(cmdArray);	if (!result)		return(NS_ERROR_OUT_OF_MEMORY);	NS_ADDREF(result);	*commands = result;	return(NS_OK);}