File indexing completed on 2024-11-10 04:50:04
0001 /* 0002 * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 * 0006 */ 0007 0008 #include "filteractionreplyto.h" 0009 0010 #include <KLocalizedString> 0011 0012 using namespace MailCommon; 0013 0014 FilterAction *FilterActionReplyTo::newAction() 0015 { 0016 return new FilterActionReplyTo; 0017 } 0018 0019 FilterActionReplyTo::FilterActionReplyTo(QObject *parent) 0020 : FilterActionWithAddress(QStringLiteral("set Reply-To"), i18n("Set Reply-To To"), parent) 0021 { 0022 } 0023 0024 FilterAction::ReturnCode FilterActionReplyTo::process(ItemContext &context, bool) const 0025 { 0026 if (mParameter.isEmpty()) { 0027 return ErrorButGoOn; 0028 } 0029 const auto msg = context.item().payload<KMime::Message::Ptr>(); 0030 const QByteArray replyTo("Reply-To"); 0031 KMime::Headers::Base *header = KMime::Headers::createHeader(replyTo); 0032 if (!header) { 0033 header = new KMime::Headers::Generic(replyTo.constData()); 0034 } 0035 header->fromUnicodeString(mParameter, "utf-8"); 0036 msg->setHeader(header); 0037 msg->assemble(); 0038 0039 context.setNeedsPayloadStore(); 0040 0041 return GoOn; 0042 } 0043 0044 SearchRule::RequiredPart FilterActionReplyTo::requiredPart() const 0045 { 0046 return SearchRule::CompleteMessage; 0047 } 0048 0049 QString FilterActionReplyTo::informationAboutNotValidAction() const 0050 { 0051 return i18n("Email address was not defined."); 0052 } 0053 0054 #include "moc_filteractionreplyto.cpp"