File indexing completed on 2024-06-23 05:18:32

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 <KJob>
0013 #include <QStringList>
0014 namespace MessageComposer
0015 {
0016 /**
0017  * @short A job to expand a distribution list to its member email addresses.
0018  */
0019 class DistributionListExpandJob : public KJob
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     /**
0025      * Creates a new distribution list expand job.
0026      *
0027      * @param name The name of the distribution list to expand.
0028      * @param parent The parent object.
0029      */
0030     explicit DistributionListExpandJob(const QString &name, QObject *parent = nullptr);
0031 
0032     /**
0033      * Destroys the distribution list expand job.
0034      */
0035     ~DistributionListExpandJob() override;
0036 
0037     /**
0038      * Starts the job.
0039      */
0040     void start() override;
0041 
0042     /**
0043      * Returns the email addresses of the list members.
0044      */
0045     [[nodiscard]] QString addresses() const;
0046 
0047     /**
0048      * Returns whether the list of email addresses is empty.
0049      */
0050     [[nodiscard]] bool isEmpty() const;
0051 
0052 private Q_SLOTS:
0053     void slotSearchDone(KJob *);
0054     void slotExpansionDone(KJob *);
0055 
0056 private:
0057     const QString mListName;
0058     QStringList mEmailAddresses;
0059     bool mIsEmpty = false;
0060 };
0061 }