Bug 1606284 - Remove non-needed parts of nsAddrDatabase, making it read-only; r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 30 Dec 2019 12:26:55 +1300
changeset 37843 5a245657c1497b0cd6d9964c185ecaa959a2eb5d
parent 37842 20abf751b302882b21564283e628455764d044a1
child 37844 4ac150bcbb59400b3655dbaef3f2394614a25445
push id397
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:16:13 +0000
reviewersmkmelin
bugs1606284
Bug 1606284 - Remove non-needed parts of nsAddrDatabase, making it read-only; r=mkmelin
mailnews/addrbook/public/nsIAddrDatabase.idl
mailnews/addrbook/src/nsAddrDatabase.cpp
mailnews/addrbook/src/nsAddrDatabase.h
--- a/mailnews/addrbook/public/nsIAddrDatabase.idl
+++ b/mailnews/addrbook/public/nsIAddrDatabase.idl
@@ -72,231 +72,28 @@ interface nsIAddrDatabase : nsISupports 
    *                                        specified location (and create was
    *                                        false).
    * @exception NS_ERROR_FILE_ACCESS_DENIED The file could not be opened as
    *                                        access was denied.
    */
   void openMDB(in nsIFile dbName, in boolean create);
   void closeMDB(in boolean commit);
 
-  void commit(in unsigned long commitType);
   void forceClosed();
 
   /**
-   * Create a new card and add to the database
-   *
-   * @param     aNewCard       the card to be added
-   * @param     aNotify        if set to true, all the listeners of the
-   *                           database will be notified.
-   * @param     aParent        parent directory or mailing list to which the
-   *                           card is added. If set to null, listeners of the
-   *                           database will not be notified of card creation.
-   */
-  void createNewCardAndAddToDB(in nsIAbCard aNewCard, in boolean aNotify, in nsIAbDirectory aParent);
-
-  void createNewListCardAndAddToDB(in nsIAbDirectory list, in unsigned long listRowID, in nsIAbCard newCard, in boolean aNotify);
-
-  /**
-   * Create a new mailing list and add to the database
-   *
-   * @param     aNewList       the mailing list to be added.
-   * @param     aNotify        if set to true, all the listeners of the
-   *                           database will be notified.
-   * @param     aParent        parent directory to which the mailing list
-   *                           is added. If set to null, listeners of the database
-   *                           will not be notified of mailing list creation.
-   */
-  void createMailListAndAddToDB(in nsIAbDirectory aNewList, in boolean aNotify, in nsIAbDirectory aParent);
-
-  /**
    * Enumerate the cards in the directory. The enumerator will return the
    * cards associated with mailing lists too.
    *
    * @param directory the directory of which to enumerate the cards.
    * @return an enumerator.
    */
   nsISimpleEnumerator enumerateCards(in nsIAbDirectory directory);
 
   /**
    * Enumerate the cards associated with the mailing lists in the directory.
    *
    * @param directory the directory of which to enumerate the cards.
    * @return an enumerator.
    */
   nsISimpleEnumerator enumerateListAddresses(in nsIAbDirectory directory,
                                              in unsigned long listRowID);
-
-  void getMailingListsFromDB(in nsIAbDirectory parentDir);
-
-  /**
-   * Delete a card from the database.
-   *
-   * @param     aCard          the card to be deleted.
-   * @param     aNotify        if set to true, all the listeners of the
-   *                           database will be notified.
-   * @param     aParent        parent directory from which the card
-   *                           is to be deleted. If set to null, listeners of
-   *                           the database will not be notified of card deletion.
-   */
-  void deleteCard(in nsIAbCard aCard, in boolean aNotify, in nsIAbDirectory aParent);
-
-  /**
-   * Edit a card in the database.
-   *
-   * @param     aCard          the card to be edited.
-   * @param     aNotify        if set to true, all the listeners of the
-   *                           database will be notified.
-   * @param     aParent        parent directory in which the card
-   *                           is to be edited. If set to null, listeners of
-   *                           the database will not be notified of card entry
-   *                           change.
-   */
-  void editCard(in nsIAbCard aCard, in boolean aNotify, in nsIAbDirectory aParent);
-  boolean containsCard(in nsIAbCard card);
-  /**
-   * Deletes a mailing list from the directory
-   *
-   * @param aMailList         The nsIAbDirectory implementation of the mailing
-   *                          list that is to be deleted.
-   * @param aParent           The parent of the mailing list that is being
-   *                          deleted. If this is supplied, then a notification
-   *                          of card entry change in the database will be made.
-   */
-  void deleteMailList(in nsIAbDirectory aMailList,
-                      [optional] in nsIAbDirectory aParent);
-  void editMailList(in nsIAbDirectory mailList, in nsIAbCard listCard, in boolean aNotify);
-  boolean containsMailList(in nsIAbDirectory mailList);
-  void deleteCardFromMailList(in nsIAbDirectory mailList, in nsIAbCard card, in boolean aNotify);
-
-  /**
-   * Gets the first card which matches the attribute/value pair supplied.
-   *
-   * @param  aDirectory       The current nsIAbDirectory associated with this
-   *                          instance of the database.
-   * @param  aName            The attribute to look up the value in.
-   * @param  aUTF8Value       The value to look up in UTF8 format.
-   * @param  aCaseInsensitive Set to true for case-insensitive matching.
-   * @result                  Returns an nsIAbCard if one is found, otherwise
-   *                          NULL.
-   */
-  nsIAbCard getCardFromAttribute(in nsIAbDirectory aDirectory, in string aName,
-                                 in AUTF8String aUTF8Value,
-                                 in boolean aCaseInsensitive);
-
-  /**
-   * Gets all cards which matches the attribute/value pair supplied.
-   *
-   * @param  aDirectory       The current nsIAbDirectory associated with this
-   *                          instance of the database.
-   * @param  aName            The attribute to look up the value in.
-   * @param  aUTF8Value       The value to look up in UTF8 format.
-   * @param  aCaseInsensitive Set to true for case-insensitive matching.
-   * @result                  Returns an nsISimpleEnumerator of nsIAbCard
-   *                          instances.
-   */
-  nsISimpleEnumerator getCardsFromAttribute(in nsIAbDirectory aDirectory,
-                                            in string aName,
-                                            in AUTF8String uUTF8Value,
-                                            in boolean aCaseInsensitive);
-
-  boolean findMailListbyUnicodeName(in wstring listName);
-
-  void getCardCount(out uint32_t count);
-
-  [noscript] readonly attribute nsIMdbRow newRow;
-  [noscript] readonly attribute nsIMdbRow newListRow;
-  [noscript] void addCardRowToDB(in nsIMdbRow newRow);
-  [noscript] void addLdifListMember(in nsIMdbRow row, in string value);
-  [noscript] void addUID(in nsIMdbRow row, in string value);
-  [noscript] void addFirstName(in nsIMdbRow row, in string value);
-  [noscript] void addLastName(in nsIMdbRow row, in string value);
-  [noscript] void addPhoneticFirstName(in nsIMdbRow row, in string value);
-  [noscript] void addPhoneticLastName(in nsIMdbRow row, in string value);
-  [noscript] void addDisplayName(in nsIMdbRow row, in string value);
-  [noscript] void addNickName(in nsIMdbRow row, in string value);
-  [noscript] void addPrimaryEmail(in nsIMdbRow row, in string value);
-  [noscript] void add2ndEmail(in nsIMdbRow row, in string value);
-  [noscript] void addWorkPhone(in nsIMdbRow row, in string value);
-  [noscript] void addHomePhone(in nsIMdbRow row, in string value);
-  [noscript] void addFaxNumber(in nsIMdbRow row, in string value);
-  [noscript] void addPagerNumber(in nsIMdbRow row, in string value);
-  [noscript] void addCellularNumber(in nsIMdbRow row, in string value);
-  [noscript] void addWorkPhoneType(in nsIMdbRow row, in string value);
-  [noscript] void addHomePhoneType(in nsIMdbRow row, in string value);
-  [noscript] void addFaxNumberType(in nsIMdbRow row, in string value);
-  [noscript] void addPagerNumberType(in nsIMdbRow row, in string value);
-  [noscript] void addCellularNumberType(in nsIMdbRow row, in string value);
-  [noscript] void addHomeAddress(in nsIMdbRow row, in string value);
-  [noscript] void addHomeAddress2(in nsIMdbRow row, in string value);
-  [noscript] void addHomeCity(in nsIMdbRow row, in string value);
-  [noscript] void addHomeState(in nsIMdbRow row, in string value);
-  [noscript] void addHomeZipCode(in nsIMdbRow row, in string value);
-  [noscript] void addHomeCountry(in nsIMdbRow row, in string value);
-  [noscript] void addWorkAddress(in nsIMdbRow row, in string value);
-  [noscript] void addWorkAddress2(in nsIMdbRow row, in string value);
-  [noscript] void addWorkCity(in nsIMdbRow row, in string value);
-  [noscript] void addWorkState(in nsIMdbRow row, in string value);
-  [noscript] void addWorkZipCode(in nsIMdbRow row, in string value);
-  [noscript] void addWorkCountry(in nsIMdbRow row, in string value);
-  [noscript] void addJobTitle(in nsIMdbRow row, in string value);
-  [noscript] void addDepartment(in nsIMdbRow row, in string value);
-  [noscript] void addCompany(in nsIMdbRow row, in string value);
-  [noscript] void addAimScreenName(in nsIMdbRow row, in string value);
-  [noscript] void addAnniversaryYear(in nsIMdbRow row, in string value);
-  [noscript] void addAnniversaryMonth(in nsIMdbRow row, in string value);
-  [noscript] void addAnniversaryDay(in nsIMdbRow row, in string value);
-  [noscript] void addSpouseName(in nsIMdbRow row, in string value);
-  [noscript] void addFamilyName(in nsIMdbRow row, in string value);
-  [noscript] void addDefaultAddress(in nsIMdbRow row, in string value);
-  [noscript] void addCategory(in nsIMdbRow row, in string value);
-  [noscript] void addWebPage1(in nsIMdbRow row, in string value);
-  [noscript] void addWebPage2(in nsIMdbRow row, in string value);
-  [noscript] void addBirthYear(in nsIMdbRow row, in string value);
-  [noscript] void addBirthMonth(in nsIMdbRow row, in string value);
-  [noscript] void addBirthDay(in nsIMdbRow row, in string value);
-  [noscript] void addCustom1(in nsIMdbRow row, in string value);
-  [noscript] void addCustom2(in nsIMdbRow row, in string value);
-  [noscript] void addCustom3(in nsIMdbRow row, in string value);
-  [noscript] void addCustom4(in nsIMdbRow row, in string value);
-  [noscript] void addNotes(in nsIMdbRow row, in string value);
-  [noscript] void addPreferMailFormat(in nsIMdbRow row, in unsigned long value);
-  [noscript] void addPopularityIndex(in nsIMdbRow row, in unsigned long value);
-
-  [noscript] void addListName(in nsIMdbRow row, in string value);
-  [noscript] void addListNickName(in nsIMdbRow row, in string value);
-  [noscript] void addListDescription(in nsIMdbRow row, in string value);
-  [noscript] void addListDirNode(in nsIMdbRow listRow);
-
-  /**
-   * use for getting and setting generic string attributes
-   * like _AimScreenName
-   */
-  void setCardValue(in nsIAbCard card, in string name, in wstring value, in boolean notify);
-  wstring getCardValue(in nsIAbCard card, in string name);
-
-  /**
-   * Add the column representing the card to the mailing list row
-   * in the database.
-   *
-   * @param     aPCard         the card to be added.
-   * @param     aPListRow      the row to which the column will be added.
-   * @param     aPos           the position of the card in the mailing list.
-   * @param     aPNewCard      a pointer to hold the new card added to the row.
-   * @param     aInMailingList If set to true, the card is already present
-   *                           in the mailing list
-   * @param     aParent        parent mailing list to which the card
-   *                           is added. If set to null, listeners of the
-   *                           database will not be notified of card creation.
-   * @param     aRoot          If the card is created while creating a new mailing
-   *                           list, its set to the parent addressbook.
-   *                           Set to null in other case.
-   */
-  void AddListCardColumnsToRow(in nsIAbCard aPCard,
-                               in nsIMdbRow aPListRow,
-                               in unsigned long aPos,
-                               out nsIAbCard aPNewCard,
-                               in boolean aInMailingList,
-                               in nsIAbDirectory aParent,
-                               in nsIAbDirectory aRoot);
-  void InitCardFromRow(in nsIAbCard aNewCard,in nsIMdbRow aCardRow);
-  void SetListAddressTotal(in nsIMdbRow aListRow, in uint32_t aTotal);
-  nsIMdbRow FindRowByCard(in nsIAbCard aCard);
 };
