Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions
nsLDAPControl Class Reference

#include <nsLDAPControl.h>

Inheritance diagram for nsLDAPControl:
Inheritance graph
[legend]
Collaboration diagram for nsLDAPControl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSILDAPCONTROL 
nsLDAPControl ()
nsresult ToLDAPControl (LDAPControl **aControl)
 return a pointer to C-SDK compatible LDAPControl structure.

Public Attributes

attribute ACString oid
 Control type, represented as a string.
attribute nsILDAPBERValue value
 The data associated with a control, if any.
attribute boolean isCritical
 Should the client or server abort if the control is not understood? Should be set to false for server controls used in abandon and unbind operations, since those have no server response.

Protected Attributes

nsCOMPtr< nsILDAPBERValuemValue
PRBool mIsCritical
nsCString mOid

Private Member Functions

 ~nsLDAPControl ()

Detailed Description

Definition at line 51 of file nsLDAPControl.h.


Constructor & Destructor Documentation

Definition at line 47 of file nsLDAPControl.cpp.

Definition at line 52 of file nsLDAPControl.cpp.

{
}

Member Function Documentation

return a pointer to C-SDK compatible LDAPControl structure.

utility routine for use inside the LDAP XPCOM SDK

Note that this is allocated with NS_Alloc and must be freed with NS_Free, both by ldap_control_free() and friends.

Exceptions:
nullpointer return if allocation failed

Definition at line 101 of file nsLDAPControl.cpp.

{
  // because nsLDAPProtocolModule::Init calls prldap_install_routines we know
  // that the C SDK will be using the NSPR allocator under the hood, so our
  // callers will therefore be able to use ldap_control_free() and friends on
  // this control.
  LDAPControl *ctl = NS_STATIC_CAST(LDAPControl *, 
                                    PR_Calloc(1, sizeof(LDAPControl)));
  if (!ctl) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  // need to ensure that this string is also alloced by PR_Alloc
  ctl->ldctl_oid = PL_strdup(mOid.get());
  if (!ctl->ldctl_oid) {
    PR_Free(ctl);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  ctl->ldctl_iscritical = mIsCritical;

  if (!mValue) {
    // no data associated with this control
    ctl->ldctl_value.bv_len = 0;
    ctl->ldctl_value.bv_val = 0;
  } else {

    // just to make the code below a bit more readable
    nsLDAPBERValue *nsBerVal = 
      NS_STATIC_CAST(nsLDAPBERValue *, NS_STATIC_CAST(nsILDAPBERValue *,
                                                      mValue.get()));
    ctl->ldctl_value.bv_len = nsBerVal->mSize;

    if (!nsBerVal->mSize) {
      // a zero-length value is associated with this control
      return NS_ERROR_NOT_IMPLEMENTED;
    } else {

      // same for the berval itself
      ctl->ldctl_value.bv_len = nsBerVal->mSize;
      ctl->ldctl_value.bv_val = NS_STATIC_CAST(char *,
                                               PR_Malloc(nsBerVal->mSize));
      if (!ctl->ldctl_value.bv_val) {
        ldap_control_free(ctl);
        return NS_ERROR_OUT_OF_MEMORY;
      }
  
      memcpy(ctl->ldctl_value.bv_val, nsBerVal->mValue,
             ctl->ldctl_value.bv_len);
    }
  }

  *control = ctl;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Should the client or server abort if the control is not understood? Should be set to false for server controls used in abandon and unbind operations, since those have no server response.

none

Definition at line 77 of file nsILDAPControl.idl.

Definition at line 73 of file nsLDAPControl.h.

Definition at line 74 of file nsLDAPControl.h.

Definition at line 72 of file nsLDAPControl.h.

attribute ACString nsILDAPControl::oid [inherited]

Control type, represented as a string.

none

Definition at line 55 of file nsILDAPControl.idl.

The data associated with a control, if any.

To specify that no data is to be associated with the control, don't set this at all (which is equivalent to setting it to null).

Note:
Specifying a zero-length value is not currently supported. At some date, setting this to an nsILDAPBERValue which has not had any of the set methods called will be the appropriate way to do that.

none

Definition at line 68 of file nsILDAPControl.idl.


The documentation for this class was generated from the following files: