File indexing completed on 2024-05-19 05:11:44
0001 /* 0002 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadi-mime_export.h" 0010 0011 #include <Akonadi/Attribute> 0012 #include <Akonadi/Collection> 0013 0014 #include <memory> 0015 0016 namespace Akonadi 0017 { 0018 class SentBehaviourAttributePrivate; 0019 0020 /** 0021 Attribute determining what will happen to a message after it is sent. The 0022 message can be deleted from the Outbox, moved to the default sent-mail 0023 collection, or moved to a custom collection. 0024 0025 @author Constantin Berzan <exit3219@gmail.com> 0026 @since 4.4 0027 */ 0028 class AKONADI_MIME_EXPORT SentBehaviourAttribute : public Akonadi::Attribute 0029 { 0030 public: 0031 /** 0032 What to do with the item in the outbox after it has been sent successfully. 0033 */ 0034 enum SentBehaviour { 0035 Delete, ///< Delete the item from the outbox. 0036 MoveToCollection, ///< Move the item to a custom collection. 0037 MoveToDefaultSentCollection ///< Move the item to the default sent-mail collection. 0038 }; 0039 0040 /** 0041 Creates a new SentBehaviourAttribute. 0042 */ 0043 explicit SentBehaviourAttribute(SentBehaviour beh = MoveToDefaultSentCollection, 0044 const Akonadi::Collection &moveToCollection = Akonadi::Collection(-1), 0045 bool sendSilently = false); 0046 0047 /** 0048 Destroys the SentBehaviourAttribute. 0049 */ 0050 ~SentBehaviourAttribute() override; 0051 0052 /* reimpl */ 0053 SentBehaviourAttribute *clone() const override; 0054 QByteArray type() const override; 0055 QByteArray serialized() const override; 0056 void deserialize(const QByteArray &data) override; 0057 0058 /** 0059 Returns the sent-behaviour of the message. 0060 @see SentBehaviour. 0061 */ 0062 SentBehaviour sentBehaviour() const; 0063 0064 /** 0065 Sets the sent-behaviour of the message. 0066 @param beh the sent-behaviour to set 0067 @see SentBehaviour. 0068 */ 0069 void setSentBehaviour(SentBehaviour beh); 0070 0071 /** 0072 Returns the collection to which the item should be moved after it is sent. 0073 Only valid if sentBehaviour() is MoveToCollection. 0074 */ 0075 Akonadi::Collection moveToCollection() const; 0076 0077 /** 0078 Sets the collection to which the item should be moved after it is sent. 0079 Make sure you set the SentBehaviour to MoveToCollection first. 0080 @param moveToCollection target collection for "move to" operation 0081 @see setSentBehaviour. 0082 */ 0083 void setMoveToCollection(const Akonadi::Collection &moveToCollection); 0084 0085 /** 0086 * Returns whether a notification should be shown after the email is sent. 0087 * @since 5.4 0088 */ 0089 bool sendSilently() const; 0090 0091 /** 0092 * Set whether a notification should be shown after the email is sent. 0093 * 0094 * Default is false. 0095 * 0096 * @since 5.4 0097 */ 0098 void setSendSilently(bool sendSilently); 0099 0100 private: 0101 std::unique_ptr<SentBehaviourAttributePrivate> const d; 0102 }; 0103 } // namespace MailTransport