Mailcommon

filteractionreplyto.cpp
1 /*
2  * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <[email protected]>
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  *
6  */
7 
8 #include "filteractionreplyto.h"
9 
10 #include <KLocalizedString>
11 
12 using namespace MailCommon;
13 
14 FilterAction *FilterActionReplyTo::newAction()
15 {
16  return new FilterActionReplyTo;
17 }
18 
19 FilterActionReplyTo::FilterActionReplyTo(QObject *parent)
20  : FilterActionWithAddress(QStringLiteral("set Reply-To"), i18n("Set Reply-To To"), parent)
21 {
22 }
23 
24 FilterAction::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, "utf-8");
36  msg->setHeader(header);
37  msg->assemble();
38 
39  context.setNeedsPayloadStore();
40 
41  return GoOn;
42 }
43 
44 SearchRule::RequiredPart FilterActionReplyTo::requiredPart() const
45 {
47 }
48 
49 QString FilterActionReplyTo::informationAboutNotValidAction() const
50 {
51  return i18n("Email address was not defined.");
52 }
Abstract base class for filter actions with a mail address as parameter.
Abstract base class for mail filter actions.
Definition: filteraction.h:38
QString i18n(const char *text, const TYPE &arg...)
RequiredPart
Possible required parts.
Definition: searchrule.h:68
void setNeedsPayloadStore()
Marks that the item's payload has been changed and needs to be written back.
Definition: itemcontext.cpp:33
virtual void fromUnicodeString(const QString &s, const QByteArray &b)=0
A helper class for the filtering process.
Definition: itemcontext.h:26
ReturnCode
Describes the possible return codes of filter processing:
Definition: filteraction.h:45
@ CompleteMessage
Whole message.
Definition: searchrule.h:71
Akonadi::Item & item()
Returns the item of the context.
Definition: itemcontext.cpp:18
The filter dialog.
T payload() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Oct 1 2022 04:00:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.