/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * 
 * 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 SDK.
 * 
 * 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>
 *                 Leif Hedstrom <leif@netscape.com>
 * 
 * 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 "nsIURI.idl"

/**
 * Strings in methods inherited from nsIURI, which are using XPIDL
 * |string| types, are expected to be UTF8 encoded. All such strings
 * in this interface, except attribute types (e.g. "cn"), should in fact
 * be UTF8. It's important to remember that attributes can not be UTF8,
 * they can only be of a limited subset of ASCII (see RFC 2251).
 */

[scriptable, uuid(7310562d-1567-43c7-a123-633c1ba3663e)]
interface nsILDAPURL : nsIURI {

    /**
     * The distinguished name of the URL (ie the base DN for the search).
     * This string is expected to be a valid UTF8 string.
     *
     * for the getter:
     *
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     * @exception NS_ERROR_OUT_OF_MEMORY	Ran out of memory
     */
    attribute AUTF8String dn;

    /**
     * Return all LDAP attributes currently set. The empty array indicates
     * that all attributes are requested.
     *
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     * @exception NS_ERROR_OUT_OF_MEMORY	Ran out of memory
     */
    void getAttributes(out unsigned long aCount, 
                       [retval, array, size_is(aCount)] out string aAttrs);

    /**
     * Set the array of attributes, dropping whatever was there before.
     *
     * @param aAttrs                        An array of LDAP attributes
     * @exception NS_ERROR_OUT_OF_MEMORY	Ran out of memory
     */
    void setAttributes(in unsigned long aCount,
                       [array, size_is(aCount)] in string aAttrs);

    /**
     * Add one attribute to the array of attributes to request. If the
     * attribute is already in our array, this becomes a noop.
     *
     * @param aAttribute          An LDAP attribute (e.g. "cn")
     */
    void addAttribute(in string aAttribute);

    /**
     * Remove one attribute from the array of attributes to request. If
     * the attribute didn't exist in the array, this becomes a noop.
     *
     * @param aAttribute                    An LDAP attribute (e.g. "cn")
     * @exception NS_ERROR_OUT_OF_MEMORY	Ran out of memory
     */
    void removeAttribute(in string aAttribute);

    /**
     * Test if an attribute is in our list of attributes already
     *
     * @param aAttribute                    An LDAP attribute (e.g. "cn")
     * @return boolean                      Truth value
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     */
    boolean hasAttribute(in string aAttribute);

    /**
     * The scope of the search.  defaults to SCOPE_BASE. 
     *
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     * @exception NS_ERROR_MALFORMED_URI	Illegal base to SET method
     */
    attribute long scope;

    /**
     * Search just the base object
     */
    const long SCOPE_BASE = 0;
    
    /** 
     * Search only the children of the base object
     */
    const long SCOPE_ONELEVEL = 1;

    /**
     * Search the entire subtree under and including the base object
     */
    const long SCOPE_SUBTREE = 2;

    /**
     * The search filter. "(objectClass=*)" is the default.
     */
    attribute AUTF8String filter;

    /**
     * Any options defined for this URL (check options using a bitwise and)
     * 
     * @exception NS_ERROR_NULL_POINTER     NULL pointer to GET method
     * @exception NS_ERROR_OUT_OF_MEMORY    Ran out of memory
     */
    attribute unsigned long options;

    /**
     * If this is set/true, this is an ldaps: URL, not an ldap: URL
     */
    const unsigned long OPT_SECURE = 0x01;

};
