File indexing completed on 2025-01-05 04:58:20

0001 /*
0002   SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 */
0007 
0008 #include "blacklistbalooemailutil.h"
0009 
0010 using namespace PimCommon;
0011 BlackListBalooEmailUtil::BlackListBalooEmailUtil() = default;
0012 
0013 BlackListBalooEmailUtil::~BlackListBalooEmailUtil() = default;
0014 
0015 void BlackListBalooEmailUtil::initialBlackList(const QStringList &blackList)
0016 {
0017     mInitialList = blackList;
0018 }
0019 
0020 void BlackListBalooEmailUtil::setNewBlackList(const QHash<QString, bool> &list)
0021 {
0022     mNewBlackList = list;
0023 }
0024 
0025 QStringList BlackListBalooEmailUtil::createNewBlackList()
0026 {
0027     if (mNewBlackList.isEmpty()) {
0028         return mInitialList;
0029     }
0030 
0031     QHashIterator<QString, bool> i(mNewBlackList);
0032     while (i.hasNext()) {
0033         i.next();
0034         const QString newEmail(i.key());
0035         if (i.value()) {
0036             if (!mInitialList.contains(newEmail)) {
0037                 mInitialList.append(newEmail);
0038             }
0039         } else {
0040             mInitialList.removeAll(newEmail);
0041         }
0042     }
0043     return mInitialList;
0044 }