File indexing completed on 2024-06-23 05:18:31
0001 /* 0002 * This file is part of KMail. 0003 * 0004 * SPDX-FileCopyrightText: 2010 KDAB 0005 * SPDX-FileContributor: Tobias Koenig <tokoe@kde.org> 0006 * 0007 * SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "messagecomposer_export.h" 0013 0014 #include <KJob> 0015 0016 #include <QMap> 0017 #include <QStringList> 0018 0019 namespace MessageComposer 0020 { 0021 /** 0022 * @short A job to expand aliases to email addresses. 0023 * 0024 * Expands aliases (distribution lists and nick names) and appends a 0025 * domain part to all email addresses which are missing the domain part. 0026 */ 0027 class MESSAGECOMPOSER_EXPORT AliasesExpandJob : public KJob 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 /** 0033 * Creates a new aliases expand job. 0034 * 0035 * @param recipients The comma separated list of recipient. 0036 * @param defaultDomain The default domain that shall be used when expanding aliases. 0037 * @param parent The parent object. 0038 */ 0039 AliasesExpandJob(const QString &recipients, const QString &defaultDomain, QObject *parent = nullptr); 0040 0041 /** 0042 * Destroys the aliases expand job. 0043 */ 0044 ~AliasesExpandJob() override; 0045 0046 /** 0047 * Starts the job. 0048 */ 0049 void start() override; 0050 0051 /** 0052 * Returns the expanded email addresses. 0053 */ 0054 [[nodiscard]] QString addresses() const; 0055 0056 /** 0057 * Returns the list of distribution lists that resolved to an empty member list. 0058 */ 0059 [[nodiscard]] QStringList emptyDistributionLists() const; 0060 0061 [[nodiscard]] QStringList emailAddressOnly() const; 0062 0063 private Q_SLOTS: 0064 MESSAGECOMPOSER_NO_EXPORT void slotDistributionListExpansionDone(KJob *); 0065 MESSAGECOMPOSER_NO_EXPORT void slotNicknameExpansionDone(KJob *); 0066 0067 private: 0068 MESSAGECOMPOSER_NO_EXPORT void finishExpansion(); 0069 0070 QStringList mEmailAddressOnly; 0071 0072 const QStringList mRecipients; 0073 const QString mDefaultDomain; 0074 0075 QString mEmailAddresses; 0076 QStringList mEmptyDistributionLists; 0077 0078 uint mDistributionListExpansionJobs = 0; 0079 uint mNicknameExpansionJobs = 0; 0080 0081 struct DistributionListExpansionResult { 0082 QString addresses; 0083 bool isEmpty = false; 0084 }; 0085 QMap<QString, DistributionListExpansionResult> mDistListExpansionResults; 0086 QMap<QString, QString> mNicknameExpansionResults; 0087 }; 0088 }