Bug 1637918 - Remove dead LDAP address book code. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 07 May 2020 21:25:00 +1200
changeset 39151 43d2da70f9d379bed1bb5f8dd2ebd0b16715b48d
parent 39150 b49e6cda4e016e78743e2a50ec5293a60433484e
child 39152 ced94145e95c92495ccab66e4d5ac45517bcf009
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersmkmelin
bugs1637918
Bug 1637918 - Remove dead LDAP address book code. r=mkmelin
mailnews/addrbook/public/moz.build
mailnews/addrbook/public/nsAbBaseCID.h
mailnews/addrbook/public/nsIAbLDAPCard.idl
mailnews/addrbook/public/nsIAbLDAPDirectory.idl
mailnews/addrbook/public/nsIAbLDAPReplicationData.idl
mailnews/addrbook/src/moz.build
mailnews/addrbook/src/nsAbLDAPCard.cpp
mailnews/addrbook/src/nsAbLDAPCard.h
mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
mailnews/addrbook/src/nsAbLDAPChangeLogData.h
mailnews/addrbook/src/nsAbLDAPChangeLogQuery.cpp
mailnews/addrbook/src/nsAbLDAPChangeLogQuery.h
mailnews/addrbook/src/nsAbLDAPDirectory.cpp
mailnews/addrbook/src/nsAbLDAPDirectory.h
mailnews/addrbook/src/nsAbLDAPDirectoryModify.cpp
mailnews/addrbook/src/nsAbLDAPDirectoryModify.h
mailnews/addrbook/src/nsAbLDAPDirectoryQuery.cpp
mailnews/addrbook/src/nsAbLDAPReplicationData.cpp
mailnews/addrbook/src/nsAbLDAPReplicationData.h
mailnews/addrbook/src/nsAbLDAPReplicationService.cpp
mailnews/addrbook/src/nsAbLDAPReplicationService.h
mailnews/build/nsMailModule.cpp
--- a/mailnews/addrbook/public/moz.build
+++ b/mailnews/addrbook/public/moz.build
@@ -18,17 +18,16 @@ XPIDL_SOURCES += [
     'nsIAbManager.idl',
     'nsIAddbookUrl.idl',
     'nsIAddrDatabase.idl',
     'nsIMsgVCardService.idl',
 ]
 
 if CONFIG['MOZ_LDAP_XPCOM']:
     XPIDL_SOURCES += [
-        'nsIAbLDAPCard.idl',
         'nsIAbLDAPDirectory.idl',
         'nsIAbLDAPReplicationData.idl',
         'nsIAbLDAPReplicationQuery.idl',
         'nsIAbLDAPReplicationService.idl',
     ]
 
 if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_MAPI_SUPPORT']:
     XPIDL_SOURCES += [
--- a/mailnews/addrbook/public/nsAbBaseCID.h
+++ b/mailnews/addrbook/public/nsAbBaseCID.h
@@ -229,28 +229,16 @@
 #define NS_ABLDAPDIRECTORYQUERY_CID                  \
   {                                                  \
     0x783E2777, 0x66D7, 0x4826, {                    \
       0x9E, 0x4B, 0x8A, 0xB5, 0x8C, 0x22, 0x8A, 0x53 \
     }                                                \
   }
 
 //
-// nsAbLDAPCard
-//
-#define NS_ABLDAPCARD_CONTRACTID "@mozilla.org/addressbook/moz-abldapcard"
-
-#define NS_ABLDAPCARD_CID                            \
-  {                                                  \
-    0x10307B01, 0xEBD6, 0x465F, {                    \
-      0xB9, 0x72, 0x16, 0x30, 0x41, 0x0F, 0x70, 0xE6 \
-    }                                                \
-  }
-
-//
 // LDAP directory factory
 //
 #define NS_ABLDAPDIRFACTORY_CONTRACTID \
   NS_AB_DIRECTORY_FACTORY_CONTRACTID_PREFIX "moz-abldapdirectory"
 
 #define NS_ABLDAPDIRFACTORY_CID                      \
   {                                                  \
     0x8e3701af, 0x8828, 0x426c, {                    \
deleted file mode 100644
--- a/mailnews/addrbook/public/nsIAbLDAPCard.idl
+++ /dev/null
@@ -1,53 +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 "nsISupports.idl"
-
-interface nsIAbLDAPAttributeMap;
-interface nsILDAPModification;
-interface nsILDAPMessage;
-interface nsIArray;
-
-[scriptable, uuid(2831b3b0-30ef-4070-8ad3-90ae04980e11)]
-interface nsIAbLDAPCard : nsISupports
-{
-  /**
-   * Returns the required information for an LDAP update message.
-   *
-   * @param  aAttrMap    The map between LDAP attributes and card properties
-   * @param  aClasses    The objectClass values that the card needs to have
-   * @param  updateType  This should be one of:
-   *                         nsILDAPModification::MOD_ADD
-   *                         nsILDAPModification::MOD_REPLACE
-   *
-   * @return             Returns an array of modifications required to
-   *                     add or replace the card in the ldap directory.
-   */
-  nsIArray getLDAPMessageInfo(in nsIAbLDAPAttributeMap aAttrMap,
-                              in Array<ACString> aClasses,
-                              in long updateType);
-
-  /**
-   * Builds a relative distinguished name (RDN) with the given set of
-   * attributes.
-   *
-   * @param  aAttrMap    The map between LDAP attributes and card properties
-   * @param  aAttributes The attributes to use for the RDN
-   *
-   * @return             The resulting RDN.
-   */
-  ACString buildRdn(in nsIAbLDAPAttributeMap aAttrMap,
-                    in Array<ACString> aAttributes);
-
-  /**
-   * Stores meta-properties from a raw LDAP search result.
-   *
-   * @param aMessage     The LDAP search result message.
-   *
-   */
-  void setMetaProperties(in nsILDAPMessage aMessage);
-
-  attribute ACString dn;
-};
--- a/mailnews/addrbook/public/nsIAbLDAPDirectory.idl
+++ b/mailnews/addrbook/public/nsIAbLDAPDirectory.idl
@@ -1,16 +1,15 @@
 /* -*- 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 "nsISupports.idl"
 
-interface nsIMutableArray;
 interface nsIFile;
 interface nsIAddrDatabase;
 interface nsIAbLDAPAttributeMap;
 interface nsILDAPURL;
 
 %{C++
 #define kLDAPDirectoryRoot         "moz-abldapdirectory://"
 #define kLDAPDirectoryRootLen      22
@@ -19,23 +18,16 @@ interface nsILDAPURL;
 /**
  * XXX This should really inherit from nsIAbDirectory, and some day it will.
  * But for now, doing that complicates implementation.
  */
 [scriptable, uuid(90dde295-e354-4d58-Add8-f9b29a95942d)]
 interface nsIAbLDAPDirectory : nsISupports
 {
   /**
-   * If set, these arrays of nsILDAPControls are passed through to the
-   * nsILDAPOperation that searchExt is called on.
-   */
-  attribute nsIMutableArray searchServerControls;
-  attribute nsIMutableArray searchClientControls;
-
-  /**
    * The Replication File Name to use.
    */
   attribute ACString replicationFileName;
 
   /**
    * The version of LDAP protocol in use.
    */
   attribute unsigned long protocolVersion;
--- a/mailnews/addrbook/public/nsIAbLDAPReplicationData.idl
+++ b/mailnews/addrbook/public/nsIAbLDAPReplicationData.idl
@@ -34,29 +34,16 @@ interface nsIAbLDAPProcessReplicationDat
     const long kAuthenticating        = 6;
     const long kReplicatingAll        = 7;
     const long kSearchingRootDSE      = 8;
     const long kFindingChanges        = 9;
     const long kReplicatingChanges    = 10;
     const long kReplicationDone       = 11;
 
    /**
-     * readonly attribute giving the current protocol used
-     */
-    readonly attribute int32_t protocolUsed ;
-
-   /**
-     * replication protocols
-     */
-    const long kDefaultDownloadAll         = 0;
-    const long kChangeLogProtocol          = 1;
-    const long kLCUPProtocol               = 2;
-    const long kLastUpdatedTimeStampMethod = 3;
-
-   /**
      * this method initializes the implementation
      */
     void init(in nsIAbLDAPDirectory directory,
               in nsILDAPConnection connection,
               in nsILDAPURL url,
               in nsIAbLDAPReplicationQuery query,
               in nsIWebProgressListener progressListener);
 
--- a/mailnews/addrbook/src/moz.build
+++ b/mailnews/addrbook/src/moz.build
@@ -41,29 +41,23 @@ if CONFIG['OS_ARCH'] == 'Darwin':
         'nsAbOSXCard.mm',
         'nsAbOSXDirectory.mm',
         'nsAbOSXUtils.mm',
     ]
 
 if CONFIG['MOZ_LDAP_XPCOM']:
     SOURCES += [
         'nsAbBoolExprToLDAPFilter.cpp',
-        'nsAbLDAPCard.cpp',
         'nsAbLDAPDirectory.cpp',
-        'nsAbLDAPDirectoryModify.cpp',
         'nsAbLDAPDirectoryQuery.cpp',
         'nsAbLDAPListenerBase.cpp',
         'nsAbLDAPReplicationData.cpp',
         'nsAbLDAPReplicationQuery.cpp',
         'nsAbLDAPReplicationService.cpp',
     ]
-    # XXX These files are not being built as they don't work. Bug 311632 should
-    # fix them.
-    # nsAbLDAPChangeLogQuery.cpp
-    # nsAbLDAPChangeLogData.cpp
 
     EXTRA_JS_MODULES += [
         'AbLDAPAutoCompleteSearch.jsm',
     ]
 
     DEFINES['MOZ_LDAP_XPCOM'] = True
 
 EXTRA_JS_MODULES += [
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPCard.cpp
+++ /dev/null
@@ -1,252 +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 "nsAbLDAPCard.h"
-#include "nsIMutableArray.h"
-#include "nsCOMPtr.h"
-#include "nsILDAPModification.h"
-#include "nsILDAPBERValue.h"
-#include "nsILDAPMessage.h"
-#include "nsIAbLDAPAttributeMap.h"
-#include "nsServiceManagerUtils.h"
-#include "nsComponentManagerUtils.h"
-#include "nsAbBaseCID.h"
-#include "nsAbUtils.h"
-#include "nsILDAPErrors.h"
-
-#include <stdio.h>
-
-#define kDNColumn "DN"
-
-nsAbLDAPCard::nsAbLDAPCard() {}
-
-nsAbLDAPCard::~nsAbLDAPCard() {}
-
-NS_IMPL_ISUPPORTS_INHERITED(nsAbLDAPCard, nsAbCardProperty, nsIAbLDAPCard)
-
-/* Retrieves the changes to the LDAP card and stores them in an LDAP
- * update message.
- *
- * Calling this method changes the LDAP card, it updates the
- * meta-properties (m_*) to reflect what the LDAP contents will be once
- * the update has been performed. This allows you to do multiple (successful)
- * consecutive edits on a card in a search result. If the meta-properties
- * were not updated, incorrect assumptions would be made about what object
- * classes to add, or  what attributes to clear.
- *
- * XXX: We need to take care when integrating this code with the asynchronous
- * update dialogs, as the current code in nsAbLDAPDirectory has a problem
- * when an update fails: the modified card still gets stored and shown to
- * the user instead of being discarded. There is one especially tricky case:
- * when you do an update on a card which changes its DN, you have two
- * operations (rename, then update the other attributes). If the rename
- * operation succeeds and not the update of the attributes, you are
- * "somewhere in between" the original card and the updated card.
- */
-NS_IMETHODIMP nsAbLDAPCard::GetLDAPMessageInfo(
-    nsIAbLDAPAttributeMap *aAttributeMap, nsTArray<nsCString> const &aClasses,
-    int32_t aType, nsIArray **aLDAPAddMessageInfo) {
-  NS_ENSURE_ARG_POINTER(aAttributeMap);
-  NS_ENSURE_ARG_POINTER(aLDAPAddMessageInfo);
-
-  nsresult rv;
-  nsCOMPtr<nsIMutableArray> modArray =
-      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Add any missing object classes. We never remove any object
-  // classes: if an entry has additional object classes, it's probably
-  // for a good reason.
-  nsAutoCString oclass;
-  for (uint32_t i = 0; i < aClasses.Length(); ++i) {
-    oclass.Assign(aClasses[i]);
-    ToLowerCase(oclass);
-
-    if (!m_objectClass.Contains(oclass)) {
-      m_objectClass.AppendElement(oclass);
-    }
-  }
-
-  nsCOMPtr<nsILDAPModification> mod =
-      do_CreateInstance("@mozilla.org/network/ldap-modification;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIMutableArray> values =
-      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  for (uint32_t i = 0; i < m_objectClass.Length(); ++i) {
-    nsCOMPtr<nsILDAPBERValue> value =
-        do_CreateInstance("@mozilla.org/network/ldap-ber-value;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = value->SetFromUTF8(m_objectClass.ElementAt(i));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = values->AppendElement(value);
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
-  rv = mod->SetUpModification(aType, NS_LITERAL_CSTRING("objectClass"), values);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  modArray->AppendElement(mod);
-
-  // Add card properties
-  nsTArray<nsCString> props;
-  rv = aAttributeMap->GetAllCardProperties(props);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsAutoCString attr;
-  nsCString propvalue;
-  for (const nsCString &prop : props) {
-    // Skip some attributes that don't map to LDAP.
-    //
-    // BirthYear : by default this is mapped to 'birthyear',
-    // which is not part of mozillaAbPersonAlpha
-    //
-    // LastModifiedDate : by default this is mapped to 'modifytimestamp',
-    // which cannot be modified
-    //
-    // PreferMailFormat : by default this is mapped to 'mozillaUseHtmlMail',
-    // which is a boolean, not plaintext/html/unknown
-    if (prop.EqualsLiteral(kBirthYearProperty) ||
-        prop.EqualsLiteral(kLastModifiedDateProperty) ||
-        prop.EqualsLiteral(kPreferMailFormatProperty))
-      continue;
-
-    rv = aAttributeMap->GetFirstAttribute(prop, attr);
-    NS_ENSURE_SUCCESS(rv, rv);
-    ToLowerCase(attr);
-
-    // If the property is not mapped to an attribute, skip it.
-    if (attr.IsEmpty()) continue;
-
-    nsCOMPtr<nsILDAPModification> mod =
-        do_CreateInstance("@mozilla.org/network/ldap-modification;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    size_t index = m_attributes.IndexOf(attr);
-
-    rv = GetPropertyAsAUTF8String(prop.get(), propvalue);
-
-    if (NS_SUCCEEDED(rv) && !propvalue.IsEmpty()) {
-      // If the new value is not empty, add/update it
-      nsCOMPtr<nsILDAPBERValue> value =
-          do_CreateInstance("@mozilla.org/network/ldap-ber-value;1", &rv);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = value->SetFromUTF8(propvalue);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = mod->SetUpModificationOneValue(aType, attr, value);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      modArray->AppendElement(mod);
-      if (index != m_attributes.NoIndex) m_attributes.AppendElement(attr);
-
-    } else if (aType == nsILDAPModification::MOD_REPLACE &&
-               index != m_attributes.NoIndex) {
-      // If the new value is empty, we are performing an update
-      // and the attribute was previously set, clear it
-      nsCOMPtr<nsIMutableArray> novalues =
-          do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = mod->SetUpModification(aType, attr, novalues);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      modArray->AppendElement(mod);
-      m_attributes.RemoveElementAt(index);
-    }
-  }
-
-  modArray.forget(aLDAPAddMessageInfo);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAbLDAPCard::BuildRdn(nsIAbLDAPAttributeMap *aAttributeMap,
-                                     nsTArray<nsCString> const &aAttributes,
-                                     nsACString &aRdn) {
-  NS_ENSURE_ARG_POINTER(aAttributeMap);
-
-  nsresult rv;
-  nsAutoCString prop;
-  nsCString propvalue;
-
-  aRdn.Truncate();
-  for (uint32_t i = 0; i < aAttributes.Length(); ++i) {
-    // Lookup the property corresponding to the attribute
-    rv = aAttributeMap->GetProperty(aAttributes[i], prop);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // Get the property value
-    rv = GetPropertyAsAUTF8String(prop.get(), propvalue);
-
-    // XXX The case where an attribute needed to build the Relative
-    // Distinguished Name is not set needs to be handled by the caller,
-    // so as to let the user know what is missing.
-    if (NS_FAILED(rv) || propvalue.IsEmpty()) {
-      NS_ERROR("nsAbLDAPCard::BuildRdn: a required attribute is not set");
-      return NS_ERROR_NOT_INITIALIZED;
-    }
-
-    aRdn.Append(aAttributes[i]);
-    aRdn.Append('=');
-    aRdn.Append(propvalue);
-    if (i < aAttributes.Length() - 1) aRdn.Append('+');
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAbLDAPCard::GetDn(nsACString &aDN) {
-  return GetPropertyAsAUTF8String(kDNColumn, aDN);
-}
-
-NS_IMETHODIMP nsAbLDAPCard::SetDn(const nsACString &aDN) {
-  SetLocalId(aDN);
-  return SetPropertyAsAUTF8String(kDNColumn, aDN);
-}
-
-NS_IMETHODIMP nsAbLDAPCard::SetMetaProperties(nsILDAPMessage *aMessage) {
-  NS_ENSURE_ARG_POINTER(aMessage);
-
-  // Get DN
-  nsAutoCString dn;
-  nsresult rv = aMessage->GetDn(dn);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  SetDn(dn);
-
-  // Get the list of set attributes
-  rv = aMessage->GetAttributes(m_attributes);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  for (uint32_t i = 0; i < m_attributes.Length(); ++i) {
-    ToLowerCase(m_attributes[i]);
-  }
-
-  // Get the objectClass values
-  m_objectClass.Clear();
-  nsTArray<nsString> vals;
-  rv = aMessage->GetValues("objectClass", vals);
-
-  // objectClass is not always included in search result entries and
-  // nsILDAPMessage::GetValues returns NS_ERROR_LDAP_DECODING_ERROR if the
-  // requested attribute doesn't exist.
-  if (rv == NS_ERROR_LDAP_DECODING_ERROR) return NS_OK;
-
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsAutoCString oclass;
-  for (uint32_t i = 0; i < vals.Length(); ++i) {
-    oclass.Assign(NS_LossyConvertUTF16toASCII(vals[i]));
-    ToLowerCase(oclass);
-    m_objectClass.AppendElement(oclass);
-  }
-
-  return NS_OK;
-}
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPCard.h
+++ /dev/null
@@ -1,26 +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/. */
-
-#ifndef nsAbLDAPCard_h__
-#define nsAbLDAPCard_h__
-
-#include "nsAbCardProperty.h"
-#include "nsIAbLDAPCard.h"
-#include "nsTArray.h"
-
-class nsAbLDAPCard : public nsAbCardProperty, public nsIAbLDAPCard {
- public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIABLDAPCARD
-
-  nsAbLDAPCard();
-
- protected:
-  virtual ~nsAbLDAPCard();
-  nsTArray<nsCString> m_attributes;
-  nsTArray<nsCString> m_objectClass;
-};
-
-#endif
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
+++ /dev/null
@@ -1,498 +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 "nsAbLDAPChangeLogData.h"
-#include "nsAbLDAPChangeLogQuery.h"
-#include "nsILDAPMessage.h"
-#include "nsIAddrBookSession.h"
-#include "nsAbBaseCID.h"
-#include "nsAbUtils.h"
-#include "nsAbLDAPCard.h"
-#include "nsIAuthPrompt.h"
-#include "nsIStringBundle.h"
-#include "nsIWindowWatcher.h"
-#include "nsUnicharUtils.h"
-#include "plstr.h"
-#include "nsILDAPErrors.h"
-#include "prmem.h"
-#include "mozilla/Services.h"
-
-// Defined here since to be used
-// only locally to this file.
-enum UpdateOp { NO_OP, ENTRY_ADD, ENTRY_DELETE, ENTRY_MODIFY };
-
-nsAbLDAPProcessChangeLogData::nsAbLDAPProcessChangeLogData()
-    : mUseChangeLog(false),
-      mChangeLogEntriesCount(0),
-      mEntriesAddedQueryCount(0) {
-  mRootDSEEntry.firstChangeNumber = 0;
-  mRootDSEEntry.lastChangeNumber = 0;
-}
-
-nsAbLDAPProcessChangeLogData::~nsAbLDAPProcessChangeLogData() {}
-
-NS_IMETHODIMP nsAbLDAPProcessChangeLogData::Init(
-    nsIAbLDAPReplicationQuery *query,
-    nsIWebProgressListener *progressListener) {
-  NS_ENSURE_ARG_POINTER(query);
-
-  // Here we are assuming that the caller will pass a nsAbLDAPChangeLogQuery
-  // object, an implementation derived from the implementation of
-  // nsIAbLDAPReplicationQuery.
-  nsresult rv = NS_OK;
-  mChangeLogQuery = do_QueryInterface(query, &rv);
-  if (NS_FAILED(rv)) return rv;
-
-  // Call the parent's Init now.
-  return nsAbLDAPProcessReplicationData::Init(query, progressListener);
-}
-
-nsresult nsAbLDAPProcessChangeLogData::OnLDAPBind(nsILDAPMessage *aMessage) {
-  NS_ENSURE_ARG_POINTER(aMessage);
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  int32_t errCode;
-
-  nsresult rv = aMessage->GetErrorCode(&errCode);
-  if (NS_FAILED(rv)) {
-    Done(false);
-    return rv;
-  }
-
-  if (errCode != nsILDAPErrors::SUCCESS) {
-    Done(false);
-    return NS_ERROR_FAILURE;
-  }
-
-  switch (mState) {
-    case kAnonymousBinding:
-      rv = GetAuthData();
-      if (NS_SUCCEEDED(rv)) rv = mChangeLogQuery->QueryAuthDN(mAuthUserID);
-      if (NS_SUCCEEDED(rv)) mState = kSearchingAuthDN;
-      break;
-    case kAuthenticatedBinding:
-      rv = mChangeLogQuery->QueryRootDSE();
-      if (NS_SUCCEEDED(rv)) mState = kSearchingRootDSE;
-      break;
-  }  // end of switch
-
-  if (NS_FAILED(rv)) Abort();
-
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::OnLDAPSearchEntry(
-    nsILDAPMessage *aMessage) {
-  NS_ENSURE_ARG_POINTER(aMessage);
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  nsresult rv = NS_OK;
-
-  switch (mState) {
-    case kSearchingAuthDN: {
-      nsAutoCString authDN;
-      rv = aMessage->GetDn(authDN);
-      if (NS_SUCCEEDED(rv) && !authDN.IsEmpty()) mAuthDN = authDN.get();
-    } break;
-    case kSearchingRootDSE:
-      rv = ParseRootDSEEntry(aMessage);
-      break;
-    case kFindingChanges:
-      rv = ParseChangeLogEntries(aMessage);
-      break;
-    // Fall through since we only add (for updates we delete and add)
-    case kReplicatingChanges:
-    case kReplicatingAll:
-      return nsAbLDAPProcessReplicationData::OnLDAPSearchEntry(aMessage);
-  }
-
-  if (NS_FAILED(rv)) Abort();
-
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::OnLDAPSearchResult(
-    nsILDAPMessage *aMessage) {
-  NS_ENSURE_ARG_POINTER(aMessage);
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  int32_t errorCode;
-
-  nsresult rv = aMessage->GetErrorCode(&errorCode);
-
-  if (NS_SUCCEEDED(rv)) {
-    if (errorCode == nsILDAPErrors::SUCCESS ||
-        errorCode == nsILDAPErrors::SIZELIMIT_EXCEEDED) {
-      switch (mState) {
-        case kSearchingAuthDN:
-          rv = OnSearchAuthDNDone();
-          break;
-        case kSearchingRootDSE: {
-          // Before starting the changeLog check the DB file, if its not there
-          // or bogus we need to create a new one and set to all.
-          nsCOMPtr<nsIAddrBookSession> abSession =
-              do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
-          if (NS_FAILED(rv)) break;
-          nsCOMPtr<nsIFile> dbPath;
-          rv = abSession->GetUserProfileDirectory(getter_AddRefs(dbPath));
-          if (NS_FAILED(rv)) break;
-
-          nsAutoCString fileName;
-          rv = mDirectory->GetReplicationFileName(fileName);
-          if (NS_FAILED(rv)) break;
-
-          rv = dbPath->AppendNative(fileName);
-          if (NS_FAILED(rv)) break;
-
-          bool fileExists;
-          rv = dbPath->Exists(&fileExists);
-          if (NS_FAILED(rv)) break;
-
-          int64_t fileSize;
-          rv = dbPath->GetFileSize(&fileSize);
-          if (NS_FAILED(rv)) break;
-
-          if (!fileExists || !fileSize) mUseChangeLog = false;
-
-          // Open / create the AB here since it calls Done,
-          // just return from here.
-          if (mUseChangeLog)
-            rv = OpenABForReplicatedDir(false);
-          else
-            rv = OpenABForReplicatedDir(true);
-          if (NS_FAILED(rv)) return rv;
-
-          // Now start the appropriate query
-          rv = OnSearchRootDSEDone();
-          break;
-        }
-        case kFindingChanges:
-          rv = OnFindingChangesDone();
-          // If success we return from here since
-          // this changes state to kReplicatingChanges
-          // and it falls through into the if clause below.
-          if (NS_SUCCEEDED(rv)) return rv;
-          break;
-        case kReplicatingAll:
-          return nsAbLDAPProcessReplicationData::OnLDAPSearchResult(aMessage);
-      }  // end of switch
-    } else
-      rv = NS_ERROR_FAILURE;
-    // If one of the changed entry in changelog is not found,
-    // continue with replicating the next one.
-    if (mState == kReplicatingChanges) rv = OnReplicatingChangeDone();
-  }  // end of outer if
-
-  if (NS_FAILED(rv)) Abort();
-
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::GetAuthData() {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
-  if (!wwatch) return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIAuthPrompt> dialog;
-  nsresult rv = wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog));
-  if (NS_FAILED(rv)) return rv;
-  if (!dialog) return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsILDAPURL> url;
-  rv = mQuery->GetReplicationURL(getter_AddRefs(url));
-  if (NS_FAILED(rv)) return rv;
-
-  nsAutoCString serverUri;
-  rv = url->GetSpec(serverUri);
-  if (NS_FAILED(rv)) return rv;
-
-  nsCOMPtr<nsIStringBundleService> bundleService =
-      mozilla::services::GetStringBundleService();
-  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
-  nsCOMPtr<nsIStringBundle> bundle;
-  rv = bundleService->CreateBundle(
-      "chrome://messenger/locale/addressbook/addressBook.properties",
-      getter_AddRefs(bundle));
-  if (NS_FAILED(rv)) return rv;
-
-  nsString title;
-  rv = bundle->GetStringFromName("AuthDlgTitle", title);
-  if (NS_FAILED(rv)) return rv;
-
-  nsString desc;
-  rv = bundle->GetStringFromName("AuthDlgDesc", desc);
-  if (NS_FAILED(rv)) return rv;
-
-  nsString username;
-  nsString password;
-  bool btnResult = false;
-  rv = dialog->PromptUsernameAndPassword(
-      title, desc, NS_ConvertUTF8toUTF16(serverUri).get(),
-      nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY, getter_Copies(username),
-      getter_Copies(password), &btnResult);
-  if (NS_SUCCEEDED(rv) && btnResult) {
-    CopyUTF16toUTF8(username, mAuthUserID);
-    CopyUTF16toUTF8(password, mAuthPswd);
-  } else
-    rv = NS_ERROR_FAILURE;
-
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::OnSearchAuthDNDone() {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  nsCOMPtr<nsILDAPURL> url;
-  nsresult rv = mQuery->GetReplicationURL(getter_AddRefs(url));
-  if (NS_SUCCEEDED(rv)) rv = mQuery->ConnectToLDAPServer(url, mAuthDN);
-  if (NS_SUCCEEDED(rv)) {
-    mState = kAuthenticatedBinding;
-    rv = mDirectory->SetAuthDn(mAuthDN);
-  }
-
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::ParseRootDSEEntry(
-    nsILDAPMessage *aMessage) {
-  NS_ENSURE_ARG_POINTER(aMessage);
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  // Populate the RootDSEChangeLogEntry
-  CharPtrArrayGuard attrs;
-  nsresult rv =
-      aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr());
-  // No attributes
-  if (NS_FAILED(rv)) return rv;
-
-  for (int32_t i = attrs.GetSize() - 1; i >= 0; i--) {
-    PRUnicharPtrArrayGuard vals;
-    rv = aMessage->GetValues(attrs.GetArray()[i], vals.GetSizeAddr(),
-                             vals.GetArrayAddr());
-    if (NS_FAILED(rv)) continue;
-    if (vals.GetSize()) {
-      if (!PL_strcasecmp(attrs[i], "changelog"))
-        CopyUTF16toUTF8(vals[0], mRootDSEEntry.changeLogDN);
-      if (!PL_strcasecmp(attrs[i], "firstChangeNumber"))
-        mRootDSEEntry.firstChangeNumber =
-            atol(NS_LossyConvertUTF16toASCII(vals[0]).get());
-      if (!PL_strcasecmp(attrs[i], "lastChangeNumber"))
-        mRootDSEEntry.lastChangeNumber =
-            atol(NS_LossyConvertUTF16toASCII(vals[0]).get());
-      if (!PL_strcasecmp(attrs[i], "dataVersion"))
-        CopyUTF16toUTF8(vals[0], mRootDSEEntry.dataVersion);
-    }
-  }
-
-  int32_t lastChangeNumber;
-  mDirectory->GetLastChangeNumber(&lastChangeNumber);
-
-  if ((mRootDSEEntry.lastChangeNumber > 0) &&
-      (lastChangeNumber < mRootDSEEntry.lastChangeNumber) &&
-      (lastChangeNumber > mRootDSEEntry.firstChangeNumber))
-    mUseChangeLog = true;
-
-  if (mRootDSEEntry.lastChangeNumber &&
-      (lastChangeNumber == mRootDSEEntry.lastChangeNumber)) {
-    Done(true);  // We are up to date no need to replicate, db not open yet so
-                 // call Done
-    return NS_OK;
-  }
-
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::OnSearchRootDSEDone() {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  nsresult rv = NS_OK;
-
-  if (mUseChangeLog) {
-    rv = mChangeLogQuery->QueryChangeLog(mRootDSEEntry.changeLogDN,
-                                         mRootDSEEntry.lastChangeNumber);
-    if (NS_FAILED(rv)) return rv;
-    mState = kFindingChanges;
-    if (mListener)
-      mListener->OnStateChange(nullptr, nullptr,
-                               nsIWebProgressListener::STATE_START, false);
-  } else {
-    rv = mQuery->QueryAllEntries();
-    if (NS_FAILED(rv)) return rv;
-    mState = kReplicatingAll;
-    if (mListener)
-      mListener->OnStateChange(nullptr, nullptr,
-                               nsIWebProgressListener::STATE_START, true);
-  }
-
-  rv = mDirectory->SetLastChangeNumber(mRootDSEEntry.lastChangeNumber);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = mDirectory->SetDataVersion(mRootDSEEntry.dataVersion);
-
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::ParseChangeLogEntries(
-    nsILDAPMessage *aMessage) {
-  NS_ENSURE_ARG_POINTER(aMessage);
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  // Populate the RootDSEChangeLogEntry
-  CharPtrArrayGuard attrs;
-  nsresult rv =
-      aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr());
-  // No attributes
-  if (NS_FAILED(rv)) return rv;
-
-  nsAutoString targetDN;
-  UpdateOp operation = NO_OP;
-  for (int32_t i = attrs.GetSize() - 1; i >= 0; i--) {
-    PRUnicharPtrArrayGuard vals;
-    rv = aMessage->GetValues(attrs.GetArray()[i], vals.GetSizeAddr(),
-                             vals.GetArrayAddr());
-    if (NS_FAILED(rv)) continue;
-    if (vals.GetSize()) {
-      if (!PL_strcasecmp(attrs[i], "targetdn")) targetDN = vals[0];
-      if (!PL_strcasecmp(attrs[i], "changetype")) {
-        if (!Compare(nsDependentString(vals[0]), NS_LITERAL_STRING("add"),
-                     nsCaseInsensitiveStringComparator()))
-          operation = ENTRY_ADD;
-        if (!Compare(nsDependentString(vals[0]), NS_LITERAL_STRING("modify"),
-                     nsCaseInsensitiveStringComparator()))
-          operation = ENTRY_MODIFY;
-        if (!Compare(nsDependentString(vals[0]), NS_LITERAL_STRING("delete"),
-                     nsCaseInsensitiveStringComparator()))
-          operation = ENTRY_DELETE;
-      }
-    }
-  }
-
-  mChangeLogEntriesCount++;
-  if (!(mChangeLogEntriesCount % 10)) {  // Inform the listener every 10 entries
-    mListener->OnProgressChange(nullptr, nullptr, mChangeLogEntriesCount, -1,
-                                mChangeLogEntriesCount, -1);
-    // In case if the LDAP Connection thread is starved and causes problem
-    // uncomment this one and try.
-    // PR_Sleep(PR_INTERVAL_NO_WAIT); // give others a chance
-  }
-
-#ifdef DEBUG_rdayal
-  printf("ChangeLog Replication : Updated Entry : %s for OpType : %u\n",
-         NS_ConvertUTF16toUTF8(targetDN).get(), operation);
-#endif
-
-  switch (operation) {
-    case ENTRY_ADD:
-      // Add the DN to the add list if not already in the list
-      if (!(mEntriesToAdd.IndexOf(targetDN) >= 0))
-        mEntriesToAdd.AppendString(targetDN);
-      break;
-    case ENTRY_DELETE:
-      // Do not check the return here since delete may fail if
-      // entry deleted in changelog does not exist in DB
-      // for e.g if the user specifies a filter, so go next entry
-      DeleteCard(targetDN);
-      break;
-    case ENTRY_MODIFY:
-      // For modify, delete the entry from DB and add updated entry
-      // we do this since we cannot access the changes attribs of changelog
-      rv = DeleteCard(targetDN);
-      if (NS_SUCCEEDED(rv))
-        if (!(mEntriesToAdd.IndexOf(targetDN) >= 0))
-          mEntriesToAdd.AppendString(targetDN);
-      break;
-    default:
-      // Should not come here, would come here only
-      // if the entry is not a changeLog entry
-      NS_WARNING(
-          "nsAbLDAPProcessChangeLogData::ParseChangeLogEntries"
-          "Not an changelog entry");
-  }
-
-  // Go ahead processing the next entry, a modify or delete DB operation
-  // can 'correctly' fail if the entry is not present in the DB,
-  // e.g. in case a filter is specified.
-  return NS_OK;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::OnFindingChangesDone() {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-#ifdef DEBUG_rdayal
-  printf("ChangeLog Replication : Finding Changes Done \n");
-#endif
-
-  nsresult rv = NS_OK;
-
-  // No entries to add/update (for updates too we delete and add) entries,
-  // we took care of deletes in ParseChangeLogEntries, all Done!
-  mEntriesAddedQueryCount = mEntriesToAdd.Count();
-  if (mEntriesAddedQueryCount <= 0) {
-    if (mReplicationDB && mDBOpen) {
-      // Close the DB, no need to commit since we have not made
-      // any changes yet to the DB.
-      rv = mReplicationDB->Close(false);
-      NS_ASSERTION(NS_SUCCEEDED(rv),
-                   "Replication DB Close(no commit) on Success failed");
-      mDBOpen = false;
-      // Once are done with the replication file, delete the backup file
-      if (mBackupReplicationFile) {
-        rv = mBackupReplicationFile->Remove(false);
-        NS_ASSERTION(NS_SUCCEEDED(rv),
-                     "Replication BackupFile Remove on Success failed");
-      }
-    }
-    Done(true);
-    return NS_OK;
-  }
-
-  // Decrement the count first to get the correct array element
-  mEntriesAddedQueryCount--;
-  rv = mChangeLogQuery->QueryChangedEntries(
-      NS_ConvertUTF16toUTF8(*(mEntriesToAdd[mEntriesAddedQueryCount])));
-  if (NS_FAILED(rv)) return rv;
-
-  if (mListener && NS_SUCCEEDED(rv))
-    mListener->OnStateChange(nullptr, nullptr,
-                             nsIWebProgressListener::STATE_START, true);
-
-  mState = kReplicatingChanges;
-  return rv;
-}
-
-nsresult nsAbLDAPProcessChangeLogData::OnReplicatingChangeDone() {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  nsresult rv = NS_OK;
-
-  if (!mEntriesAddedQueryCount) {
-    if (mReplicationDB && mDBOpen) {
-      rv = mReplicationDB->Close(true);  // Commit and close the DB
-      NS_ASSERTION(NS_SUCCEEDED(rv),
-                   "Replication DB Close (commit) on Success failed");
-      mDBOpen = false;
-    }
-    // Once we done with the replication file, delete the backup file.
-    if (mBackupReplicationFile) {
-      rv = mBackupReplicationFile->Remove(false);
-      NS_ASSERTION(NS_SUCCEEDED(rv),
-                   "Replication BackupFile Remove on Success failed");
-    }
-    Done(true);  // All data is received
-    return NS_OK;
-  }
-
-  // Remove the entry already added from the list and query the next one.
-  if (mEntriesAddedQueryCount < mEntriesToAdd.Count() &&
-      mEntriesAddedQueryCount >= 0)
-    mEntriesToAdd.RemoveStringAt(mEntriesAddedQueryCount);
-  mEntriesAddedQueryCount--;
-  rv = mChangeLogQuery->QueryChangedEntries(
-      NS_ConvertUTF16toUTF8(*(mEntriesToAdd[mEntriesAddedQueryCount])));
-
-  return rv;
-}
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPChangeLogData.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* 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/. */
-
-#ifndef nsAbLDAPChangeLogData_h__
-#define nsAbLDAPChangeLogData_h__
-
-#include "mozilla/Attributes.h"
-#include "nsAbLDAPReplicationData.h"
-#include "nsAbLDAPChangeLogQuery.h"
-
-typedef struct {
-  nsCString changeLogDN;
-  int32_t firstChangeNumber;
-  int32_t lastChangeNumber;
-  nsCString dataVersion;
-} RootDSEChangeLogEntry;
-
-class nsAbLDAPProcessChangeLogData : public nsAbLDAPProcessReplicationData {
- public:
-  nsAbLDAPProcessChangeLogData();
-
-  NS_IMETHOD Init(nsIAbLDAPReplicationQuery *query,
-                  nsIWebProgressListener *progressListener);
-
- protected:
-  ~nsAbLDAPProcessChangeLogData();
-
-  nsCOMPtr<nsIAbLDAPChangeLogQuery> mChangeLogQuery;
-
-  nsresult OnLDAPBind(nsILDAPMessage *aMessage);
-  nsresult OnLDAPSearchEntry(nsILDAPMessage *aMessage) override;
-  nsresult OnLDAPSearchResult(nsILDAPMessage *aMessage) override;
-
-  nsresult ParseChangeLogEntries(nsILDAPMessage *aMessage);
-  nsresult ParseRootDSEEntry(nsILDAPMessage *aMessage);
-
-  nsresult GetAuthData();  // displays username and password prompt
-  nsCString mAuthUserID;   // user id of the user making the connection
-
-  nsresult OnSearchAuthDNDone();
-  nsresult OnSearchRootDSEDone();
-  nsresult OnFindingChangesDone();
-  nsresult OnReplicatingChangeDone();
-
-  RootDSEChangeLogEntry mRootDSEEntry;
-  bool mUseChangeLog;
-  int32_t mChangeLogEntriesCount;
-
-  int32_t mEntriesAddedQueryCount;
-  nsStringArray mEntriesToAdd;
-};
-
-#endif  // nsAbLDAPChangeLogData_h__
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPChangeLogQuery.cpp
+++ /dev/null
@@ -1,148 +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 "nsCOMPtr.h"
-#include "nsAbLDAPChangeLogQuery.h"
-#include "nsAbLDAPReplicationService.h"
-#include "nsAbLDAPChangeLogData.h"
-#include "nsAbUtils.h"
-#include "prprf.h"
-#include "nsDirPrefs.h"
-#include "nsAbBaseCID.h"
-
-// The tables below were originally in nsAbLDAPProperties.cpp, which has since
-// gone away.
-static const char *sChangeLogRootDSEAttribs[] = {
-    "changelog", "firstChangeNumber", "lastChangeNumber", "dataVersion"};
-static const char *sChangeLogEntryAttribs[] = {"targetdn", "changetype"};
-
-NS_IMPL_ISUPPORTS_INHERITED(nsAbLDAPChangeLogQuery, nsAbLDAPReplicationQuery,
-                            nsIAbLDAPChangeLogQuery)
-
-nsAbLDAPChangeLogQuery::nsAbLDAPChangeLogQuery() {}
-
-nsAbLDAPChangeLogQuery::~nsAbLDAPChangeLogQuery() {}
-
-// this is to be defined only till this is not hooked to SSL to get authDN and
-// authPswd
-#define USE_AUTHDLG
-
-NS_IMETHODIMP nsAbLDAPChangeLogQuery::Init(
-    const nsACString &aPrefName, nsIWebProgressListener *aProgressListener) {
-  if (aPrefName.IsEmpty()) return NS_ERROR_UNEXPECTED;
-
-  mDirPrefName = aPrefName;
-
-  nsresult rv = InitLDAPData();
-  if (NS_FAILED(rv)) return rv;
-
-  // create the ChangeLog Data Processor
-  mDataProcessor =
-      do_CreateInstance(NS_ABLDAP_PROCESSCHANGELOGDATA_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) return rv;
-
-  // 'this' initialized
-  mInitialized = true;
-
-  return mDataProcessor->Init(this, aProgressListener);
-}
-
-NS_IMETHODIMP nsAbLDAPChangeLogQuery::DoReplicationQuery() {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-#ifdef USE_AUTHDLG
-  return ConnectToLDAPServer(mURL, EmptyCString());
-#else
-  mDataProcessor->PopulateAuthData();
-  return ConnectToLDAPServer(mURL, mAuthDN);
-#endif
-}
-
-NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryAuthDN(
-    const nsACString &aValueUsedToFindDn) {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  nsCOMPtr<nsIAbLDAPAttributeMap> attrMap;
-  nsresult rv = mDirectory->GetAttributeMap(getter_AddRefs(attrMap));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsAutoCString filter;
-  rv = attrMap->GetFirstAttribute(NS_LITERAL_CSTRING("PrimaryEmail"), filter);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  filter += '=';
-  filter += aValueUsedToFindDn;
-
-  nsAutoCString dn;
-  rv = mURL->GetDn(dn);
-  if (NS_FAILED(rv)) return rv;
-
-  rv = CreateNewLDAPOperation();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // XXX We really should be using LDAP_NO_ATTRS here once its exposed via
-  // the XPCOM layer of the directory code.
-  return mOperation->SearchExt(dn, nsILDAPURL::SCOPE_SUBTREE, filter, 0,
-                               nullptr, 0, 0);
-}
-
-NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryRootDSE() {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-
-  nsresult rv = CreateNewLDAPOperation();
-  NS_ENSURE_SUCCESS(rv, rv);
-  return mOperation->SearchExt(EmptyCString(), nsILDAPURL::SCOPE_BASE,
-                               NS_LITERAL_CSTRING("objectclass=*"),
-                               sizeof(sChangeLogRootDSEAttribs),
-                               sChangeLogRootDSEAttribs, 0, 0);
-}
-
-NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryChangeLog(
-    const nsACString &aChangeLogDN, int32_t aLastChangeNo) {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-  if (aChangeLogDN.IsEmpty()) return NS_ERROR_UNEXPECTED;
-
-  int32_t lastChangeNumber;
-  nsresult rv = mDirectory->GetLastChangeNumber(&lastChangeNumber);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // make sure that the filter here just have one condition
-  // and should not be enclosed in enclosing brackets.
-  // also condition '>' does not work, it should be '>='/
-  nsAutoCString filter(NS_LITERAL_CSTRING("changenumber>="));
-  filter.AppendInt(lastChangeNumber + 1);
-
-  rv = CreateNewLDAPOperation();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return mOperation->SearchExt(aChangeLogDN, nsILDAPURL::SCOPE_ONELEVEL, filter,
-                               sizeof(sChangeLogEntryAttribs),
-                               sChangeLogEntryAttribs, 0, 0);
-}
-
-NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryChangedEntries(
-    const nsACString &aChangedEntryDN) {
-  if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
-  if (aChangedEntryDN.IsEmpty()) return NS_ERROR_UNEXPECTED;
-
-  nsAutoCString urlFilter;
-  nsresult rv = mURL->GetFilter(urlFilter);
-  if (NS_FAILED(rv)) return rv;
-
-  int32_t scope;
-  rv = mURL->GetScope(&scope);
-  if (NS_FAILED(rv)) return rv;
-
-  CharPtrArrayGuard attributes;
-  rv = mURL->GetAttributes(attributes.GetSizeAddr(), attributes.GetArrayAddr());
-  if (NS_FAILED(rv)) return rv;
-
-  rv = CreateNewLDAPOperation();
-  NS_ENSURE_SUCCESS(rv, rv);
-  return mOperation->SearchExt(aChangedEntryDN, scope, urlFilter,
-                               attributes.GetSize(), attributes.GetArray(), 0,
-                               0);
-}
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPChangeLogQuery.h
+++ /dev/null
@@ -1,28 +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/. */
-
-#ifndef nsAbLDAPChangeLogQuery_h__
-#define nsAbLDAPChangeLogQuery_h__
-
-#include "mozilla/Attributes.h"
-#include "nsAbLDAPReplicationQuery.h"
-#include "nsString.h"
-
-class nsAbLDAPChangeLogQuery : public nsIAbLDAPChangeLogQuery,
-                               public nsAbLDAPReplicationQuery {
- public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIABLDAPCHANGELOGQUERY
-
-  nsAbLDAPChangeLogQuery();
-  virtual ~nsAbLDAPChangeLogQuery();
-
-  NS_IMETHOD DoReplicationQuery() override;
-  NS_IMETHOD Init(const nsACString &aPrefName,
-                  nsIWebProgressListener *aProgressListener);
-};
-
-#endif  // nsAbLDAPChangeLogQuery_h__
--- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
@@ -20,17 +20,16 @@
 #include "nsIAddrDatabase.h"
 #include "nsILDAPURL.h"
 #include "nsILDAPConnection.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsIFile.h"
 #include "nsILDAPModification.h"
 #include "nsILDAPService.h"
-#include "nsIAbLDAPCard.h"
 #include "nsAbUtils.h"
 #include "nsArrayUtils.h"
 #include "nsIPrefService.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
 #include "nsIWeakReference.h"
@@ -377,37 +376,17 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetSupp
     bool *aSupportsMailingsLists) {
   NS_ENSURE_ARG_POINTER(aSupportsMailingsLists);
   *aSupportsMailingsLists = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::GetReadOnly(bool *aReadOnly) {
   NS_ENSURE_ARG_POINTER(aReadOnly);
-
   *aReadOnly = true;
-
-#ifdef MOZ_EXPERIMENTAL_WRITEABLE_LDAP
-  bool readOnly;
-  nsresult rv = GetBoolValue("readonly", false, &readOnly);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (readOnly) return NS_OK;
-
-  // when online, we'll allow writing as well
-  bool offline;
-  nsCOMPtr<nsIIOService> ioService = mozilla::services::GetIOService();
-  NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
-
-  rv = ioService->GetOffline(&offline);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!offline) *aReadOnly = false;
-#endif
-
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::GetIsRemote(bool *aIsRemote) {
   NS_ENSURE_ARG_POINTER(aIsRemote);
   *aIsRemote = true;
   return NS_OK;
 }
@@ -500,40 +479,16 @@ NS_IMETHODIMP nsAbLDAPDirectory::UseForA
     rv = databaseFile->Exists(&exists);
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aResult = exists;
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsAbLDAPDirectory::GetSearchClientControls(
-    nsIMutableArray **aControls) {
-  NS_IF_ADDREF(*aControls = mSearchClientControls);
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAbLDAPDirectory::SetSearchClientControls(
-    nsIMutableArray *aControls) {
-  mSearchClientControls = aControls;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAbLDAPDirectory::GetSearchServerControls(
-    nsIMutableArray **aControls) {
-  NS_IF_ADDREF(*aControls = mSearchServerControls);
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAbLDAPDirectory::SetSearchServerControls(
-    nsIMutableArray *aControls) {
-  mSearchServerControls = aControls;
-  return NS_OK;
-}
-
 NS_IMETHODIMP nsAbLDAPDirectory::GetProtocolVersion(
     uint32_t *aProtocolVersion) {
   nsAutoCString versionString;
 
   nsresult rv =
       GetStringValue("protocolVersion", NS_LITERAL_CSTRING("3"), versionString);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -640,190 +595,26 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetRepl
 
   profileDir.forget(aResult);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::AddCard(nsIAbCard *aUpdatedCard,
                                          nsIAbCard **aAddedCard) {
-  NS_ENSURE_ARG_POINTER(aUpdatedCard);
-  NS_ENSURE_ARG_POINTER(aAddedCard);
-
-  nsCOMPtr<nsIAbLDAPAttributeMap> attrMap;
-  nsresult rv = GetAttributeMap(getter_AddRefs(attrMap));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Create a new LDAP card
-  nsCOMPtr<nsIAbLDAPCard> card =
-      do_CreateInstance(NS_ABLDAPCARD_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = Initiate();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Copy over the card data
-  nsCOMPtr<nsIAbCard> copyToCard = do_QueryInterface(card, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = copyToCard->Copy(aUpdatedCard);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Retrieve preferences
-  nsAutoCString prefString;
-  rv = GetRdnAttributes(prefString);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsTArray<nsCString> rdnAttrs;
-  ParseString(prefString, ',', rdnAttrs);
-
-  rv = GetObjectClasses(prefString);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsTArray<nsCString> objClass;
-  ParseString(prefString, ',', objClass);
-
-  // Process updates
-  nsCOMPtr<nsIArray> modArray;
-  rv = card->GetLDAPMessageInfo(attrMap, objClass, nsILDAPModification::MOD_ADD,
-                                getter_AddRefs(modArray));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // For new cards, the base DN is the search base DN
-  nsCOMPtr<nsILDAPURL> currentUrl;
-  rv = GetLDAPURL(getter_AddRefs(currentUrl));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsAutoCString baseDN;
-  rv = currentUrl->GetDn(baseDN);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Calculate DN
-  nsAutoCString cardDN;
-  rv = card->BuildRdn(attrMap, rdnAttrs, cardDN);
-  NS_ENSURE_SUCCESS(rv, rv);
-  cardDN.Append(',');
-  cardDN.Append(baseDN);
-
-  rv = card->SetDn(cardDN);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsAutoCString ourUuid;
-  GetUuid(ourUuid);
-  copyToCard->SetDirectoryId(ourUuid);
-
-  // Launch query
-  rv = DoModify(this, nsILDAPModification::MOD_ADD, cardDN, modArray,
-                EmptyCString(), EmptyCString());
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  copyToCard.forget(aAddedCard);
-  return NS_OK;
+  return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::DeleteCards(
     const nsTArray<RefPtr<nsIAbCard>> &aCards) {
-  uint32_t cardCount = aCards.Length();
-  uint32_t i;
-  nsAutoCString cardDN;
-
-  for (i = 0; i < cardCount; ++i) {
-    nsresult rv;
-    nsCOMPtr<nsIAbLDAPCard> card(do_QueryInterface(aCards[i], &rv));
-    if (NS_FAILED(rv)) {
-      NS_WARNING("Wrong type of card passed to nsAbLDAPDirectory::DeleteCards");
-      break;
-    }
-
-    // Set up the search ldap url - this is mURL
-    rv = Initiate();
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = card->GetDn(cardDN);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    aCards[i]->SetDirectoryId(EmptyCString());
-
-    // Launch query
-    rv = DoModify(this, nsILDAPModification::MOD_DELETE, cardDN, nullptr,
-                  EmptyCString(), EmptyCString());
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
-  return NS_OK;
+  return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::ModifyCard(nsIAbCard *aUpdatedCard) {
-  NS_ENSURE_ARG_POINTER(aUpdatedCard);
-
-  nsCOMPtr<nsIAbLDAPAttributeMap> attrMap;
-  nsresult rv = GetAttributeMap(getter_AddRefs(attrMap));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Get the LDAP card
-  nsCOMPtr<nsIAbLDAPCard> card = do_QueryInterface(aUpdatedCard, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = Initiate();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Retrieve preferences
-  nsAutoCString prefString;
-  rv = GetObjectClasses(prefString);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsTArray<nsCString> objClass;
-  ParseString(prefString, ',', objClass);
-
-  // Process updates
-  nsCOMPtr<nsIArray> modArray;
-  rv = card->GetLDAPMessageInfo(attrMap, objClass,
-                                nsILDAPModification::MOD_REPLACE,
-                                getter_AddRefs(modArray));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Get current DN
-  nsAutoCString oldDN;
-  rv = card->GetDn(oldDN);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsILDAPService> ldapSvc =
-      do_GetService("@mozilla.org/network/ldap-service;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Retrieve base DN and RDN attributes
-  nsAutoCString baseDN;
-  nsAutoCString oldRDN;
-  nsTArray<nsCString> rdnAttrs;
-  rv = ldapSvc->ParseDn(oldDN.get(), oldRDN, baseDN, rdnAttrs);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Calculate new RDN and check whether it has changed
-  nsAutoCString newRDN;
-  rv = card->BuildRdn(attrMap, rdnAttrs, newRDN);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (newRDN.Equals(oldRDN)) {
-    // Launch query
-    rv = DoModify(this, nsILDAPModification::MOD_REPLACE, oldDN, modArray,
-                  EmptyCString(), EmptyCString());
-  } else {
-    // Build and store the new DN
-    nsAutoCString newDN(newRDN);
-    newDN.Append(',');
-    newDN.Append(baseDN);
-
-    rv = card->SetDn(newDN);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // Launch query
-    rv = DoModify(this, nsILDAPModification::MOD_REPLACE, oldDN, modArray,
-                  newRDN, baseDN);
-  }
-  return rv;
+  return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::GetRdnAttributes(nsACString &aRdnAttributes) {
   return GetStringValue("rdnAttributes", NS_LITERAL_CSTRING("cn"),
                         aRdnAttributes);
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::SetRdnAttributes(
--- a/mailnews/addrbook/src/nsAbLDAPDirectory.h
+++ b/mailnews/addrbook/src/nsAbLDAPDirectory.h
@@ -3,26 +3,24 @@
  * 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/. */
 
 #ifndef nsAbLDAPDirectory_h__
 #define nsAbLDAPDirectory_h__
 
 #include "mozilla/Attributes.h"
 #include "nsAbDirProperty.h"
-#include "nsAbLDAPDirectoryModify.h"
 #include "nsIAbDirectoryQuery.h"
 #include "nsIAbDirSearchListener.h"
 #include "nsIAbLDAPDirectory.h"
 #include "nsIMutableArray.h"
 #include "nsInterfaceHashtable.h"
 #include "mozilla/Mutex.h"
 
 class nsAbLDAPDirectory : public nsAbDirProperty,  // nsIAbDirectory
-                          public nsAbLDAPDirectoryModify,
                           public nsIAbLDAPDirectory,
                           public nsIAbDirSearchListener {
  public:
   NS_DECL_ISUPPORTS_INHERITED
 
   nsAbLDAPDirectory();
 
   NS_IMETHOD Init(const char *aUri) override;
@@ -58,13 +56,11 @@ class nsAbLDAPDirectory : public nsAbDir
   bool mPerformingQuery;
   int32_t mContext;
   int32_t mMaxHits;
 
   nsInterfaceHashtable<nsISupportsHashKey, nsIAbCard> mCache;
 
   mozilla::Mutex mLock;
   nsCOMPtr<nsIAbDirectoryQuery> mDirectoryQuery;
-  nsCOMPtr<nsIMutableArray> mSearchServerControls;
-  nsCOMPtr<nsIMutableArray> mSearchClientControls;
 };
 
 #endif
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPDirectoryModify.cpp
+++ /dev/null
@@ -1,332 +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 "nsAbLDAPDirectoryModify.h"
-#include "nsAbLDAPListenerBase.h"
-#include "nsILDAPMessage.h"
-#include "nsILDAPConnection.h"
-#include "nsILDAPErrors.h"
-#include "nsILDAPModification.h"
-#include "nsIAbLDAPDirectory.h"
-#include "nsIMutableArray.h"
-#include "nsComponentManagerUtils.h"
-#include "nsServiceManagerUtils.h"
-
-#include <stdio.h>
-
-using namespace mozilla;
-
-class nsAbModifyLDAPMessageListener : public nsAbLDAPListenerBase {
- public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-
-  nsAbModifyLDAPMessageListener(const int32_t type, const nsACString &cardDN,
-                                nsIArray *modArray, const nsACString &newRDN,
-                                const nsACString &newBaseDN,
-                                nsILDAPURL *directoryUrl,
-                                nsILDAPConnection *connection,
-                                nsIMutableArray *serverSearchControls,
-                                nsIMutableArray *clientSearchControls,
-                                const nsACString &login,
-                                const int32_t timeOut = 0);
-  // nsILDAPMessageListener
-  NS_IMETHOD OnLDAPMessage(nsILDAPMessage *aMessage) override;
-
- protected:
-  virtual ~nsAbModifyLDAPMessageListener();
-
-  nsresult Cancel();
-  virtual void InitFailed(bool aCancelled = false) override;
-  virtual nsresult DoTask() override;
-  nsresult DoMainTask();
-  nsresult OnLDAPMessageModifyResult(nsILDAPMessage *aMessage);
-  nsresult OnLDAPMessageRenameResult(nsILDAPMessage *aMessage);
-
-  int32_t mType;
-  nsCString mCardDN;
-  nsCOMPtr<nsIArray> mModification;
-  nsCString mNewRDN;
-  nsCString mNewBaseDN;
-
-  bool mFinished;
-  bool mCanceled;
-  bool mFlagRename;
-
-  nsCOMPtr<nsILDAPOperation> mModifyOperation;
-  nsCOMPtr<nsIMutableArray> mServerSearchControls;
-  nsCOMPtr<nsIMutableArray> mClientSearchControls;
-};
-
-NS_IMPL_ISUPPORTS(nsAbModifyLDAPMessageListener, nsILDAPMessageListener)
-
-nsAbModifyLDAPMessageListener::nsAbModifyLDAPMessageListener(
-    const int32_t type, const nsACString &cardDN, nsIArray *modArray,
-    const nsACString &newRDN, const nsACString &newBaseDN,
-    nsILDAPURL *directoryUrl, nsILDAPConnection *connection,
-    nsIMutableArray *serverSearchControls,
-    nsIMutableArray *clientSearchControls, const nsACString &login,
-    const int32_t timeOut)
-    : nsAbLDAPListenerBase(directoryUrl, connection, login, timeOut),
-      mType(type),
-      mCardDN(cardDN),
-      mModification(modArray),
-      mNewRDN(newRDN),
-      mNewBaseDN(newBaseDN),
-      mFinished(false),
-      mCanceled(false),
-      mFlagRename(false),
-      mServerSearchControls(serverSearchControls),
-      mClientSearchControls(clientSearchControls) {
-  if (mType == nsILDAPModification::MOD_REPLACE && !mNewRDN.IsEmpty() &&
-      !mNewBaseDN.IsEmpty())
-    mFlagRename = true;
-}
-
-nsAbModifyLDAPMessageListener::~nsAbModifyLDAPMessageListener() {}
-
-nsresult nsAbModifyLDAPMessageListener::Cancel() {
-  nsresult rv = Initiate();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  MutexAutoLock lock(mLock);
-
-  if (mFinished || mCanceled) return NS_OK;
-
-  mCanceled = true;
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAbModifyLDAPMessageListener::OnLDAPMessage(
-    nsILDAPMessage *aMessage) {
-  nsresult rv = Initiate();
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  int32_t messageType;
-  rv = aMessage->GetType(&messageType);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  bool cancelOperation = false;
-
-  // Enter lock
-  {
-    MutexAutoLock lock(mLock);
-
-    if (mFinished) return NS_OK;
-
-    // for these messages, no matter the outcome, we're done
-    if ((messageType == nsILDAPMessage::RES_ADD) ||
-        (messageType == nsILDAPMessage::RES_DELETE) ||
-        (messageType == nsILDAPMessage::RES_MODIFY))
-      mFinished = true;
-    else if (mCanceled) {
-      mFinished = true;
-      cancelOperation = true;
-    }
-  }
-  // Leave lock
-
-  //    nsCOMPtr<nsIAbDirectoryQueryResult> queryResult;
-  if (!cancelOperation) {
-    switch (messageType) {
-      case nsILDAPMessage::RES_BIND:
-        rv = OnLDAPMessageBind(aMessage);
-        if (NS_FAILED(rv))
-          // We know the bind failed and hence the message has an error, so we
-          // can just call ModifyResult with the message and that'll sort it out
-          // for us.
-          rv = OnLDAPMessageModifyResult(aMessage);
-        break;
-      case nsILDAPMessage::RES_ADD:
-      case nsILDAPMessage::RES_MODIFY:
-      case nsILDAPMessage::RES_DELETE:
-        rv = OnLDAPMessageModifyResult(aMessage);
-        break;
-      case nsILDAPMessage::RES_MODDN:
-        mFlagRename = false;
-        rv = OnLDAPMessageRenameResult(aMessage);
-        if (NS_FAILED(rv))
-          // Rename failed, so we stop here
-          mFinished = true;
-        break;
-      default:
-        break;
-    }
-  } else {
-    if (mModifyOperation) rv = mModifyOperation->AbandonExt();
-
-    // reset because we might re-use this listener...except don't do this
-    // until the search is done, so we'll ignore results from a previous
-    // search.
-    mCanceled = mFinished = false;
-  }
-
-  return rv;
-}
-
-void nsAbModifyLDAPMessageListener::InitFailed(bool aCancelled) {
-  // XXX Just cancel the operation for now
-  // we'll need to review this when we've got the proper listeners in place.
-  Cancel();
-}
-
-nsresult nsAbModifyLDAPMessageListener::DoTask() {
-  nsresult rv;
-  mCanceled = mFinished = false;
-
-  mModifyOperation = do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = mModifyOperation->Init(mConnection, this, nullptr);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // XXX do we need the search controls?
-  rv = mModifyOperation->SetServerControls(mServerSearchControls);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = mModifyOperation->SetClientControls(mClientSearchControls);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (mFlagRename)
-    return mModifyOperation->Rename(mCardDN, mNewRDN, mNewBaseDN, true);
-
-  switch (mType) {
-    case nsILDAPModification::MOD_ADD:
-      return mModifyOperation->AddExt(mCardDN, mModification);
-    case nsILDAPModification::MOD_DELETE:
-      return mModifyOperation->DeleteExt(mCardDN);
-    case nsILDAPModification::MOD_REPLACE:
-      return mModifyOperation->ModifyExt(mCardDN, mModification);
-    default:
-      NS_ERROR("Bad LDAP modification requested");
-      return NS_ERROR_UNEXPECTED;
-  }
-}
-
-nsresult nsAbModifyLDAPMessageListener::OnLDAPMessageModifyResult(
-    nsILDAPMessage *aMessage) {
-  nsresult rv;
-  NS_ENSURE_ARG_POINTER(aMessage);
-
-  int32_t errCode;
-  rv = aMessage->GetErrorCode(&errCode);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (errCode != nsILDAPErrors::SUCCESS) {
-    nsAutoCString errMessage;
-    rv = aMessage->GetErrorMessage(errMessage);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    printf("LDAP modification failed (code: %i, message: %s)\n", errCode,
-           errMessage.get());
-    return NS_ERROR_FAILURE;
-  }
-
-  printf("LDAP modification succeeded\n");
-  return NS_OK;
-}
-
-nsresult nsAbModifyLDAPMessageListener::OnLDAPMessageRenameResult(
-    nsILDAPMessage *aMessage) {
-  nsresult rv;
-  NS_ENSURE_ARG_POINTER(aMessage);
-
-  int32_t errCode;
-  rv = aMessage->GetErrorCode(&errCode);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (errCode != nsILDAPErrors::SUCCESS) {
-    nsAutoCString errMessage;
-    rv = aMessage->GetErrorMessage(errMessage);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    printf("LDAP rename failed (code: %i, message: %s)\n", errCode,
-           errMessage.get());
-    return NS_ERROR_FAILURE;
-  }
-
-  // Rename succeeded, now update the card DN and
-  // process the main task
-  mCardDN.Assign(mNewRDN);
-  mCardDN.Append(',');
-  mCardDN.Append(mNewBaseDN);
-
-  printf("LDAP rename succeeded\n");
-  return DoTask();
-}
-
-nsAbLDAPDirectoryModify::nsAbLDAPDirectoryModify() {}
-
-nsAbLDAPDirectoryModify::~nsAbLDAPDirectoryModify() {}
-
-nsresult nsAbLDAPDirectoryModify::DoModify(nsIAbLDAPDirectory *directory,
-                                           const int32_t &updateType,
-                                           const nsACString &cardDN,
-                                           nsIArray *modArray,
-                                           const nsACString &newRDN,
-                                           const nsACString &newBaseDN) {
-  NS_ENSURE_ARG_POINTER(directory);
-  // modArray may be null in the delete operation case.
-  if (!modArray && (updateType == nsILDAPModification::MOD_ADD ||
-                    updateType == nsILDAPModification::MOD_REPLACE))
-    return NS_ERROR_NULL_POINTER;
-
-  nsresult rv;
-
-  // it's an error if we don't have a dn
-  if (cardDN.IsEmpty()) return NS_ERROR_INVALID_ARG;
-
-  nsCOMPtr<nsILDAPURL> currentUrl;
-  rv = directory->GetLDAPURL(getter_AddRefs(currentUrl));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Get the ldap connection
-  nsCOMPtr<nsILDAPConnection> ldapConnection =
-      do_CreateInstance(NS_LDAPCONNECTION_CONTRACTID, &rv);
-
-  nsCOMPtr<nsIMutableArray> serverSearchControls;
-  rv = directory->GetSearchServerControls(getter_AddRefs(serverSearchControls));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIMutableArray> clientSearchControls;
-  rv = directory->GetSearchClientControls(getter_AddRefs(clientSearchControls));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  /*
-  // XXX we need to fix how this all works - specifically, see the first patch
-  // on bug 124553 for how the query equivalent did this
-  // too soon? Do we need a new listener?
-  if (alreadyInitialized)
-  {
-    nsAbQueryLDAPMessageListener *msgListener =
-      NS_STATIC_CAST(nsAbQueryLDAPMessageListener *,
-                     NS_STATIC_CAST(nsILDAPMessageListener *, mListener.get()));
-    if (msgListener)
-      {
-        msgListener->mUrl = url;
-        return msgListener->DoSearch();
-      }
-  }*/
-
-  nsCString login;
-  rv = directory->GetAuthDn(login);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  uint32_t protocolVersion;
-  rv = directory->GetProtocolVersion(&protocolVersion);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Initiate LDAP message listener
-  nsAbModifyLDAPMessageListener *_messageListener =
-      new nsAbModifyLDAPMessageListener(
-          updateType, cardDN, modArray, newRDN, newBaseDN, currentUrl,
-          ldapConnection, serverSearchControls, clientSearchControls, login, 0);
-  if (_messageListener == NULL) return NS_ERROR_OUT_OF_MEMORY;
-
-  // Now lets initialize the LDAP connection properly. We'll kick
-  // off the bind operation in the callback function, |OnLDAPInit()|.
-  return ldapConnection->Init(currentUrl, login, _messageListener, nullptr,
-                              protocolVersion);
-}
deleted file mode 100644
--- a/mailnews/addrbook/src/nsAbLDAPDirectoryModify.h
+++ /dev/null
@@ -1,23 +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/. */
-
-#ifndef nsAbLDAPDirectoryModify_h__
-#define nsAbLDAPDirectoryModify_h__
-
-#include "nsIAbLDAPDirectory.h"
-#include "nsIArray.h"
-
-class nsAbLDAPDirectoryModify {
- public:
-  nsAbLDAPDirectoryModify();
-  virtual ~nsAbLDAPDirectoryModify();
-
- protected:
-  nsresult DoModify(nsIAbLDAPDirectory *directory, const int32_t &aUpdateType,
-                    const nsACString &aCardDN, nsIArray *modArray,
-                    const nsACString &aNewRDN, const nsACString &aNewBaseDN);
-};
-
-#endif  // nsAbLDAPDirectoryModify_h__
--- a/mailnews/addrbook/src/nsAbLDAPDirectoryQuery.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPDirectoryQuery.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIAbCard.h"
 #include "nsAbLDAPDirectoryQuery.h"
 #include "nsAbBoolExprToLDAPFilter.h"
 #include "nsILDAPMessage.h"
 #include "nsILDAPErrors.h"
 #include "nsIAbLDAPAttributeMap.h"
-#include "nsIAbLDAPCard.h"
 #include "nsAbUtils.h"
 #include "nsAbBaseCID.h"
 #include "nsString.h"
 #include "prprf.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCategoryManagerUtils.h"
 #include "nsAbLDAPDirectory.h"
@@ -34,19 +33,17 @@ class nsAbQueryLDAPMessageListener : pub
   // Note that the directoryUrl is the details of the ldap directory
   // without any search params or return attributes specified. The searchUrl
   // therefore has the search params and return attributes specified.
   //  nsAbQueryLDAPMessageListener(nsIAbDirectoryQuery* directoryQuery,
   nsAbQueryLDAPMessageListener(
       nsIAbDirectoryQueryResultListener *resultListener,
       nsILDAPURL *directoryUrl, nsILDAPURL *searchUrl,
       nsILDAPConnection *connection,
-      nsIAbDirectoryQueryArguments *queryArguments,
-      nsIMutableArray *serverSearchControls,
-      nsIMutableArray *clientSearchControls, const nsACString &login,
+      nsIAbDirectoryQueryArguments *queryArguments, const nsACString &login,
       const nsACString &mechanism, const int32_t resultLimit = -1,
       const int32_t timeOut = 0);
 
   // nsILDAPMessageListener
   NS_IMETHOD OnLDAPMessage(nsILDAPMessage *aMessage) override;
 
  protected:
   virtual ~nsAbQueryLDAPMessageListener();
@@ -62,40 +59,33 @@ class nsAbQueryLDAPMessageListener : pub
   nsCOMPtr<nsILDAPURL> mSearchUrl;
   nsIAbDirectoryQueryResultListener *mResultListener;
   int32_t mContextID;
   nsCOMPtr<nsIAbDirectoryQueryArguments> mQueryArguments;
   int32_t mResultLimit;
 
   bool mFinished;
   bool mCanceled;
-
-  nsCOMPtr<nsIMutableArray> mServerSearchControls;
-  nsCOMPtr<nsIMutableArray> mClientSearchControls;
 };
 
 NS_IMPL_ISUPPORTS(nsAbQueryLDAPMessageListener, nsILDAPMessageListener)
 
 nsAbQueryLDAPMessageListener::nsAbQueryLDAPMessageListener(
     nsIAbDirectoryQueryResultListener *resultListener, nsILDAPURL *directoryUrl,
     nsILDAPURL *searchUrl, nsILDAPConnection *connection,
-    nsIAbDirectoryQueryArguments *queryArguments,
-    nsIMutableArray *serverSearchControls,
-    nsIMutableArray *clientSearchControls, const nsACString &login,
+    nsIAbDirectoryQueryArguments *queryArguments, const nsACString &login,
     const nsACString &mechanism, const int32_t resultLimit,
     const int32_t timeOut)
     : nsAbLDAPListenerBase(directoryUrl, connection, login, timeOut),
       mSearchUrl(searchUrl),
       mResultListener(resultListener),
       mQueryArguments(queryArguments),
       mResultLimit(resultLimit),
       mFinished(false),
-      mCanceled(false),
-      mServerSearchControls(serverSearchControls),
-      mClientSearchControls(clientSearchControls) {
+      mCanceled(false) {
   mSaslMechanism.Assign(mechanism);
 }
 
 nsAbQueryLDAPMessageListener::~nsAbQueryLDAPMessageListener() {}
 
 nsresult nsAbQueryLDAPMessageListener::Cancel() {
   nsresult rv = Initiate();
   NS_ENSURE_SUCCESS(rv, rv);
@@ -206,22 +196,16 @@ nsresult nsAbQueryLDAPMessageListener::D
   nsAutoCString filter;
   rv = mSearchUrl->GetFilter(filter);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString attributes;
   rv = mSearchUrl->GetAttributes(attributes);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = mOperation->SetServerControls(mServerSearchControls);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = mOperation->SetClientControls(mClientSearchControls);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   return mOperation->SearchExt(dn, scope, filter, attributes, mTimeOut,
                                mResultLimit);
 }
 
 void nsAbQueryLDAPMessageListener::InitFailed(bool aCancelled) {
   if (!mResultListener) return;
 
   // In the !aCancelled case we know there was an error, but we won't be
@@ -241,28 +225,23 @@ nsresult nsAbQueryLDAPMessageListener::O
   // the map for translating between LDAP attrs <-> addrbook fields
   nsCOMPtr<nsISupports> iSupportsMap;
   rv = mQueryArguments->GetTypeSpecificArg(getter_AddRefs(iSupportsMap));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIAbLDAPAttributeMap> map = do_QueryInterface(iSupportsMap, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIAbCard> card = do_CreateInstance(NS_ABLDAPCARD_CONTRACTID, &rv);
+  nsCOMPtr<nsIAbCard> card =
+      do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = map->SetCardPropertiesFromLDAPMessage(aMessage, card);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIAbLDAPCard> ldapCard = do_QueryInterface(card, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = ldapCard->SetMetaProperties(aMessage);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   return mResultListener->OnQueryFoundCard(card);
 }
 
 nsresult nsAbQueryLDAPMessageListener::OnLDAPMessageSearchResult(
     nsILDAPMessage *aMessage) {
   int32_t errorCode;
   nsresult rv = aMessage->GetErrorCode(&errorCode);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -480,42 +459,30 @@ NS_IMETHODIMP nsAbLDAPDirectoryQuery::Do
       msgListener->mDirectoryUrl = mDirectoryUrl;
       msgListener->mSearchUrl = url;
       // Also ensure we set the correct result limit
       msgListener->mResultLimit = aResultLimit;
       return msgListener->DoTask();
     }
   }
 
-  nsCOMPtr<nsIAbLDAPDirectory> abLDAPDir = do_QueryInterface(aDirectory, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIMutableArray> serverSearchControls;
-  rv = abLDAPDir->GetSearchServerControls(getter_AddRefs(serverSearchControls));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIMutableArray> clientSearchControls;
-  rv = abLDAPDir->GetSearchClientControls(getter_AddRefs(clientSearchControls));
-  NS_ENSURE_SUCCESS(rv, rv);
-
   // Create the new connection (which cause the old one to be dropped if
   // necessary)
   mConnection = do_CreateInstance(NS_LDAPCONNECTION_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIAbDirectoryQueryResultListener> resultListener =
       do_QueryInterface((nsIAbDirectoryQuery *)this, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Initiate LDAP message listener
   nsAbQueryLDAPMessageListener *_messageListener =
       new nsAbQueryLDAPMessageListener(
           resultListener, mDirectoryUrl, url, mConnection, aArguments,
-          serverSearchControls, clientSearchControls, mCurrentLogin,
-          mCurrentMechanism, aResultLimit, aTimeOut);
+          mCurrentLogin, mCurrentMechanism, aResultLimit, aTimeOut);
   if (_messageListener == NULL) return NS_ERROR_OUT_OF_MEMORY;
 
   mListener = _messageListener;
   *_retval = 1;
 
   // Now lets initialize the LDAP connection properly. We'll kick
   // off the bind operation in the callback function, |OnLDAPInit()|.
   rv = mConnection->Init(mDirectoryUrl, mCurrentLogin, mListener, nullptr,
--- a/mailnews/addrbook/src/nsAbLDAPReplicationData.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPReplicationData.cpp
@@ -22,21 +22,17 @@ using namespace mozilla;
 // threadsafe implementation is not really thread safe since each object should
 // exist independently along with its related independent
 // nsAbLDAPReplicationQuery object.
 NS_IMPL_ISUPPORTS(nsAbLDAPProcessReplicationData,
                   nsIAbLDAPProcessReplicationData, nsILDAPMessageListener,
                   nsIObserver)
 
 nsAbLDAPProcessReplicationData::nsAbLDAPProcessReplicationData()
-    : nsAbLDAPListenerBase(),
-      mState(kIdle),
-      mProtocol(-1),
-      mCount(0),
-      mInitialized(false) {}
+    : nsAbLDAPListenerBase(), mState(kIdle), mCount(0), mInitialized(false) {}
 
 nsAbLDAPProcessReplicationData::~nsAbLDAPProcessReplicationData() {}
 
 NS_IMETHODIMP nsAbLDAPProcessReplicationData::Init(
     nsIAbLDAPDirectory *aDirectory, nsILDAPConnection *aConnection,
     nsILDAPURL *aURL, nsIAbLDAPReplicationQuery *aQuery,
     nsIWebProgressListener *aProgressListener) {
   NS_ENSURE_ARG_POINTER(aDirectory);
@@ -76,23 +72,16 @@ NS_IMETHODIMP nsAbLDAPProcessReplication
 
 NS_IMETHODIMP nsAbLDAPProcessReplicationData::GetReplicationState(
     int32_t *aReplicationState) {
   NS_ENSURE_ARG_POINTER(aReplicationState);
   *aReplicationState = mState;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsAbLDAPProcessReplicationData::GetProtocolUsed(
-    int32_t *aProtocolUsed) {
-  NS_ENSURE_ARG_POINTER(aProtocolUsed);
-  *aProtocolUsed = mProtocol;
-  return NS_OK;
-}
-
 NS_IMETHODIMP nsAbLDAPProcessReplicationData::OnLDAPMessage(
     nsILDAPMessage *aMessage) {
   NS_ENSURE_ARG_POINTER(aMessage);
 
   if (!mInitialized) return NS_ERROR_NOT_INITIALIZED;
 
   int32_t messageType;
   nsresult rv = aMessage->GetType(&messageType);
--- a/mailnews/addrbook/src/nsAbLDAPReplicationData.h
+++ b/mailnews/addrbook/src/nsAbLDAPReplicationData.h
@@ -43,17 +43,16 @@ class nsAbLDAPProcessReplicationData : p
 
   nsCOMPtr<nsIAbDirectory> mReplicationDB;
   nsCOMPtr<nsIFile> mReplicationFile;
   nsCOMPtr<nsIFile> mOldReplicationFile;
   nsCString mReplicationFileName;
 
   // state of processing, protocol used and count of results
   int32_t mState;
-  int32_t mProtocol;
   int32_t mCount;
   bool mInitialized;
 
   nsCOMPtr<nsIAbLDAPDirectory> mDirectory;
   nsCOMPtr<nsIAbLDAPAttributeMap> mAttrMap;  // maps ab properties to ldap attrs
 
   virtual nsresult OnLDAPSearchEntry(nsILDAPMessage *aMessage);
   virtual nsresult OnLDAPSearchResult(nsILDAPMessage *aMessage);
--- a/mailnews/addrbook/src/nsAbLDAPReplicationService.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPReplicationService.cpp
@@ -5,18 +5,16 @@
 #include "nsCOMPtr.h"
 #include "nsAbLDAPReplicationService.h"
 #include "nsAbLDAPReplicationQuery.h"
 #include "nsAbBaseCID.h"
 #include "nsIWebProgressListener.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 
-// XXX Change log replication doesn't work. Bug 311632 should fix it.
-//#include "nsAbLDAPChangeLogQuery.h"
 #include "nsIAbLDAPReplicationData.h"
 
 /*** implementation of the service ******/
 
 NS_IMPL_ISUPPORTS(nsAbLDAPReplicationService, nsIAbLDAPReplicationService)
 
 nsAbLDAPReplicationService::nsAbLDAPReplicationService()
     : mReplicating(false) {}
@@ -24,38 +22,24 @@ nsAbLDAPReplicationService::nsAbLDAPRepl
 nsAbLDAPReplicationService::~nsAbLDAPReplicationService() {}
 
 /* void startReplication(in string aURI, in nsIWebProgressListener
  * progressListener); */
 NS_IMETHODIMP nsAbLDAPReplicationService::StartReplication(
     nsIAbLDAPDirectory *aDirectory, nsIWebProgressListener *progressListener) {
   NS_ENSURE_ARG_POINTER(aDirectory);
 
-#ifdef DEBUG_rdayal
-  printf("Start Replication called");
-#endif
-
   // Makes sure to allow only one replication at a time.
   if (mReplicating) return NS_ERROR_FAILURE;
 
   mDirectory = aDirectory;
 
   nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
 
-  switch (DecideProtocol()) {
-    case nsIAbLDAPProcessReplicationData::kDefaultDownloadAll:
-      mQuery = do_CreateInstance(NS_ABLDAP_REPLICATIONQUERY_CONTRACTID, &rv);
-      break;
-      // XXX Change log replication doesn't work. Bug 311632 should fix it.
-      // case nsIAbLDAPProcessReplicationData::kChangeLogProtocol:
-      //  mQuery = do_CreateInstance (NS_ABLDAP_CHANGELOGQUERY_CONTRACTID, &rv);
-      //  break;
-    default:
-      break;
-  }
+  mQuery = do_CreateInstance(NS_ABLDAP_REPLICATIONQUERY_CONTRACTID, &rv);
 
   if (NS_SUCCEEDED(rv) && mQuery) {
     rv = mQuery->Init(mDirectory, progressListener);
     if (NS_SUCCEEDED(rv)) {
       rv = mQuery->DoReplicationQuery();
       if (NS_SUCCEEDED(rv)) {
         mReplicating = true;
         return rv;
@@ -96,20 +80,8 @@ NS_IMETHODIMP nsAbLDAPReplicationService
   mReplicating = false;
   if (mQuery) {
     mQuery = nullptr;      // Release query obj
     mDirectory = nullptr;  // Release directory
   }
 
   return NS_OK;
 }
-
-// XXX: This method should query the RootDSE for the changeLog attribute,
-// if it exists ChangeLog protocol is supported.
-int32_t nsAbLDAPReplicationService::DecideProtocol() {
-  // Do the changeLog, it will decide if there is a need to replicate all
-  // entries or only update existing DB and will do the appropriate thing.
-  //
-  // XXX: Bug 231965 changed this from kChangeLogProtocol to
-  // kDefaultDownloadAll because of a problem with ldap replication not
-  // working correctly. We need to change this back at some stage (bug 311632).
-  return nsIAbLDAPProcessReplicationData::kDefaultDownloadAll;
-}
--- a/mailnews/addrbook/src/nsAbLDAPReplicationService.h
+++ b/mailnews/addrbook/src/nsAbLDAPReplicationService.h
@@ -11,18 +11,16 @@
 
 class nsAbLDAPReplicationService : public nsIAbLDAPReplicationService {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIABLDAPREPLICATIONSERVICE
 
   nsAbLDAPReplicationService();
 
-  int32_t DecideProtocol();
-
  protected:
   virtual ~nsAbLDAPReplicationService();
   nsCOMPtr<nsIAbLDAPReplicationQuery> mQuery;
   bool mReplicating;
   nsCOMPtr<nsIAbLDAPDirectory> mDirectory;
 };
 
 #endif /* nsAbLDAPReplicationService_h___ */
--- a/mailnews/build/nsMailModule.cpp
+++ b/mailnews/build/nsMailModule.cpp
@@ -107,39 +107,35 @@
 #include "nsStopwatch.h"
 #include "MailNewsDLF.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // addrbook includes
 ////////////////////////////////////////////////////////////////////////////////
 #include "nsAbBaseCID.h"
 #include "nsAddrDatabase.h"
+#include "nsAbCardProperty.h"
 #include "nsAbContentHandler.h"
 #include "nsAbDirProperty.h"
 #include "nsAbAddressCollector.h"
 #include "nsAddbookProtocolHandler.h"
 #include "nsAddbookUrl.h"
 
 #include "nsAbDirectoryQuery.h"
 #include "nsAbBooleanExpression.h"
 #include "nsAbDirectoryQueryProxy.h"
 #include "nsMsgVCardService.h"
 #include "nsAbLDIFService.h"
 
 #if defined(MOZ_LDAP_XPCOM)
 #  include "nsAbLDAPDirectory.h"
 #  include "nsAbLDAPDirectoryQuery.h"
-#  include "nsAbLDAPCard.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"
 #endif
 
 #if defined(MOZ_MAPI_SUPPORT)
 #  include "nsAbOutlookInterface.h"
 #  include "nsAbOutlookDirectory.h"
 #endif
 
 #ifdef XP_MACOSX
@@ -443,24 +439,19 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlo
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryArguments)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBooleanConditionString)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBooleanExpression)
 
 #if defined(MOZ_LDAP_XPCOM)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPDirectory)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPDirectoryQuery)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPCard)
 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)
 #endif
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryProxy)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgVCardService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDIFService)
 
 #ifdef XP_MACOSX
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOSXDirectory)
@@ -480,17 +471,16 @@ NS_DEFINE_NAMED_CID(NS_BOOLEANEXPRESSION
 #if defined(MOZ_MAPI_SUPPORT)
 NS_DEFINE_NAMED_CID(NS_ABOUTLOOKDIRECTORY_CID);
 NS_DEFINE_NAMED_CID(NS_ABOUTLOOKINTERFACE_CID);
 #endif
 
 #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_ABLDAP_REPLICATIONSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAP_REPLICATIONQUERY_CID);
 NS_DEFINE_NAMED_CID(NS_ABLDAP_PROCESSREPLICATIONDATA_CID);
 #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);
@@ -896,17 +886,16 @@ const mozilla::Module::CIDEntry kMailNew
     {&kNS_BOOLEANCONDITIONSTRING_CID, false, NULL,
      nsAbBooleanConditionStringConstructor},
     {&kNS_BOOLEANEXPRESSION_CID, false, NULL, nsAbBooleanExpressionConstructor},
 
 #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},
 #endif
     {&kNS_ABDIRECTORYQUERYPROXY_CID, false, NULL,
@@ -1129,17 +1118,16 @@ const mozilla::Module::ContractIDEntry k
     {NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,
      &kNS_ABDIRECTORYQUERYARGUMENTS_CID},
     {NS_BOOLEANCONDITIONSTRING_CONTRACTID, &kNS_BOOLEANCONDITIONSTRING_CID},
     {NS_BOOLEANEXPRESSION_CONTRACTID, &kNS_BOOLEANEXPRESSION_CID},
 
 #if defined(MOZ_LDAP_XPCOM)
     {NS_ABLDAPDIRECTORY_CONTRACTID, &kNS_ABLDAPDIRECTORY_CID},
     {NS_ABLDAPDIRECTORYQUERY_CONTRACTID, &kNS_ABLDAPDIRECTORYQUERY_CID},
-    {NS_ABLDAPCARD_CONTRACTID, &kNS_ABLDAPCARD_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},
 #endif
 
     {NS_ABDIRECTORYQUERYPROXY_CONTRACTID, &kNS_ABDIRECTORYQUERYPROXY_CID},