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

0001 /*
0002    SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "addresseelineeditbaloo.h"
0008 #include "baloocompletionemail.h"
0009 #include <KConfigGroup>
0010 #include <KSharedConfig>
0011 
0012 using namespace PimCommon;
0013 
0014 AddresseeLineEditBaloo::AddresseeLineEditBaloo()
0015     : mBalooCompletionEmail(new PimCommon::BalooCompletionEmail)
0016 {
0017     loadBalooBlackList();
0018 }
0019 
0020 AddresseeLineEditBaloo::~AddresseeLineEditBaloo()
0021 {
0022     delete mBalooCompletionEmail;
0023 }
0024 
0025 int AddresseeLineEditBaloo::balooCompletionSource() const
0026 {
0027     return mBalooCompletionSource;
0028 }
0029 
0030 void AddresseeLineEditBaloo::setBalooCompletionSource(int value)
0031 {
0032     mBalooCompletionSource = value;
0033 }
0034 
0035 QStringList AddresseeLineEditBaloo::balooBlackList() const
0036 {
0037     return mBalooCompletionEmail->balooCompletionEmailInfo().mBlackList;
0038 }
0039 
0040 QStringList AddresseeLineEditBaloo::domainExcludeList() const
0041 {
0042     return mBalooCompletionEmail->balooCompletionEmailInfo().mExcludeDomains;
0043 }
0044 
0045 void AddresseeLineEditBaloo::loadBalooBlackList()
0046 {
0047     KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
0048     config->reparseConfiguration();
0049     KConfigGroup group(config, QStringLiteral("AddressLineEdit"));
0050     PimCommon::BalooCompletionEmail::BalooCompletionEmailInfo info;
0051     const QStringList balooBlackList = group.readEntry("BalooBackList", QStringList());
0052     const QStringList domainExcludeList = group.readEntry("ExcludeDomain", QStringList());
0053     const QStringList lstExcludeEmailsRegularExpressions = group.readEntry("ExcludeEmailsRegexp", QStringList());
0054 
0055     info.mExcludeEmailsRegularExpressions = lstExcludeEmailsRegularExpressions;
0056     info.mBlackList = balooBlackList;
0057     info.mExcludeDomains = domainExcludeList;
0058     mBalooCompletionEmail->setBalooCompletionEmailInfo(info);
0059 }
0060 
0061 QStringList AddresseeLineEditBaloo::cleanupEmailList(const QStringList &inputList)
0062 {
0063     PimCommon::BalooCompletionEmail::BalooCompletionEmailInfo info = mBalooCompletionEmail->balooCompletionEmailInfo();
0064     info.mListEmail = inputList;
0065     mBalooCompletionEmail->setBalooCompletionEmailInfo(info);
0066     return mBalooCompletionEmail->cleanupEmailList();
0067 }