diff --git a/mailnews/addrbook/public/nsILDAPAutoCompleteSession.idl b/mailnews/addrbook/public/nsILDAPAutoCompleteSession.idl index 11068214785e..9f08e91414a0 100644 --- a/mailnews/addrbook/public/nsILDAPAutoCompleteSession.idl +++ b/mailnews/addrbook/public/nsILDAPAutoCompleteSession.idl @@ -44,12 +44,13 @@ interface nsILDAPURL; interface nsILDAPAutoCompFormatter; interface nsIAuthPrompt; +interface nsIMutableArray; /** * Extends nsIAutoCompleteSession to have various LDAP-specific parameters. * and output format. */ -[scriptable, uuid(82b6a78e-1dd2-11b2-a3d0-876e20e7b350)] +[scriptable, uuid(e7f26534-f96c-4c87-803c-30cdf0bc2973)] interface nsILDAPAutoCompleteSession : nsIAutoCompleteSession { /** @@ -138,4 +139,11 @@ interface nsILDAPAutoCompleteSession : nsIAutoCompleteSession { * @exception NS_ERROR_NULL_POINTER null pointer passed to getter */ attribute unsigned long version; + + /** + * If set, these arrays of nsILDAPControls are passed through to the + * nsILDAPOperation that searchExt is called on. + */ + attribute nsIMutableArray searchServerControls; + attribute nsIMutableArray searchClientControls; }; diff --git a/mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp b/mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp index c0be0a35b011..7dd01f5ea9b7 100644 --- a/mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp +++ b/mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp @@ -281,14 +281,14 @@ nsLDAPAutoCompleteSession::OnStopLookup() // Abandon the operation, if there is one // if (mOperation) { - nsresult rv = mOperation->Abandon(); + nsresult rv = mOperation->AbandonExt(); if (NS_FAILED(rv)) { // since there's nothing interesting that can or should be // done if this abandon failed, warn about it and move on // NS_WARNING("nsLDAPAutoCompleteSession::OnStopLookup(): " - "error calling mOperation->Abandon()"); + "error calling mOperation->AbandonExt()"); } // force nsCOMPtr to release mOperation @@ -899,6 +899,28 @@ nsLDAPAutoCompleteSession::StartLDAPSearch() return NS_ERROR_UNEXPECTED; } + // set the server and client controls on the operation + if (mSearchServerControls) { + rv = mOperation->SetServerControls(mSearchServerControls); + if (NS_FAILED(rv)) { + NS_ERROR("nsLDAPAutoCompleteSession::StartLDAPSearch(): couldn't " + "initialize LDAP search operation server controls"); + FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, + BOUND); + return NS_ERROR_UNEXPECTED; + } + } + if (mSearchClientControls) { + rv = mOperation->SetClientControls(mSearchClientControls); + if (NS_FAILED(rv)) { + NS_ERROR("nsLDAPAutoCompleteSession::StartLDAPSearch(): couldn't " + "initialize LDAP search operation client controls"); + FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, + BOUND); + return NS_ERROR_UNEXPECTED; + } + } + // get the search filter associated with the directory server url; // it will be ANDed with the rest of the search filter that we're using. // @@ -1017,13 +1039,31 @@ nsLDAPAutoCompleteSession::StartLDAPSearch() return NS_ERROR_UNEXPECTED; } + // take the relevant controls on this object and set them + // on the operation + rv = mOperation->SetServerControls(mSearchServerControls.get()); + if ( NS_FAILED(rv) ){ + mState = BOUND; + FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, + BOUND); + return NS_ERROR_UNEXPECTED; + } + + rv = mOperation->SetClientControls(mSearchClientControls.get()); + if ( NS_FAILED(rv) ){ + mState = BOUND; + FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, + BOUND); + return NS_ERROR_UNEXPECTED; + } + // time to kick off the search. // // XXXdmose what about timeouts? // rv = mOperation->SearchExt(dn, scope, searchFilter, mSearchAttrsSize, - NS_CONST_CAST(const char **, mSearchAttrs), 0, - mMaxHits); + NS_CONST_CAST(const char **, mSearchAttrs), + 0, mMaxHits); if (NS_FAILED(rv)) { switch(rv) { @@ -1587,4 +1627,32 @@ nsLDAPAutoCompleteSession::SetVersion(PRUint32 aVersion) return NS_OK; } +NS_IMETHODIMP +nsLDAPAutoCompleteSession::GetSearchServerControls(nsIMutableArray **aControls) +{ + NS_IF_ADDREF(*aControls = mSearchServerControls); + return NS_OK; +} + +NS_IMETHODIMP +nsLDAPAutoCompleteSession::SetSearchServerControls(nsIMutableArray *aControls) +{ + mSearchServerControls = aControls; + return NS_OK; +} + +NS_IMETHODIMP +nsLDAPAutoCompleteSession::GetSearchClientControls(nsIMutableArray **aControls) +{ + NS_IF_ADDREF(*aControls = mSearchClientControls); + return NS_OK; +} + +NS_IMETHODIMP +nsLDAPAutoCompleteSession::SetSearchClientControls(nsIMutableArray *aControls) +{ + mSearchClientControls = aControls; + return NS_OK; +} + #endif diff --git a/mailnews/addrbook/src/nsLDAPAutoCompleteSession.h b/mailnews/addrbook/src/nsLDAPAutoCompleteSession.h index f066d6d03e9e..eb5209f66567 100644 --- a/mailnews/addrbook/src/nsLDAPAutoCompleteSession.h +++ b/mailnews/addrbook/src/nsLDAPAutoCompleteSession.h @@ -49,6 +49,7 @@ #include "nsISupportsArray.h" #include "nsIConsoleService.h" #include "nsIAuthPrompt.h" +#include "nsIArray.h" // 964665d0-1dd1-11b2-aeae-897834fb00b9 // @@ -131,5 +132,7 @@ class nsLDAPAutoCompleteSession : public nsILDAPMessageListener, // create and initialize the results array nsresult CreateResultsArray(void); + nsCOMPtr mSearchServerControls; + nsCOMPtr mSearchClientControls; };