Add basic support for LDAP controls to the LDAP XPCOM SDK, LDAP autocomplete code, and LDAP addressbook (bug 297131). r=bienvenu, sr=roc, a=bsmedberg

This commit is contained in:
dmose%mozilla.org 2005-11-15 20:09:15 +00:00
Родитель 347fa072ac
Коммит 0adf7691dc
3 изменённых файлов: 84 добавлений и 5 удалений

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

@ -44,12 +44,13 @@
interface nsILDAPURL; interface nsILDAPURL;
interface nsILDAPAutoCompFormatter; interface nsILDAPAutoCompFormatter;
interface nsIAuthPrompt; interface nsIAuthPrompt;
interface nsIMutableArray;
/** /**
* Extends nsIAutoCompleteSession to have various LDAP-specific parameters. * Extends nsIAutoCompleteSession to have various LDAP-specific parameters.
* and output format. * and output format.
*/ */
[scriptable, uuid(82b6a78e-1dd2-11b2-a3d0-876e20e7b350)] [scriptable, uuid(e7f26534-f96c-4c87-803c-30cdf0bc2973)]
interface nsILDAPAutoCompleteSession : nsIAutoCompleteSession { interface nsILDAPAutoCompleteSession : nsIAutoCompleteSession {
/** /**
@ -138,4 +139,11 @@ interface nsILDAPAutoCompleteSession : nsIAutoCompleteSession {
* @exception NS_ERROR_NULL_POINTER null pointer passed to getter * @exception NS_ERROR_NULL_POINTER null pointer passed to getter
*/ */
attribute unsigned long version; 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;
}; };

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

@ -281,14 +281,14 @@ nsLDAPAutoCompleteSession::OnStopLookup()
// Abandon the operation, if there is one // Abandon the operation, if there is one
// //
if (mOperation) { if (mOperation) {
nsresult rv = mOperation->Abandon(); nsresult rv = mOperation->AbandonExt();
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// since there's nothing interesting that can or should be // since there's nothing interesting that can or should be
// done if this abandon failed, warn about it and move on // done if this abandon failed, warn about it and move on
// //
NS_WARNING("nsLDAPAutoCompleteSession::OnStopLookup(): " NS_WARNING("nsLDAPAutoCompleteSession::OnStopLookup(): "
"error calling mOperation->Abandon()"); "error calling mOperation->AbandonExt()");
} }
// force nsCOMPtr to release mOperation // force nsCOMPtr to release mOperation
@ -899,6 +899,28 @@ nsLDAPAutoCompleteSession::StartLDAPSearch()
return NS_ERROR_UNEXPECTED; 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; // 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. // 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; 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. // time to kick off the search.
// //
// XXXdmose what about timeouts? // XXXdmose what about timeouts?
// //
rv = mOperation->SearchExt(dn, scope, searchFilter, mSearchAttrsSize, rv = mOperation->SearchExt(dn, scope, searchFilter, mSearchAttrsSize,
NS_CONST_CAST(const char **, mSearchAttrs), 0, NS_CONST_CAST(const char **, mSearchAttrs),
mMaxHits); 0, mMaxHits);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
switch(rv) { switch(rv) {
@ -1587,4 +1627,32 @@ nsLDAPAutoCompleteSession::SetVersion(PRUint32 aVersion)
return NS_OK; 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 #endif

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

@ -49,6 +49,7 @@
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsIConsoleService.h" #include "nsIConsoleService.h"
#include "nsIAuthPrompt.h" #include "nsIAuthPrompt.h"
#include "nsIArray.h"
// 964665d0-1dd1-11b2-aeae-897834fb00b9 // 964665d0-1dd1-11b2-aeae-897834fb00b9
// //
@ -131,5 +132,7 @@ class nsLDAPAutoCompleteSession : public nsILDAPMessageListener,
// create and initialize the results array // create and initialize the results array
nsresult CreateResultsArray(void); nsresult CreateResultsArray(void);
nsCOMPtr<nsIMutableArray> mSearchServerControls;
nsCOMPtr<nsIMutableArray> mSearchClientControls;
}; };