Messagelib

recipient.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
3 Based in kmail/recipientseditor.h/cpp
4 SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org>
5
6 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
7*/
8
9#include "recipient.h"
10
11#include <KLocalizedString>
12
13using namespace KPIM;
14using namespace MessageComposer;
15
16class MessageComposer::RecipientPrivate
17{
18public:
19 RecipientPrivate(const QString &email, Recipient::Type type)
20 : mType(type)
21 , mEmail(email)
22 {
23 }
24
25 Kleo::Action mEncryptionAction = Kleo::Impossible;
26 MessageComposer::Recipient::Type mType;
27 QString mEmail;
28 QString mName;
29 GpgME::Key mKey;
30};
31
32Recipient::Recipient(const QString &email, Recipient::Type type)
33 : d(new MessageComposer::RecipientPrivate(email, type))
34{
35}
36
37Recipient::~Recipient() = default;
38
39void Recipient::setType(Type type)
40{
41 d->mType = type;
42}
43
44Recipient::Type Recipient::type() const
45{
46 return d->mType;
47}
48
49void Recipient::setEmail(const QString &email)
50{
51 d->mEmail = email;
52}
53
54QString Recipient::email() const
55{
56 return d->mEmail;
57}
58
59void Recipient::setName(const QString &name)
60{
61 d->mName = name;
62}
63
64QString Recipient::name() const
65{
66 return d->mName;
67}
68
69bool Recipient::isEmpty() const
70{
71 return d->mEmail.isEmpty();
72}
73
74void Recipient::clear()
75{
76 d->mEmail.clear();
77 d->mType = Recipient::To;
78}
79
80int Recipient::typeToId(Recipient::Type type)
81{
82 return static_cast<int>(type);
83}
84
85Recipient::Type Recipient::idToType(int id)
86{
87 return static_cast<Type>(id);
88}
89
90QString Recipient::typeLabel() const
91{
92 return typeLabel(d->mType);
93}
94
95QString Recipient::typeLabel(Recipient::Type type)
96{
97 switch (type) {
98 case To:
99 return i18nc("@label:listbox Recipient of an email message.", "To");
100 case Cc:
101 return i18nc("@label:listbox Carbon Copy recipient of an email message.", "CC");
102 case Bcc:
103 return i18nc("@label:listbox Blind carbon copy recipient of an email message.", "BCC");
104 case ReplyTo:
105 return i18nc("@label:listbox Reply-To recipient of an email message.", "Reply-To");
106 case Undefined:
107 break;
108 }
109
110 return xi18nc("@label:listbox", "<placeholder>Undefined Recipient Type</placeholder>");
111}
112
113QStringList Recipient::allTypeLabels()
114{
115 QStringList types;
116 types.append(typeLabel(To));
117 types.append(typeLabel(Cc));
118 types.append(typeLabel(Bcc));
119 types.append(typeLabel(ReplyTo));
120 return types;
121}
122
123GpgME::Key Recipient::key() const
124{
125 return d->mKey;
126}
127
128void Recipient::setKey(const GpgME::Key &key)
129{
130 d->mKey = key;
131}
132
133Kleo::Action MessageComposer::Recipient::encryptionAction() const
134{
135 return d->mEncryptionAction;
136}
137
138void MessageComposer::Recipient::setEncryptionAction(const Kleo::Action action)
139{
140 d->mEncryptionAction = action;
141}
QString xi18nc(const char *context, const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString name(GameStandardAction id)
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
void append(QList< T > &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.