File indexing completed on 2024-06-23 05:18:34
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 #include "messagecomposer_export.h" 0009 #include <Akonadi/MDNStateAttribute> 0010 #include <MessageComposer/MessageFactoryNG> 0011 #include <QObject> 0012 0013 namespace MessageComposer 0014 { 0015 class MESSAGECOMPOSER_EXPORT MDNAdviceHelper : public QObject 0016 { 0017 Q_OBJECT 0018 public: 0019 static MDNAdviceHelper *instance() 0020 { 0021 if (!s_instance) { 0022 s_instance = new MDNAdviceHelper; 0023 } 0024 0025 return s_instance; 0026 } 0027 0028 /** 0029 * Checks the MDN headers to see if the user needs to be asked for any 0030 * confirmations. Will ask the user if action is required. 0031 * 0032 * Returns whether to send an MDN or not, and the sending mode for the MDN 0033 * to be created. 0034 * 0035 * Will also set the Akonadi::MDNStateAttribute on the given item 0036 * to what the user has selected. 0037 */ 0038 [[nodiscard]] QPair<bool, KMime::MDN::SendingMode> checkAndSetMDNInfo(const Akonadi::Item &item, KMime::MDN::DispositionType d, bool forceSend = false); 0039 0040 [[nodiscard]] static Akonadi::MDNStateAttribute::MDNSentState dispositionToSentState(KMime::MDN::DispositionType d); 0041 0042 [[nodiscard]] QPair<QString, bool> mdnMessageText(const char *what); 0043 0044 private: 0045 MESSAGECOMPOSER_NO_EXPORT explicit MDNAdviceHelper(QObject *parent = nullptr) 0046 : QObject(parent) 0047 { 0048 } 0049 0050 ~MDNAdviceHelper() override = default; 0051 0052 [[nodiscard]] MESSAGECOMPOSER_NO_EXPORT int requestAdviceOnMDN(const char *what); 0053 MESSAGECOMPOSER_NO_EXPORT MessageComposer::MDNAdvice questionIgnoreSend(const QString &text, bool canDeny); 0054 0055 static MDNAdviceHelper *s_instance; 0056 }; 0057 }