зеркало из https://github.com/mozilla/pjs.git
fix for #132225. local addressbook searches return (bogus) duplicate results if you have mailing lists.
r=racham, sr=bienvenu, a=asa
This commit is contained in:
Родитель
1769c7a05e
Коммит
24a8669d1b
|
@ -134,7 +134,7 @@ NS_IMETHODIMP nsAbDirectoryQuerySimpleBooleanExpression::AgetExpressions(PRUint3
|
|||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbDirectoryQueryArguments, nsIAbDirectoryQueryArguments)
|
||||
|
||||
nsAbDirectoryQueryArguments::nsAbDirectoryQueryArguments() :
|
||||
mQuerySubDirectories (PR_TRUE)
|
||||
mQuerySubDirectories(PR_TRUE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
@ -162,18 +162,14 @@ NS_IMETHODIMP nsAbDirectoryQueryArguments::SetExpression(nsISupports* aExpressio
|
|||
/* attribute boolean querySubDirectories; */
|
||||
NS_IMETHODIMP nsAbDirectoryQueryArguments::GetQuerySubDirectories(PRBool* aQuerySubDirectories)
|
||||
{
|
||||
if (!aQuerySubDirectories)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aQuerySubDirectories);
|
||||
*aQuerySubDirectories = mQuerySubDirectories;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirectoryQueryArguments::SetQuerySubDirectories(PRBool aQuerySubDirectories)
|
||||
{
|
||||
mQuerySubDirectories = aQuerySubDirectories;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -183,7 +179,7 @@ NS_IMETHODIMP nsAbDirectoryQueryArguments::SetReturnProperties(PRUint32 returnPr
|
|||
const char** returnPropertiesArray)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = CharPtrArrayToCStringArray::Convert (mReturnProperties,
|
||||
rv = CharPtrArrayToCStringArray::Convert(mReturnProperties,
|
||||
returnPropertiesSize,
|
||||
returnPropertiesArray);
|
||||
|
||||
|
@ -387,9 +383,8 @@ nsresult nsAbDirectoryQuery::query (nsIAbDirectory* directory,
|
|||
|
||||
PRBool doSubDirectories;
|
||||
arguments->GetQuerySubDirectories (&doSubDirectories);
|
||||
if (doSubDirectories == PR_TRUE && *resultLimit != 0)
|
||||
{
|
||||
rv = queryChildren (directory, arguments, listener, resultLimit);
|
||||
if (doSubDirectories && *resultLimit != 0) {
|
||||
rv = queryChildren(directory, arguments, listener, resultLimit);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -407,7 +402,7 @@ nsresult nsAbDirectoryQuery::queryChildren (nsIAbDirectory* directory,
|
|||
rv = directory->GetChildNodes(getter_AddRefs(subDirectories));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = subDirectories->First ();
|
||||
rv = subDirectories->First();
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
|
@ -423,7 +418,7 @@ nsresult nsAbDirectoryQuery::queryChildren (nsIAbDirectory* directory,
|
|||
rv = query (subDirectory, arguments, listener, resultLimit);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = subDirectories->Next ();
|
||||
rv = subDirectories->Next();
|
||||
}
|
||||
while (rv == NS_OK);
|
||||
|
||||
|
@ -450,14 +445,14 @@ nsresult nsAbDirectoryQuery::queryCards (nsIAbDirectory* directory,
|
|||
if (!cards)
|
||||
return NS_OK;
|
||||
|
||||
rv = cards->First ();
|
||||
rv = cards->First();
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
do
|
||||
{
|
||||
nsCOMPtr<nsISupports> item;
|
||||
rv = cards->CurrentItem (getter_AddRefs (item));
|
||||
rv = cards->CurrentItem(getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(item, &rv));
|
||||
|
|
|
@ -408,7 +408,7 @@ NS_IMETHODIMP nsAbMDBDirectory::GetChildCards(nsIEnumerator* *result)
|
|||
if (mIsQueryURI)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = StartSearch ();
|
||||
rv = StartSearch();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// TODO
|
||||
|
@ -416,7 +416,7 @@ NS_IMETHODIMP nsAbMDBDirectory::GetChildCards(nsIEnumerator* *result)
|
|||
// results after search is complete
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
NS_NewISupportsArray(getter_AddRefs(array));
|
||||
mSearchCache.Enumerate (enumerateSearchCache, (void* )array);
|
||||
mSearchCache.Enumerate(enumerateSearchCache, (void*)array);
|
||||
return array->Enumerate(result);
|
||||
}
|
||||
|
||||
|
@ -912,31 +912,36 @@ NS_IMETHODIMP nsAbMDBDirectory::StartSearch()
|
|||
nsresult rv;
|
||||
|
||||
mPerformingQuery = PR_TRUE;
|
||||
mSearchCache.Reset ();
|
||||
mSearchCache.Reset();
|
||||
|
||||
nsCOMPtr<nsIAbDirectoryQueryArguments> arguments = do_CreateInstance(NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbBooleanExpression> expression;
|
||||
rv = nsAbQueryStringToExpression::Convert (mQueryString.get (),
|
||||
rv = nsAbQueryStringToExpression::Convert(mQueryString.get(),
|
||||
getter_AddRefs(expression));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = arguments->SetExpression (expression);
|
||||
rv = arguments->SetExpression(expression);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set the return properties to
|
||||
// return nsIAbCard interfaces
|
||||
nsCStringArray properties;
|
||||
properties.AppendCString (nsCAutoString ("card:nsIAbCard"));
|
||||
CharPtrArrayGuard returnProperties (PR_FALSE);
|
||||
rv = CStringArrayToCharPtrArray::Convert (properties,returnProperties.GetSizeAddr(),
|
||||
properties.AppendCString(nsCAutoString("card:nsIAbCard"));
|
||||
CharPtrArrayGuard returnProperties(PR_FALSE);
|
||||
rv = CStringArrayToCharPtrArray::Convert(properties,returnProperties.GetSizeAddr(),
|
||||
returnProperties.GetArrayAddr(), PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = arguments->SetReturnProperties (returnProperties.GetSize(), returnProperties.GetArray());
|
||||
rv = arguments->SetReturnProperties(returnProperties.GetSize(), returnProperties.GetArray());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = arguments->SetQuerySubDirectories (PR_TRUE);
|
||||
// don't search the subdirectories
|
||||
// if the current directory is a mailing list, it won't have any subdirectories
|
||||
// if the current directory is a addressbook, searching both it
|
||||
// and the subdirectories (the mailing lists), will yield duplicate results
|
||||
// because every entry in a mailing list will be an entry in the parent addressbook
|
||||
rv = arguments->SetQuerySubDirectories(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set the the query listener
|
||||
|
@ -945,24 +950,23 @@ NS_IMETHODIMP nsAbMDBDirectory::StartSearch()
|
|||
new nsAbDirSearchListener (this);
|
||||
queryListener = _queryListener;
|
||||
|
||||
|
||||
// Get the directory without the query
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = gRDFService->GetResource (mURINoQuery.get (), getter_AddRefs (resource));
|
||||
rv = gRDFService->GetResource (mURINoQuery.get(), getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbDirectory> directory (do_QueryInterface(resource, &rv));
|
||||
nsCOMPtr<nsIAbDirectory> directory(do_QueryInterface(resource, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Initiate the proxy query with the no query directory
|
||||
nsCOMPtr<nsIAbDirectoryQueryProxy> queryProxy =
|
||||
do_CreateInstance (NS_ABDIRECTORYQUERYPROXY_CONTRACTID, &rv);
|
||||
do_CreateInstance(NS_ABDIRECTORYQUERYPROXY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = queryProxy->Initiate (directory);
|
||||
rv = queryProxy->Initiate(directory);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = queryProxy->DoQuery (arguments, queryListener, -1, 0, &mContext);
|
||||
rv = queryProxy->DoQuery(arguments, queryListener, -1, 0, &mContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче