Final part of bug 452232 - Move LDAP autocomplete over to toolkit interfaces. Switch build configs to actually use the toolkit interfaces. r=jcranmer,sr=Neil,a=Standard8 CLOSED TREE
authorMark Banner <bugzilla@standard8.plus.com>
Wed, 17 Jul 2013 14:39:57 +0200
changeset 18302 0ba38b41f77f623b4c1dc1a6d31042dd3820b88d
parent 18301 c06df11f1abf92b09be9401efe8ee4399e2da51d
child 18303 a333b9c43801605ab79f485a4bbb3c232ed7a907
push id870
push userPidgeot18@gmail.com
push dateFri, 19 Jul 2013 16:25:33 +0000
treeherdertry-comm-central@b38feb3af283 [default view] [failures only]
reviewersjcranmer, Neil, Standard8
bugs452232
Final part of bug 452232 - Move LDAP autocomplete over to toolkit interfaces. Switch build configs to actually use the toolkit interfaces. r=jcranmer,sr=Neil,a=Standard8 CLOSED TREE
mail/configure.in
mailnews/addrbook/public/moz.build
mailnews/addrbook/public/nsIAbLDAPAutoCompFormatter.idl
mailnews/addrbook/public/nsILDAPAutoCompFormatter.idl
mailnews/addrbook/public/nsILDAPAutoCompleteSession.idl
mailnews/addrbook/src/Makefile.in
mailnews/addrbook/src/moz.build
mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp
mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.h
mailnews/addrbook/src/nsAddrbook.manifest
mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp
mailnews/addrbook/src/nsLDAPAutoCompleteSession.h
mailnews/build/Makefile.in
mailnews/build/nsMailModule.cpp
suite/configure.in
--- a/mail/configure.in
+++ b/mail/configure.in
@@ -55,38 +55,32 @@ dnl ====================================
 dnl = LDAP
 dnl =========================================================
 MOZ_ARG_DISABLE_BOOL(ldap,
 [  --disable-ldap          Disable LDAP support],
     MOZ_LDAP_XPCOM=,
     MOZ_LDAP_XPCOM=1)
 
 if test "$MOZ_LDAP_XPCOM"; then
-    MOZ_ARG_ENABLE_BOOL(incomplete-toolkit-ldap-autocomplete,
-    [  --enable-incomplete-toolkit-ldap-autocomplete Builds a JavaScript component that implements an LDAP autocomplete component using the toolkit interfaces rather than the C++ component using the obsolete XPFE interfaces. ],
-        MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE=1,
-        MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE= )
-
     LDAP_CFLAGS='-I${DIST}/public/ldap'
     if test "$OS_ARCH" = "WINNT"; then
         if test -n "$GNU_CC"; then
             LDAP_LIBS='-L$(DIST)/lib -lnsldap32v60 -lnsldappr32v60 -lnsldif32v60'
         else
             LDAP_LIBS='$(DIST)/lib/$(LIB_PREFIX)nsldap32v60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)nsldappr32v60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)nsldif32v60.${IMPORT_LIB_SUFFIX}'
         fi
     elif test "$OS_ARCH" = "OS2"; then
             LDAP_LIBS='$(DIST)/lib/$(LIB_PREFIX)ldap60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)prldap60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)ldif60.${IMPORT_LIB_SUFFIX}'
     else
         LDAP_LIBS='-L${DIST}/bin -L${DIST}/lib -lldap60 -lprldap60 -lldif60'
     fi
 
     LDAP_COMPONENT=mozldap
     LDAP_MODULE="MODULE(nsLDAPProtocolModule)"
 fi
-AC_SUBST(MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE)
 
 AC_SUBST(MOZ_LDAP_XPCOM)
 AC_SUBST(LDAP_CFLAGS)
 AC_SUBST(LDAP_LIBS)
 
 dnl =========================================================
 dnl = MAPI support (Windows only)
 dnl =========================================================
--- a/mailnews/addrbook/public/moz.build
+++ b/mailnews/addrbook/public/moz.build
@@ -34,21 +34,14 @@ if CONFIG['MOZ_LDAP_XPCOM']:
     XPIDL_SOURCES += [
         'nsIAbLDAPCard.idl',
         'nsIAbLDAPDirectory.idl',
         'nsIAbLDAPReplicationData.idl',
         'nsIAbLDAPReplicationQuery.idl',
         'nsIAbLDAPReplicationService.idl',
     ]
 
-    if not CONFIG['MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE']:
-        XPIDL_SOURCES += [
-            'nsIAbLDAPAutoCompFormatter.idl',
-            'nsILDAPAutoCompFormatter.idl',
-            'nsILDAPAutoCompleteSession.idl',
-        ]
-
 MODULE = 'addrbook'
 
 EXPORTS += [
     'nsAbBaseCID.h',
 ]
 
deleted file mode 100644
--- a/mailnews/addrbook/public/nsIAbLDAPAutoCompFormatter.idl
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsILDAPAutoCompFormatter.idl"
-
-/** 
- * An interface for formatter LDAP messages to be used as nsAutoCompleteItems
- * for use in RFC 2822 message headers.
- */
-[scriptable, uuid(cde8836e-1dd1-11b2-baff-a6d918243e80)]
-interface nsIAbLDAPAutoCompFormatter: nsILDAPAutoCompFormatter {
-
-    /**
-     * All three Format attributes are templates, which work as follows:
-     *
-     * Required LDAP attributes are delimited by curly braces, and
-     * optional LDAP attributes are determined by brackets.  Backslash
-     * escapes any character, including itself.  Someday perhaps we'll rev 
-     * this interface and change these to a more flexible format; perhaps 
-     * something regexp based.
-     *
-     * If any of these are unset, components implementing this interface 
-     * are free to choose reasonable defaults.  As an example, the 
-     *"@mozilla.org/ldap-autocomplete-formatter;1?type=addrbook"
-     * implementation currently happens to use the following default
-     * strings:
-     * 
-     * nameFormat: "[cn]"
-     * addressFormat: "{mail}"
-     * commentFormat: ""
-     *
-     * and generates autocomplete items like this:
-     *
-     * value: John Doe <john.doe@foo.org>         
-     * comment: Foo Organization
-     *
-     * Note that nsILDAPAutoCompFormatter::getAttributes() is only
-     * required to be called by the nsILDAPAutoCompleteSession
-     * implementation when the nsILDAPAutoCompleteSession::formatter
-     * IDL attribute is set.  So if for some reason the format
-     * attributes exposed through this interface get changed (eg a
-     * user changes their prefs), it is the changing code's
-     * responsibly to re-set the nsILDAPAutoCompleteSession::formatter
-     * IDL attribute to the same object to force a new getAttributes()
-     * call.
-     */
-
-    attribute AString nameFormat;
-    attribute AString addressFormat;
-    attribute AString commentFormat;
-};
deleted file mode 100644
--- a/mailnews/addrbook/public/nsILDAPAutoCompFormatter.idl
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-interface nsIAutoCompleteItem;
-interface nsILDAPMessage;
-
-/**
- * An interface to allow different users of nsILDAPAutoCompleteSession to 
- * format each nsILDAPMessage into an nsIAutoCompleteItem as it sees fit.
- */
-[scriptable, uuid(450cb44e-1752-49d0-890a-f895f8163cc3)]
-interface nsILDAPAutoCompFormatter : nsISupports {
-    
-    /**
-     * Returns an nsIAutoCompleteItem generated from the data in 
-     * the given nsILDAPMessage.
-     *
-     * @param aMessage  message to be formatted
-     * @return          resulting nsIAutoCompleteItem
-     */
-    nsIAutoCompleteItem format(in nsILDAPMessage aMessage);
-
-    /**
-     * Gets a list of all the LDAP attributes that should be requested
-     * from the LDAP server when a lookup is done.  This avoids
-     * wasting server time, bandwidth, and client time processing
-     * unused attributes.
-     *
-     * Note that this is only required to be called by the
-     * nsILDAPAutoCompleteSession implementation when the
-     * nsILDAPAutoCompleteSession::formatter IDL attribute is set.  .
-     * So if for some reason, the LDAP attributes to be returned by
-     * searches has to change (eg because the user changed a
-     * preference), the nsILDAPAutoCompleteSession::formatter IDL
-     * attribute should be re-set to the same object to force a new
-     * getAttributes() call.
-     * 
-     * @return  A comma-separated list of attributes.
-     */
-    readonly attribute ACString attributes;
-
-    /** 
-     * This method formats an error condition into an nsIAutoCompleteItem
-     * for display to the user.  Specifically, the state that the session
-     * was in when the error occured (aState) is formatted into a general
-     * error message which is put in the value attribute of the item,
-     * and the specific error (aErrorCode) is formatted into another message
-     * which is put in an nsISupportsString in the param attribute of the
-     * item.
-     *
-     * @param aState        state of autocomplete session when error occurred
-     * @param aErrorCode    specific error encountered
-     *
-     * @return              newly generated item
-     */
-    nsIAutoCompleteItem formatException(in long aState, 
-                                        in nsresult aErrorCode);
-
-    /**
-     *  Possible states that can be passed in aState to formatException
-     */
-    const long STATE_UNBOUND = 0;
-    const long STATE_INITIALIZING = 1;
-    const long STATE_BINDING = 2;
-    const long STATE_BOUND = 3;
-    const long STATE_SEARCHING = 4;
-
-};
deleted file mode 100644
--- a/mailnews/addrbook/public/nsILDAPAutoCompleteSession.idl
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsIAutoCompleteSession.idl"
-
-// forward decls
-//
-interface nsILDAPURL;   
-interface nsILDAPAutoCompFormatter;
-interface nsIMutableArray;
-
-/**
- * Extends nsIAutoCompleteSession to have various LDAP-specific parameters.
- * and output format.
- *
- * Note: the formatter attribute should be set prior to starting the LDAP
- * lookup via nsIAutoCompleteSession::OnStartLookup.
- */
-[scriptable, uuid(d6a64827-6206-4070-9bf9-24578df0afe2)]
-interface nsILDAPAutoCompleteSession : nsIAutoCompleteSession {
-
-    /**
-     * A template used to construct the RFC 1960 LDAP search filter to use 
-     * while autocompleting.  
-     *
-     * The authoritative documentation for the format in use can be found at 
-     * at <http://docs.iplanet.com/docs/manuals/dirsdk/csdk41/html/filter.htm>.
-     * The Linux/OpenLDAP man page for ldapfilter.conf(5) does a pretty decent
-     * job as well, however.
-     *
-     * As of this writing, the "@mozilla.org/autocompleteSession;1?type=ldap" 
-     * contractid happens to use a default value of 
-     * (|(cn=%v1*%v2-*)(mail=%v1*%v2-*)(sn=%v1*%v2-*))
-     *
-     * @exception NS_ERROR_NULL_POINTER     NULL pointer passed to getter
-     * @exception NS_ERROR_OUT_OF_MEMORY    Getter couldn't allocate string
-     */
-    attribute AUTF8String filterTemplate;
-
-    /**
-     * At most this many nsIAutoCompleteItems will be returned.  This
-     * is useful for keeping bandwidth usage over slow-speed
-     * connections as well as ensuring that the number of choices
-     * offered in the UI is manageble.
-     *
-     * 1-65535 are interpreted literally
-     * 0 means "unlimited"
-     * -1 uses the default limit for the LDAP connection in use
-     * 
-     * @exception NS_ERROR_NULL_POINTER     NULL pointer passed to getter
-     * @exception NS_ERROR_ILLEGAL_VALUE    Out-of-range value passed to setter
-     */
-    attribute long maxHits;
-
-    /**
-     * Strings shorter than this will return |nsIAutoCompleteStatus::ignored|
-     * rather than triggering a search.  This allows browsers to be
-     * configured to not search on substrings so short that they
-     * aren't indexed by the LDAP server (such searches can use
-     * significantly more server resources and return a very large
-     * number of entries).  cjkMinStringLength is used for CJK
-     * languages, and minStringLength for everything else.  As of this
-     * writing, the "@mozilla.org/autocompleteSession;1?type=ldap"
-     * contractid uses defaults of two and zero, respectively.  This
-     * avoids most unindexed searches with at least one widely-deployed
-     * webserver, but allows CJK languages, where a single glyph can be an
-     * an entire name to still get results.
-     * 
-     * @exception NS_ERROR_NULL_POINTER  NULL pointer passed to getter
-     */
-    attribute unsigned long minStringLength;
-    attribute unsigned long cjkMinStringLength;
-
-    /**
-     * LDAP server to complete against, in ldap: URL format.  
-     * May change to an nsILDAPServer once that infrastructure lands.
-     *
-     * @exception NS_ERROR_NULL_POINTER     NULL pointer passed to getter    
-     */
-    attribute nsILDAPURL serverURL;
-
-    /** 
-     * Callback used to format an individual LDAP message into an
-     * nsIAutoCompleteItem. This is required to be set before calling
-     * OnStartLookup.
-     */
-    attribute nsILDAPAutoCompFormatter formatter;
-
-    /**
-     * "Login as..." this ID.  Currently, this must be specified as a DN.
-     * In the future, we may support userid and/or email address as well.
-     * If unset, bind anonymously.
-     */
-    attribute AUTF8String login;
-
-    /**
-     * SASL Mechanism to use to perform bind. If unset, a simple bind will
-     * be performed.
-     *
-     * @exception NS_ERROR_OUT_OF_MEMORY    Getter couldn't allocate string
-     * @exception NS_ERROR_NULL_POINTER   null pointer passed to getter
-     */
-    attribute ACString saslMechanism;
-    
-    /**
-     * What version of the LDAP protocol should be used?  Allowed version
-     * number constants are defined in nsILDAPConnection.idl.
-     *
-     * @exception NS_ERROR_ILLEGAL_VALUE  illegal version num passed to setter
-     * @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;
-};
--- a/mailnews/addrbook/src/Makefile.in
+++ b/mailnews/addrbook/src/Makefile.in
@@ -18,20 +18,16 @@ endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_CXXFLAGS += -DNOMINMAX
 endif
 
 ifdef MOZ_LDAP_XPCOM
 DEFINES += -DMOZ_LDAP_XPCOM
 
-ifdef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-DEFINES += -DMOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-endif
-
 # XXX These files are not being built as they don't work. Bug 311632 should
 # fix them.
 # nsAbLDAPChangeLogQuery.cpp
 # nsAbLDAPChangeLogData.cpp
 endif
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
--- a/mailnews/addrbook/src/moz.build
+++ b/mailnews/addrbook/src/moz.build
@@ -65,23 +65,19 @@ if CONFIG['MOZ_LDAP_XPCOM']:
         'nsAbLDAPDirectoryQuery.cpp',
         'nsAbLDAPDirectoryModify.cpp',
         'nsAbLDAPListenerBase.cpp',
         'nsAbLDAPReplicationData.cpp',
         'nsAbLDAPReplicationQuery.cpp',
         'nsAbLDAPReplicationService.cpp',
     ]
 
-    if CONFIG['MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE']:
-        EXTRA_COMPONENTS += ['nsAbLDAPAutoCompleteSearch.js']
-    else:
-        CPP_SOURCES += [
-            'nsAbLDAPAutoCompFormatter.cpp',
-            'nsLDAPAutoCompleteSession.cpp',
-        ]
+    EXTRA_COMPONENTS += [
+        'nsAbLDAPAutoCompleteSearch.js',
+    ]
 
 EXTRA_COMPONENTS += [
     'nsAbAutoCompleteMyDomain.js',
     'nsAbAutoCompleteSearch.js',
     'nsAbLDAPAttributeMap.js',
 ]
 
 EXTRA_PP_COMPONENTS += [
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp
+++ /dev/null
@@ -1,645 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * 
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsAbLDAPAutoCompFormatter.h"
-#include "nsIAutoCompleteResults.h"
-#include "nsServiceManagerUtils.h"
-#include "nsComponentManagerUtils.h"
-#include "nsIMsgHeaderParser.h"
-#include "nsILDAPMessage.h"
-#include "nsIStringBundle.h"
-#include "nsXPCOM.h"
-#include "nsISupportsPrimitives.h"
-#include "nsError.h"
-#include "nsMemory.h"
-#include "nsILDAPErrors.h"
-#include "nsMsgUtils.h"
-#include "mozilla/Services.h"
-
-#define LDAP_ERROR_BUNDLE "chrome://mozldap/locale/ldap.properties"
-#define LDAP_AUTOCOMPLETE_ERROR_BUNDLE "chrome://messenger/locale/addressbook/ldapAutoCompErrs.properties"
-
-NS_IMPL_ISUPPORTS2(nsAbLDAPAutoCompFormatter, 
-		   nsILDAPAutoCompFormatter, 
-		   nsIAbLDAPAutoCompFormatter)
-
-nsAbLDAPAutoCompFormatter::nsAbLDAPAutoCompFormatter() :
-    mNameFormat(NS_LITERAL_STRING("[cn]")),
-    mAddressFormat(NS_LITERAL_STRING("{mail}"))
-{
-}
-
-nsAbLDAPAutoCompFormatter::~nsAbLDAPAutoCompFormatter()
-{
-}
-
-NS_IMETHODIMP
-nsAbLDAPAutoCompFormatter::Format(nsILDAPMessage *aMsg, 
-                                  nsIAutoCompleteItem **aItem) 
-{
-    nsresult rv;
-
-    nsCOMPtr<nsIMsgHeaderParser> msgHdrParser = 
-        do_GetService("@mozilla.org/messenger/headerparser;1", &rv);
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompFormatter::Format(): do_GetService()"
-                 " failed trying to obtain"
-                 " '@mozilla.org/messenger/headerparser;1'");
-        return NS_ERROR_NOT_AVAILABLE;
-    }
-
-    // generate the appropriate string
-    //
-    nsAutoCString name;
-    rv = ProcessFormat(mNameFormat, aMsg, &name, 0);
-    if (NS_FAILED(rv)) {
-        // Something went wrong lower down the stack; a message should
-        // have already been logged there.  Return an error, rather
-        // than trying to generate a bogus nsIAutoCompleteItem
-        //
-        return rv;
-    }
-
-    nsAutoCString address;
-    rv = ProcessFormat(mAddressFormat, aMsg, &address, 0);
-    if (NS_FAILED(rv)) {
-        // Something went wrong lower down the stack; a message should have 
-        // already been logged there.  Return an error, rather than trying to 
-        // generate a bogus nsIAutoCompleteItem.
-        //
-        return rv;
-    }
-
-    nsCString value;
-    rv = msgHdrParser->MakeFullAddressString(name.get(), address.get(), 
-                                             getter_Copies(value));
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompFormatter::Format(): call to"
-                 " MakeFullAddressString() failed");
-        return rv;
-    }
-
-    // create an nsIAutoCompleteItem to hold the returned value
-    //
-    nsCOMPtr<nsIAutoCompleteItem> item = do_CreateInstance(
-        NS_AUTOCOMPLETEITEM_CONTRACTID, &rv);
-
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompFormatter::Format(): couldn't"
-                 " create " NS_AUTOCOMPLETEITEM_CONTRACTID "\n");
-        return NS_ERROR_NOT_AVAILABLE;
-    }
-
-    // this is that part that actually gets autocompleted to
-    //
-    rv = item->SetValue(NS_ConvertUTF8toUTF16(value));
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompFormatter::Format(): "
-                 "item->SetValue failed");
-        return rv;
-    }
-
-    // generate the appropriate string to appear as a comment off to the side
-    //
-    nsAutoCString comment;
-    rv = ProcessFormat(mCommentFormat, aMsg, &comment, 0);
-    if (NS_SUCCEEDED(rv)) {
-        rv = item->SetComment(NS_ConvertUTF8toUTF16(comment).get());
-        if (NS_FAILED(rv)) {
-            NS_WARNING("nsAbLDAPAutoCompFormatter::Format():"
-                       " item->SetComment() failed");
-        }
-    }
-
-    rv = item->SetClassName("remote-abook");
-    if (NS_FAILED(rv)) {
-        NS_WARNING("nsAbLDAPAutoCompleteFormatter::Format():"
-                   " item->SetClassName() failed");
-    }
-
-    // all done; return the item
-    NS_IF_ADDREF(*aItem = item);
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAbLDAPAutoCompFormatter::FormatException(int32_t aState, 
-                                           nsresult aErrorCode, 
-                                           nsIAutoCompleteItem **aItem) 
-{
-    int32_t errorKey;
-    nsresult rv;
-
-    // create an nsIAutoCompleteItem to hold the returned value
-    //
-    nsCOMPtr<nsIAutoCompleteItem> item = do_CreateInstance(
-        NS_AUTOCOMPLETEITEM_CONTRACTID, &rv);
-
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompFormatter::FormatException(): couldn't"
-                 " create " NS_AUTOCOMPLETEITEM_CONTRACTID "\n");
-        return NS_ERROR_NOT_AVAILABLE;
-    }
-
-    // get the string bundle service
-    //
-    nsString errMsg, ldapErrMsg, alertMsg, ldapHint;
-    nsString errCodeNum;
-
-    nsCOMPtr<nsIStringBundleService> stringBundleSvc =
-        mozilla::services::GetStringBundleService();
-    if (stringBundleSvc) {
-        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
-                 " error getting string bundle service");
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    // get the string bundles relevant here: the main LDAP bundle,
-    // and the ldap AutoCompletion-specific bundle
-    //
-    nsCOMPtr<nsIStringBundle> ldapBundle, ldapACBundle;
-
-    rv = stringBundleSvc->CreateBundle(
-        LDAP_ERROR_BUNDLE,
-        getter_AddRefs(ldapBundle));
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
-                 " error creating string bundle "
-                 LDAP_ERROR_BUNDLE);
-        return rv;
-    } 
-
-    rv = stringBundleSvc->CreateBundle(
-        LDAP_AUTOCOMPLETE_ERROR_BUNDLE,
-        getter_AddRefs(ldapACBundle));
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
-                 " error creating string bundle "
-                 LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
-        return rv;
-    }
-
-    // get the general error that goes in the dropdown and the window
-    // title
-    //
-    rv = ldapACBundle->GetStringFromID(aState, getter_Copies(errMsg));
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
-                 " error getting general error from bundle "
-                 LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
-        return rv;
-    }
-
-    // for LDAP errors
-    //
-    if (NS_ERROR_GET_MODULE(aErrorCode) == NS_ERROR_MODULE_LDAP) {
-
-        errorKey = NS_ERROR_GET_CODE(aErrorCode);
-
-        // put the number itself in string form
-        //
-        errCodeNum.AppendInt(errorKey);
-
-        // get the LDAP error message itself
-        //
-        rv = ldapBundle->GetStringFromID(NS_ERROR_GET_CODE(aErrorCode), 
-                                                getter_Copies(ldapErrMsg));
-        if (NS_FAILED(rv)) {
-            NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException"
-                     "(): error getting string 2 from bundle "
-                     LDAP_ERROR_BUNDLE);
-            return rv;
-        }
-  
-    } else {
-
-        // put the entire nsresult in string form
-        //
-        errCodeNum.AppendLiteral("0x");
-        errCodeNum.AppendInt(static_cast<uint32_t>(aErrorCode), 16);
-
-        // figure out the key to index into the string bundle
-        //
-        const int32_t HOST_NOT_FOUND_ERROR=5000;
-        const int32_t GENERIC_ERROR=9999;
-        errorKey = ( (aErrorCode == NS_ERROR_UNKNOWN_HOST) ? 
-                     HOST_NOT_FOUND_ERROR : GENERIC_ERROR );
-
-        // get the specific error message itself
-        rv = ldapACBundle->GetStringFromID(errorKey,
-                                           getter_Copies(ldapErrMsg));
-        if (NS_FAILED(rv)) {
-            NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException"
-                     "(): error getting specific non LDAP error-string "
-                     "from bundle "
-                     LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
-            return rv;
-        }
-    }
-
-    // and try to find a hint about what the user should do next
-    //
-    const int32_t HINT_BASE=10000;
-    const int32_t GENERIC_HINT_CODE = 9999;
-    rv = ldapACBundle->GetStringFromID(HINT_BASE + errorKey, 
-                                       getter_Copies(ldapHint));
-    if (NS_FAILED(rv)) {
-        rv = ldapACBundle->GetStringFromID(HINT_BASE + GENERIC_HINT_CODE,
-                                           getter_Copies(ldapHint));
-        if (NS_FAILED(rv)) {
-            NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException()"
-                     "(): error getting hint string from bundle "
-                     LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
-            return rv;
-        }
-    }
-        
-    const PRUnichar *stringParams[3] = { errCodeNum.get(),
-                                         ldapErrMsg.get(), ldapHint.get() };
-
-    rv = ldapACBundle->FormatStringFromName(
-        NS_LITERAL_STRING("errorAlertFormat").get(), stringParams, 3,
-        getter_Copies(alertMsg));
-    if (NS_FAILED(rv)) {
-        NS_WARNING("Failed to format warning string\n");
-    }
-
-    // put the error message, between angle brackets, into the XPIDL |value|
-    // attribute.  Note that the hardcoded string is only used since 
-    // stringbundles have already failed us.
-    //
-    if (errMsg.Length()) {
-        nsString tErrMsg(NS_LITERAL_STRING("<"));
-        tErrMsg.Append(errMsg);
-        tErrMsg.AppendLiteral(">");
-        rv = item->SetValue(tErrMsg);
-    } else {
-        rv = item->SetValue(
-            NS_LITERAL_STRING("<Unknown LDAP autocompletion error>"));
-    }
-
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsAbLDAPAutoCompFormatter::FormatException(): "
-                 "item->SetValue failed");
-        return rv;
-    }
-    
-    // pass the alert message in as the param; if that fails, proceed anyway
-    //
-    nsCOMPtr<nsISupportsString> alert(do_CreateInstance(
-                                           NS_SUPPORTS_STRING_CONTRACTID,
-                                           &rv));
-    if (NS_FAILED(rv)) {
-        NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): "
-                   "could not create nsISupportsString");
-    } else {
-        rv = alert->SetData(alertMsg);
-        if (NS_FAILED(rv)) {
-            NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): "
-                     "alert.Set() failed");
-        } else {
-            rv = item->SetParam(alert);
-            if (NS_FAILED(rv)) {
-                NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): "
-                           "item->SetParam failed");
-            }
-        }
-    }
-
-    // this is a remote addressbook, set the class name so the autocomplete 
-    // item can be styled to show this
-    //
-    rv = item->SetClassName("remote-err");
-    if (NS_FAILED(rv)) {
-        NS_WARNING("nsAbLDAPAutoCompleteFormatter::FormatException():"
-                   " item->SetClassName() failed");
-    }
-
-    // all done; return the item
-    //
-    NS_IF_ADDREF(*aItem = item);
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAbLDAPAutoCompFormatter::GetAttributes(nsACString &aResult)
-{
-    nsAutoCString searchAttrs;
-    nsresult rv = ProcessFormat(mNameFormat, 0, 0, &searchAttrs);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("nsAbLDAPAutoCompFormatter::SetNameFormat(): "
-                   "ProcessFormat() failed");
-        return rv;
-    }
-    rv = ProcessFormat(mAddressFormat, 0, 0, &searchAttrs);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("nsAbLDAPAutoCompFormatter::SetNameFormat(): "
-                   "ProcessFormat() failed");
-        return rv;
-    }
-    rv = ProcessFormat(mCommentFormat, 0, 0, &searchAttrs);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("nsAbLDAPAutoCompFormatter::SetNameFormat(): "
-                   "ProcessFormat() failed");
-        return rv;
-    }
-
-    aResult = searchAttrs;
-    return NS_OK;
-}
-
-// parse and process a formatting attribute.
-// Generate an autocomplete value from the
-// information in aMessage and append it to aValue.  Any errors
-// (including failure to find a required attribute while building up aValue) 
-// return an NS_ERROR_* up the stack so that the caller doesn't try and
-// generate an nsIAutoCompleteItem from this.
-//
-nsresult
-nsAbLDAPAutoCompFormatter::ProcessFormat(const nsAString & aFormat,
-                                         nsILDAPMessage *aMessage, 
-                                         nsACString *aValue,
-                                         nsCString *aAttrs)
-{
-    nsresult rv;    // temp for return values
-
-    // get some iterators to parse aFormat
-    //
-    const PRUnichar *iter = aFormat.BeginReading();
-    const PRUnichar *iterEnd = aFormat.EndReading();
-
-    // get the console service for error logging
-    //
-    nsCOMPtr<nsIConsoleService> consoleSvc = 
-        do_GetService("@mozilla.org/consoleservice;1", &rv);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("nsAbLDAPAutoCompFormatter::ProcessFormat(): "
-                   "couldn't get console service");
-    }
-
-    bool attrRequired = false;     // is this attr required or optional?
-    nsAutoCString attrName;             // current attr to get
-
-    // parse until we hit the end of the string
-    //
-    while (iter != iterEnd) {
-
-        switch (*iter) {            // process the next char
-
-        case PRUnichar('{'):
-
-            attrRequired = true;  // this attribute is required
-
-            /*FALLTHROUGH*/
-
-        case PRUnichar('['):
-
-            rv = ParseAttrName(&iter, iterEnd, attrRequired,
-                               consoleSvc, attrName);
-
-            if ( NS_FAILED(rv) ) {
-
-                // something unrecoverable happened; stop parsing and 
-                // propagate the error up the stack
-                //
-                return rv;
-            }
-
-            // If we're building a string of attributes...
-            if (aAttrs) { 
-                // ...and it doesn't already contain this string
-                if (aAttrs->Find(attrName, CaseInsensitiveCompare) == kNotFound)
-                {
-                    // add it
-                    if (!aAttrs->IsEmpty())
-                        aAttrs->Append(',');
-                    aAttrs->Append(attrName);
-                }
-            } else {
-
-                // otherwise, append the first value of this attr to aValue
-                // XXXdmose should do better than this; bug 76595
-
-                rv = AppendFirstAttrValue(attrName, aMessage, attrRequired, 
-                                          *aValue);
-                if ( NS_FAILED(rv) ) {
-
-                    // something unrecoverable happened; stop parsing and 
-                    // propagate the error up the stack
-                    //
-                    return rv;
-                }
-            }
-
-            attrName.Truncate();     // clear out for next pass
-            attrRequired = false; // reset to the default for the next pass
-
-            break;
-
-        case PRUnichar('\\'):
-
-            // advance the iterator and be sure we haven't run off the end
-            //
-            ++iter;
-            if (iter == iterEnd) {
-
-                // abort; missing escaped char
-                //
-                if (consoleSvc) {
-                    consoleSvc->LogStringMessage(
-                        NS_LITERAL_STRING(
-                            "LDAP addressbook autocomplete formatter: error parsing format string: premature end of string after \\ escape").get());
-
-                    NS_ERROR("LDAP addressbook autocomplete formatter: error "
-                             "parsing format string: premature end of string "
-                             "after \\ escape");
-                }
-
-                return NS_ERROR_ILLEGAL_VALUE;
-            }
-
-            /*FALLTHROUGH*/
-
-        default:
-            
-            // if we're not just building an array of attribute names, append
-            // this character to the item we're generating.
-            //
-            if (!aAttrs) {
-
-                // this character gets treated as a literal
-                //
-                aValue->Append(NS_ConvertUTF16toUTF8(iter, 1));
-            }
-        }
-
-        ++iter; // advance the iterator
-    }
-
-    return NS_OK;
-}
-
-nsresult 
-nsAbLDAPAutoCompFormatter::ParseAttrName(
-    const PRUnichar **aIter,                     // iterators for mOutputString
-    const PRUnichar *aIterEnd, 
-    bool aAttrRequired,                       // required?  or just optional?
-    nsCOMPtr<nsIConsoleService> &aConsoleSvc,   // no need to reacquire this
-    nsACString &aAttrName)                      // attribute token
-{
-    // reset attrname, and move past the opening brace
-    //
-    ++(*aIter);
-
-    // get the rest of the attribute name
-    //
-    do {
-
-        // be sure we haven't run off the end
-        //
-        if (*aIter == aIterEnd) {
-
-            // abort; missing closing delimiter
-            //
-            if (aConsoleSvc) {
-                aConsoleSvc->LogStringMessage(
-                    NS_LITERAL_STRING(
-                        "LDAP address book autocomplete formatter: error parsing format string: missing } or ]").get());
-
-                NS_ERROR("LDAP address book autocomplete formatter: error "
-                         "parsing format string: missing } or ]");
-            }
-
-            return NS_ERROR_ILLEGAL_VALUE;
-
-        } else if ( (aAttrRequired && **aIter == PRUnichar('}')) ||
-                    (!aAttrRequired && **aIter == PRUnichar(']')) ) {
-
-            // done with this attribute
-            //
-            break;
-
-        } else {
-
-            // this must be part of the attribute name
-            //
-            aAttrName.Append(static_cast<char>(**aIter));
-        }
-
-        ++(*aIter);
-
-    } while (1);
-
-    return NS_OK;
-}
-
-nsresult
-nsAbLDAPAutoCompFormatter::AppendFirstAttrValue(
-    const nsACString &aAttrName, // attr to get
-    nsILDAPMessage *aMessage, // msg to get values from
-    bool aAttrRequired, // is this a required value?
-    nsACString &aValue)
-{
-    // get the attribute values for the field which will be used 
-    // to fill in nsIAutoCompleteItem::value
-    //
-    uint32_t numVals;
-    PRUnichar **values;
-
-    nsresult rv;
-    rv = aMessage->GetValues(nsCString(aAttrName).get(), &numVals, 
-                             &values);
-    if (NS_FAILED(rv)) {
-
-        switch (rv) {
-        case NS_ERROR_LDAP_DECODING_ERROR:
-            // this may not be an error, per se; it could just be that the 
-            // requested attribute does not exist in this particular message,
-            // either because we didn't request it with the search operation,
-            // or because it doesn't exist on the server.
-            //
-            break;
-
-        case NS_ERROR_OUT_OF_MEMORY:
-        case NS_ERROR_UNEXPECTED:
-            break;
-
-        default:
-            NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPSearchEntry(): "
-                     "unexpected return code from aMessage->getValues()");
-            rv = NS_ERROR_UNEXPECTED;
-            break;
-        }
-
-        // if this was a required attribute, don't append anything to aValue
-        // and return the error code
-        //
-        if (aAttrRequired) {
-            return rv;
-        } else {
-            // otherwise forget about this attribute, but return NS_OK, which
-            // will cause our caller to continue processing nameFormat in 
-            // order to generate an nsIAutoCompleteItem.
-            //
-            return NS_OK;
-        }
-    }
-
-    // append the value to our string; then free the array of results
-    //
-    aValue.Append(NS_ConvertUTF16toUTF8(values[0]));
-    NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numVals, values);
-
-    // if this attribute wasn't required, we fall through to here, and return 
-    // ok
-    //
-    return NS_OK;
-}
-
-// attribute AString nameFormat;
-NS_IMETHODIMP 
-nsAbLDAPAutoCompFormatter::GetNameFormat(nsAString & aNameFormat)
-{
-    aNameFormat  = mNameFormat;
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsAbLDAPAutoCompFormatter::SetNameFormat(const nsAString & aNameFormat)
-{
-    mNameFormat = aNameFormat; 
-    return NS_OK;
-}
-
-// attribute AString addressFormat;
-NS_IMETHODIMP 
-nsAbLDAPAutoCompFormatter::GetAddressFormat(nsAString & aAddressFormat)
-{
-    aAddressFormat  = mAddressFormat;
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsAbLDAPAutoCompFormatter::SetAddressFormat(const nsAString & 
-                                            aAddressFormat)
-{
-    mAddressFormat = aAddressFormat; 
-    return NS_OK;
-}
-
-// attribute AString commentFormat;
-NS_IMETHODIMP 
-nsAbLDAPAutoCompFormatter::GetCommentFormat(nsAString & aCommentFormat)
-{
-    aCommentFormat  = mCommentFormat;
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsAbLDAPAutoCompFormatter::SetCommentFormat(const nsAString & 
-                                            aCommentFormat)
-{
-    mCommentFormat = aCommentFormat; 
-
-    return NS_OK;
-}
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * 
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsStringGlue.h"
-#include "nsIAbLDAPAutoCompFormatter.h"
-#include "nsIConsoleService.h"
-#include "nsCOMPtr.h"
-
-class nsAbLDAPAutoCompFormatter : public nsIAbLDAPAutoCompFormatter
-{
-  public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSILDAPAUTOCOMPFORMATTER
-    NS_DECL_NSIABLDAPAUTOCOMPFORMATTER
-
-    nsAbLDAPAutoCompFormatter();
-    virtual ~nsAbLDAPAutoCompFormatter();
-
-  protected:
-    nsString mNameFormat;               // how to format these pieces
-    nsString mAddressFormat;
-    nsString mCommentFormat;
-
-    // parse and process format
-    nsresult ProcessFormat(const nsAString & aFormat,
-                           nsILDAPMessage *aMessage, 
-                           nsACString *aValue,
-                           nsCString *aAttrs);
-
-    // process a single attribute while parsing format
-    nsresult ParseAttrName(const PRUnichar **aIter,  
-                           const PRUnichar *aIterEnd, 
-                           bool aAttrRequired,
-                           nsCOMPtr<nsIConsoleService> & aConsoleSvc,
-                           nsACString & aAttrName);
-
-    // append the first value associated with aAttrName in aMessage to aValue
-    nsresult AppendFirstAttrValue(const nsACString &aAttrName, 
-                                  nsILDAPMessage *aMessage,
-                                  bool aAttrRequired,
-                                  nsACString &aValue);
-};
-
--- a/mailnews/addrbook/src/nsAddrbook.manifest
+++ b/mailnews/addrbook/src/nsAddrbook.manifest
@@ -1,12 +1,12 @@
 component {5b259db2-e451-4de9-8a6f-cfba91402973} nsAbAutoCompleteMyDomain.js
 contract @mozilla.org/autocomplete/search;1?name=mydomain {5b259db2-e451-4de9-8a6f-cfba91402973}
 component {2f946df9-114c-41fe-8899-81f10daf4f0c} nsAbAutoCompleteSearch.js
 contract @mozilla.org/autocomplete/search;1?name=addrbook {2f946df9-114c-41fe-8899-81f10daf4f0c}
 component {127b341a-bdda-4270-85e1-edff569a9b85} nsAbLDAPAttributeMap.js
 contract @mozilla.org/addressbook/ldap-attribute-map;1 {127b341a-bdda-4270-85e1-edff569a9b85}
 component {4ed7d5e1-8800-40da-9e78-c4f509d7ac5e} nsAbLDAPAttributeMap.js
 contract @mozilla.org/addressbook/ldap-attribute-map-service;1 {4ed7d5e1-8800-40da-9e78-c4f509d7ac5e}
-#ifdef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
+#ifdef MOZ_LDAP_XPCOM
 component {227e6482-fe9f-441f-9b7d-7b60375e7449} nsAbLDAPAutoCompleteSearch.js
 contract @mozilla.org/autocomplete/search;1?name=ldap {227e6482-fe9f-441f-9b7d-7b60375e7449}
-#endif
+#endif
\ No newline at end of file
deleted file mode 100644
--- a/mailnews/addrbook/src/nsLDAPAutoCompleteSession.cpp
+++ /dev/null
@@ -1,1247 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * 
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsLDAPAutoCompleteSession.h"
-#include "nsIComponentManager.h"
-#include "nsIServiceManager.h"
-#include "nsILDAPURL.h"
-#include "nsILDAPService.h"
-#include "nspr.h"
-#include "nsIStringBundle.h"
-#include "nsCRTGlue.h"
-#include "nsIObserverService.h"
-#include "nsNetUtil.h"
-#include "nsICategoryManager.h"
-#include "nsCategoryManagerUtils.h"
-#include "nsILDAPService.h"
-#include "nsILDAPMessage.h"
-#include "nsILDAPErrors.h"
-#include "nsXPCOMCIDInternal.h"
-
-#ifdef PR_LOGGING
-static PRLogModuleInfo *sLDAPAutoCompleteLogModule = 0;
-#endif
-
-
-// Because this object gets called via proxies, we need to use a THREADSAFE
-// ISUPPORTS; if bug 101252 gets fixed, we can go back to the non-threadsafe
-// version.
-//
-NS_IMPL_THREADSAFE_ISUPPORTS3(nsLDAPAutoCompleteSession, 
-                              nsIAutoCompleteSession, nsILDAPMessageListener,
-                              nsILDAPAutoCompleteSession)
-
-nsLDAPAutoCompleteSession::nsLDAPAutoCompleteSession() :
-    mState(UNBOUND), 
-    mFilterTemplate("(|(cn=%v1*%v2-*)(mail=%v1*%v2-*)(sn=%v1*%v2-*))"),
-    mMaxHits(100), mMinStringLength(2), mCjkMinStringLength(0), 
-    mVersion(nsILDAPConnection::VERSION3)
-{
-}
-
-nsLDAPAutoCompleteSession::~nsLDAPAutoCompleteSession()
-{
-    NS_IF_RELEASE(mConnection);
-}
-
-#define IS_CJK_CHAR_FOR_LDAP(u)  (0x2e80 <= (u) && (u) <= 0xd7ff)
-
-/* void onStartLookup (in wstring searchString, in nsIAutoCompleteResults previousSearchResult, in nsIAutoCompleteListener listener); */
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::OnStartLookup(const PRUnichar *searchString, 
-                                         nsIAutoCompleteResults *previousSearchResult,
-                                         nsIAutoCompleteListener *listener)
-{
-  NS_ENSURE_ARG_POINTER(listener);
-  if (!mFormatter)
-  {
-    NS_WARNING("mFormatter should not be null for nsLDAPAutoCompleteSession::OnStartLookup");
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-
-    nsresult rv; // Hold return values from XPCOM calls
-
-#ifdef PR_LOGGING
-    // Initialize logging, if it hasn't been already.
-    if (!sLDAPAutoCompleteLogModule) {
-        sLDAPAutoCompleteLogModule = PR_NewLogModule("ldapautocomplete");
-
-        NS_ABORT_IF_FALSE(sLDAPAutoCompleteLogModule, 
-                          "failed to initialize ldapautocomplete log module");
-    }
-#endif
-
-    PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-           ("nsLDAPAutoCompleteSession::OnStartLookup entered\n"));
-
-    mListener = listener;
-
-    // Ignore the empty string, strings with @ in them, and strings
-    // that are too short.
-    if (searchString[0] == 0 ||
-        nsDependentString(searchString).FindChar(PRUnichar('@'), 0) != -1 || 
-        nsDependentString(searchString).FindChar(PRUnichar(','), 0) != -1 || 
-        ( !IS_CJK_CHAR_FOR_LDAP(searchString[0]) ?
-          mMinStringLength && NS_strlen(searchString) < mMinStringLength :
-          mCjkMinStringLength && NS_strlen(searchString) < 
-          mCjkMinStringLength ) ) {
-
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::ignored, NS_OK, mState);
-        return NS_OK;
-    } else {
-        mSearchString = searchString;        // save it for later use
-    }
-
-    // Make sure this was called appropriately.
-    if (mState == SEARCHING || mState == BINDING) {
-        NS_ERROR("nsLDAPAutoCompleteSession::OnStartLookup(): called while "
-                 "search already in progress; no lookup started.");
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems,
-                                 NS_ERROR_FAILURE, mState);
-        return NS_ERROR_FAILURE;
-    }
-
-    // See if this is a narrow search that we could potentially do locally.
-    if (previousSearchResult) {
-
-        // Get the string representing previous search results.
-        nsString prevSearchStr;
-
-        rv = previousSearchResult->GetSearchString(
-            getter_Copies(prevSearchStr));
-        if ( NS_FAILED(rv) ) {
-            NS_ERROR("nsLDAPAutoCompleteSession::OnStartLookup(): couldn't "
-                     "get search string from previousSearchResult");
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, 
-                                     NS_ERROR_FAILURE, mState);
-            return NS_ERROR_FAILURE;
-        }
-
-        // Does the string actually contain anything?
-        if ( prevSearchStr.get() && prevSearchStr.get()[0]) {
-
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::OnStartLookup(): starting "
-                    "narrowing search\n"));
-
-            // XXXdmose for performance, we should really do a local,
-            // synchronous search against the existing dataset instead of
-            // just kicking off a new LDAP search here.  When implementing
-            // this, need to be sure that only previous results which did not
-            // hit the size limit and were successfully completed are used.
-            //
-            mState = SEARCHING;
-            return DoTask();
-        }
-    }
-
-    // Init connection if necessary
-    //
-    switch (mState) {
-    case UNBOUND:
-
-        // Initialize the connection.  
-        //
-        rv = InitConnection();
-        if (NS_FAILED(rv)) {
-
-            // InitConnection() will have already called
-            // FinishAutoCompleteLookup for us as necessary
-            //
-            return rv;
-        }
-
-        return NS_OK;
-
-    case BOUND:
-
-        PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-               ("nsLDAPAutoComplete::OnStartLookup(): subsequent search "
-                "starting"));
-
-        // Kick off an LDAP search
-        mState = SEARCHING;
-        return DoTask();
-
-    case INITIALIZING:
-        // We don't need to do anything here (for now at least), because
-        // we can't really abandon the initialization. If we allowed the
-        // initialization to be aborted, we could potentially lock the
-        // UI thread again, since the DNS service might be stalled.
-        //
-        return NS_OK;
-
-    case BINDING:
-    case SEARCHING:
-        // We should never get here
-        NS_ERROR("nsLDAPAutoCompleteSession::OnStartLookup(): unexpected "
-                 "value of mStatus");
-        return NS_ERROR_UNEXPECTED;
-    }
-    
-    return NS_ERROR_UNEXPECTED;     /*NOTREACHED*/
-}
-
-/* void onStopLookup (); */
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::OnStopLookup()
-{
-#ifdef PR_LOGGING
-    // Initialize logging, if it hasn't been already.
-    if (!sLDAPAutoCompleteLogModule) {
-        sLDAPAutoCompleteLogModule = PR_NewLogModule("ldapautocomplete");
-
-        NS_ABORT_IF_FALSE(sLDAPAutoCompleteLogModule, 
-                          "failed to initialize ldapautocomplete log module");
-    }
-#endif
-
-    PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-           ("nsLDAPAutoCompleteSession::OnStopLookup entered\n"));
-
-    switch (mState) {
-    case UNBOUND:
-        // Nothing to stop
-        return NS_OK;
-
-    case BOUND:
-        // Nothing to stop
-        return NS_OK;
-
-    case INITIALIZING:
-        // We can't or shouldn't abort the initialization, because then the
-        // DNS service can hang again...
-        //
-        return NS_OK;
-
-    case BINDING:
-    case SEARCHING:
-        // Abandon the operation, if there is one
-        if (mOperation) {
-            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->AbandonExt()");
-            }
-
-            // Force nsCOMPtr to release mOperation
-            mOperation = 0;
-        }
-
-        // Set the status properly, set to UNBOUND of we were binding, or
-        // to BOUND if we were searching.
-        mState = (mState == BINDING ? UNBOUND : BOUND);
-        if (mState == UNBOUND)
-          NS_IF_RELEASE(mConnection);
-    }
-
-    mResultsArray = 0;
-    mResults = 0;
-    mListener = 0;
-
-    return NS_OK;
-}
-
-/* void onAutoComplete (in wstring searchString, in nsIAutoCompleteResults previousSearchResult, in nsIAutoCompleteListener listener); */
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::OnAutoComplete(const PRUnichar *searchString, 
-                                 nsIAutoCompleteResults *previousSearchResult, 
-                                          nsIAutoCompleteListener *listener)
-{
-    // OnStopLookup should have already been called, so there's nothing to
-    // free here.  Additionally, as of this writing, no one is hanging around
-    // waiting for mListener->OnAutoComplete() to be called either, and if
-    // they were, it's unclear what we'd return, since we're not guaranteed
-    // to be in any particular state.  My suspicion is that this method
-    // (nsIAutoCompleteSession::OnAutoComplete) should probably be removed
-    // from the interface.
-
-    return NS_OK;
-}
-
-/**
- * Messages received are passed back via this function.
- *
- * @arg aMessage  The message that was returned, NULL if none was.
- *
- * void OnLDAPMessage (in nsILDAPMessage aMessage)
- */
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::OnLDAPMessage(nsILDAPMessage *aMessage)
-{
-    int32_t messageType;
-
-    // Just in case.
-    // XXXdmose the semantics of NULL are currently undefined, but are likely
-    // to be defined once we insert timeout handling code into the XPCOM SDK
-    // At that time we should figure out if this still the right thing to do.
-    if (!aMessage) {
-        return NS_OK;
-    }
-
-    // Figure out what sort of message was returned.
-    nsresult rv = aMessage->GetType(&messageType);
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPMessage(): unexpected "
-                 "error in aMessage->GetType()");
-       
-        // Don't call FinishAutoCompleteLookup(), as this could conceivably 
-        // be an anomaly, and perhaps the next message will be ok. If this
-        // really was a problem, this search should eventually get
-        // reaped by a timeout (once that code gets implemented).
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    // If this message is not associated with the current operation,
-    // discard it, since it is probably from a previous (aborted)
-    // operation.
-    bool isCurrent;
-    rv = IsMessageCurrent(aMessage, &isCurrent);
-    if (NS_FAILED(rv)) {
-        // IsMessageCurrent will have logged any necessary errors
-        return rv;
-    }
-    if ( ! isCurrent ) {
-        PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG,
-               ("nsLDAPAutoCompleteSession::OnLDAPMessage(): received message "
-                "from operation other than current one; discarded"));
-        return NS_OK;
-    }
-
-    // XXXdmose - we may want a small state machine either here or
-    // or in the nsLDAPConnection object, to make sure that things are
-    // happening in the right order and timing out appropriately. This will
-    // certainly depend on how timeouts are implemented, and how binding
-    // gets is dealt with by nsILDAPService. Also need to deal with the case
-    // where a bind callback happens after onStopLookup was called.
-    switch (messageType) {
-
-    case nsILDAPMessage::RES_BIND:
-
-        // A bind has completed
-        if (mState != BINDING) {
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::OnLDAPMessage(): LDAP bind "
-                    "entry returned after OnStopLookup() called; ignoring"));
-
-            // XXXdmose when nsLDAPService integration happens, need to make
-            // sure that the possibility of having an already bound
-            // connection, due to a previously unaborted bind, doesn't cause
-            // any problems.
-
-            return NS_OK;
-        }
-
-        rv = OnLDAPMessageBind(aMessage);
-        if (NS_FAILED(rv)) {
-          mState = UNBOUND;
-          FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, 
-                                   rv, UNBOUND);
-        }
-        else
-          mState = SEARCHING;
-
-        return rv;
-
-    case nsILDAPMessage::RES_SEARCH_ENTRY:
-        
-        // Ignore this if OnStopLookup was already called.
-        if (mState != SEARCHING) {
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::OnLDAPMessage(): LDAP search "
-                    "entry returned after OnStopLoookup() called; ignoring"));
-            return NS_OK;
-        }
-
-        // A search entry has been returned.
-        return OnLDAPSearchEntry(aMessage);
-
-    case nsILDAPMessage::RES_SEARCH_RESULT:
-
-        // Ignore this if OnStopLookup was already called.
-        if (mState != SEARCHING) {
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG,
-                   ("nsLDAPAutoCompleteSession::OnLDAPMessage(): LDAP search "
-                    "result returned after OnStopLookup called; ignoring"));
-            return NS_OK;
-        }
-
-        // The search is finished; we're all done.
-        return OnLDAPSearchResult(aMessage);
-
-    default:
-        
-        // Given the LDAP operations nsLDAPAutoCompleteSession uses, we should
-        // never get here. If we do get here in a release build, it's
-        // probably a bug, but maybe it's the LDAP server doing something
-        // weird. Might as well try and continue anyway. The session should
-        // eventually get reaped by the timeout code, if necessary.
-        //
-        NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPMessage(): unexpected "
-                 "LDAP message received");
-        return NS_OK;
-    }
-}
-
-void
-nsLDAPAutoCompleteSession::InitFailed(bool aCancelled)
-{
-  FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, NS_OK,
-                           UNBOUND);
-}
-
-// void onLDAPInit (in nsresult aStatus);
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::OnLDAPInit(nsILDAPConnection *aConn, nsresult aStatus)
-{
-  nsresult rv = nsAbLDAPListenerBase::OnLDAPInit(aConn, aStatus);
-
-  if (NS_SUCCEEDED(rv))
-    mState = BINDING;
-
-  return rv;
-}
-
-nsresult
-nsLDAPAutoCompleteSession::OnLDAPSearchEntry(nsILDAPMessage *aMessage)
-{
-    PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-           ("nsLDAPAutoCompleteSession::OnLDAPSearchEntry entered\n"));
-
-    // Make sure this is only getting called after DoTask has
-    // initialized the result set.
-    NS_ASSERTION(mResultsArray,
-                 "nsLDAPAutoCompleteSession::OnLDAPSearchEntry(): "
-                 "mResultsArrayItems is uninitialized");
-
-    // Errors in this method return an error (which ultimately gets
-    // ignored, since this is being called through an async proxy).
-    // But the important thing is that we're bailing out here rather
-    // than trying to generate a bogus nsIAutoCompleteItem. Also note
-    // that FinishAutoCompleteLookup is _NOT_ being called here, because
-    // this error may just have to do with this particular item.
-
-    // Generate an autocomplete item from this message by calling the
-    // formatter.
-    nsCOMPtr<nsIAutoCompleteItem> item;
-    nsresult rv = mFormatter->Format(aMessage, getter_AddRefs(item));
-    if (NS_FAILED(rv)) {
-        PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG,
-               ("nsLDAPAutoCompleteSession::OnLDAPSearchEntry(): "
-                "mFormatter->Format() failed"));
-        return NS_ERROR_FAILURE;
-    }
-
-  nsString itemValue;
-  item->GetValue(itemValue);
-
-  uint32_t nbrOfItems;
-  rv = mResultsArray->Count(&nbrOfItems);
-  if (NS_FAILED(rv)) {
-    NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPSearchEntry(): "
-             "mResultsArray->Count() failed");
-    return NS_ERROR_FAILURE;
-  }
-
-  int32_t insertPosition = 0;
-
-  nsCOMPtr<nsIAutoCompleteItem> currentItem;
-  for (; insertPosition < nbrOfItems; insertPosition++) {
-    currentItem = do_QueryElementAt(mResultsArray, insertPosition, &rv);
-
-    if (NS_FAILED(rv))
-      continue;
-
-    nsString currentItemValue;
-    currentItem->GetValue(currentItemValue);
-    if (itemValue < currentItemValue) 
-      break;
-  }
-
-  mResultsArray->InsertElementAt(item, insertPosition);
-
-  // Remember that something has been returned.
-  mEntriesReturned++;
-
-  return NS_OK;
-}
-
-nsresult
-nsLDAPAutoCompleteSession::OnLDAPSearchResult(nsILDAPMessage *aMessage)
-{
-    nsresult rv;        // Temp for return vals
-
-    PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-           ("nsLDAPAutoCompleteSession::OnLDAPSearchResult entered\n"));
-
-    // Figure out if we succeeded or failed, and set the status
-    // and default index appropriately.
-    AutoCompleteStatus status;
-    int32_t lderrno;
-
-    if (mEntriesReturned) {
-
-        status = nsIAutoCompleteStatus::matchFound;
-
-        // There's at least one match, so the default index should
-        // point to the first thing here.  This ensures that if the local
-        // addressbook autocomplete session only found foo@local.domain,
-        // this will be given preference.
-        rv = mResults->SetDefaultItemIndex(0);
-        if (NS_FAILED(rv)) {
-            NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPSearchResult(): "
-                     "mResults->SetDefaultItemIndex(0) failed");
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     BOUND);
-        }
-    } else {
-        // Note that we only look at the error code if there are no results for
-        // this session; if we got results and then an error happened, this
-        // is ignored, in part because it seems likely to be confusing to the
-        // user, and in part because it is likely to be scrolled out of view
-        // anyway.
-        aMessage->GetErrorCode(&lderrno);
-        if (lderrno != nsILDAPErrors::SUCCESS) {
-
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::OnLDAPSearchResult(): "
-                    "lderrno=%d\n", lderrno));
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, 
-                                     NS_ERROR_GENERATE_FAILURE(
-                                         NS_ERROR_MODULE_LDAP, lderrno), 
-                                     BOUND);
-            return NS_OK;
-        }
-
-        // We could potentially keep track of non-fatal errors to the
-        // search, and if there has been more than 1, and there are no entries,
-        // we could return |failed| instead of |noMatch|. It's unclear to me
-        // that this actually buys us anything though.
-        status = nsIAutoCompleteStatus::noMatch;
-    }
-
-    // Call the mListener's OnAutoComplete and clean up
-    //
-    // XXXdmose should we really leave the connection BOUND here?
-    FinishAutoCompleteLookup(status, NS_OK, BOUND);
-
-    return NS_OK;
-}
-
-nsresult
-nsLDAPAutoCompleteSession::DoTask()
-{
-    nsresult rv; // temp for xpcom return values
-
-    PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-           ("nsLDAPAutoCompleteSession::DoTask entered\n"));
-
-    // Create and initialize an LDAP operation (to be used for the search).
-    mOperation = 
-        do_CreateInstance("@mozilla.org/network/ldap-operation;1", &rv);
-
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
-                 "create @mozilla.org/network/ldap-operation;1");
-
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                 BOUND);
-        return NS_ERROR_FAILURE;
-    }
-
-    // Initialize the LDAP operation object.
-    rv = mOperation->Init(mConnection, this, nullptr);
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
-                 "initialize LDAP operation");
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                 BOUND);
-        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::DoTask(): 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::DoTask(): 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.
-    nsAutoCString urlFilter;
-    rv = mDirectoryUrl->GetFilter(urlFilter);
-    if ( NS_FAILED(rv) ){
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
-                                 BOUND);
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    // Get the LDAP service, since createFilter is called through it.
-    nsCOMPtr<nsILDAPService> ldapSvc = do_GetService(
-        "@mozilla.org/network/ldap-service;1", &rv);
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): couldn't "
-                 "get @mozilla.org/network/ldap-service;1");
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
-                                 BOUND);
-        return NS_ERROR_FAILURE;
-    }
-
-    // If urlFilter is unset (or set to the default "objectclass=*"), there's
-    // no need to AND in an empty search term, so leave prefix and suffix empty.
-    nsAutoCString prefix, suffix;
-    if (urlFilter.Length() && !urlFilter.EqualsLiteral("(objectclass=*)")) {
-
-        // If urlFilter isn't parenthesized, we need to add in parens so that
-        // the filter works as a term to &
-        if (urlFilter[0] != '(') {
-            prefix.AssignLiteral("(&(");
-            prefix.Append(urlFilter);
-            prefix.AppendLiteral(")");
-        } else {
-            prefix.AssignLiteral("(&");
-            prefix.Append(urlFilter);
-        }
-        
-        suffix = ')';
-    }
-
-    // Generate an LDAP search filter from mFilterTemplate. If it's unset,
-    // use the default.
-#define MAX_AUTOCOMPLETE_FILTER_SIZE 1024
-    nsAutoCString searchFilter;
-    rv = ldapSvc->CreateFilter(MAX_AUTOCOMPLETE_FILTER_SIZE,
-                               mFilterTemplate,
-                               prefix, suffix, EmptyCString(), 
-                               NS_ConvertUTF16toUTF8(mSearchString),
-                               searchFilter);
-    if (NS_FAILED(rv)) {
-        switch(rv) {
-
-        case NS_ERROR_OUT_OF_MEMORY:
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
-                                     BOUND);
-            return rv;
-
-        case NS_ERROR_NOT_AVAILABLE:
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::DoTask(): "
-                    "createFilter generated filter longer than max filter "
-                    "size of %d", MAX_AUTOCOMPLETE_FILTER_SIZE));
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
-                                     BOUND);
-            return rv;
-
-        case NS_ERROR_INVALID_ARG:
-        case NS_ERROR_UNEXPECTED:
-        default:
-
-            // All this stuff indicates code bugs.
-            NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): "
-                     "createFilter returned unexpected value");
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     BOUND);
-            return NS_ERROR_UNEXPECTED;
-        }
-
-    }
-
-    // If the results array for this search hasn't already been created, do
-    // so now. Note that we don't return ::failureItems here, because if
-    // there's no array, there's nowhere to put the items.
-    rv = CreateResultsArray();
-    if (NS_FAILED(rv)) {
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failed, rv, BOUND);
-    }
-
-    // Nothing returned yet!
-    mEntriesReturned = 0;
-    
-    // Get the base dn to search
-    nsAutoCString dn;
-    rv = mDirectoryUrl->GetDn(dn);
-    if ( NS_FAILED(rv) ){
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
-                                 BOUND);
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    // And the scope
-    int32_t scope;
-    rv = mDirectoryUrl->GetScope(&scope);
-    if ( NS_FAILED(rv) ){
-        mState = BOUND;
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                 BOUND);
-        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, mSearchAttrs, 0,
-                               mMaxHits);
-    if (NS_FAILED(rv)) {
-        switch(rv) {
-
-        case NS_ERROR_LDAP_ENCODING_ERROR:
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::DoTask(): SearchExt "
-                    "returned NS_ERROR_LDAP_ENCODING_ERROR"));
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     BOUND);
-            return NS_OK;
-
-        case NS_ERROR_LDAP_FILTER_ERROR:
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::DoTask(): SearchExt "
-                    "returned NS_ERROR_LDAP_FILTER_ERROR"));
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     BOUND);
-            return NS_OK;
-
-        case NS_ERROR_LDAP_SERVER_DOWN:
-            // XXXdmose discuss with leif how to handle this in general in the
-            // LDAP XPCOM SDK.
-
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::DoTask(): SearchExt "
-                    "returned NS_ERROR_LDAP_SERVER_DOWN"));
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv,
-                                     UNBOUND);
-            return NS_OK;
-
-        case NS_ERROR_OUT_OF_MEMORY:
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     BOUND);
-            return NS_ERROR_OUT_OF_MEMORY;
-
-        case NS_ERROR_LDAP_NOT_SUPPORTED:
-        case NS_ERROR_NOT_INITIALIZED:        
-        case NS_ERROR_INVALID_ARG:
-        default:
-
-            // All this stuff indicates code bugs.
-            NS_ERROR("nsLDAPAutoCompleteSession::DoTask(): SearchExt "
-                     "returned unexpected value");
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     BOUND);
-            return NS_ERROR_UNEXPECTED;
-        }
-    }
-
-    return NS_OK;
-}
-
-// XXXdmose - stopgap routine until nsLDAPService is working
-//
-nsresult
-nsLDAPAutoCompleteSession::InitConnection()
-{
-    nsresult rv;        // temp for xpcom return values
-    NS_ASSERTION(!mConnection, "in InitConnection w/ existing connection");
-
-    // Create an LDAP connection
-    nsCOMPtr<nsILDAPConnection> connection =
-      do_CreateInstance("@mozilla.org/network/ldap-connection;1", &rv);
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::InitConnection(): could "
-                 "not create @mozilla.org/network/ldap-connection;1");
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                 UNBOUND);
-        return NS_ERROR_FAILURE;
-    }
-
-    NS_ADDREF(mConnection = connection);
-
-    // Have we been properly initialized?
-    if (!mDirectoryUrl) {
-        NS_ERROR("nsLDAPAutoCompleteSession::InitConnection(): mDirectoryUrl "
-                 "is NULL");
-        FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                 UNBOUND);
-        return NS_ERROR_NOT_INITIALIZED;
-    }
-
-    // Initialize the connection. This will cause an asynchronous DNS
-    // lookup to occur, and we'll finish the binding of the connection
-    // in the OnLDAPInit() listener function.
-    rv = mConnection->Init(mDirectoryUrl, mLogin, this, nullptr, mVersion);
-    if (NS_FAILED(rv)) {
-        switch (rv) {
-
-        case NS_ERROR_OUT_OF_MEMORY:
-        case NS_ERROR_NOT_AVAILABLE:
-        case NS_ERROR_FAILURE:
-            PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-                   ("nsLDAPAutoCompleteSession::InitConnection(): mSimpleBind "
-                    "failed, rv = 0x%lx", rv));
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     UNBOUND);
-            return rv;
-
-        case NS_ERROR_ILLEGAL_VALUE:
-        default:
-            FinishAutoCompleteLookup(nsIAutoCompleteStatus::failureItems, rv, 
-                                     UNBOUND);
-            return NS_ERROR_UNEXPECTED;
-        }
-    }
-
-    // Set our state
-    mState = INITIALIZING;
-
-    return NS_OK;
-}
-
-nsresult
-nsLDAPAutoCompleteSession::CreateResultsArray(void)
-{
-    nsresult rv;
-
-    // Create a result set
-    mResults = do_CreateInstance(NS_AUTOCOMPLETERESULTS_CONTRACTID, &rv);
-
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::DoTask() couldn't"
-                 " create " NS_AUTOCOMPLETERESULTS_CONTRACTID);
-        return NS_ERROR_FAILURE;
-    }
-
-    // This seems to be necessary for things to work, though I'm not sure
-    // why that's true.
-    rv = mResults->SetSearchString(mSearchString.get());
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPSearchResult(): couldn't "
-                 "set search string in results object");
-        return NS_ERROR_FAILURE;
-    }
-
-    // Get a pointer to the array in question now, so that we don't have to
-    // keep re-fetching it every time an entry callback happens.
-    rv = mResults->GetItems(getter_AddRefs(mResultsArray));
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::DoTask() couldn't "
-                 "get results array.");
-        return NS_ERROR_FAILURE;
-    }
-
-    return NS_OK;
-}
-
-void
-nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(
-    AutoCompleteStatus aACStatus, const nsresult aResult,
-    enum SessionState aEndState)
-{
-    nsCOMPtr<nsIAutoCompleteItem> errorItem; // pointer to item we may create
-    nsresult rv; // temp for return value 
-
-    // If there's a listener, inform the listener that the search is over.
-    rv = NS_OK;
-    if (mListener) {
-        
-        switch (aACStatus) {
-
-        case nsIAutoCompleteStatus::matchFound:
-            rv = mListener->OnAutoComplete(mResults, aACStatus);
-            break;
-
-        case nsIAutoCompleteStatus::failureItems:
-            // If the results array hasn't already been created, make one
-            // to return the error message.  If there's an error, fallback
-            // to ::failed
-            if (!mResults) {
-                rv = CreateResultsArray();
-                if (NS_FAILED(rv)) {
-                    NS_ERROR("nsLDAPAutoCompleteSession::"
-                             "FinishAutoCompleteLookup():"
-                             " CreateResultsArray() failed");
-                    rv = mListener->OnAutoComplete(0, 
-                                                nsIAutoCompleteStatus::failed);
-                    break;
-                }
-            }
-
-            // Create the error item.
-            rv = mFormatter->FormatException(mState, aResult,
-                                             getter_AddRefs(errorItem));
-            if (NS_SUCCEEDED(rv)) {
-
-                // Try and append the error item; falling back to ::failed
-                // if there's a problem.
-                //
-                rv = mResultsArray->AppendElement(errorItem);
-                if (NS_FAILED(rv)) {
-                    NS_ERROR("nsLDAPAutoCompleteSession::"
-                             "FinishAutoCompleteLookup():"
-                             " mItems->AppendElement() failed");
-                    rv = mListener->OnAutoComplete(0, 
-                                                nsIAutoCompleteStatus::failed);
-                    break;
-                } 
-
-                // We don't want the autocomplete widget trying to
-                // automagically use the error item for anything. If
-                // something goes wrong here, continue on anyway.
-                //
-                (void)mResults->SetDefaultItemIndex(-1);
-
-                rv = mListener->OnAutoComplete(mResults, 
-                                          nsIAutoCompleteStatus::failureItems);
-                break;
-            } 
-
-            // Fallback to ::failed
-            NS_ERROR("nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(): "
-                     "error calling FormatException()");
-
-            rv = mListener->OnAutoComplete(0, nsIAutoCompleteStatus::failed);
-            break;
-        
-        case nsIAutoCompleteStatus::failed:
-        default:
-            rv = mListener->OnAutoComplete(0, aACStatus);
-            break;
-        }
-
-    } else {
-        // If there's no listener, something's wrong.
-        NS_ERROR("nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(): "
-                 "called with mListener unset!");
-    }
-
-    if (NS_FAILED(rv)) {
-
-        // There's nothing we can actually do here other than warn.
-        NS_WARNING("nsLDAPAutoCompleteSession::FinishAutoCompleteLookup(): "
-                   "error calling mListener->OnAutoComplete()");
-    }
-
-    // Set the state appropriately.
-    mState = aEndState;
-
-    // We're done with various things; cause nsCOMPtr to release them.
-    mResultsArray = 0;
-    mResults = 0;
-    mListener = 0;
-    mOperation = 0;
-
-    // If we are unbound, drop the connection (if any).
-    if (mState == UNBOUND) {
-        NS_IF_RELEASE(mConnection);
-    }
-}
-
-// methods for nsILDAPAutoCompleteSession
-
-// attribute AUTF8String searchFilter;
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::GetFilterTemplate(nsACString & aFilterTemplate)
-{
-    aFilterTemplate.Assign(mFilterTemplate);
-
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::SetFilterTemplate(const nsACString & aFilterTemplate)
-{
-    mFilterTemplate.Assign(aFilterTemplate);
-
-    return NS_OK;
-}
-
-
-// attribute long maxHits;
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::GetMaxHits(int32_t *aMaxHits)
-{
-    if (!aMaxHits) {
-        return NS_ERROR_NULL_POINTER;
-    }
-
-    *aMaxHits = mMaxHits;
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::SetMaxHits(int32_t aMaxHits)
-{
-    if ( aMaxHits < -1 || aMaxHits > 65535) {
-        return NS_ERROR_ILLEGAL_VALUE;
-    }
-
-    mMaxHits = aMaxHits;
-    return NS_OK;
-}
-
-// attribute nsILDAPURL serverURL; 
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::GetServerURL(nsILDAPURL * *aServerURL)
-{
-    if (! aServerURL ) {
-        return NS_ERROR_NULL_POINTER;
-    }
-    
-    NS_IF_ADDREF(*aServerURL = mDirectoryUrl);
-
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::SetServerURL(nsILDAPURL * aServerURL)
-{
-    if (! aServerURL ) {
-        return NS_ERROR_NULL_POINTER;
-    }
-
-    mDirectoryUrl = aServerURL;
-
-    // The following line will cause the next call to OnStartLookup to
-    // call InitConnection again. This will reinitialize all the relevant
-    // member variables and kick off an LDAP bind. By virtue of the magic of
-    // nsCOMPtrs, doing this will cause all the nsISupports-based stuff to
-    // be Released, which will eventually result in the old connection being
-    // destroyed, and the destructor for that calls ldap_unbind()
-    mState = UNBOUND;
-
-    return NS_OK;
-}
-
-// attribute unsigned long minStringLength
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::GetMinStringLength(uint32_t *aMinStringLength)
-{
-    if (!aMinStringLength) {
-        return NS_ERROR_NULL_POINTER;
-    }
-
-    *aMinStringLength = mMinStringLength;
-    return NS_OK;
-}
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::SetMinStringLength(uint32_t aMinStringLength)
-{
-    mMinStringLength = aMinStringLength;
-
-    return NS_OK;
-}
-
-// attribute unsigned long cjkMinStringLength
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::GetCjkMinStringLength(uint32_t *aCjkMinStringLength)
-{
-    if (!aCjkMinStringLength) {
-        return NS_ERROR_NULL_POINTER;
-    }
-
-    *aCjkMinStringLength = mCjkMinStringLength;
-    return NS_OK;
-}
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::SetCjkMinStringLength(uint32_t aCjkMinStringLength)
-{
-    mCjkMinStringLength = aCjkMinStringLength;
-
-    return NS_OK;
-}
-
-// Check to see if the message returned is related to our current operation
-// if there is no current operation, it's not. :-)
-nsresult 
-nsLDAPAutoCompleteSession::IsMessageCurrent(nsILDAPMessage *aMessage, 
-                                            bool *aIsCurrent)
-{
-    // If there's no operation, this message must be stale (ie non-current).
-    if ( !mOperation ) {
-        *aIsCurrent = false;
-        return NS_OK;
-    }
-
-    // Get the message id from the current operation.
-    int32_t currentId;
-    nsresult rv = mOperation->GetMessageID(&currentId);
-    if (NS_FAILED(rv)) {
-        PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-               ("nsLDAPAutoCompleteSession::IsMessageCurrent(): unexpected "
-                "error 0x%lx calling mOperation->GetMessageId()", rv));
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    // Get the message operation from the message.
-    nsCOMPtr<nsILDAPOperation> msgOp;
-    rv = aMessage->GetOperation(getter_AddRefs(msgOp));
-    if (NS_FAILED(rv)) {
-        PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-               ("nsLDAPAutoCompleteSession::IsMessageCurrent(): unexpected "
-                "error 0x%lx calling aMessage->GetOperation()", rv));
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    // Get the message operation id from the message operation.
-    int32_t msgOpId;
-    rv = msgOp->GetMessageID(&msgOpId);
-    if (NS_FAILED(rv)) {
-        PR_LOG(sLDAPAutoCompleteLogModule, PR_LOG_DEBUG, 
-               ("nsLDAPAutoCompleteSession::IsMessageCurrent(): unexpected "
-                "error 0x%lx calling msgOp->GetMessageId()", rv));
-        return NS_ERROR_UNEXPECTED;
-    }
-    
-    *aIsCurrent = (msgOpId == currentId);
-
-    return NS_OK;
-}
-
-// attribute nsILDAPAutoCompFormatter formatter
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::GetFormatter(nsILDAPAutoCompFormatter* *aFormatter)
-{
-    if (! aFormatter ) {
-        return NS_ERROR_NULL_POINTER;
-    }
-    
-    NS_IF_ADDREF(*aFormatter = mFormatter);
-
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::SetFormatter(nsILDAPAutoCompFormatter* aFormatter)
-{
-    if (! aFormatter ) {
-        return NS_ERROR_NULL_POINTER;
-    }
-
-    NS_ASSERTION(mState == UNBOUND || mState == BOUND, 
-                 "nsLDAPAutoCompleteSession::SetFormatter was called when "
-                 "mState was set to something other than BOUND or UNBOUND");
-
-    mFormatter = aFormatter;
-
-    // Get and cache the attributes that will be used to do lookups.
-    nsresult rv = mFormatter->GetAttributes(mSearchAttrs);
-    if (NS_FAILED(rv)) {
-        NS_ERROR("nsLDAPAutoCompleteSession::SetFormatter(): "
-                 " mFormatter->GetAttributes failed");
-        return NS_ERROR_FAILURE;
-    }
-    
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::SetLogin(const nsACString & aLogin)
-{
-    mLogin = aLogin;
-    return NS_OK;
-}
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::GetLogin(nsACString & aLogin) 
-{
-    aLogin = mLogin;
-    return NS_OK;
-}
-
-// attribute ACString saslMechanism
-
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::SetSaslMechanism(const nsACString & aSaslMechanism)
-{
-    mSaslMechanism.Assign(aSaslMechanism);
-    return NS_OK;
-}
-NS_IMETHODIMP
-nsLDAPAutoCompleteSession::GetSaslMechanism(nsACString & aSaslMechanism)
-{
-    aSaslMechanism.Assign(mSaslMechanism);
-    return NS_OK;
-}
-
-// attribute unsigned long version;
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::GetVersion(uint32_t *aVersion)
-{
-    if (!aVersion) {
-        return NS_ERROR_NULL_POINTER;
-    }
-
-    *aVersion = mVersion;
-    return NS_OK;
-}
-NS_IMETHODIMP 
-nsLDAPAutoCompleteSession::SetVersion(uint32_t aVersion)
-{
-    if ( mVersion != nsILDAPConnection::VERSION2 && 
-         mVersion != nsILDAPConnection::VERSION3) {
-        return NS_ERROR_ILLEGAL_VALUE;
-    }
-
-    mVersion = 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;
-}
deleted file mode 100644
--- a/mailnews/addrbook/src/nsLDAPAutoCompleteSession.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * 
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/Attributes.h"
-#include "nsCOMPtr.h"
-#include "nsIAutoCompleteSession.h"
-#include "nsILDAPConnection.h"
-#include "nsILDAPOperation.h"
-#include "nsILDAPAutoCompleteSession.h"
-#include "nsILDAPAutoCompFormatter.h"
-#include "nsILDAPURL.h"
-#include "nsStringGlue.h"
-#include "nsISupportsArray.h"
-#include "nsIConsoleService.h"
-#include "nsIMutableArray.h"
-#include "nsAbLDAPListenerBase.h"
-
-// 964665d0-1dd1-11b2-aeae-897834fb00b9
-//
-#define NS_LDAPAUTOCOMPLETESESSION_CID \
-{ 0x964665d0, 0x1dd1, 0x11b2, \
- { 0xae, 0xae, 0x89, 0x78, 0x34, 0xfb, 0x00, 0xb9 }}
-
-class nsLDAPAutoCompleteSession : public nsAbLDAPListenerBase,
-                                  public nsILDAPAutoCompleteSession
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIAUTOCOMPLETESESSION
-  NS_DECL_NSILDAPAUTOCOMPLETESESSION
-
-  nsLDAPAutoCompleteSession();
-  virtual ~nsLDAPAutoCompleteSession();
-
-  NS_IMETHOD OnLDAPMessage(nsILDAPMessage *aMessage) MOZ_OVERRIDE;
-  NS_IMETHOD OnLDAPInit(nsILDAPConnection *aConn, nsresult aStatus) MOZ_OVERRIDE;
-
-protected:
-  // Called if an LDAP initialization fails.
-  virtual void InitFailed(bool aCancelled = false) MOZ_OVERRIDE;
-
-  // Called to start off the required task after a bind.
-  virtual nsresult DoTask() MOZ_OVERRIDE;
-
-    enum SessionState { 
-        UNBOUND = nsILDAPAutoCompFormatter::STATE_UNBOUND,
-        INITIALIZING = nsILDAPAutoCompFormatter::STATE_INITIALIZING, 
-        BINDING = nsILDAPAutoCompFormatter::STATE_BINDING, 
-        BOUND = nsILDAPAutoCompFormatter::STATE_BOUND, 
-        SEARCHING = nsILDAPAutoCompFormatter::STATE_SEARCHING 
-    } mState;
-    uint32_t mEntriesReturned;                    // # of entries returned?
-    nsCOMPtr<nsIAutoCompleteListener> mListener;  // callback 
-    nsCOMPtr<nsIAutoCompleteResults> mResults;    // being built up
-    nsCOMPtr<nsISupportsArray> mResultsArray;     // cached, to avoid re-gets
-    nsString mSearchString;                       // autocomplete this string
-    nsCString mFilterTemplate;                    // search filter template
-    int32_t mMaxHits;                       // return at most this many entries
-    uint32_t mMinStringLength;              // strings < this size are ignored
-    uint32_t mCjkMinStringLength;           // ignore CJK strings < this size
-    nsCString mSearchAttrs;     // outputFormat search attrs for SearchExt call
-    uint32_t mVersion;                      // version of LDAP to use
-
-    // used to format the ldap message into an nsIAutoCompleteItem
-    //
-    nsCOMPtr<nsILDAPAutoCompFormatter> mFormatter;
-
-    // stopgap until nsLDAPService works
-    nsresult InitConnection();             
-
-    // check that we bound ok and start then call StartLDAPSearch
-    nsresult OnLDAPBind(nsILDAPMessage *aMessage); 
-
-    // add to the results set
-    nsresult OnLDAPSearchEntry(nsILDAPMessage *aMessage); 
-
-    // all done; call OnAutoComplete
-    nsresult OnLDAPSearchResult(nsILDAPMessage *aMessage); 
-
-    // check if the LDAP message received is current
-    nsresult IsMessageCurrent(nsILDAPMessage *aMessage, bool *aIsCurrent);
-
-    // finish a search by calling mListener->OnAutoComplete, resetting state,
-    // and freeing resources.  if aACStatus == 
-    // nsIAutoCompleteStatus::failureItems, then the formatter is called with
-    // aResult and aEndState to create an autocomplete item with the error
-    // info in it.  See nsILDAPAutoCompFormatter.idl for more info on this.
-    void FinishAutoCompleteLookup(AutoCompleteStatus aACStatus, 
-                                  const nsresult aResult,
-                                  enum SessionState aEndState);
-
-    // create and initialize the results array
-    nsresult CreateResultsArray(void);
-
-    nsCOMPtr<nsIMutableArray> mSearchServerControls;
-    nsCOMPtr<nsIMutableArray> mSearchClientControls;
-};
-
--- a/mailnews/build/Makefile.in
+++ b/mailnews/build/Makefile.in
@@ -20,19 +20,16 @@ else
 MOZILLA_INTERNAL_API = 1
 LIBXUL_LIBRARY	= 1
 endif
 FORCE_USE_PIC   = 1
 
 
 ifdef MOZ_LDAP_XPCOM
 DEFINES		+= -DMOZ_LDAP_XPCOM
-ifdef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-DEFINES += -DMOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-endif
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 DEFINES		+= -DZLIB_DLL
 endif
 
 SHARED_LIBRARY_LIBS = \
 	        ../base/util/$(LIB_PREFIX)msgbsutl_s.$(LIB_SUFFIX) \
--- a/mailnews/build/nsMailModule.cpp
+++ b/mailnews/build/nsMailModule.cpp
@@ -148,20 +148,16 @@
 #include "nsAbLDAPDirFactory.h"
 #include "nsAbLDAPReplicationService.h"
 #include "nsAbLDAPReplicationQuery.h"
 #include "nsAbLDAPReplicationData.h"
 // XXX These files are not being built as they don't work. Bug 311632 should
 // fix them.
 //#include "nsAbLDAPChangeLogQuery.h"
 //#include "nsAbLDAPChangeLogData.h"
-#ifndef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-#include "nsAbLDAPAutoCompFormatter.h"
-#include "nsLDAPAutoCompleteSession.h"
-#endif
 #endif
 
 
 #if defined(MOZ_MAPI_SUPPORT)
 #include "nsAbOutlookDirFactory.h"
 #include "nsAbOutlookDirectory.h"
 #endif
 
@@ -467,20 +463,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPC
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPDirFactory)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPReplicationService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPReplicationQuery)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPProcessReplicationData)
 // XXX These files are not being built as they don't work. Bug 311632 should
 // fix them.
 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPChangeLogQuery)
 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPProcessChangeLogData)
-#ifndef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPAutoCompFormatter)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsLDAPAutoCompleteSession)
-#endif
 #endif
 
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryProxy)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbView)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgVCardService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDIFService)
 
@@ -514,20 +506,16 @@ NS_DEFINE_NAMED_CID(NS_ABOUTLOOKDIRFACTO
 #if defined(MOZ_LDAP_XPCOM)
 NS_DEFINE_NAMED_CID(NS_ABLDAPDIRECTORY_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAPDIRECTORYQUERY_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAPCARD_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAPDIRFACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAP_REPLICATIONSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAP_REPLICATIONQUERY_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAP_PROCESSREPLICATIONDATA_CID);
-#ifndef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-NS_DEFINE_NAMED_CID(NS_ABLDAPAUTOCOMPFORMATTER_CID);
-NS_DEFINE_NAMED_CID(NS_LDAPAUTOCOMPLETESESSION_CID);
-#endif
 #endif
 NS_DEFINE_NAMED_CID(NS_ABDIRECTORYQUERYPROXY_CID);
 #ifdef XP_MACOSX
 NS_DEFINE_NAMED_CID(NS_ABOSXDIRECTORY_CID);
 NS_DEFINE_NAMED_CID(NS_ABOSXCARD_CID);
 NS_DEFINE_NAMED_CID(NS_ABOSXDIRFACTORY_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_ABVIEW_CID);
@@ -899,20 +887,16 @@ const mozilla::Module::CIDEntry kMailNew
 #if defined(MOZ_LDAP_XPCOM)
   { &kNS_ABLDAPDIRECTORY_CID, false, NULL, nsAbLDAPDirectoryConstructor },
   { &kNS_ABLDAPDIRECTORYQUERY_CID, false, NULL, nsAbLDAPDirectoryQueryConstructor },
   { &kNS_ABLDAPCARD_CID, false, NULL, nsAbLDAPCardConstructor },
   { &kNS_ABLDAP_REPLICATIONSERVICE_CID, false, NULL, nsAbLDAPReplicationServiceConstructor },
   { &kNS_ABLDAP_REPLICATIONQUERY_CID, false, NULL, nsAbLDAPReplicationQueryConstructor },
   { &kNS_ABLDAP_PROCESSREPLICATIONDATA_CID, false, NULL, nsAbLDAPProcessReplicationDataConstructor },
   { &kNS_ABLDAPDIRFACTORY_CID, false, NULL, nsAbLDAPDirFactoryConstructor },
-#ifndef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-  { &kNS_ABLDAPAUTOCOMPFORMATTER_CID, false, NULL, nsAbLDAPAutoCompFormatterConstructor },
-  { &kNS_LDAPAUTOCOMPLETESESSION_CID, false, NULL, nsLDAPAutoCompleteSessionConstructor },
-#endif
 #endif
   { &kNS_ABDIRECTORYQUERYPROXY_CID, false, NULL, nsAbDirectoryQueryProxyConstructor },
 #ifdef XP_MACOSX
   { &kNS_ABOSXDIRECTORY_CID, false, NULL, nsAbOSXDirectoryConstructor },
   { &kNS_ABOSXCARD_CID, false, NULL, nsAbOSXCardConstructor },
   { &kNS_ABOSXDIRFACTORY_CID, false, NULL, nsAbOSXDirFactoryConstructor },
 #endif
   { &kNS_ABVIEW_CID, false, NULL, nsAbViewConstructor },
@@ -1106,20 +1090,16 @@ const mozilla::Module::ContractIDEntry k
   { NS_ABLDAPDIRECTORYQUERY_CONTRACTID, &kNS_ABLDAPDIRECTORYQUERY_CID },
   { NS_ABLDAPCARD_CONTRACTID, &kNS_ABLDAPCARD_CID },
   { NS_ABLDAPDIRFACTORY_CONTRACTID, &kNS_ABLDAPDIRFACTORY_CID },
   { NS_ABLDAP_REPLICATIONSERVICE_CONTRACTID, &kNS_ABLDAP_REPLICATIONSERVICE_CID },
   { NS_ABLDAP_REPLICATIONQUERY_CONTRACTID, &kNS_ABLDAP_REPLICATIONQUERY_CID },
   { NS_ABLDAP_PROCESSREPLICATIONDATA_CONTRACTID, &kNS_ABLDAP_PROCESSREPLICATIONDATA_CID },
   { NS_ABLDAPACDIRFACTORY_CONTRACTID, &kNS_ABLDAPDIRFACTORY_CID },
   { NS_ABLDAPSACDIRFACTORY_CONTRACTID, &kNS_ABLDAPDIRFACTORY_CID },
-#ifndef MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE
-  { NS_ABLDAPAUTOCOMPFORMATTER_CONTRACTID, &kNS_ABLDAPAUTOCOMPFORMATTER_CID },
-  { "@mozilla.org/autocompleteSession;1?type=ldap", &kNS_LDAPAUTOCOMPLETESESSION_CID },
-#endif
 #endif
 
   { NS_ABDIRECTORYQUERYPROXY_CONTRACTID, &kNS_ABDIRECTORYQUERYPROXY_CID },
 #ifdef XP_MACOSX
   { NS_ABOSXDIRECTORY_CONTRACTID, &kNS_ABOSXDIRECTORY_CID },
   { NS_ABOSXCARD_CONTRACTID, &kNS_ABOSXCARD_CID },
   { NS_ABOSXDIRFACTORY_CONTRACTID, &kNS_ABOSXDIRFACTORY_CID },
 #endif
--- a/suite/configure.in
+++ b/suite/configure.in
@@ -55,38 +55,32 @@ dnl ====================================
 dnl = LDAP
 dnl =========================================================
 MOZ_ARG_DISABLE_BOOL(ldap,
 [  --disable-ldap          Disable LDAP support],
     MOZ_LDAP_XPCOM=,
     MOZ_LDAP_XPCOM=1)
 
 if test "$MOZ_LDAP_XPCOM"; then
-    MOZ_ARG_ENABLE_BOOL(incomplete-toolkit-ldap-autocomplete,
-    [  --enable-incomplete-toolkit-ldap-autocomplete Builds a JavaScript component that implements an LDAP autocomplete component using the toolkit interfaces rather than the C++ component using the obsolete XPFE interfaces. ],
-        MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE=1,
-        MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE= )
-
     LDAP_CFLAGS='-I${DIST}/public/ldap'
     if test "$OS_ARCH" = "WINNT"; then
         if test -n "$GNU_CC"; then
             LDAP_LIBS='-L$(DIST)/lib -lnsldap32v60 -lnsldappr32v60 -lnsldif32v60'
         else
             LDAP_LIBS='$(DIST)/lib/$(LIB_PREFIX)nsldap32v60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)nsldappr32v60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)nsldif32v60.${IMPORT_LIB_SUFFIX}'
         fi
     elif test "$OS_ARCH" = "OS2"; then
             LDAP_LIBS='$(DIST)/lib/$(LIB_PREFIX)ldap60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)prldap60.${IMPORT_LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)ldif60.${IMPORT_LIB_SUFFIX}'
     else
         LDAP_LIBS='-L${DIST}/bin -L${DIST}/lib -lldap60 -lprldap60 -lldif60'
     fi
 
     LDAP_COMPONENT=mozldap
     LDAP_MODULE="MODULE(nsLDAPProtocolModule)"
 fi
-AC_SUBST(MOZ_INCOMPLETE_TOOLKIT_LDAP_AUTOCOMPLETE)
 
 AC_SUBST(MOZ_LDAP_XPCOM)
 AC_SUBST(LDAP_CFLAGS)
 AC_SUBST(LDAP_LIBS)
 
 dnl =========================================================
 dnl = MAPI support (Windows only)
 dnl =========================================================