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

0001 /*
0002     SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
0003     Based in kmail/recipientseditor.h/cpp
0004     SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0007 */
0008 
0009 #pragma once
0010 
0011 #include "messagecomposer_export.h"
0012 
0013 #include <Libkdepim/MultiplyingLine>
0014 
0015 #include <Libkleo/Enum>
0016 #include <gpgme++/key.h>
0017 
0018 #include <QSharedPointer>
0019 #include <QString>
0020 namespace MessageComposer
0021 {
0022 /** Represents a mail recipient. */
0023 class RecipientPrivate;
0024 /**
0025  * @brief The Recipient class
0026  */
0027 class MESSAGECOMPOSER_EXPORT Recipient : public KPIM::MultiplyingLineData
0028 {
0029 public:
0030     using Ptr = QSharedPointer<Recipient>;
0031     using List = QList<Recipient::Ptr>;
0032 
0033     enum Type {
0034         To,
0035         Cc,
0036         Bcc,
0037         ReplyTo,
0038         Undefined,
0039     };
0040 
0041     Recipient(const QString &email = QString(), Type type = To); // krazy:exclude=explicit
0042     ~Recipient() override;
0043     void setType(Type type);
0044     [[nodiscard]] Type type() const;
0045 
0046     void setEmail(const QString &email);
0047     [[nodiscard]] QString email() const;
0048 
0049     void setName(const QString &name);
0050     [[nodiscard]] QString name() const;
0051 
0052     [[nodiscard]] bool isEmpty() const override;
0053     void clear() override;
0054 
0055     [[nodiscard]] static int typeToId(Type type);
0056     [[nodiscard]] static Type idToType(int id);
0057 
0058     [[nodiscard]] QString typeLabel() const;
0059     [[nodiscard]] static QString typeLabel(Type type);
0060     [[nodiscard]] static QStringList allTypeLabels();
0061 
0062     void setEncryptionAction(const Kleo::Action action);
0063     [[nodiscard]] Kleo::Action encryptionAction() const;
0064 
0065     void setKey(const GpgME::Key &key);
0066     [[nodiscard]] GpgME::Key key() const;
0067 
0068 private:
0069     std::unique_ptr<RecipientPrivate> const d;
0070 };
0071 }