mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 14:46:02 +00:00
preliminary impl of nsILDAPMessageListener; fix nsLDAPConnection::NextAttribute() to not assert when the last attribute is reached; canonicalize names to interCaps style. a=r=(not built)
This commit is contained in:
parent
9e16120aa9
commit
50889ce100
@ -53,7 +53,6 @@ lds(class nsLDAPChannel *chan, const char *url)
|
||||
PRInt32 lden;
|
||||
nsresult rv;
|
||||
|
||||
|
||||
// create an LDAP connection
|
||||
//
|
||||
myConnection = do_CreateInstance("mozilla.network.ldapconnection", &rv);
|
||||
@ -149,7 +148,6 @@ lds(class nsLDAPChannel *chan, const char *url)
|
||||
while ( returnCode != LDAP_RES_SEARCH_RESULT ) {
|
||||
|
||||
char *dn, *attr;
|
||||
int rc2;
|
||||
|
||||
PR_fprintf(PR_STDERR,".");
|
||||
|
||||
@ -179,7 +177,7 @@ lds(class nsLDAPChannel *chan, const char *url)
|
||||
// get the DN
|
||||
// XXX better err handling
|
||||
//
|
||||
rv = myMessage->GetDN(&dn);
|
||||
rv = myMessage->GetDn(&dn);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
chan->pipeWrite("dn: ");
|
||||
@ -258,18 +256,7 @@ lds(class nsLDAPChannel *chan, const char *url)
|
||||
break;
|
||||
|
||||
case LDAP_RES_SEARCH_RESULT: // all done (the while condition sees this)
|
||||
#ifdef DEBUG_dmose
|
||||
PR_fprintf(PR_STDERR, "\nresult returned: \n");
|
||||
#endif
|
||||
|
||||
// XXX should use GetErrorString here?
|
||||
//
|
||||
rv = myMessage->GetErrorCode(&rc2);
|
||||
if ( NS_FAILED(rv) ) {
|
||||
PR_fprintf(PR_STDERR, " %s\n", ldap_err2string(rc2));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
PR_fprintf(PR_STDERR, "success\n");
|
||||
chan->OnLDAPSearchResult(myMessage);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -282,15 +269,5 @@ lds(class nsLDAPChannel *chan, const char *url)
|
||||
PR_Sleep(200);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_dmose
|
||||
PR_fprintf(PR_STDERR,"unbinding\n");
|
||||
#endif
|
||||
|
||||
myConnection = 0;
|
||||
|
||||
#ifdef DEBUG_dmose
|
||||
PR_fprintf(PR_STDERR,"unbound\n");
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -52,8 +52,8 @@
|
||||
|
||||
NS_METHOD lds(class nsLDAPChannel *chan, const char *);
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS3(nsLDAPChannel, nsIChannel, nsIRequest,
|
||||
nsIRunnable);
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsLDAPChannel, nsIChannel, nsIRequest,
|
||||
nsIRunnable, nsILDAPMessageListener);
|
||||
|
||||
nsLDAPChannel::nsLDAPChannel()
|
||||
{
|
||||
@ -577,8 +577,7 @@ nsLDAPChannel::Run(void)
|
||||
|
||||
// since the LDAP SDK does all the socket management, we don't have
|
||||
// an underlying transport channel to create an nsIInputStream to hand
|
||||
// back to the nsIStreamListener. So (only on the first call to AsyncRead)
|
||||
// we do it ourselves:
|
||||
// back to the nsIStreamListener. So we do it ourselves:
|
||||
//
|
||||
if (!mReadPipeIn) {
|
||||
|
||||
@ -646,3 +645,86 @@ nsLDAPChannel::pipeWrite(char *str)
|
||||
mReadPipeOffset += bytesWritten;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// methods for nsILDAPMessageListener
|
||||
//
|
||||
// void OnLDAPSearchEntry (in nsILDAPMessage aMessage);
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsLDAPChannel::OnLDAPSearchEntry(nsILDAPMessage *aMessage)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// void OnLDAPSearchReference (in nsILDAPMessage aMessage);
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsLDAPChannel::OnLDAPSearchReference(nsILDAPMessage *aMessage)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// void OnLDAPSearchResult (in nsILDAPMessage aMessage);
|
||||
//
|
||||
// XXX need to addref my message? deal with scope?
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsLDAPChannel::OnLDAPSearchResult(nsILDAPMessage *aMessage)
|
||||
{
|
||||
PRInt32 errorCode; // the LDAP error code
|
||||
nsresult rv;
|
||||
|
||||
#ifdef DEBUG_dmose
|
||||
PR_fprintf(PR_STDERR, "\nresult returned: \n");
|
||||
#endif
|
||||
|
||||
// XXX should use GetErrorString here?
|
||||
//
|
||||
rv = aMessage->GetErrorCode(&errorCode);
|
||||
if ( NS_FAILED(rv) ) {
|
||||
PR_fprintf(PR_STDERR, " %s\n", ldap_err2string(errorCode));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_dmose
|
||||
PR_fprintf(PR_STDERR, "success\n");
|
||||
#endif
|
||||
|
||||
// done with this message; cause nsCOMPtr to call the destructor
|
||||
//
|
||||
aMessage = 0;
|
||||
|
||||
// XXX need to destroy the connection (to unbind) here
|
||||
// the old code that did this in ldapSearch.cpp is pasted below
|
||||
//
|
||||
#if 0
|
||||
#ifdef DEBUG_dmose
|
||||
PR_fprintf(PR_STDERR,"unbinding\n");
|
||||
#endif
|
||||
|
||||
myConnection = 0;
|
||||
|
||||
#ifdef DEBUG_dmose
|
||||
PR_fprintf(PR_STDERR,"unbound\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// void OnLDAPError ();
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsLDAPChannel::OnLDAPError()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// void OnLDAPTimeout ();
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsLDAPChannel::OnLDAPTimeout()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -44,15 +44,18 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIBufferInputStream.h"
|
||||
#include "nsIBufferOutputStream.h"
|
||||
#include "nsILDAPMessageListener.h"
|
||||
|
||||
/* Header file */
|
||||
class nsLDAPChannel : public nsIChannel, public nsIRunnable
|
||||
class nsLDAPChannel : public nsIChannel, public nsIRunnable,
|
||||
public nsILDAPMessageListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSIRUNNABLE
|
||||
NS_DECL_NSILDAPMESSAGELISTENER
|
||||
|
||||
nsLDAPChannel();
|
||||
virtual ~nsLDAPChannel();
|
||||
|
@ -101,7 +101,6 @@ NS_IMETHODIMP
|
||||
nsLDAPMessage::Init(nsILDAPOperation *aOperation, LDAPMessage *aMsgHandle)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILDAPConnection> connection;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aOperation);
|
||||
NS_ENSURE_ARG_POINTER(aMsgHandle);
|
||||
@ -113,10 +112,10 @@ nsLDAPMessage::Init(nsILDAPOperation *aOperation, LDAPMessage *aMsgHandle)
|
||||
|
||||
// cache the connection handle associated with this operation
|
||||
//
|
||||
rv = mOperation->GetConnection(getter_AddRefs(connection));
|
||||
rv = mOperation->GetConnection(getter_AddRefs(mConnection));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = connection->GetConnectionHandle(&mConnectionHandle);
|
||||
rv = mConnection->GetConnectionHandle(&mConnectionHandle);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
return NS_OK;
|
||||
@ -205,7 +204,26 @@ nsLDAPMessage::NextAttribute(char* *aAttribute)
|
||||
if (*aAttribute) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
// figure out whether this returned NULL because it was the
|
||||
// last attribute (which is OK), or because there was an error
|
||||
//
|
||||
nsresult rv;
|
||||
PRInt32 lderr;
|
||||
|
||||
rv = mConnection->GetLdErrno(NULL, NULL, &lderr);
|
||||
if (NS_FAILED(rv)) {
|
||||
// some sort of internal error; propagate upwards
|
||||
//
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (lderr == LDAP_SUCCESS) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
// XXX should really propagate lderr upwards
|
||||
//
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,7 +238,7 @@ nsLDAPMessage::Type(void)
|
||||
// wrapper for ldap_get_dn
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsLDAPMessage::GetDN(char* *aDN)
|
||||
nsLDAPMessage::GetDn(char* *aDN)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDN);
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the mozilla.org LDAP XPCOM component.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Dan Mosedale <dmose@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU General Public License Version 2 or later (the
|
||||
* "GPL"), in which case the provisions of the GPL are applicable
|
||||
* instead of those above. If you wish to allow use of your
|
||||
* version of this file only under the terms of the GPL and not to
|
||||
* allow others to use your version of this file under the MPL,
|
||||
* indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by
|
||||
* the GPL. If you do not delete the provisions above, a recipient
|
||||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*/
|
||||
|
||||
#include "nsLDAPURI.h"
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS1(nsLDAPURI, nsILDAPURI)
|
||||
|
||||
nsLDAPURI::nsLDAPURI()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
nsLDAPURI::~nsLDAPURI()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the mozilla.org LDAP XPCOM component.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Dan Mosedale <dmose@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU General Public License Version 2 or later (the
|
||||
* "GPL"), in which case the provisions of the GPL are applicable
|
||||
* instead of those above. If you wish to allow use of your
|
||||
* version of this file only under the terms of the GPL and not to
|
||||
* allow others to use your version of this file under the MPL,
|
||||
* indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by
|
||||
* the GPL. If you do not delete the provisions above, a recipient
|
||||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*/
|
||||
|
||||
#ifndef nsLDAPURI_h__
|
||||
#define nsLDAPURI_h__
|
||||
|
||||
#include "nsILDAPURI.h"
|
||||
|
||||
class nsLDAPURI : public nsILDAPURI
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSILDAPURI
|
||||
|
||||
nsLDAPURI();
|
||||
virtual ~nsLDAPURI();
|
||||
/* additional members */
|
||||
};
|
||||
|
||||
#endif // nsLDAPURI_h__
|
Loading…
x
Reference in New Issue
Block a user