Make LDAP autocompletion respect UI setting for maximum number of hits to return (bug 77388). r=leif@netscape.com, sr=mscott@netscape.com, a=blizzard@mozilla.org

This commit is contained in:
dmose%netscape.com 2005-11-15 20:08:37 +00:00
Родитель d15126d398
Коммит 3918d68b81
3 изменённых файлов: 24 добавлений и 14 удалений

Просмотреть файл

@ -61,13 +61,19 @@ interface nsILDAPAutoCompleteSession : nsIAutoCompleteSession {
attribute wstring outputFormat;
/**
* If non-zero, limit lookups to at most this many entries. If this
* limit is hit during a lookup, the search will simply return
* |nsIAutoCompleteStatus::ignored|.
* At most this many nsIAutoCompleteItems will be returned. This
* is useful for keeping bandwidth usage over slow-speed
* connections as well as ensuring that the number of choices
* offered in the UI is manageble.
*
* @exception NS_ERROR_NULL_POINTER NULL pointer passed to getter
* 1-65535 are interpreted literally
* 0 means "unlimited"
* -1 uses the default limit for the LDAP connection in use
*
* @exception NS_ERROR_NULL_POINTER NULL pointer passed to getter
* @exception NS_ERROR_ILLEGAL_VALUE Out-of-range value passed to setter
*/
attribute long sizeLimit;
attribute long maxHits;
/**
* Strings shorter than this will return |nsIAutoCompleteStatus::ignored|

Просмотреть файл

@ -48,7 +48,7 @@ NS_IMPL_ISUPPORTS3(nsLDAPAutoCompleteSession, nsIAutoCompleteSession,
nsILDAPMessageListener, nsILDAPAutoCompleteSession)
nsLDAPAutoCompleteSession::nsLDAPAutoCompleteSession() :
mState(UNBOUND), mMinStringLength(0)
mState(UNBOUND), mMaxHits(100), mMinStringLength(0)
{
NS_INIT_ISUPPORTS();
}
@ -918,7 +918,7 @@ nsLDAPAutoCompleteSession::StartLDAPSearch()
//
rv = mOperation->SearchExt(NS_ConvertUTF8toUCS2(dn).get(), scope,
NS_ConvertUTF8toUCS2(searchFilter).get(),
0, nsILDAPOperation::NO_LIMIT);
0, mMaxHits);
if (NS_FAILED(rv)) {
switch(rv) {
@ -1196,21 +1196,25 @@ nsLDAPAutoCompleteSession::SetOutputFormat(const PRUnichar * aOutputFormat)
return NS_OK;
}
// attribute long sizeLimit;
// attribute long maxHits;
NS_IMETHODIMP
nsLDAPAutoCompleteSession::GetSizeLimit(PRInt32 *aSizeLimit)
nsLDAPAutoCompleteSession::GetMaxHits(PRInt32 *aMaxHits)
{
if (!aSizeLimit) {
if (!aMaxHits) {
return NS_ERROR_NULL_POINTER;
}
*aSizeLimit = mSizeLimit;
*aMaxHits = mMaxHits;
return NS_OK;
}
NS_IMETHODIMP
nsLDAPAutoCompleteSession::SetSizeLimit(PRInt32 aSizeLimit)
nsLDAPAutoCompleteSession::SetMaxHits(PRInt32 aMaxHits)
{
mSizeLimit = aSizeLimit;
if ( aMaxHits < -1 || aMaxHits > 65535) {
return NS_ERROR_ILLEGAL_VALUE;
}
mMaxHits = aMaxHits;
return NS_OK;
}

Просмотреть файл

@ -61,7 +61,7 @@ class nsLDAPAutoCompleteSession : public nsILDAPMessageListener,
nsString mFilterTemplate; // search filter template
nsString mOutputFormat; // how to format output
nsCOMPtr<nsILDAPURL> mServerURL; // URL for the directory to search
PRInt32 mSizeLimit; // return at most this many entries
PRInt32 mMaxHits; // return at most this many entries
PRUint32 mMinStringLength; // strings < this size are ignored
// stopgap until nsLDAPService works