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_DISPATCHMODEATTRIBUTE_H
21#define MAILTRANSPORT_DISPATCHMODEATTRIBUTE_H
22
23#include <mailtransport/mailtransport_export.h>
24
25#include <QtCore/QDateTime>
26
27#include <akonadi/attribute.h>
28
29namespace MailTransport {
30
31/**
32 Attribute determining how and when a message from the outbox should be
33 dispatched. Messages can be sent immediately, sent only when the user
34 explicitly requests it, or sent automatically at a certain date and time.
35
36 @author Constantin Berzan <exit3219@gmail.com>
37 @since 4.4
38*/
39class MAILTRANSPORT_EXPORT DispatchModeAttribute : public Akonadi::Attribute
40{
41 public:
42 /**
43 Determines how the message is sent.
44 */
45 enum DispatchMode {
46 Automatic, ///< Send message as soon as possible, but no earlier than
47 /// specified by setSendAfter()
48 Manual ///< Send message only when the user requests so.
49 };
50
51 /**
52 Creates a new DispatchModeAttribute.
53 */
54 explicit DispatchModeAttribute( DispatchMode mode = Automatic );
55
56 /**
57 Destroys the DispatchModeAttribute.
58 */
59 virtual ~DispatchModeAttribute();
60
61 /* reimpl */
62 virtual DispatchModeAttribute *clone() const;
63 virtual QByteArray type() const;
64 virtual QByteArray serialized() const;
65 virtual void deserialize( const QByteArray &data );
66
67 /**
68 Returns the dispatch mode for the message.
69 @see DispatchMode.
70 */
71 DispatchMode dispatchMode() const;
72
73 /**
74 Sets the dispatch mode for the message.
75 @param mode the dispatch mode to set
76 @see DispatchMode.
77 */
78 void setDispatchMode( DispatchMode mode );
79
80 /**
81 Returns the date and time when the message should be sent.
82 Only valid if dispatchMode() is Automatic.
83 */
84 QDateTime sendAfter() const;
85
86 /**
87 Sets the date and time when the message should be sent.
88 @param date the date and time to set
89 @see setDispatchMode.
90 */
91 void setSendAfter( const QDateTime &date );
92
93 private:
94 class Private;
95 Private *const d;
96
97};
98
99} // namespace MailTransport
100
101#endif // MAILTRANSPORT_DISPATCHMODEATTRIBUTE_H
102