Messagelib

aliasesexpandjob.h
1 /*
2  * This file is part of KMail.
3  *
4  * SPDX-FileCopyrightText: 2010 KDAB
5  * SPDX-FileContributor: Tobias Koenig <[email protected]>
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #pragma once
11 
12 #include "messagecomposer_export.h"
13 
14 #include <KJob>
15 
16 #include <QMap>
17 #include <QStringList>
18 
19 namespace MessageComposer
20 {
21 /**
22  * @short A job to expand aliases to email addresses.
23  *
24  * Expands aliases (distribution lists and nick names) and appends a
25  * domain part to all email addresses which are missing the domain part.
26  */
27 class MESSAGECOMPOSER_EXPORT AliasesExpandJob : public KJob
28 {
29  Q_OBJECT
30 
31 public:
32  /**
33  * Creates a new aliases expand job.
34  *
35  * @param recipients The comma separated list of recipient.
36  * @param defaultDomain The default domain that shall be used when expanding aliases.
37  * @param parent The parent object.
38  */
39  AliasesExpandJob(const QString &recipients, const QString &defaultDomain, QObject *parent = nullptr);
40 
41  /**
42  * Destroys the aliases expand job.
43  */
44  ~AliasesExpandJob() override;
45 
46  /**
47  * Starts the job.
48  */
49  void start() override;
50 
51  /**
52  * Returns the expanded email addresses.
53  */
54  Q_REQUIRED_RESULT QString addresses() const;
55 
56  /**
57  * Returns the list of distribution lists that resolved to an empty member list.
58  */
59  Q_REQUIRED_RESULT QStringList emptyDistributionLists() const;
60 
61  Q_REQUIRED_RESULT QStringList emailAddressOnly() const;
62 
63 private Q_SLOTS:
64  void slotDistributionListExpansionDone(KJob *);
65  void slotNicknameExpansionDone(KJob *);
66 
67 private:
68  void finishExpansion();
69 
70  QStringList mEmailAddressOnly;
71 
72  QStringList mRecipients;
73  QString mDefaultDomain;
74 
75  QString mEmailAddresses;
76  QStringList mEmptyDistributionLists;
77 
78  uint mDistributionListExpansionJobs = 0;
79  uint mNicknameExpansionJobs = 0;
80 
81  struct DistributionListExpansionResult {
82  QString addresses;
83  bool isEmpty = false;
84  };
85  QMap<QString, DistributionListExpansionResult> mDistListExpansionResults;
86  QMap<QString, QString> mNicknameExpansionResults;
87 };
88 }
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
Q_SCRIPTABLE Q_NOREPLY void start()
A job to expand aliases to email addresses.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 19 2022 03:53:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.