1 | /* |
2 | Copyright (C) 2010 Klarälvdalens Datakonsult AB, |
3 | a KDAB Group company, info@kdab.net, |
4 | author Tobias Koenig <tokoe@kdab.com> |
5 | |
6 | This library is free software; you can redistribute it and/or modify it |
7 | under the terms of the GNU Library General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or (at your |
9 | option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, but WITHOUT |
12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
14 | License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to the |
18 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 | 02110-1301, USA. |
20 | */ |
21 | |
22 | #ifndef MAILTRANSPORT_SENTACTIONATTRIBUTE_H |
23 | #define MAILTRANSPORT_SENTACTIONATTRIBUTE_H |
24 | |
25 | #include <mailtransport/mailtransport_export.h> |
26 | |
27 | #include <QtCore/QSharedDataPointer> |
28 | #include <QtCore/QVariant> |
29 | |
30 | #include <akonadi/attribute.h> |
31 | |
32 | namespace MailTransport { |
33 | |
34 | /** |
35 | * @short An Attribute that stores the action to execute after sending. |
36 | * |
37 | * This attribute stores the action that will be executed by the mail dispatcher |
38 | * after a mail has successfully be sent. |
39 | * |
40 | * @author Tobias Koenig <tokoe@kdab.com> |
41 | * @since 4.6 |
42 | */ |
43 | class MAILTRANSPORT_EXPORT SentActionAttribute : public Akonadi::Attribute |
44 | { |
45 | public: |
46 | /** |
47 | * @short A sent action. |
48 | */ |
49 | class MAILTRANSPORT_EXPORT Action |
50 | { |
51 | public: |
52 | /** |
53 | * Describes the action type. |
54 | */ |
55 | enum Type { |
56 | Invalid, ///< An invalid action. |
57 | MarkAsReplied, ///< The message will be marked as replied. |
58 | MarkAsForwarded ///< The message will be marked as forwarded. |
59 | }; |
60 | |
61 | /** |
62 | * Describes a list of sent actions. |
63 | */ |
64 | typedef QList<Action> List; |
65 | |
66 | /** |
67 | * Creates a new invalid action. |
68 | */ |
69 | Action(); |
70 | |
71 | /** |
72 | * Creates a new action. |
73 | * |
74 | * @param action The action that shall be executed. |
75 | * @param value The action specific argument. |
76 | */ |
77 | Action( Type type, const QVariant &value ); |
78 | |
79 | /** |
80 | * Creates an action from an @p other action. |
81 | */ |
82 | Action( const Action &other ); |
83 | |
84 | /** |
85 | * Destroys the action. |
86 | */ |
87 | ~Action(); |
88 | |
89 | /** |
90 | * Returns the type of the action. |
91 | */ |
92 | Type type() const; |
93 | |
94 | /** |
95 | * Returns the argument value of the action. |
96 | */ |
97 | QVariant value() const; |
98 | |
99 | /** |
100 | * @internal |
101 | */ |
102 | Action &operator=( const Action &other ); |
103 | |
104 | /** |
105 | * @internal |
106 | */ |
107 | bool operator==( const Action &other ) const; |
108 | |
109 | private: |
110 | //@cond PRIVATE |
111 | class Private; |
112 | QSharedDataPointer<Private> d; |
113 | //@endcond |
114 | }; |
115 | |
116 | /** |
117 | * Creates a new sent action attribute. |
118 | */ |
119 | explicit SentActionAttribute(); |
120 | |
121 | /** |
122 | * Destroys the sent action attribute. |
123 | */ |
124 | virtual ~SentActionAttribute(); |
125 | |
126 | /** |
127 | * Adds a new action to the attribute. |
128 | * |
129 | * @param type The type of the action that shall be executed. |
130 | * @param value The action specific argument. |
131 | */ |
132 | void addAction( Action::Type type, const QVariant &value ); |
133 | |
134 | /** |
135 | * Returns the list of actions. |
136 | */ |
137 | Action::List actions() const; |
138 | |
139 | /* reimpl */ |
140 | virtual SentActionAttribute *clone() const; |
141 | virtual QByteArray type() const; |
142 | virtual QByteArray serialized() const; |
143 | virtual void deserialize( const QByteArray &data ); |
144 | |
145 | private: |
146 | //@cond PRIVATE |
147 | class Private; |
148 | Private *const d; |
149 | //@endcond |
150 | }; |
151 | |
152 | } |
153 | |
154 | #endif |
155 | |