Messagelib

mdnwarningwidgetjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2022 Laurent Montel <[email protected]>
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>
13 using namespace MessageComposer;
14 
15 MDNWarningWidgetJob::MDNWarningWidgetJob(QObject *parent)
16  : QObject{parent}
17 {
18 }
19 
20 MDNWarningWidgetJob::~MDNWarningWidgetJob() = default;
21 
22 bool MDNWarningWidgetJob::canStart() const
23 {
24  return mItem.isValid();
25 }
26 
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()) {
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);
74  deleteLater();
75  return result;
76 }
77 
78 const Akonadi::Item &MDNWarningWidgetJob::item() const
79 {
80  return mItem;
81 }
82 
83 void MDNWarningWidgetJob::setItem(const Akonadi::Item &newItem)
84 {
85  mItem = newItem;
86 }
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
Q_SCRIPTABLE Q_NOREPLY void start()
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 MDNReturnPathEmpty(const KMime::Message::Ptr &msg)
If sending an MDN requires confirmation due to discrepancy between MDN header and Return-Path header.
static bool MDNMDNUnknownOption(const KMime::Message::Ptr &msg)
If the MDN headers contain options that KMail can't parse.
static bool MDNConfirmMultipleRecipients(const KMime::Message::Ptr &msg)
If sending an MDN requires confirmation due to multiple addresses.
QObject * parent() const const
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:08:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.