--- a/mailnews/addrbook/src/nsAddrDatabase.cpp
+++ b/mailnews/addrbook/src/nsAddrDatabase.cpp
@@ -66,19 +66,17 @@ struct mdbOid gAddressBookTableOID;
 
 static const char kMailListAddressFormat[] = "Address%d";
 
 nsAddrDatabase::nsAddrDatabase()
     : m_mdbEnv(nullptr),
       m_mdbStore(nullptr),
       m_mdbPabTable(nullptr),
       m_mdbTokensInitialized(false),
-      m_mdbDeletedCardsTableRemoved(false),
       m_PabTableKind(0),
-      m_MailListTableKind(0),
       m_DeletedCardsTableKind(0),
       m_CardRowScopeToken(0),
       m_UIDColumnToken(0),
       m_FirstNameColumnToken(0),
       m_LastNameColumnToken(0),
       m_PhoneticFirstNameColumnToken(0),
       m_PhoneticLastNameColumnToken(0),
       m_DisplayNameColumnToken(0),
@@ -125,17 +123,16 @@ nsAddrDatabase::nsAddrDatabase()
       m_Custom2ColumnToken(0),
       m_Custom3ColumnToken(0),
       m_Custom4ColumnToken(0),
       m_NotesColumnToken(0),
       m_LastModDateColumnToken(0),
       m_MailFormatColumnToken(0),
       m_PopularityIndexColumnToken(0),
       m_AddressCharSetColumnToken(0),
-      m_LastRecordKey(0),
       m_dbDirectory(nullptr) {}
 
 nsAddrDatabase::~nsAddrDatabase() {
   Close(false);  // better have already been closed.
 
   RemoveFromCache(this);
   // clean up after ourself!
   if (m_mdbPabTable) m_mdbPabTable->Release();
@@ -464,41 +461,25 @@ NS_IMETHODIMP nsAddrDatabase::OpenMDB(ns
       if (NS_SUCCEEDED(ret) && outDone) {
         ret = mdbFactory->ThumbToOpenStore(m_mdbEnv, thumb, &m_mdbStore);
         if (NS_SUCCEEDED(ret) && m_mdbStore) {
           ret = InitExistingDB();
           create = false;
         }
       }
     } else if (create && ret != NS_ERROR_FILE_ACCESS_DENIED) {
-      nsIMdbFile *newFile = 0;
-      ret =
-          mdbFactory->CreateNewFile(m_mdbEnv, dbHeap, filePath.get(), &newFile);
-      if (newFile) {
-        if (NS_SUCCEEDED(ret)) {
-          mdbOpenPolicy inOpenPolicy;
-
-          inOpenPolicy.mOpenPolicy_ScopePlan.mScopeStringSet_Count = 0;
-          inOpenPolicy.mOpenPolicy_MinMemory = 0;
-          inOpenPolicy.mOpenPolicy_MaxLazy = 0;
-
-          ret = mdbFactory->CreateNewFileStore(m_mdbEnv, dbHeap, newFile,
-                                               &inOpenPolicy, &m_mdbStore);
-          if (NS_SUCCEEDED(ret)) ret = InitNewDB();
-        }
-        NS_RELEASE(newFile);  // always release our file ref, store has own
-      }
+      ret = NS_ERROR_NOT_IMPLEMENTED;
     }
     NS_IF_RELEASE(thumb);
   }
   return ret;
 }
 
 NS_IMETHODIMP nsAddrDatabase::CloseMDB(bool commit) {
-  if (commit) Commit(nsAddrDBCommitType::kSessionCommit);
+  if (commit) return NS_ERROR_NOT_IMPLEMENTED;
   //???    RemoveFromCache(this);  // if we've closed it, better not leave it in
   // the cache.
   return NS_OK;
 }
 
 // force the database to close - this'll flush out anybody holding onto
 // a database without having a listener!
 // This is evil in the com world, but there are times we need to delete the
@@ -513,299 +494,55 @@ NS_IMETHODIMP nsAddrDatabase::ForceClose
   RemoveFromCache(this);
 
   err = CloseMDB(false);  // since we're about to delete it, no need to commit.
   NS_IF_RELEASE(m_mdbStore);
   NS_RELEASE_THIS();
   return err;
 }
 
-NS_IMETHODIMP nsAddrDatabase::Commit(uint32_t commitType) {
-  nsresult err = NS_OK;
-  nsIMdbThumb *commitThumb = nullptr;
-
-  if (commitType == nsAddrDBCommitType::kLargeCommit ||
-      commitType == nsAddrDBCommitType::kSessionCommit) {
-    mdb_percent outActualWaste = 0;
-    mdb_bool outShould;
-    if (m_mdbStore && m_mdbEnv) {
-      // check how much space would be saved by doing a compress commit.
-      // If it's more than 30%, go for it.
-      // N.B. - I'm not sure this calls works in Mork for all cases.
-      err =
-          m_mdbStore->ShouldCompress(m_mdbEnv, 30, &outActualWaste, &outShould);
-      if (NS_SUCCEEDED(err) && outShould) {
-        commitType = nsAddrDBCommitType::kCompressCommit;
-      }
-    }
-  }
-
-  if (m_mdbStore && m_mdbEnv) {
-    switch (commitType) {
-      case nsAddrDBCommitType::kLargeCommit:
-        err = m_mdbStore->LargeCommit(m_mdbEnv, &commitThumb);
-        break;
-      case nsAddrDBCommitType::kSessionCommit:
-        // comment out until persistence works.
-        err = m_mdbStore->SessionCommit(m_mdbEnv, &commitThumb);
-        break;
-      case nsAddrDBCommitType::kCompressCommit:
-        err = m_mdbStore->CompressCommit(m_mdbEnv, &commitThumb);
-        break;
-    }
-  }
-  if (commitThumb && m_mdbEnv) {
-    mdb_count outTotal = 0;      // total somethings to do in operation
-    mdb_count outCurrent = 0;    // subportion of total completed so far
-    mdb_bool outDone = false;    // is operation finished?
-    mdb_bool outBroken = false;  // is operation irreparably dead and broken?
-    while (!outDone && !outBroken && NS_SUCCEEDED(err)) {
-      err = commitThumb->DoMore(m_mdbEnv, &outTotal, &outCurrent, &outDone,
-                                &outBroken);
-    }
-    NS_RELEASE(commitThumb);
-  }
-  // ### do something with error, but clear it now because mork errors out on
-  // commits.
-  if (m_mdbEnv) m_mdbEnv->ClearErrors();
-  return err;
-}
-
 NS_IMETHODIMP nsAddrDatabase::Close(bool forceCommit /* = TRUE */) {
   return CloseMDB(forceCommit);
 }
 
-// set up empty tablesetc.
-nsresult nsAddrDatabase::InitNewDB() {
-  nsresult err = InitMDBInfo();
-  if (NS_SUCCEEDED(err)) {
-    err = InitPabTable();
-    err = InitLastRecorKey();
-    Commit(nsAddrDBCommitType::kLargeCommit);
-  }
-  return err;
-}
-
 nsresult nsAddrDatabase::InitPabTable() {
   return m_mdbStore && m_mdbEnv
              ? m_mdbStore->NewTableWithOid(
                    m_mdbEnv, &gAddressBookTableOID, m_PabTableKind, false,
                    (const mdbOid *)nullptr, &m_mdbPabTable)
              : NS_ERROR_NULL_POINTER;
 }
 
