1/*
2 Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
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 KIMAP_APPENDJOB_H
21#define KIMAP_APPENDJOB_H
22
23#include <kdatetime.h>
24#include "kimap_export.h"
25
26#include "job.h"
27
28namespace KIMAP {
29
30class Session;
31struct Message;
32class AppendJobPrivate;
33
34/**
35 * Appends a message to a mailbox.
36 *
37 * This job can only be run when the session is in the
38 * authenticated (or selected) state.
39 *
40 * If the server supports ACLs, the user will need the
41 * Acl::Insert right on the mailbox.
42 */
43class KIMAP_EXPORT AppendJob : public Job
44{
45 Q_OBJECT
46 Q_DECLARE_PRIVATE( AppendJob )
47
48 friend class SessionPrivate;
49
50 public:
51 AppendJob( Session *session );
52 virtual ~AppendJob();
53
54 /**
55 * Set the mailbox to append the message to.
56 *
57 * If the mailbox does not exist, it will not automatically
58 * be created and the command will fail.
59 *
60 * @param mailBox the (unquoted) name of the mailbox
61 */
62 void setMailBox( const QString &mailBox );
63 /**
64 * The mailbox that the message will be appended to.
65 */
66 QString mailBox() const;
67
68 /**
69 * Set the flags that should be applied to the appended message.
70 *
71 * @param flags a list of flags
72 */
73 void setFlags( const QList<QByteArray> &flags);
74 /**
75 * The flags that will be set on the appended message.
76 */
77 QList<QByteArray> flags() const;
78
79 /**
80 * Set the internal date that should be applied to the appended message.
81 *
82 * This is the date/time the IMAP server should set internally for the appended message.
83 * See http://tools.ietf.org/html/rfc3501#section-6.3.11
84 *
85 * If this is not set, the server will use the current date/time.
86 *
87 * @param internalDate the internal date
88 *
89 * @since 4.13
90 */
91 void setInternalDate( const KDateTime &internalDate );
92 /**
93 * The internal date that will be set on the appended message.
94 *
95 * @since 4.13
96 */
97 KDateTime internalDate() const;
98
99 /**
100 * The content of the message.
101 *
102 * This should be in RFC-2822 format, although some required header
103 * lines may be omitted in certain cases, for example when appending
104 * to a Drafts folder.
105 *
106 * @param content usually an RFC-2822 message
107 */
108 void setContent( const QByteArray &content );
109 /**
110 * The content that the message will have.
111 */
112 QByteArray content() const;
113
114 /**
115 * The UID of the new message.
116 *
117 * This will be zero if it is unknown.
118 *
119 * The UID will not be known until the job has been successfully
120 * executed, and it will only be known at all if the server
121 * supports the UIDPLUS extension (RFC 4315).
122 */
123 qint64 uid() const;
124
125 protected:
126 virtual void doStart();
127 virtual void handleResponse(const Message &response);
128};
129
130}
131
132#endif
133