View | Details | Raw Unified | Return to issue 8148
Collapse All | Expand All

(-)MQuery.cxx (+38 lines)
Lines 423-428 Link Here
423
        OSL_TRACE("Not using a Query Proxy, Query i/f supported by directory\n");
423
        OSL_TRACE("Not using a Query Proxy, Query i/f supported by directory\n");
424
#endif /* DEBUG */
424
#endif /* DEBUG */
425
425
426
    /*
427
    // The problem here is that an LDAP Address Book may exist as 
428
    // a Mozilla Address Book. So we need to limit the number of
429
    // records returned by the Server:
430
    // 1. Determine if this is an LDAP Address Book 
431
    // [LDAP overrides the default operations(write|read|search) of all types with search only].
432
    // 2. Determine if the limit is already set by us.
433
    // 3. Use the mozilla preferences to see if this value is set.
434
    // 4. Use value or else default to 100.
435
    */
436
    PRBool isWriteable;
437
    rv = directory->GetOperations (&isWriteable);
438
    NS_ENSURE_SUCCESS(rv, rv);
439
    if (!(isWriteable & nsIAbDirectory::opWrite))
440
    {
441
        if(m_nMaxNrOfReturns == -1)
442
        {
443
            // Determine if the limit maxHits has been set in the mozilla preferences
444
            // if set, then use the value otherwise default to 100
445
            nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv); 
446
            NS_ENSURE_SUCCESS(rv, rv);
447
448
            // create the ldap maxHits entry for the preferences file.
449
            // Note: maxHits is applicable to LDAP only in mozilla.
450
            nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers."));
451
            const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(m_aAddressbook);
452
            prefName.Append(pAddressBook);
453
            prefName.Append(NS_LITERAL_CSTRING(".maxHits"));
454
455
           PRInt32 maxHits;
456
           rv = prefs->GetIntPref(prefName.get(), &maxHits);
457
           if (NS_FAILED(rv))
458
               m_nMaxNrOfReturns = 100;
459
           else
460
               m_nMaxNrOfReturns = maxHits;
461
        }
462
    }
463
426
    nsCOMPtr< nsIAbBooleanExpression > queryExpression = do_CreateInstance( kBooleanExpressionCID , &rv);
464
    nsCOMPtr< nsIAbBooleanExpression > queryExpression = do_CreateInstance( kBooleanExpressionCID , &rv);
427
    NS_ENSURE_SUCCESS( rv, rv );
465
    NS_ENSURE_SUCCESS( rv, rv );
428
    rv = generateExpression( this, &m_aExpr, queryExpression );
466
    rv = generateExpression( this, &m_aExpr, queryExpression );

Return to issue 8148