-// save the last record number, store in m_DataRowScopeToken, row 1
-nsresult nsAddrDatabase::InitLastRecorKey() {
-  if (!m_mdbPabTable || !m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsIMdbRow *pDataRow = nullptr;
-  mdbOid dataRowOid;
-  dataRowOid.mOid_Scope = m_DataRowScopeToken;
-  dataRowOid.mOid_Id = DATAROW_ROWID;
-  nsresult err = m_mdbStore->NewRowWithOid(m_mdbEnv, &dataRowOid, &pDataRow);
-
-  if (NS_SUCCEEDED(err) && pDataRow) {
-    m_LastRecordKey = 0;
-    err = AddIntColumn(pDataRow, m_LastRecordKeyColumnToken, 0);
-    err = m_mdbPabTable->AddRow(m_mdbEnv, pDataRow);
-    NS_RELEASE(pDataRow);
-  }
-  return err;
-}
-
-nsresult nsAddrDatabase::GetDataRow(nsIMdbRow **pDataRow) {
-  if (!m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsIMdbRow *pRow = nullptr;
-  mdbOid dataRowOid;
-  dataRowOid.mOid_Scope = m_DataRowScopeToken;
-  dataRowOid.mOid_Id = DATAROW_ROWID;
-  m_mdbStore->GetRow(m_mdbEnv, &dataRowOid, &pRow);
-  *pDataRow = pRow;
-
-  return pRow ? NS_OK : NS_ERROR_FAILURE;
-}
-
-nsresult nsAddrDatabase::GetLastRecordKey() {
-  if (!m_mdbPabTable) return NS_ERROR_NULL_POINTER;
-
-  nsCOMPtr<nsIMdbRow> pDataRow;
-  nsresult err = GetDataRow(getter_AddRefs(pDataRow));
-
-  if (NS_SUCCEEDED(err) && pDataRow) {
-    m_LastRecordKey = 0;
-    err =
-        GetIntColumn(pDataRow, m_LastRecordKeyColumnToken, &m_LastRecordKey, 0);
-    if (NS_FAILED(err)) err = NS_ERROR_NOT_AVAILABLE;
-    return NS_OK;
-  }
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-nsresult nsAddrDatabase::UpdateLastRecordKey() {
-  if (!m_mdbPabTable || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsCOMPtr<nsIMdbRow> pDataRow;
-  nsresult err = GetDataRow(getter_AddRefs(pDataRow));
-
-  if (NS_SUCCEEDED(err) && pDataRow) {
-    err = AddIntColumn(pDataRow, m_LastRecordKeyColumnToken, m_LastRecordKey);
-    err = m_mdbPabTable->AddRow(m_mdbEnv, pDataRow);
-    return NS_OK;
-  } else if (!pDataRow)
-    err = InitLastRecorKey();
-  else
-    return NS_ERROR_NOT_AVAILABLE;
-  return err;
-}
-
 nsresult nsAddrDatabase::InitExistingDB() {
   nsresult err = InitMDBInfo();
   if (NS_SUCCEEDED(err)) {
     if (!m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
 
     err = m_mdbStore->GetTable(m_mdbEnv, &gAddressBookTableOID, &m_mdbPabTable);
     if (NS_SUCCEEDED(err) && m_mdbPabTable) {
-      err = GetLastRecordKey();
-      if (err == NS_ERROR_NOT_AVAILABLE) CheckAndUpdateRecordKey();
-      UpdateLowercaseEmailListName();
+      // This code has always run here. Removing it fails an assertion in the
+      // Mork code which indicates a bad state. In the interest of saving
+      // effort, and since this whole file is doomed after the next release,
+      // I'm leaving it behind.
+      nsIMdbTableRowCursor *rowCursor = nullptr;
+      nsIMdbRow *findRow = nullptr;
+      mdb_pos rowPos = 0;
+
+      err = m_mdbPabTable->GetTableRowCursor(m_mdbEnv, -1, &rowCursor);
+      if (NS_SUCCEEDED(err) && rowCursor) {
+        do {
+          err = rowCursor->NextRow(m_mdbEnv, &findRow, &rowPos);
+        } while (NS_SUCCEEDED(err) && findRow);
+        rowCursor->Release();
+      }
     }
   }
   return err;
 }
 
-nsresult nsAddrDatabase::CheckAndUpdateRecordKey() {
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsresult err = NS_OK;
-  nsIMdbTableRowCursor *rowCursor = nullptr;
-  nsIMdbRow *findRow = nullptr;
-  mdb_pos rowPos = 0;
-
-  nsresult merror = m_mdbPabTable->GetTableRowCursor(m_mdbEnv, -1, &rowCursor);
-
-  NS_ENSURE_TRUE(NS_SUCCEEDED(merror) && rowCursor, NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsIMdbRow> pDataRow;
-  err = GetDataRow(getter_AddRefs(pDataRow));
-  if (NS_FAILED(err)) InitLastRecorKey();
-
-  do {  // add key to each card and mailing list row
-    merror = rowCursor->NextRow(m_mdbEnv, &findRow, &rowPos);
-    if (NS_SUCCEEDED(merror) && findRow) {
-      mdbOid rowOid;
-
-      if (NS_SUCCEEDED(findRow->GetOid(m_mdbEnv, &rowOid))) {
-        if (!IsDataRowScopeToken(rowOid.mOid_Scope)) {
-          m_LastRecordKey++;
-          err = AddIntColumn(findRow, m_RecordKeyColumnToken, m_LastRecordKey);
-        }
-      }
-    }
-  } while (findRow);
-
-  UpdateLastRecordKey();
-  Commit(nsAddrDBCommitType::kLargeCommit);
-  return NS_OK;
-}
-
-nsresult nsAddrDatabase::UpdateLowercaseEmailListName() {
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsresult err = NS_OK;
-  nsIMdbTableRowCursor *rowCursor = nullptr;
-  nsIMdbRow *findRow = nullptr;
-  mdb_pos rowPos = 0;
-  bool commitRequired = false;
-
-  nsresult merror = m_mdbPabTable->GetTableRowCursor(m_mdbEnv, -1, &rowCursor);
-
-  NS_ENSURE_TRUE(NS_SUCCEEDED(merror) && rowCursor, NS_ERROR_FAILURE);
-
-  do {  // Add lowercase primary+secondary email to each card and mailing list
-        // row.
-    merror = rowCursor->NextRow(m_mdbEnv, &findRow, &rowPos);
-    if (NS_SUCCEEDED(merror) && findRow) {
-      mdbOid rowOid;
-
-      if (NS_SUCCEEDED(findRow->GetOid(m_mdbEnv, &rowOid))) {
-        nsAutoString tempString;
-        if (IsCardRowScopeToken(rowOid.mOid_Scope)) {
-          err =
-              GetStringColumn(findRow, m_LowerPriEmailColumnToken, tempString);
-          if (NS_FAILED(err))  // not set yet
-          {
-            err = ConvertAndAddLowercaseColumn(findRow, m_PriEmailColumnToken,
-                                               m_LowerPriEmailColumnToken);
-            commitRequired = commitRequired || NS_SUCCEEDED(err);
-          }
-
-          err =
-              GetStringColumn(findRow, m_Lower2ndEmailColumnToken, tempString);
-          if (NS_FAILED(err))  // not set yet
-          {
-            err = ConvertAndAddLowercaseColumn(findRow, m_2ndEmailColumnToken,
-                                               m_Lower2ndEmailColumnToken);
-            commitRequired = commitRequired || NS_SUCCEEDED(err);
-          }
-        } else if (IsListRowScopeToken(rowOid.mOid_Scope)) {
-          err =
-              GetStringColumn(findRow, m_LowerListNameColumnToken, tempString);
-          if (NS_SUCCEEDED(err))  // already set up
-            continue;
-
-          err = ConvertAndAddLowercaseColumn(findRow, m_ListNameColumnToken,
-                                             m_LowerListNameColumnToken);
-          commitRequired = commitRequired || NS_SUCCEEDED(err);
-        }
-      }
-      findRow->Release();
-    }
-  } while (findRow);
-
-  if (findRow) findRow->Release();
-  rowCursor->Release();
-  if (commitRequired) Commit(nsAddrDBCommitType::kLargeCommit);
-  return NS_OK;
-}
-
-/*
-We store UTF8 strings in the database.  We need to convert the UTF8
-string into unicode string, then convert to lower case.  Before storing
-back into the database,  we need to convert the lowercase unicode string
-into UTF8 string.
-*/
-nsresult nsAddrDatabase::ConvertAndAddLowercaseColumn(nsIMdbRow *row,
-                                                      mdb_token fromCol,
-                                                      mdb_token toCol) {
-  nsAutoString colString;
-
-  nsresult rv = GetStringColumn(row, fromCol, colString);
-  if (!colString.IsEmpty()) {
-    rv = AddLowercaseColumn(row, toCol, NS_ConvertUTF16toUTF8(colString).get());
-  }
-  return rv;
-}
-
-// Change the unicode string to lowercase, then convert to UTF8 string to store
-// in db
-nsresult nsAddrDatabase::AddUnicodeToColumn(nsIMdbRow *row, mdb_token aColToken,
-                                            mdb_token aLowerCaseColToken,
-                                            const char16_t *aUnicodeStr) {
-  nsresult rv = AddCharStringColumn(row, aColToken,
-                                    NS_ConvertUTF16toUTF8(aUnicodeStr).get());
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = AddLowercaseColumn(row, aLowerCaseColToken,
-                          NS_ConvertUTF16toUTF8(aUnicodeStr).get());
-  NS_ENSURE_SUCCESS(rv, rv);
-  return rv;
-}
-
 // initialize the various tokens and tables in our db's env
 nsresult nsAddrDatabase::InitMDBInfo() {
   nsresult err = NS_OK;
 
   if (!m_mdbTokensInitialized && m_mdbStore && m_mdbEnv) {
     m_mdbTokensInitialized = true;
     err = m_mdbStore->StringToToken(m_mdbEnv, kCardRowScope,
                                     &m_CardRowScopeToken);
@@ -945,309 +682,22 @@ nsresult nsAddrDatabase::InitMDBInfo() {
                                 &m_DeletedCardsTableKind);
     }
   }
   return err;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-nsresult nsAddrDatabase::AddRecordKeyColumnToRow(nsIMdbRow *pRow) {
-  if (pRow && m_mdbEnv) {
-    m_LastRecordKey++;
-    nsresult err = AddIntColumn(pRow, m_RecordKeyColumnToken, m_LastRecordKey);
-    NS_ENSURE_SUCCESS(err, err);
-
-    err = m_mdbPabTable->AddRow(m_mdbEnv, pRow);
-    UpdateLastRecordKey();
-    return err;
-  }
-  return NS_ERROR_NULL_POINTER;
-}
-
-nsresult nsAddrDatabase::AddAttributeColumnsToRow(nsIAbCard *card,
-                                                  nsIMdbRow *cardRow) {
-  nsresult rv = NS_OK;
-
-  if ((!card && !cardRow) || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  mdbOid rowOid;
-  cardRow->GetOid(m_mdbEnv, &rowOid);
-
-  card->SetPropertyAsUint32(kRowIDProperty, rowOid.mOid_Id);
-
-  // add the row to the singleton table.
-  if (card && cardRow) {
-    nsCOMPtr<nsISimpleEnumerator> properties;
-    rv = card->GetProperties(getter_AddRefs(properties));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    bool hasMore;
-    while (NS_SUCCEEDED(properties->HasMoreElements(&hasMore)) && hasMore) {
-      nsCOMPtr<nsISupports> next;
-      rv = properties->GetNext(getter_AddRefs(next));
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      nsCOMPtr<nsIProperty> prop = do_QueryInterface(next);
-      nsAutoString name;
-      prop->GetName(name);
-
-      nsCOMPtr<nsIVariant> variant;
-      prop->GetValue(getter_AddRefs(variant));
-
-      // We can't get as a char * because that messes up UTF8 stuff
-      nsAutoCString value;
-      variant->GetAsAUTF8String(value);
-
-      mdb_token token;
-      rv = m_mdbStore->StringToToken(m_mdbEnv,
-                                     NS_ConvertUTF16toUTF8(name).get(), &token);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = AddCharStringColumn(cardRow, token, value.get());
-      NS_ENSURE_SUCCESS(rv, rv);
-    }
-
-    // Primary email is special: it is stored lowercase as well as in its
-    // original format.
-    nsAutoString primaryEmail;
-    card->GetPrimaryEmail(primaryEmail);
-    AddPrimaryEmail(cardRow, NS_ConvertUTF16toUTF8(primaryEmail).get());
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAddrDatabase::CreateNewCardAndAddToDB(
-    nsIAbCard *aNewCard, bool aNotify /* = FALSE */, nsIAbDirectory *aParent) {
-  nsCOMPtr<nsIMdbRow> cardRow;
-
-  if (!aNewCard || !m_mdbPabTable || !m_mdbEnv || !m_mdbStore)
-    return NS_ERROR_NULL_POINTER;
-
-  // Ensure the new card has a UID.
-  nsAutoCString uid;
-  aNewCard->GetUID(uid);
-
-  // Per the UUID requirements, we want to try to reuse the local id if at all
-  // possible. nsACString::ToInteger probably won't fail if the local id looks
-  // like "23bozo" (returning 23 instead), but it's okay since we aren't going
-  // to overwrite anything with 23 if it already exists and the id for the row
-  // doesn't matter otherwise.
-  nsresult rv;
-
-  nsAutoCString id;
-  aNewCard->GetLocalId(id);
-
-  mdbOid rowId;
-  rowId.mOid_Scope = m_CardRowScopeToken;
-  rowId.mOid_Id = id.ToInteger(&rv);
-  if (NS_SUCCEEDED(rv)) {
-    // Mork is being very naughty here. If the table does not have the oid, we
-    // should be able to reuse it. To be on the safe side, however, we're going
-    // to reference the store's reference count.
-    mdb_count rowCount = 1;
-    m_mdbStore->GetRowRefCount(m_mdbEnv, &rowId, &rowCount);
-    if (rowCount == 0) {
-      // So apparently, the row can have a count of 0 yet still exist (probably
-      // meaning we haven't flushed it out of memory). In this case, we need to
-      // get the row and cut its cells.
-      rv = m_mdbStore->GetRow(m_mdbEnv, &rowId, getter_AddRefs(cardRow));
-      if (NS_SUCCEEDED(rv) && cardRow)
-        cardRow->CutAllColumns(m_mdbEnv);
-      else
-        rv = m_mdbStore->NewRowWithOid(m_mdbEnv, &rowId,
-                                       getter_AddRefs(cardRow));
-    }
-  }
-
-  // If we don't have a cardRow yet, just get one with any ol' id.
-  if (!cardRow) rv = GetNewRow(getter_AddRefs(cardRow));
-
-  if (NS_SUCCEEDED(rv) && cardRow) {
-    AddAttributeColumnsToRow(aNewCard, cardRow);
-    AddRecordKeyColumnToRow(cardRow);
-
-    // we need to do this for dnd
-    uint32_t key = 0;
-    rv = GetIntColumn(cardRow, m_RecordKeyColumnToken, &key, 0);
-    if (NS_SUCCEEDED(rv)) aNewCard->SetPropertyAsUint32(kRecordKeyColumn, key);
-
-    aNewCard->GetPropertyAsAUTF8String(kRowIDProperty, id);
-    aNewCard->SetLocalId(id);
-
-    nsCOMPtr<nsIAbDirectory> abDir = do_QueryReferent(m_dbDirectory);
-    if (abDir) abDir->GetUuid(id);
-
-    aNewCard->SetDirectoryId(id);
-
-    nsresult merror = m_mdbPabTable->AddRow(m_mdbEnv, cardRow);
-    NS_ENSURE_SUCCESS(merror, NS_ERROR_FAILURE);
-  }
-
-  return rv;
-}
-
-NS_IMETHODIMP nsAddrDatabase::CreateNewListCardAndAddToDB(
-    nsIAbDirectory *aList, uint32_t listRowID, nsIAbCard *newCard,
-    bool notify /* = FALSE */) {
-  if (!newCard || !m_mdbPabTable || !m_mdbStore || !m_mdbEnv)
-    return NS_ERROR_NULL_POINTER;
-
-  nsIMdbRow *pListRow = nullptr;
-  mdbOid listRowOid;
-  listRowOid.mOid_Scope = m_ListRowScopeToken;
-  listRowOid.mOid_Id = listRowID;
-  nsresult rv = m_mdbStore->GetRow(m_mdbEnv, &listRowOid, &pListRow);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!pListRow) return NS_OK;
-
-  nsCOMPtr<nsIMutableArray> addressList;
-  rv = aList->GetAddressLists(getter_AddRefs(addressList));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  uint32_t count;
-  addressList->GetLength(&count);
-
-  nsAutoString newEmail;
-  rv = newCard->GetPrimaryEmail(newEmail);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (newEmail.IsEmpty()) return NS_OK;
-
-  uint32_t i;
-  for (i = 0; i < count; i++) {
-    nsCOMPtr<nsIAbCard> currentCard = do_QueryElementAt(addressList, i, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    bool equals;
-    rv = newCard->Equals(currentCard, &equals);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (equals) {
-      // card is already in list, bail out.
-      // this can happen when dropping a card on a mailing list from the
-      // directory that contains the mailing list
-      return NS_OK;
-    }
-
-    nsAutoString currentEmail;
-    rv = currentCard->GetPrimaryEmail(currentEmail);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (newEmail.Equals(currentEmail)) {
-      // card is already in list, bail out
-      // this can happen when dropping a card on a mailing list from another
-      // directory (not the one that contains the mailing list or if you have
-      // multiple cards on a directory, with the same primary email address.
-      return NS_OK;
-    }
-  }
-
-  // start from 1
-  uint32_t totalAddress = GetListAddressTotal(pListRow) + 1;
-  SetListAddressTotal(pListRow, totalAddress);
-  nsCOMPtr<nsIAbCard> pNewCard;
-  rv = AddListCardColumnsToRow(newCard, pListRow, totalAddress,
-                               getter_AddRefs(pNewCard),
-                               true /* aInMailingList */, aList, nullptr);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  addressList->AppendElement(newCard);
-
-  return rv;
-}
-
-NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow(
-    nsIAbCard *aPCard, nsIMdbRow *aPListRow, uint32_t aPos,
-    nsIAbCard **aPNewCard, bool aInMailingList, nsIAbDirectory *aParent,
-    nsIAbDirectory *aRoot) {
-  if (!aPCard || !aPListRow || !m_mdbStore || !m_mdbEnv)
-    return NS_ERROR_NULL_POINTER;
-
-  nsresult err = NS_OK;
-  nsString email;
-  aPCard->GetPrimaryEmail(email);
-  if (!email.IsEmpty()) {
-    nsIMdbRow *pCardRow = nullptr;
-    // Please DO NOT change the 3rd param of GetRowFromAttribute() call to
-    // true (ie, case insensitive) without reading bugs #128535 and #121478.
-    err = GetRowFromAttribute(kPriEmailProperty, NS_ConvertUTF16toUTF8(email),
-                              false /* retain case */, &pCardRow, nullptr);
-    bool cardWasAdded = false;
-    if (NS_FAILED(err) || !pCardRow) {
-      // New Email, then add a new row with this email
-      err = GetNewRow(&pCardRow);
-
-      if (NS_SUCCEEDED(err) && pCardRow) {
-        AddPrimaryEmail(pCardRow, NS_ConvertUTF16toUTF8(email).get());
-        err = m_mdbPabTable->AddRow(m_mdbEnv, pCardRow);
-        // Create a key for this row as well.
-        if (NS_SUCCEEDED(err)) AddRecordKeyColumnToRow(pCardRow);
-      }
-
-      cardWasAdded = true;
-    }
-
-    NS_ENSURE_TRUE(pCardRow, NS_ERROR_NULL_POINTER);
-
-    nsString name;
-    aPCard->GetDisplayName(name);
-    if (!name.IsEmpty()) {
-      AddDisplayName(pCardRow, NS_ConvertUTF16toUTF8(name).get());
-      err = m_mdbPabTable->AddRow(m_mdbEnv, pCardRow);
-    }
-
-    CreateABCard(pCardRow, 0, aPNewCard);
-
-    // add a column with address row id to the list row
-    mdb_token listAddressColumnToken;
-
-    char columnStr[COLUMN_STR_MAX];
-    PR_snprintf(columnStr, COLUMN_STR_MAX, kMailListAddressFormat, aPos);
-    m_mdbStore->StringToToken(m_mdbEnv, columnStr, &listAddressColumnToken);
-
-    mdbOid outOid;
-
-    if (NS_SUCCEEDED(pCardRow->GetOid(m_mdbEnv, &outOid))) {
-      // save address row ID to the list row
-      err = AddIntColumn(aPListRow, listAddressColumnToken, outOid.mOid_Id);
-    }
-    NS_RELEASE(pCardRow);
-  }
-
-  return NS_OK;
-}
-
-nsresult nsAddrDatabase::AddListAttributeColumnsToRow(nsIAbDirectory *list,
-                                                      nsIMdbRow *listRow,
-                                                      nsIAbDirectory *aParent) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
 uint32_t nsAddrDatabase::GetListAddressTotal(nsIMdbRow *listRow) {
   uint32_t count = 0;
   GetIntColumn(listRow, m_ListTotalColumnToken, &count, 0);
   return count;
 }
 
-NS_IMETHODIMP nsAddrDatabase::SetListAddressTotal(nsIMdbRow *aListRow,
-                                                  uint32_t aTotal) {
-  return AddIntColumn(aListRow, m_ListTotalColumnToken, aTotal);
-}
-
-NS_IMETHODIMP nsAddrDatabase::FindRowByCard(nsIAbCard *aCard,
-                                            nsIMdbRow **aRow) {
-  nsString primaryEmail;
-  aCard->GetPrimaryEmail(primaryEmail);
-  return GetRowForCharColumn(primaryEmail.get(), m_PriEmailColumnToken, true,
-                             true, aRow, nullptr);
-}
-
 nsresult nsAddrDatabase::GetAddressRowByPos(nsIMdbRow *listRow, uint16_t pos,
                                             nsIMdbRow **cardRow) {
   if (!m_mdbStore || !listRow || !cardRow || !m_mdbEnv)
     return NS_ERROR_NULL_POINTER;
 
   mdb_token listAddressColumnToken;
 
   char columnStr[COLUMN_STR_MAX];
@@ -1258,483 +708,16 @@ nsresult nsAddrDatabase::GetAddressRowBy
   mdb_id rowID;
   nsresult err =
       GetIntColumn(listRow, listAddressColumnToken, (uint32_t *)&rowID, 0);
   NS_ENSURE_SUCCESS(err, err);
 
   return GetCardRowByRowID(rowID, cardRow);
 }
 
-NS_IMETHODIMP nsAddrDatabase::CreateMailListAndAddToDB(
-    nsIAbDirectory *aNewList, bool aNotify /* = FALSE */,
-    nsIAbDirectory *aParent) {
-  if (!aNewList || !m_mdbPabTable || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsIMdbRow *listRow;
-  nsresult err = GetNewListRow(&listRow);
-
-  if (NS_SUCCEEDED(err) && listRow) {
-    AddListAttributeColumnsToRow(aNewList, listRow, aParent);
-    AddRecordKeyColumnToRow(listRow);
-    nsresult merror = m_mdbPabTable->AddRow(m_mdbEnv, listRow);
-    NS_ENSURE_SUCCESS(merror, NS_ERROR_FAILURE);
-
-    nsCOMPtr<nsIAbCard> listCard;
-    CreateABListCard(listRow, getter_AddRefs(listCard));
-
-    NS_RELEASE(listRow);
-    return NS_OK;
-  }
-
-  return NS_ERROR_FAILURE;
-}
-
-void nsAddrDatabase::DeleteCardFromAllMailLists(nsIAbCard *aCard) {
-  if (!m_mdbEnv) return;
-
-  mdb_id cardRowID;
-  nsresult rv = aCard->GetPropertyAsUint32(kRowIDProperty, &cardRowID);
-  if (NS_FAILED(rv)) {
-    return;
-  }
-
-  nsCOMPtr<nsIMdbTableRowCursor> rowCursor;
-  m_mdbPabTable->GetTableRowCursor(m_mdbEnv, -1, getter_AddRefs(rowCursor));
-
-  if (rowCursor) {
-    nsCOMPtr<nsIMdbRow> pListRow;
-    mdb_pos rowPos;
-    do {
-      rv = rowCursor->NextRow(m_mdbEnv, getter_AddRefs(pListRow), &rowPos);
-
-      if (NS_SUCCEEDED(rv) && pListRow) {
-        mdbOid rowOid;
-
-        if (NS_SUCCEEDED(pListRow->GetOid(m_mdbEnv, &rowOid))) {
-          if (IsListRowScopeToken(rowOid.mOid_Scope)) {
-            bool cardFound = false;
-            DeleteCardFromListRow(pListRow, cardRowID, &cardFound);
-            if (cardFound) {
-              nsCOMPtr<nsIObserverService> observerService =
-                  mozilla::services::GetObserverService();
-              if (observerService) {
-                nsAutoString listUID;
-                GetStringColumn(pListRow, m_UIDColumnToken, listUID);
-                if (!listUID.IsEmpty()) {
-                  observerService->NotifyObservers(
-                      aCard, "addrbook-list-member-removed", listUID.get());
-                }
-              }
-            }
-          }
-        }
-      }
-    } while (pListRow);
-  }
-}
-
-NS_IMETHODIMP nsAddrDatabase::DeleteCard(nsIAbCard *aCard, bool aNotify,
-                                         nsIAbDirectory *aParent) {
-  if (!aCard || !m_mdbPabTable || !m_mdbStore || !m_mdbEnv)
-    return NS_ERROR_NULL_POINTER;
-
-  nsresult err = NS_OK;
-  bool bIsMailList = false;
-  aCard->GetIsMailList(&bIsMailList);
-
-  // get the right row
-  nsIMdbRow *pCardRow = nullptr;
-  mdbOid rowOid;
-
-  rowOid.mOid_Scope = bIsMailList ? m_ListRowScopeToken : m_CardRowScopeToken;
-
-  err = aCard->GetPropertyAsUint32(kRowIDProperty, &rowOid.mOid_Id);
-  NS_ENSURE_SUCCESS(err, err);
-
-  err = m_mdbStore->GetRow(m_mdbEnv, &rowOid, &pCardRow);
-  NS_ENSURE_SUCCESS(err, err);
-  if (!pCardRow) return NS_OK;
-
-  // Delete the person card from all mailing list.
-  if (!bIsMailList) DeleteCardFromAllMailLists(aCard);
-
-  // Reset the directory id
-  aCard->SetDirectoryId(EmptyCString());
-
-  // And here a greeting from the quirky old past:
-  // Before there was a "deleted cards" table where deleted cards
-  // were stored for six month. If we find this table, we empty it out.
-  if (!m_mdbDeletedCardsTableRemoved) {
-    m_mdbDeletedCardsTableRemoved = true;
-    struct mdbOid deletedCardsTableOID;
-    deletedCardsTableOID.mOid_Scope = m_CardRowScopeToken;
-    deletedCardsTableOID.mOid_Id = ID_DELETEDCARDS_TABLE;
-    nsIMdbTable *deletedCardsTable;
-    m_mdbStore->GetTable(m_mdbEnv, &deletedCardsTableOID, &deletedCardsTable);
-    if (deletedCardsTable) {
-      deletedCardsTable->CutAllRows(m_mdbEnv);
-      deletedCardsTable->Release();
-      Commit(nsAddrDBCommitType::kCompressCommit);
-    }
-  }
-
-  err = DeleteRow(m_mdbPabTable, pCardRow);
-
-  NS_RELEASE(pCardRow);
-  return NS_OK;
-}
-
-nsresult nsAddrDatabase::DeleteCardFromListRow(nsIMdbRow *pListRow,
-                                               mdb_id cardRowID,
-                                               bool *cardFound) {
-  NS_ENSURE_ARG_POINTER(pListRow);
-  if (!m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsresult err = NS_OK;
-
-  uint32_t totalAddress = GetListAddressTotal(pListRow);
-
-  uint32_t pos;
-  for (pos = 1; pos <= totalAddress; pos++) {
-    mdb_token listAddressColumnToken;
-    mdb_id rowID;
-
-    char columnStr[COLUMN_STR_MAX];
-    PR_snprintf(columnStr, COLUMN_STR_MAX, kMailListAddressFormat, pos);
-    m_mdbStore->StringToToken(m_mdbEnv, columnStr, &listAddressColumnToken);
-
-    err = GetIntColumn(pListRow, listAddressColumnToken, (uint32_t *)&rowID, 0);
-
-    if (cardRowID == rowID) {
-      *cardFound = true;
-      if (pos == totalAddress)
-        err = pListRow->CutColumn(m_mdbEnv, listAddressColumnToken);
-      else {
-        // replace the deleted one with the last one and delete the last one
-        mdb_id lastRowID;
-        mdb_token lastAddressColumnToken;
-        PR_snprintf(columnStr, COLUMN_STR_MAX, kMailListAddressFormat,
-                    totalAddress);
-        m_mdbStore->StringToToken(m_mdbEnv, columnStr, &lastAddressColumnToken);
-
-        err = GetIntColumn(pListRow, lastAddressColumnToken,
-                           (uint32_t *)&lastRowID, 0);
-        NS_ENSURE_SUCCESS(err, err);
-
-        err = AddIntColumn(pListRow, listAddressColumnToken, lastRowID);
-        NS_ENSURE_SUCCESS(err, err);
-
-        err = pListRow->CutColumn(m_mdbEnv, lastAddressColumnToken);
-        NS_ENSURE_SUCCESS(err, err);
-      }
-
-      // Reset total count after the card has been deleted.
-      SetListAddressTotal(pListRow, totalAddress - 1);
-      break;
-    }
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAddrDatabase::DeleteCardFromMailList(nsIAbDirectory *mailList,
-                                                     nsIAbCard *card,
-                                                     bool aNotify) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-NS_IMETHODIMP nsAddrDatabase::SetCardValue(nsIAbCard *card, const char *name,
-                                           const char16_t *value, bool notify) {
-  NS_ENSURE_ARG_POINTER(card);
-  NS_ENSURE_ARG_POINTER(name);
-  NS_ENSURE_ARG_POINTER(value);
-  if (!m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsresult rv = NS_OK;
-
-  nsCOMPtr<nsIMdbRow> cardRow;
-  mdbOid rowOid;
-  rowOid.mOid_Scope = m_CardRowScopeToken;
-
-  // it might be that the caller always has a nsAbMDBCard
-  rv = card->GetPropertyAsUint32(kRowIDProperty, &rowOid.mOid_Id);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = m_mdbStore->GetRow(m_mdbEnv, &rowOid, getter_AddRefs(cardRow));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!cardRow) return NS_OK;
-
-  mdb_token token;
-  rv = m_mdbStore->StringToToken(m_mdbEnv, name, &token);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return AddCharStringColumn(cardRow, token,
-                             NS_ConvertUTF16toUTF8(value).get());
-}
-
-NS_IMETHODIMP nsAddrDatabase::GetCardValue(nsIAbCard *card, const char *name,
-                                           char16_t **value) {
-  if (!m_mdbStore || !card || !name || !value || !m_mdbEnv)
-    return NS_ERROR_NULL_POINTER;
-
-  nsresult rv = NS_OK;
-
-  nsCOMPtr<nsIMdbRow> cardRow;
-  mdbOid rowOid;
-  rowOid.mOid_Scope = m_CardRowScopeToken;
-
-  // it might be that the caller always has a nsAbMDBCard
-  rv = card->GetPropertyAsUint32(kRowIDProperty, &rowOid.mOid_Id);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = m_mdbStore->GetRow(m_mdbEnv, &rowOid, getter_AddRefs(cardRow));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!cardRow) {
-    *value = nullptr;
-    // this can happen when adding cards when editing a mailing list
-    return NS_OK;
-  }
-
-  mdb_token token;
-  m_mdbStore->StringToToken(m_mdbEnv, name, &token);
-
-  // XXX fix me
-  // avoid extra copying and allocations (did dmb already do this on the trunk?)
-  nsAutoString tempString;
-  rv = GetStringColumn(cardRow, token, tempString);
-  if (NS_FAILED(rv)) {
-    // not all cards are going this column
-    *value = nullptr;
-    return NS_OK;
-  }
-
-  *value = NS_xstrdup(tempString.get());
-  if (!*value) return NS_ERROR_OUT_OF_MEMORY;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAddrDatabase::EditCard(nsIAbCard *aCard, bool aNotify,
-                                       nsIAbDirectory *aParent) {
-  // XXX make sure this isn't getting called when we're just editing one or two
-  // well known fields
-  if (!aCard || !m_mdbPabTable || !m_mdbStore || !m_mdbEnv)
-    return NS_ERROR_NULL_POINTER;
-
-  nsresult err = NS_OK;
-
-  nsCOMPtr<nsIMdbRow> cardRow;
-  mdbOid rowOid;
-  rowOid.mOid_Scope = m_CardRowScopeToken;
-
-  uint32_t nowInSeconds;
-  PRTime now = PR_Now();
-  PRTime2Seconds(now, &nowInSeconds);
-  aCard->SetPropertyAsUint32(kLastModifiedDateProperty, nowInSeconds);
-  err = aCard->GetPropertyAsUint32(kRowIDProperty, &rowOid.mOid_Id);
-  NS_ENSURE_SUCCESS(err, err);
-
-  err = m_mdbStore->GetRow(m_mdbEnv, &rowOid, getter_AddRefs(cardRow));
-  NS_ENSURE_SUCCESS(err, err);
-
-  if (!cardRow) return NS_OK;
-
-  err = AddAttributeColumnsToRow(aCard, cardRow);
-  NS_ENSURE_SUCCESS(err, err);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAddrDatabase::ContainsCard(nsIAbCard *card, bool *hasCard) {
-  if (!card || !m_mdbPabTable || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsresult err = NS_OK;
-  mdb_bool hasOid;
-  mdbOid rowOid;
-  bool bIsMailList;
-
-  card->GetIsMailList(&bIsMailList);
-
-  if (bIsMailList)
-    rowOid.mOid_Scope = m_ListRowScopeToken;
-  else
-    rowOid.mOid_Scope = m_CardRowScopeToken;
-
-  err = card->GetPropertyAsUint32(kRowIDProperty, &rowOid.mOid_Id);
-  NS_ENSURE_SUCCESS(err, err);
-
-  err = m_mdbPabTable->HasOid(m_mdbEnv, &rowOid, &hasOid);
-  if (NS_SUCCEEDED(err)) {
-    *hasCard = hasOid;
-  }
-
-  return err;
-}
-
-NS_IMETHODIMP nsAddrDatabase::DeleteMailList(nsIAbDirectory *aMailList,
-                                             nsIAbDirectory *aParent) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-NS_IMETHODIMP nsAddrDatabase::EditMailList(nsIAbDirectory *mailList,
-                                           nsIAbCard *listCard, bool notify) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-NS_IMETHODIMP nsAddrDatabase::ContainsMailList(nsIAbDirectory *mailList,
-                                               bool *hasList) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-NS_IMETHODIMP nsAddrDatabase::GetNewRow(nsIMdbRow **newRow) {
-  if (!m_mdbStore || !newRow || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  return m_mdbStore->NewRow(m_mdbEnv, m_CardRowScopeToken, newRow);
-}
-
-NS_IMETHODIMP nsAddrDatabase::GetNewListRow(nsIMdbRow **newRow) {
-  if (!m_mdbStore || !newRow || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  return m_mdbStore->NewRow(m_mdbEnv, m_ListRowScopeToken, newRow);
-}
-
-NS_IMETHODIMP nsAddrDatabase::AddCardRowToDB(nsIMdbRow *newRow) {
-  if (m_mdbPabTable && m_mdbEnv) {
-    if (NS_SUCCEEDED(m_mdbPabTable->AddRow(m_mdbEnv, newRow))) {
-      AddRecordKeyColumnToRow(newRow);
-      return NS_OK;
-    }
-  }
-
-  return NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP nsAddrDatabase::AddLdifListMember(nsIMdbRow *listRow,
-                                                const char *value) {
-  if (!m_mdbStore || !listRow || !value || !m_mdbEnv)
-    return NS_ERROR_NULL_POINTER;
-
-  uint32_t total = GetListAddressTotal(listRow);
-  // add member
-  nsAutoCString valueString(value);
-  nsAutoCString email;
-  int32_t emailPos = valueString.Find("mail=");
-  emailPos += strlen("mail=");
-  email = Substring(valueString, emailPos);
-  nsCOMPtr<nsIMdbRow> cardRow;
-  // Please DO NOT change the 3rd param of GetRowFromAttribute() call to
-  // true (ie, case insensitive) without reading bugs #128535 and #121478.
-  nsresult rv =
-      GetRowFromAttribute(kPriEmailProperty, email, false /* retain case */,
-                          getter_AddRefs(cardRow), nullptr);
-  if (NS_SUCCEEDED(rv) && cardRow) {
-    mdbOid outOid;
-    mdb_id rowID = 0;
-    if (NS_SUCCEEDED(cardRow->GetOid(m_mdbEnv, &outOid)))
-      rowID = outOid.mOid_Id;
-
-    // start from 1
-    total += 1;
-    mdb_token listAddressColumnToken;
-    char columnStr[COLUMN_STR_MAX];
-    PR_snprintf(columnStr, COLUMN_STR_MAX, kMailListAddressFormat, total);
-    m_mdbStore->StringToToken(m_mdbEnv, columnStr, &listAddressColumnToken);
-
-    rv = AddIntColumn(listRow, listAddressColumnToken, rowID);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    SetListAddressTotal(listRow, total);
-  }
-  return NS_OK;
-}
-
-void nsAddrDatabase::GetCharStringYarn(char *str, struct mdbYarn *strYarn) {
-  strYarn->mYarn_Grow = nullptr;
-  strYarn->mYarn_Buf = str;
-  strYarn->mYarn_Size = PL_strlen((const char *)strYarn->mYarn_Buf) + 1;
-  strYarn->mYarn_Fill = strYarn->mYarn_Size - 1;
-  strYarn->mYarn_Form = 0;
-}
-
-void nsAddrDatabase::GetStringYarn(const nsAString &aStr,
-                                   struct mdbYarn *strYarn) {
-  strYarn->mYarn_Buf = ToNewUTF8String(aStr);
-  strYarn->mYarn_Size = PL_strlen((const char *)strYarn->mYarn_Buf) + 1;
-  strYarn->mYarn_Fill = strYarn->mYarn_Size - 1;
-  strYarn->mYarn_Form = 0;
-}
-
-void nsAddrDatabase::GetIntYarn(uint32_t nValue, struct mdbYarn *intYarn) {
-  intYarn->mYarn_Fill = intYarn->mYarn_Size;
-  intYarn->mYarn_Form = 0;
-  intYarn->mYarn_Grow = nullptr;
-
-  PR_snprintf((char *)intYarn->mYarn_Buf, intYarn->mYarn_Size, "%lx", nValue);
-  intYarn->mYarn_Fill = PL_strlen((const char *)intYarn->mYarn_Buf);
-}
-
-nsresult nsAddrDatabase::AddCharStringColumn(nsIMdbRow *cardRow,
-                                             mdb_column inColumn,
-                                             const char *str) {
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  struct mdbYarn yarn;
-
-  GetCharStringYarn((char *)str, &yarn);
-  nsresult err = cardRow->AddColumn(m_mdbEnv, inColumn, &yarn);
-
-  return (NS_SUCCEEDED(err)) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-nsresult nsAddrDatabase::AddStringColumn(nsIMdbRow *aCardRow,
-                                         mdb_column aInColumn,
-                                         const nsAString &aStr) {
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  struct mdbYarn yarn;
-
-  GetStringYarn(aStr, &yarn);
-  nsresult err = aCardRow->AddColumn(m_mdbEnv, aInColumn, &yarn);
-
-  return (NS_SUCCEEDED(err)) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-nsresult nsAddrDatabase::AddIntColumn(nsIMdbRow *cardRow, mdb_column inColumn,
-                                      uint32_t nValue) {
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  struct mdbYarn yarn;
-  char yarnBuf[100];
-
-  yarn.mYarn_Buf = (void *)yarnBuf;
-  yarn.mYarn_Size = sizeof(yarnBuf);
-  GetIntYarn(nValue, &yarn);
-  nsresult err = cardRow->AddColumn(m_mdbEnv, inColumn, &yarn);
-
-  return (NS_SUCCEEDED(err)) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-nsresult nsAddrDatabase::AddBoolColumn(nsIMdbRow *cardRow, mdb_column inColumn,
-                                       bool bValue) {
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  struct mdbYarn yarn;
-  char yarnBuf[100];
-
-  yarn.mYarn_Buf = (void *)yarnBuf;
-  yarn.mYarn_Size = sizeof(yarnBuf);
-
-  GetIntYarn(bValue ? 1 : 0, &yarn);
-
-  nsresult err = cardRow->AddColumn(m_mdbEnv, inColumn, &yarn);
-
-  return (NS_SUCCEEDED(err)) ? NS_OK : NS_ERROR_FAILURE;
-}
-
 nsresult nsAddrDatabase::GetStringColumn(nsIMdbRow *cardRow, mdb_token outToken,
                                          nsString &str) {
   nsresult err = NS_ERROR_NULL_POINTER;
   nsIMdbCell *cardCell;
 
   if (cardRow && m_mdbEnv) {
     err = cardRow->GetCell(m_mdbEnv, outToken, &cardCell);
     if (NS_SUCCEEDED(err) && cardCell) {
@@ -1772,93 +755,16 @@ nsresult nsAddrDatabase::GetIntColumn(ns
       YarnToUInt32(&yarn, pValue);
       cardCell->Release();
     } else
       err = NS_ERROR_FAILURE;
   }
   return err;
 }
 
-nsresult nsAddrDatabase::GetBoolColumn(nsIMdbRow *cardRow, mdb_token outToken,
-                                       bool *pValue) {
-  NS_ENSURE_ARG_POINTER(pValue);
-
-  nsresult err = NS_ERROR_NULL_POINTER;
-  nsIMdbCell *cardCell;
-  uint32_t nValue = 0;
-
-  if (cardRow && m_mdbEnv) {
-    err = cardRow->GetCell(m_mdbEnv, outToken, &cardCell);
-    if (NS_SUCCEEDED(err) && cardCell) {
-      struct mdbYarn yarn;
-      cardCell->AliasYarn(m_mdbEnv, &yarn);
-      YarnToUInt32(&yarn, &nValue);
-      cardCell->Release();
-    } else
-      err = NS_ERROR_FAILURE;
-  }
-
-  *pValue = nValue ? true : false;
-  return err;
-}
-
-/*  value is UTF8 string */
-NS_IMETHODIMP nsAddrDatabase::AddPrimaryEmail(nsIMdbRow *aRow,
-                                              const char *aValue) {
-  NS_ENSURE_ARG_POINTER(aValue);
-
-  nsresult rv = AddCharStringColumn(aRow, m_PriEmailColumnToken, aValue);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = AddLowercaseColumn(aRow, m_LowerPriEmailColumnToken, aValue);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return rv;
-}
-
-/*  value is UTF8 string */
-NS_IMETHODIMP nsAddrDatabase::Add2ndEmail(nsIMdbRow *aRow, const char *aValue) {
-  NS_ENSURE_ARG_POINTER(aValue);
-
-  nsresult rv = AddCharStringColumn(aRow, m_2ndEmailColumnToken, aValue);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = AddLowercaseColumn(aRow, m_Lower2ndEmailColumnToken, aValue);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return rv;
-}
-
-/*  value is UTF8 string */
-NS_IMETHODIMP nsAddrDatabase::AddListName(nsIMdbRow *aRow, const char *aValue) {
-  NS_ENSURE_ARG_POINTER(aValue);
-
-  nsresult rv = AddCharStringColumn(aRow, m_ListNameColumnToken, aValue);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = AddLowercaseColumn(aRow, m_LowerListNameColumnToken, aValue);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return rv;
-}
-
-/*
-columnValue is UTF8 string, need to convert back to lowercase unicode then
-back to UTF8 string
-*/
-nsresult nsAddrDatabase::AddLowercaseColumn(nsIMdbRow *row,
-                                            mdb_token columnToken,
-                                            const char *columnValue) {
-  nsresult rv = NS_OK;
-  if (columnValue) {
-    NS_ConvertUTF8toUTF16 newUnicodeString(columnValue);
-    ToLowerCase(newUnicodeString);
-    rv = AddCharStringColumn(row, columnToken,
-                             NS_ConvertUTF16toUTF8(newUnicodeString).get());
-  }
-  return rv;
-}
-
 NS_IMETHODIMP nsAddrDatabase::InitCardFromRow(nsIAbCard *newCard,
                                               nsIMdbRow *cardRow) {
   nsresult rv = NS_OK;
   if (!newCard || !cardRow || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
 
   nsCOMPtr<nsIMdbRowCellCursor> cursor;
   nsCOMPtr<nsIMdbCell> cell;
 
@@ -1927,21 +833,16 @@ nsresult nsAddrDatabase::GetListCardFrom
     listCard->SetPropertyAsAString(kNotesProperty, tempString);
   }
   uint32_t key = 0;
   err = GetIntColumn(listRow, m_RecordKeyColumnToken, &key, 0);
   if (NS_SUCCEEDED(err)) listCard->SetPropertyAsUint32(kRecordKeyColumn, key);
   return err;
 }
 
-nsresult nsAddrDatabase::GetListFromDB(nsIAbDirectory *newList,
-                                       nsIMdbRow *listRow) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
 class nsAddrDBEnumerator : public nsSimpleEnumerator {
  public:
   const nsID &DefaultInterface() override { return NS_GET_IID(nsIAbCard); }
 
   // nsISimpleEnumerator methods:
   NS_DECL_NSISIMPLEENUMERATOR
 
   // nsAddrDBEnumerator methods:
@@ -2129,85 +1030,24 @@ nsListAddressEnumerator::GetNext(nsISupp
 
 NS_IMETHODIMP nsAddrDatabase::EnumerateCards(nsIAbDirectory *directory,
                                              nsISimpleEnumerator **result) {
   NS_ADDREF(*result = new nsAddrDBEnumerator(this));
   m_dbDirectory = do_GetWeakReference(directory);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsAddrDatabase::GetMailingListsFromDB(nsIAbDirectory *parentDir) {
-  nsCOMPtr<nsIAbDirectory> resultList;
-  nsIMdbTableRowCursor *rowCursor = nullptr;
-  nsCOMPtr<nsIMdbRow> currentRow;
-  mdb_pos rowPos;
-  bool done = false;
-
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  m_dbDirectory = do_GetWeakReference(parentDir);
-
-  nsIMdbTable *dbTable = GetPabTable();
-
-  if (!dbTable) return NS_ERROR_FAILURE;
-
-  dbTable->GetTableRowCursor(m_mdbEnv, -1, &rowCursor);
-  if (!rowCursor) return NS_ERROR_FAILURE;
-
-  while (!done) {
-    nsresult rv =
-        rowCursor->NextRow(m_mdbEnv, getter_AddRefs(currentRow), &rowPos);
-    if (currentRow && NS_SUCCEEDED(rv)) {
-      mdbOid rowOid;
-
-      if (NS_SUCCEEDED(currentRow->GetOid(m_mdbEnv, &rowOid))) {
-        if (IsListRowScopeToken(rowOid.mOid_Scope))
-          rv = CreateABList(currentRow, getter_AddRefs(resultList));
-      }
-    } else
-      done = true;
-  }
-  NS_IF_RELEASE(rowCursor);
-  return NS_OK;
-}
-
 NS_IMETHODIMP nsAddrDatabase::EnumerateListAddresses(
     nsIAbDirectory *directory, uint32_t listRowID,
     nsISimpleEnumerator **result) {
   NS_ADDREF(*result = new nsListAddressEnumerator(this, listRowID));
   m_dbDirectory = do_GetWeakReference(directory);
   return NS_OK;
 }
 
-nsresult nsAddrDatabase::CreateCardFromDeletedCardsTable(nsIMdbRow *cardRow,
-                                                         mdb_id listRowID,
-                                                         nsIAbCard **result) {
-  if (!cardRow || !m_mdbEnv || !result) return NS_ERROR_NULL_POINTER;
-
-  nsresult rv = NS_OK;
-
-  mdbOid outOid;
-  mdb_id rowID = 0;
-
-  if (NS_SUCCEEDED(cardRow->GetOid(m_mdbEnv, &outOid))) rowID = outOid.mOid_Id;
-
-  if (NS_SUCCEEDED(rv)) {
-    nsCOMPtr<nsIAbCard> personCard;
-    personCard = do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    InitCardFromRow(personCard, cardRow);
-    personCard->SetPropertyAsUint32(kRowIDProperty, rowID);
-
-    personCard.forget(result);
-  }
-
-  return rv;
-}
-
 nsresult nsAddrDatabase::CreateCard(nsIMdbRow *cardRow, mdb_id listRowID,
                                     nsIAbCard **result) {
   if (!cardRow || !m_mdbEnv || !result) return NS_ERROR_NULL_POINTER;
 
   nsresult rv = NS_OK;
 
   mdbOid outOid;
   mdb_id rowID = 0;
@@ -2282,22 +1122,16 @@ nsresult nsAddrDatabase::CreateABListCar
   }
 
   personCard.forget(result);
   if (listURI) PR_smprintf_free(listURI);
 
   return rv;
 }
 
-/* create a sub directory for mailing list in the address book left pane */
-nsresult nsAddrDatabase::CreateABList(nsIMdbRow *listRow,
-                                      nsIAbDirectory **result) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
 nsresult nsAddrDatabase::GetCardRowByRowID(mdb_id rowID, nsIMdbRow **dbRow) {
   if (!m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
 
   mdbOid rowOid;
   rowOid.mOid_Scope = m_CardRowScopeToken;
   rowOid.mOid_Id = rowID;
 
   return m_mdbStore->GetRow(m_mdbEnv, &rowOid, dbRow);
@@ -2307,197 +1141,8 @@ nsresult nsAddrDatabase::GetListRowByRow
   if (!m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
 
   mdbOid rowOid;
   rowOid.mOid_Scope = m_ListRowScopeToken;
   rowOid.mOid_Id = rowID;
 
   return m_mdbStore->GetRow(m_mdbEnv, &rowOid, dbRow);
 }
-
-nsresult nsAddrDatabase::GetRowFromAttribute(const char *aName,
-                                             const nsACString &aUTF8Value,
-                                             bool aCaseInsensitive,
-                                             nsIMdbRow **aCardRow,
-                                             mdb_pos *aRowPos) {
-  NS_ENSURE_ARG_POINTER(aName);
-  NS_ENSURE_ARG_POINTER(aCardRow);
-  if (!m_mdbStore || !m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  mdb_token token;
-  m_mdbStore->StringToToken(m_mdbEnv, aName, &token);
-  NS_ConvertUTF8toUTF16 newUnicodeString(aUTF8Value);
-
-  return GetRowForCharColumn(newUnicodeString.get(), token, true,
-                             aCaseInsensitive, aCardRow, aRowPos);
-}
-
-NS_IMETHODIMP nsAddrDatabase::GetCardFromAttribute(nsIAbDirectory *aDirectory,
-                                                   const char *aName,
-                                                   const nsACString &aUTF8Value,
-                                                   bool aCaseInsensitive,
-                                                   nsIAbCard **aCardResult) {
-  NS_ENSURE_ARG_POINTER(aCardResult);
-
-  m_dbDirectory = do_GetWeakReference(aDirectory);
-  nsCOMPtr<nsIMdbRow> cardRow;
-  if (NS_SUCCEEDED(GetRowFromAttribute(aName, aUTF8Value, aCaseInsensitive,
-                                       getter_AddRefs(cardRow), nullptr)) &&
-      cardRow)
-    return CreateABCard(cardRow, 0, aCardResult);
-
-  *aCardResult = nullptr;
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsAddrDatabase::GetCardsFromAttribute(
-    nsIAbDirectory *aDirectory, const char *aName, const nsACString &aUTF8Value,
-    bool aCaseInsensitive, nsISimpleEnumerator **cards) {
-  NS_ENSURE_ARG_POINTER(cards);
-
-  m_dbDirectory = do_GetWeakReference(aDirectory);
-  nsCOMPtr<nsIMdbRow> row;
-  bool done = false;
-  nsCOMArray<nsIAbCard> list;
-  nsCOMPtr<nsIAbCard> card;
-  mdb_pos rowPos = -1;
-
-  do {
-    if (NS_SUCCEEDED(GetRowFromAttribute(aName, aUTF8Value, aCaseInsensitive,
-                                         getter_AddRefs(row), &rowPos)) &&
-        row) {
-      if (NS_FAILED(CreateABCard(row, 0, getter_AddRefs(card)))) continue;
-      list.AppendObject(card);
-    } else
-      done = true;
-  } while (!done);
-
-  return NS_NewArrayEnumerator(cards, list, NS_GET_IID(nsIAbCard));
-}
-
-NS_IMETHODIMP nsAddrDatabase::AddListDirNode(nsIMdbRow *listRow) {
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-NS_IMETHODIMP nsAddrDatabase::FindMailListbyUnicodeName(
-    const char16_t *listName, bool *exist) {
-  nsAutoString unicodeString(listName);
-  ToLowerCase(unicodeString);
-
-  nsCOMPtr<nsIMdbRow> listRow;
-  nsresult rv =
-      GetRowForCharColumn(unicodeString.get(), m_LowerListNameColumnToken,
-                          false, false, getter_AddRefs(listRow), nullptr);
-  *exist = (NS_SUCCEEDED(rv) && listRow);
-  return rv;
-}
-
-NS_IMETHODIMP nsAddrDatabase::GetCardCount(uint32_t *count) {
-  nsresult rv;
-  mdb_count c;
-  rv = m_mdbPabTable->GetCount(m_mdbEnv, &c);
-  if (NS_SUCCEEDED(rv)) *count = c - 1;  // Don't count LastRecordKey
-
-  return rv;
-}
-
-bool nsAddrDatabase::HasRowForCharColumn(const char16_t *unicodeStr,
-                                         mdb_column findColumn, bool aIsCard,
-                                         nsIMdbRow **aFindRow) {
-  if (!m_mdbStore || !aFindRow || !m_mdbEnv) return false;
-
-  mdbYarn sourceYarn;
-
-  NS_ConvertUTF16toUTF8 UTF8String(unicodeStr);
-  sourceYarn.mYarn_Buf = (void *)UTF8String.get();
-  sourceYarn.mYarn_Fill = UTF8String.Length();
-  sourceYarn.mYarn_Form = 0;
-  sourceYarn.mYarn_Size = sourceYarn.mYarn_Fill;
-
-  mdbOid outRowId;
-  nsresult rv;
-
-  if (aIsCard) {
-    rv = m_mdbStore->FindRow(m_mdbEnv, m_CardRowScopeToken, findColumn,
-                             &sourceYarn, &outRowId, aFindRow);
-    return (NS_SUCCEEDED(rv) && *aFindRow);
-  }
-
-  rv = m_mdbStore->FindRow(m_mdbEnv, m_ListRowScopeToken, findColumn,
-                           &sourceYarn, &outRowId, aFindRow);
-  return (NS_SUCCEEDED(rv) && *aFindRow);
-}
-
-/* @param aRowPos Contains the row position for multiple calls. Should be
- *                instantiated to -1 on the first call. Or can be null
- *                if you are not making multiple calls.
- */
-nsresult nsAddrDatabase::GetRowForCharColumn(
-    const char16_t *unicodeStr, mdb_column findColumn, bool aIsCard,
-    bool aCaseInsensitive, nsIMdbRow **aFindRow, mdb_pos *aRowPos) {
-  NS_ENSURE_ARG_POINTER(unicodeStr);
-  NS_ENSURE_ARG_POINTER(aFindRow);
-  NS_ENSURE_TRUE(m_mdbEnv && m_mdbPabTable, NS_ERROR_NULL_POINTER);
-
-  *aFindRow = nullptr;
-
-  if (!aRowPos &&
-      !HasRowForCharColumn(unicodeStr, findColumn, aIsCard, aFindRow)) {
-    // If we have a row, return NS_OK.
-    // If we don't have a row, there are two possible conditions: either the
-    // card does not exist, or we are doing case-insensitive searching and the
-    // value isn't lowercase.
-
-    // Valid result, return.
-    if (*aFindRow) return NS_OK;
-
-    // We definitely don't have anything at this point if case-sensitive.
-    if (!aCaseInsensitive) return NS_ERROR_FAILURE;
-  }
-
-  // Check if there is matching card.
-  nsCOMPtr<nsIMdbTableRowCursor> rowCursor;
-  mdb_pos rowPos = -1;
-  bool done = false;
-  nsCOMPtr<nsIMdbRow> currentRow;
-  nsAutoString columnValue;
-
-  if (aRowPos) rowPos = *aRowPos;
-
-  mdb_scope targetScope = aIsCard ? m_CardRowScopeToken : m_ListRowScopeToken;
-
-  m_mdbPabTable->GetTableRowCursor(m_mdbEnv, rowPos, getter_AddRefs(rowCursor));
-  if (!rowCursor) return NS_ERROR_FAILURE;
-
-  while (!done) {
-    nsresult rv =
-        rowCursor->NextRow(m_mdbEnv, getter_AddRefs(currentRow), &rowPos);
-    if (currentRow && NS_SUCCEEDED(rv)) {
-      mdbOid rowOid;
-      if (NS_SUCCEEDED(currentRow->GetOid(m_mdbEnv, &rowOid)) &&
-          (rowOid.mOid_Scope == targetScope)) {
-        rv = GetStringColumn(currentRow, findColumn, columnValue);
-
-        bool equals = aCaseInsensitive
-                          ? columnValue.Equals(
-                                unicodeStr, nsCaseInsensitiveStringComparator())
-                          : columnValue.Equals(unicodeStr);
-
-        if (NS_SUCCEEDED(rv) && equals) {
-          currentRow.forget(aFindRow);
-          if (aRowPos) *aRowPos = rowPos;
-          return NS_OK;
-        }
-      }
-    } else
-      done = true;
-  }
-  return NS_ERROR_FAILURE;
-}
-
-nsresult nsAddrDatabase::DeleteRow(nsIMdbTable *dbTable, nsIMdbRow *dbRow) {
-  if (!m_mdbEnv) return NS_ERROR_NULL_POINTER;
-
-  nsresult err = dbRow->CutAllColumns(m_mdbEnv);
-  err = dbTable->CutRow(m_mdbEnv, dbRow);
-
-  return (NS_SUCCEEDED(err)) ? NS_OK : NS_ERROR_FAILURE;
-}
--- a/mailnews/addrbook/src/nsAddrDatabase.h
+++ b/mailnews/addrbook/src/nsAddrDatabase.h
@@ -31,309 +31,39 @@ class nsAddrDatabase : public nsIAddrDat
 
   NS_IMETHOD GetDbPath(nsIFile **aDbPath) override;
   NS_IMETHOD SetDbPath(nsIFile *aDbPath) override;
   NS_IMETHOD Open(nsIFile *aMabFile, bool aCreate, bool upgrading,
                   nsIAddrDatabase **pCardDB) override;
   NS_IMETHOD Close(bool forceCommit) override;
   NS_IMETHOD OpenMDB(nsIFile *dbName, bool create) override;
   NS_IMETHOD CloseMDB(bool commit) override;
-  NS_IMETHOD Commit(uint32_t commitType) override;
   NS_IMETHOD ForceClosed() override;
 
-  NS_IMETHOD CreateNewCardAndAddToDB(nsIAbCard *newCard, bool notify,
-                                     nsIAbDirectory *parent) override;
-  NS_IMETHOD CreateNewListCardAndAddToDB(nsIAbDirectory *list,
-                                         uint32_t listRowID, nsIAbCard *newCard,
-                                         bool notify) override;
-  NS_IMETHOD CreateMailListAndAddToDB(nsIAbDirectory *newList, bool notify,
-                                      nsIAbDirectory *parent) override;
   NS_IMETHOD EnumerateCards(nsIAbDirectory *directory,
                             nsISimpleEnumerator **result) override;
-  NS_IMETHOD GetMailingListsFromDB(nsIAbDirectory *parentDir) override;
   NS_IMETHOD EnumerateListAddresses(nsIAbDirectory *directory,
                                     uint32_t listRowID,
                                     nsISimpleEnumerator **result) override;
-  NS_IMETHOD DeleteCard(nsIAbCard *newCard, bool notify,
-                        nsIAbDirectory *parent) override;
-  NS_IMETHOD EditCard(nsIAbCard *card, bool notify,
-                      nsIAbDirectory *parent) override;
-  NS_IMETHOD ContainsCard(nsIAbCard *card, bool *hasCard) override;
-  NS_IMETHOD DeleteMailList(nsIAbDirectory *aMailList,
-                            nsIAbDirectory *aParent) override;
-  NS_IMETHOD EditMailList(nsIAbDirectory *mailList, nsIAbCard *listCard,
-                          bool notify) override;
-  NS_IMETHOD ContainsMailList(nsIAbDirectory *mailList, bool *hasCard) override;
-  NS_IMETHOD DeleteCardFromMailList(nsIAbDirectory *mailList, nsIAbCard *card,
-                                    bool aNotify) override;
-  NS_IMETHOD GetCardFromAttribute(nsIAbDirectory *aDirectory, const char *aName,
-                                  const nsACString &aValue,
-                                  bool aCaseInsensitive,
-                                  nsIAbCard **card) override;
-  NS_IMETHOD GetCardsFromAttribute(nsIAbDirectory *aDirectory,
-                                   const char *aName,
-                                   const nsACString &uUTF8Value,
-                                   bool aCaseInsensitive,
-                                   nsISimpleEnumerator **cards) override;
-  NS_IMETHOD GetNewRow(nsIMdbRow **newRow) override;
-  NS_IMETHOD GetNewListRow(nsIMdbRow **newRow) override;
-  NS_IMETHOD AddCardRowToDB(nsIMdbRow *newRow) override;
-  NS_IMETHOD AddLdifListMember(nsIMdbRow *row, const char *value) override;
-
-  NS_IMETHOD AddUID(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_UIDColumnToken, value);
-  }
-
-  NS_IMETHOD AddFirstName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_FirstNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddLastName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_LastNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddPhoneticFirstName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_PhoneticFirstNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddPhoneticLastName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_PhoneticLastNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddDisplayName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_DisplayNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddNickName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_NickNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddPrimaryEmail(nsIMdbRow *row, const char *value) override;
-
-  NS_IMETHOD Add2ndEmail(nsIMdbRow *row, const char *value) override;
-
-  NS_IMETHOD AddPreferMailFormat(nsIMdbRow *row, uint32_t value) override {
-    return AddIntColumn(row, m_MailFormatColumnToken, value);
-  }
-
-  NS_IMETHOD AddPopularityIndex(nsIMdbRow *row, uint32_t value) override {
-    return AddIntColumn(row, m_PopularityIndexColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkPhone(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkPhoneColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomePhone(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomePhoneColumnToken, value);
-  }
-
-  NS_IMETHOD AddFaxNumber(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_FaxColumnToken, value);
-  }
-
-  NS_IMETHOD AddPagerNumber(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_PagerColumnToken, value);
-  }
-
-  NS_IMETHOD AddCellularNumber(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_CellularColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkPhoneType(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkPhoneTypeColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomePhoneType(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomePhoneTypeColumnToken, value);
-  }
-
-  NS_IMETHOD AddFaxNumberType(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_FaxTypeColumnToken, value);
-  }
-
-  NS_IMETHOD AddPagerNumberType(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_PagerTypeColumnToken, value);
-  }
-
-  NS_IMETHOD AddCellularNumberType(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_CellularTypeColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomeAddress(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomeAddressColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomeAddress2(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomeAddress2ColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomeCity(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomeCityColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomeState(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomeStateColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomeZipCode(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomeZipCodeColumnToken, value);
-  }
-
-  NS_IMETHOD AddHomeCountry(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_HomeCountryColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkAddress(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkAddressColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkAddress2(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkAddress2ColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkCity(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkCityColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkState(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkStateColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkZipCode(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkZipCodeColumnToken, value);
-  }
-
-  NS_IMETHOD AddWorkCountry(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WorkCountryColumnToken, value);
-  }
-
-  NS_IMETHOD AddJobTitle(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_JobTitleColumnToken, value);
-  }
-
-  NS_IMETHOD AddDepartment(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_DepartmentColumnToken, value);
-  }
-
-  NS_IMETHOD AddCompany(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_CompanyColumnToken, value);
-  }
-
-  NS_IMETHOD AddAimScreenName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_AimScreenNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddAnniversaryYear(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_AnniversaryYearColumnToken, value);
-  }
-
-  NS_IMETHOD AddAnniversaryMonth(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_AnniversaryMonthColumnToken, value);
-  }
-
-  NS_IMETHOD AddAnniversaryDay(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_AnniversaryDayColumnToken, value);
-  }
-
-  NS_IMETHOD AddSpouseName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_SpouseNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddFamilyName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_FamilyNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddDefaultAddress(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_DefaultAddressColumnToken, value);
-  }
-
-  NS_IMETHOD AddCategory(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_CategoryColumnToken, value);
-  }
-
-  NS_IMETHOD AddWebPage1(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WebPage1ColumnToken, value);
-  }
-
-  NS_IMETHOD AddWebPage2(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_WebPage2ColumnToken, value);
-  }
-
-  NS_IMETHOD AddBirthYear(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_BirthYearColumnToken, value);
-  }
-
-  NS_IMETHOD AddBirthMonth(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_BirthMonthColumnToken, value);
-  }
-
-  NS_IMETHOD AddBirthDay(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_BirthDayColumnToken, value);
-  }
-
-  NS_IMETHOD AddCustom1(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_Custom1ColumnToken, value);
-  }
-
-  NS_IMETHOD AddCustom2(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_Custom2ColumnToken, value);
-  }
-
-  NS_IMETHOD AddCustom3(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_Custom3ColumnToken, value);
-  }
-
-  NS_IMETHOD AddCustom4(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_Custom4ColumnToken, value);
-  }
-
-  NS_IMETHOD AddNotes(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_NotesColumnToken, value);
-  }
-
-  NS_IMETHOD AddListName(nsIMdbRow *row, const char *value) override;
-
-  NS_IMETHOD AddListNickName(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_ListNickNameColumnToken, value);
-  }
-
-  NS_IMETHOD AddListDescription(nsIMdbRow *row, const char *value) override {
-    return AddCharStringColumn(row, m_ListDescriptionColumnToken, value);
-  }
-
-  NS_IMETHOD AddListDirNode(nsIMdbRow *listRow) override;
-
-  NS_IMETHOD FindMailListbyUnicodeName(const char16_t *listName,
-                                       bool *exist) override;
-
-  NS_IMETHOD GetCardCount(uint32_t *count) override;
-
-  NS_IMETHOD SetCardValue(nsIAbCard *card, const char *name,
-                          const char16_t *value, bool notify) override;
-  NS_IMETHOD GetCardValue(nsIAbCard *card, const char *name,
-                          char16_t **value) override;
-  // nsAddrDatabase methods:
 
   nsAddrDatabase();
 
   nsresult GetMDBFactory(nsIMdbFactory **aMdbFactory);
   nsIMdbEnv *GetEnv() { return m_mdbEnv; }
   uint32_t GetCurVersion();
   nsIMdbTableRowCursor *GetTableRowCursor();
   nsIMdbTable *GetPabTable() { return m_mdbPabTable; }
 
   static already_AddRefed<nsAddrDatabase> FindInCache(nsIFile *dbName);
 
   static void CleanupCache();
 
   nsresult CreateABCard(nsIMdbRow *cardRow, mdb_id listRowID,
                         nsIAbCard **result);
   nsresult CreateABListCard(nsIMdbRow *listRow, nsIAbCard **result);
-  nsresult CreateABList(nsIMdbRow *listRow, nsIAbDirectory **result);
 
   bool IsListRowScopeToken(mdb_scope scope) {
     return (scope == m_ListRowScopeToken) ? true : false;
   }
   bool IsCardRowScopeToken(mdb_scope scope) {
     return (scope == m_CardRowScopeToken) ? true : false;
   }
   bool IsDataRowScopeToken(mdb_scope scope) {
@@ -341,100 +71,47 @@ class nsAddrDatabase : public nsIAddrDat
   }
   nsresult GetCardRowByRowID(mdb_id rowID, nsIMdbRow **dbRow);
   nsresult GetListRowByRowID(mdb_id rowID, nsIMdbRow **dbRow);
 
   uint32_t GetListAddressTotal(nsIMdbRow *listRow);
   nsresult GetAddressRowByPos(nsIMdbRow *listRow, uint16_t pos,
                               nsIMdbRow **cardRow);
 
-  NS_IMETHOD AddListCardColumnsToRow(nsIAbCard *aPCard, nsIMdbRow *aPListRow,
-                                     uint32_t aPos, nsIAbCard **aPNewCard,
-                                     bool aInMailingList,
-                                     nsIAbDirectory *aParent,
-                                     nsIAbDirectory *aRoot) override;
-  NS_IMETHOD InitCardFromRow(nsIAbCard *aNewCard, nsIMdbRow *aCardRow) override;
-  NS_IMETHOD SetListAddressTotal(nsIMdbRow *aListRow, uint32_t aTotal) override;
-  NS_IMETHOD FindRowByCard(nsIAbCard *card, nsIMdbRow **aRow) override;
+  nsresult InitCardFromRow(nsIAbCard *aNewCard, nsIMdbRow *aCardRow);
 
  protected:
   virtual ~nsAddrDatabase();
 
   static void RemoveFromCache(nsAddrDatabase *pAddrDB);
   bool MatchDbName(nsIFile *dbName);  // returns TRUE if they match
 
   void YarnToUInt32(struct mdbYarn *yarn, uint32_t *pResult);
-  void GetCharStringYarn(char *str, struct mdbYarn *strYarn);
-  void GetStringYarn(const nsAString &aStr, struct mdbYarn *strYarn);
-  void GetIntYarn(uint32_t nValue, struct mdbYarn *intYarn);
-  nsresult AddCharStringColumn(nsIMdbRow *cardRow, mdb_column inColumn,
-                               const char *str);
-  nsresult AddStringColumn(nsIMdbRow *aCardRow, mdb_column aInColumn,
-                           const nsAString &aStr);
-  nsresult AddIntColumn(nsIMdbRow *cardRow, mdb_column inColumn,
-                        uint32_t nValue);
-  nsresult AddBoolColumn(nsIMdbRow *cardRow, mdb_column inColumn, bool bValue);
   nsresult GetStringColumn(nsIMdbRow *cardRow, mdb_token outToken,
                            nsString &str);
   nsresult GetIntColumn(nsIMdbRow *cardRow, mdb_token outToken,
                         uint32_t *pValue, uint32_t defaultValue);
-  nsresult GetBoolColumn(nsIMdbRow *cardRow, mdb_token outToken, bool *pValue);
   nsresult GetListCardFromDB(nsIAbCard *listCard, nsIMdbRow *listRow);
-  nsresult GetListFromDB(nsIAbDirectory *newCard, nsIMdbRow *listRow);
-  nsresult AddRecordKeyColumnToRow(nsIMdbRow *pRow);
-  nsresult AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *cardRow);
-  nsresult AddListAttributeColumnsToRow(nsIAbDirectory *list,
-                                        nsIMdbRow *listRow,
-                                        nsIAbDirectory *parent);
   nsresult CreateCard(nsIMdbRow *cardRow, mdb_id listRowID, nsIAbCard **result);
-  nsresult CreateCardFromDeletedCardsTable(nsIMdbRow *cardRow, mdb_id listRowID,
-                                           nsIAbCard **result);
-  nsresult DeleteCardFromListRow(nsIMdbRow *pListRow, mdb_id cardRowID,
-                                 bool *cardFound);
-  void DeleteCardFromAllMailLists(nsIAbCard *aCard);
-  nsresult NotifyListEntryChange(uint32_t abCode, nsIAbDirectory *dir);
-
-  nsresult AddLowercaseColumn(nsIMdbRow *row, mdb_token columnToken,
-                              const char *utf8String);
-  nsresult GetRowFromAttribute(const char *aName, const nsACString &aUTF8Value,
-                               bool aCaseInsensitive, nsIMdbRow **aCardRow,
-                               mdb_pos *aRowPos);
 
   static nsTArray<nsAddrDatabase *> *m_dbCache;
   static nsTArray<nsAddrDatabase *> *GetDBCache();
 
   // mdb bookkeeping stuff
   nsresult InitExistingDB();
-  nsresult InitNewDB();
   nsresult InitMDBInfo();
   nsresult InitPabTable();
 
-  nsresult InitLastRecorKey();
-  nsresult GetDataRow(nsIMdbRow **pDataRow);
-  nsresult GetLastRecordKey();
-  nsresult UpdateLastRecordKey();
-  nsresult CheckAndUpdateRecordKey();
-  nsresult UpdateLowercaseEmailListName();
-  nsresult ConvertAndAddLowercaseColumn(nsIMdbRow *row, mdb_token fromCol,
-                                        mdb_token toCol);
-  nsresult AddUnicodeToColumn(nsIMdbRow *row, mdb_token colToken,
-                              mdb_token lowerCaseColToken,
-                              const char16_t *pUnicodeStr);
-
-  nsresult DeleteRow(nsIMdbTable *dbTable, nsIMdbRow *dbRow);
-
   nsIMdbEnv *m_mdbEnv;  // to be used in all the db calls.
   nsIMdbStore *m_mdbStore;
   nsIMdbTable *m_mdbPabTable;
   nsCOMPtr<nsIFile> m_dbName;
   bool m_mdbTokensInitialized;
-  bool m_mdbDeletedCardsTableRemoved;
 
   mdb_kind m_PabTableKind;
-  mdb_kind m_MailListTableKind;
   mdb_kind m_DeletedCardsTableKind;
 
   mdb_scope m_CardRowScopeToken;
   mdb_scope m_ListRowScopeToken;
   mdb_scope m_DataRowScopeToken;
 
   mdb_token m_UIDColumnToken;
   mdb_token m_FirstNameColumnToken;
@@ -502,27 +179,20 @@ class nsAddrDatabase : public nsIAddrDat
   mdb_token m_LastRecordKeyColumnToken;
 
   mdb_token m_ListNameColumnToken;
   mdb_token m_ListNickNameColumnToken;
   mdb_token m_ListDescriptionColumnToken;
   mdb_token m_ListTotalColumnToken;
   mdb_token m_LowerListNameColumnToken;
 
-  uint32_t m_LastRecordKey;
   nsWeakPtr m_dbDirectory;
   nsCOMPtr<nsIMdbFactory> mMdbFactory;
 
  private:
-  nsresult GetRowForCharColumn(const char16_t *unicodeStr,
-                               mdb_column findColumn, bool bIsCard,
-                               bool aCaseInsensitive, nsIMdbRow **findRow,
-                               mdb_pos *aRowPos);
-  bool HasRowForCharColumn(const char16_t *unicodeStr, mdb_column findColumn,
-                           bool aIsCard, nsIMdbRow **aFindRow);
   nsresult OpenInternal(nsIFile *aMabFile, bool aCreate,
                         nsIAddrDatabase **pCardDB);
   nsresult AlertAboutCorruptMabFile(const nsString &aOldFileName,
                                     const nsString &aNewFileName);
   nsresult AlertAboutLockedMabFile(const nsString &aFileName);
   nsresult DisplayAlert(const char16_t *titleName,
                         const char16_t *alertStringName,
                         nsTArray<nsString> &formatStrings);