Messagelib

mdnwarningwidgetjob.cpp
1/*
2 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "mdnwarningwidgetjob.h"
8#include "messagecomposer_debug.h"
9#include <MessageComposer/MDNAdviceHelper>
10#include <MessageComposer/MessageFactoryNG>
11#include <MessageComposer/Util>
12#include <MessageViewer/MessageViewerSettings>
13using namespace MessageComposer;
14
15MDNWarningWidgetJob::MDNWarningWidgetJob(QObject *parent)
16 : QObject{parent}
17{
18}
19
20MDNWarningWidgetJob::~MDNWarningWidgetJob() = default;
21
22bool MDNWarningWidgetJob::canStart() const
23{
24 return mItem.isValid();
25}
26
27bool MDNWarningWidgetJob::start()
28{
29 QPair<QString, bool> mdnInfo;
30 KMime::MDN::SendingMode s = KMime::MDN::SentAutomatically; // set to manual if asked user
31 bool result = false;
32 if (canStart()) {
33 KMime::Message::Ptr msg = MessageComposer::Util::message(mItem);
34 int mode = MessageViewer::MessageViewerSettings::self()->defaultPolicy();
35 if (!mode || (mode < 0) || (mode > 3)) {
36 // Nothing
37 } else {
39 mdnInfo = MessageComposer::MDNAdviceHelper::instance()->mdnMessageText("mdnUnknownOption");
40 s = KMime::MDN::SentManually;
41 // TODO set type to Failed as well
42 // and clear modifiers
43 }
44
46 mdnInfo = MessageComposer::MDNAdviceHelper::instance()->mdnMessageText("mdnMultipleAddressesInReceiptTo");
47 s = KMime::MDN::SentManually;
48 }
49
51 mdnInfo = MessageComposer::MDNAdviceHelper::instance()->mdnMessageText("mdnReturnPathEmpty");
52 s = KMime::MDN::SentManually;
53 }
54
55 if (MessageComposer::MessageFactoryNG::MDNReturnPathNotInRecieptTo(msg)) {
56 mdnInfo = MessageComposer::MDNAdviceHelper::instance()->mdnMessageText("mdnReturnPathNotInReceiptTo");
57 s = KMime::MDN::SentManually;
58 }
59
61 if (s != KMime::MDN::SentManually) {
62 // don't ask again if user has already been asked. use the users' decision
63 mdnInfo = MessageComposer::MDNAdviceHelper::instance()->mdnMessageText("mdnNormalAsk");
64 }
65 } else { // if message doesn't have a disposition header, never send anything.
66 mode = 0;
67 }
68 }
69 result = true;
70 } else {
71 qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to start job";
72 }
73 Q_EMIT showMdnInfo(mdnInfo, s);
75 return result;
76}
77
78const Akonadi::Item &MDNWarningWidgetJob::item() const
79{
80 return mItem;
81}
82
83void MDNWarningWidgetJob::setItem(const Akonadi::Item &newItem)
84{
85 mItem = newItem;
86}
87
88#include "moc_mdnwarningwidgetjob.cpp"
bool isValid() const
static bool MDNRequested(const KMime::Message::Ptr &msg)
When creating MDNs, the user needs to be asked for confirmation in specific cases according to RFC 22...
static bool MDNMDNUnknownOption(const KMime::Message::Ptr &msg)
If the MDN headers contain options that KMail can't parse.
static bool MDNReturnPathEmpty(const KMime::Message::Ptr &msg)
If sending an MDN requires confirmation due to discrepancy between MDN header and Return-Path header.
static bool MDNConfirmMultipleRecipients(const KMime::Message::Ptr &msg)
If sending an MDN requires confirmation due to multiple addresses.
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
Q_EMITQ_EMIT
void deleteLater()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.