Index: MQuery.cxx =================================================================== RCS file: /cvs/dba/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx,v retrieving revision 1.8 diff -u -r1.8 MQuery.cxx --- MQuery.cxx 26 Sep 2002 10:03:26 -0000 1.8 +++ MQuery.cxx 10 Oct 2002 10:17:00 -0000 @@ -423,6 +423,44 @@ OSL_TRACE("Not using a Query Proxy, Query i/f supported by directory\n"); #endif /* DEBUG */ + /* + // The problem here is that an LDAP Address Book may exist as + // a Mozilla Address Book. So we need to limit the number of + // records returned by the Server: + // 1. Determine if this is an LDAP Address Book + // [LDAP overrides the default operations(write|read|search) of all types with search only]. + // 2. Determine if the limit is already set by us. + // 3. Use the mozilla preferences to see if this value is set. + // 4. Use value or else default to 100. + */ + PRBool isWriteable; + rv = directory->GetOperations (&isWriteable); + NS_ENSURE_SUCCESS(rv, rv); + if (!(isWriteable & nsIAbDirectory::opWrite)) + { + if(m_nMaxNrOfReturns == -1) + { + // Determine if the limit maxHits has been set in the mozilla preferences + // if set, then use the value otherwise default to 100 + nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + // create the ldap maxHits entry for the preferences file. + // Note: maxHits is applicable to LDAP only in mozilla. + nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers.")); + const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(m_aAddressbook); + prefName.Append(pAddressBook); + prefName.Append(NS_LITERAL_CSTRING(".maxHits")); + + PRInt32 maxHits; + rv = prefs->GetIntPref(prefName.get(), &maxHits); + if (NS_FAILED(rv)) + m_nMaxNrOfReturns = 100; + else + m_nMaxNrOfReturns = maxHits; + } + } + nsCOMPtr< nsIAbBooleanExpression > queryExpression = do_CreateInstance( kBooleanExpressionCID , &rv); NS_ENSURE_SUCCESS( rv, rv ); rv = generateExpression( this, &m_aExpr, queryExpression );