1/*
2 Copyright 2009 Constantin Berzan <exit3219@gmail.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef MAILTRANSPORT_SENTBEHAVIOURATTRIBUTE_H
21#define MAILTRANSPORT_SENTBEHAVIOURATTRIBUTE_H
22
23#include <mailtransport/mailtransport_export.h>
24
25#include <akonadi/attribute.h>
26#include <akonadi/collection.h>
27
28namespace MailTransport {
29
30/**
31 Attribute determining what will happen to a message after it is sent. The
32 message can be deleted from the Outbox, moved to the default sent-mail
33 collection, or moved to a custom collection.
34
35 @author Constantin Berzan <exit3219@gmail.com>
36 @since 4.4
37*/
38class MAILTRANSPORT_EXPORT SentBehaviourAttribute : public Akonadi::Attribute
39{
40 public:
41 /**
42 What to do with the item in the outbox after it has been sent successfully.
43 */
44 enum SentBehaviour {
45 Delete, ///< Delete the item from the outbox.
46 MoveToCollection, ///< Move the item to a custom collection.
47 MoveToDefaultSentCollection ///< Move the item to the default sent-mail collection.
48 };
49
50 /**
51 Creates a new SentBehaviourAttribute.
52 */
53 explicit SentBehaviourAttribute( SentBehaviour beh = MoveToDefaultSentCollection,
54 Akonadi::Collection moveToCollection = Akonadi::Collection( -1 ) );
55
56 /**
57 Destroys the SentBehaviourAttribute.
58 */
59 virtual ~SentBehaviourAttribute();
60
61 /* reimpl */
62 virtual SentBehaviourAttribute *clone() const;
63 virtual QByteArray type() const;
64 virtual QByteArray serialized() const;
65 virtual void deserialize( const QByteArray &data );
66
67 /**
68 Returns the sent-behaviour of the message.
69 @see SentBehaviour.
70 */
71 SentBehaviour sentBehaviour() const;
72
73 /**
74 Sets the sent-behaviour of the message.
75 @param beh the sent-behaviour to set
76 @see SentBehaviour.
77 */
78 void setSentBehaviour( SentBehaviour beh );
79
80 /**
81 Returns the collection to which the item should be moved after it is sent.
82 Only valid if sentBehaviour() is MoveToCollection.
83 */
84 Akonadi::Collection moveToCollection() const;
85
86 /**
87 Sets the collection to which the item should be moved after it is sent.
88 Make sure you set the SentBehaviour to MoveToCollection first.
89 @param moveToCollection target collection for "move to" operation
90 @see setSentBehaviour.
91 */
92 void setMoveToCollection( Akonadi::Collection moveToCollection );
93
94 private:
95 class Private;
96 Private *const d;
97
98};
99
100} // namespace MailTransport
101
102#endif // MAILTRANSPORT_SENTBEHAVIOURATTRIBUTE_H
103