Mailcommon

filteractionsendreceipt.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 "filteractionsendreceipt.h"
9
10#include "kernel/mailkernel.h"
11#include "util/mailutil.h"
12
13#include <MessageComposer/MessageFactoryNG>
14#include <MessageComposer/MessageSender>
15
16#include <KLocalizedString>
17
18using namespace MailCommon;
19
20FilterActionSendReceipt::FilterActionSendReceipt(QObject *parent)
21 : FilterActionWithNone(QStringLiteral("confirm delivery"), i18n("Confirm Delivery"), parent)
22{
23}
24
25FilterAction::ReturnCode FilterActionSendReceipt::process(ItemContext &context, bool) const
26{
27 const auto msg = context.item().payload<KMime::Message::Ptr>();
28
29 MessageComposer::MessageFactoryNG factory(msg, context.item().id());
30 factory.setFolderIdentity(Util::folderIdentity(context.item()));
31 factory.setIdentityManager(KernelIf->identityManager());
32
33 const KMime::Message::Ptr receipt = factory.createDeliveryReceipt();
34 if (!receipt) {
35 return ErrorButGoOn;
36 }
37
38 // Queue message. This is a) so that the user can check
39 // the receipt before sending and b) for speed reasons.
40 KernelIf->msgSender()->send(receipt, MessageComposer::MessageSender::SendLater);
41
42 return GoOn;
43}
44
45SearchRule::RequiredPart FilterActionSendReceipt::requiredPart() const
46{
48}
49
50FilterAction *FilterActionSendReceipt::newAction()
51{
52 return new FilterActionSendReceipt;
53}
54
55#include "moc_filteractionsendreceipt.cpp"
Id id() const
T payload() const
Abstract base class for filter actions with no 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
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...)
MAILCOMMON_EXPORT uint folderIdentity(const Akonadi::Item &item)
Returns the identity of the folder that contains the given Akonadi::Item.
Definition mailutil.cpp:176
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Aug 30 2024 11:53:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.