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 "filteractionsendreceipt.h" 0009 0010 #include "kernel/mailkernel.h" 0011 #include "util/mailutil.h" 0012 0013 #include <MessageComposer/MessageFactoryNG> 0014 #include <MessageComposer/MessageSender> 0015 0016 #include <KLocalizedString> 0017 0018 using namespace MailCommon; 0019 0020 FilterActionSendReceipt::FilterActionSendReceipt(QObject *parent) 0021 : FilterActionWithNone(QStringLiteral("confirm delivery"), i18n("Confirm Delivery"), parent) 0022 { 0023 } 0024 0025 FilterAction::ReturnCode FilterActionSendReceipt::process(ItemContext &context, bool) const 0026 { 0027 const auto msg = context.item().payload<KMime::Message::Ptr>(); 0028 0029 MessageComposer::MessageFactoryNG factory(msg, context.item().id()); 0030 factory.setFolderIdentity(Util::folderIdentity(context.item())); 0031 factory.setIdentityManager(KernelIf->identityManager()); 0032 0033 const KMime::Message::Ptr receipt = factory.createDeliveryReceipt(); 0034 if (!receipt) { 0035 return ErrorButGoOn; 0036 } 0037 0038 // Queue message. This is a) so that the user can check 0039 // the receipt before sending and b) for speed reasons. 0040 KernelIf->msgSender()->send(receipt, MessageComposer::MessageSender::SendLater); 0041 0042 return GoOn; 0043 } 0044 0045 SearchRule::RequiredPart FilterActionSendReceipt::requiredPart() const 0046 { 0047 return SearchRule::CompleteMessage; 0048 } 0049 0050 FilterAction *FilterActionSendReceipt::newAction() 0051 { 0052 return new FilterActionSendReceipt; 0053 } 0054 0055 #include "moc_filteractionsendreceipt.cpp"