File indexing completed on 2025-01-26 04:45:35

0001 /******************************************************************************
0002  *
0003  *  SPDX-FileCopyrightText: 2010 Leo Franchi <lfranchi@kde.org>
0004  *  SPDX-FileCopyrightText: 2010 KDAB
0005  *
0006  *  SPDX-License-Identifier: LGPL-2.0-or-later
0007  *
0008  *****************************************************************************/
0009 
0010 #pragma once
0011 #include "akonadi-mime_export.h"
0012 
0013 #include <Akonadi/Attribute>
0014 #include <memory>
0015 
0016 namespace Akonadi
0017 {
0018 /**
0019  * @short An Attribute that keeps track of the MDN state of a mail message.
0020  *
0021  * Once a mail that contains a Message Disposition Notification is processed,
0022  * the outcome of the user action will be stored in this attribute.
0023  *
0024  * @author Leo Franchi <lfranchi@kde.org>
0025  * @see Akonadi::Attribute
0026  * @since 4.6
0027  */
0028 class AKONADI_MIME_EXPORT MDNStateAttribute : public Akonadi::Attribute
0029 {
0030 public:
0031     /**
0032      * Describes the "MDN sent" state.
0033      */
0034     enum MDNSentState {
0035         MDNStateUnknown, ///< The state is unknown.
0036         MDNNone, ///< No MDN has been set.
0037         MDNIgnore, ///< Ignore sending a MDN.
0038         MDNDisplayed, ///< The message has been displayed by the UA to someone reading the recipient's mailbox.
0039         MDNDeleted, ///< The message has been deleted.
0040         MDNDispatched, ///< The message has been sent somewhere in some manner without necessarily having been previously displayed to the user.
0041         MDNProcessed, ///< The message has been processed in some manner without being displayed to the user.
0042         MDNDenied, ///< The recipient does not wish the sender to be informed of the message's disposition.
0043         MDNFailed ///< A failure occurred that prevented the proper generation of an MDN.
0044     };
0045 
0046     /**
0047      * Creates a new MDN state attribute.
0048      *
0049      * @param state The state the attribute will have.
0050      */
0051     explicit MDNStateAttribute(MDNSentState state = MDNStateUnknown);
0052 
0053     /**
0054      * Creates a new MDN state attribute.
0055      *
0056      * @param state The string representation of the state the attribute will have.
0057      */
0058     explicit MDNStateAttribute(const QByteArray &state);
0059 
0060     /**
0061      * Destroys the MDN state attribute.
0062      */
0063     ~MDNStateAttribute() override;
0064 
0065     /**
0066      * Reimplemented from Attribute
0067      */
0068     QByteArray type() const override;
0069 
0070     /**
0071      * Reimplemented from Attribute
0072      */
0073     MDNStateAttribute *clone() const override;
0074 
0075     /**
0076      * Reimplemented from Attribute
0077      */
0078     QByteArray serialized() const override;
0079 
0080     /**
0081      * Reimplemented from Attribute
0082      */
0083     void deserialize(const QByteArray &data) override;
0084 
0085     /**
0086      * Sets the MDN @p state.
0087      */
0088     void setMDNState(MDNSentState state);
0089 
0090     /**
0091      * Returns the MDN state.
0092      */
0093     MDNStateAttribute::MDNSentState mdnState() const;
0094 
0095     bool operator==(const MDNStateAttribute &other) const;
0096 
0097 private:
0098     //@cond PRIVATE
0099     class MDNStateAttributePrivate;
0100     std::unique_ptr<MDNStateAttributePrivate> const d;
0101     //@endcond
0102 };
0103 }