Mailcommon

filteractionreplyto.cpp
1/*
2 * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 *
6 */
7
8#include "filteractionreplyto.h"
9
10#include <KLocalizedString>
11
12using namespace MailCommon;
13
14FilterAction *FilterActionReplyTo::newAction()
15{
16 return new FilterActionReplyTo;
17}
18
19FilterActionReplyTo::FilterActionReplyTo(QObject *parent)
20 : FilterActionWithAddress(QStringLiteral("set Reply-To"), i18n("Set Reply-To To"), parent)
21{
22}
23
24FilterAction::ReturnCode FilterActionReplyTo::process(ItemContext &context, bool) const
25{
26 if (mParameter.isEmpty()) {
27 return ErrorButGoOn;
28 }
29 const auto msg = context.item().payload<KMime::Message::Ptr>();
30 const QByteArray replyTo("Reply-To");
31 KMime::Headers::Base *header = KMime::Headers::createHeader(replyTo);
32 if (!header) {
33 header = new KMime::Headers::Generic(replyTo.constData());
34 }
35 header->fromUnicodeString(mParameter);
36 msg->setHeader(header);
37 msg->assemble();
38
39 context.setNeedsPayloadStore();
40
41 return GoOn;
42}
43
44SearchRule::RequiredPart FilterActionReplyTo::requiredPart() const
45{
47}
48
49QString FilterActionReplyTo::informationAboutNotValidAction() const
50{
51 return i18n("Email address was not defined.");
52}
53
54#include "moc_filteractionreplyto.cpp"
T payload() const
virtual void fromUnicodeString(const QString &s)=0
Abstract base class for filter actions with a mail address as parameter.
Abstract base class for mail filter actions.
ReturnCode
Describes the possible return codes of filter processing:
@ ErrorButGoOn
A non-critical error occurred.
@ GoOn
Go on with applying filter actions.
A helper class for the filtering process.
Definition itemcontext.h:27
void setNeedsPayloadStore()
Marks that the item's payload has been changed and needs to be written back.
Akonadi::Item & item()
Returns the item of the context.
RequiredPart
Possible required parts.
Definition searchrule.h:68
@ CompleteMessage
Whole message.
Definition searchrule.h:71
QString i18n(const char *text, const TYPE &arg...)
The filter dialog.
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.