Mailcommon

filteractionsendreceipt.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 "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 
18 using namespace MailCommon;
19 
20 FilterActionSendReceipt::FilterActionSendReceipt(QObject *parent)
21  : FilterActionWithNone(QStringLiteral("confirm delivery"), i18n("Confirm Delivery"), parent)
22 {
23 }
24 
25 FilterAction::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 
45 SearchRule::RequiredPart FilterActionSendReceipt::requiredPart() const
46 {
48 }
49 
50 FilterAction *FilterActionSendReceipt::newAction()
51 {
52  return new FilterActionSendReceipt;
53 }
MAILCOMMON_EXPORT uint folderIdentity(const Akonadi::Item &item)
Returns the identity of the folder that contains the given Akonadi::Item.
Definition: mailutil.cpp:148
Abstract base class for filter actions with no 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
A helper class for the filtering process.
Definition: itemcontext.h:26
ReturnCode
Describes the possible return codes of filter processing:
Definition: filteraction.h:45
Id id() const
@ 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 Sep 24 2022 03:58:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.