File indexing completed on 2024-05-12 05:17:21
0001 /* 0002 Copyright (c) 2009 Kevin Ottens <ervin@kde.org> 0003 0004 This library is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to the 0016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0017 02110-1301, USA. 0018 */ 0019 0020 #ifndef KIMAP2_APPENDJOB_H 0021 #define KIMAP2_APPENDJOB_H 0022 0023 #include "kimap2_export.h" 0024 0025 #include "job.h" 0026 #include <QDateTime> 0027 0028 namespace KIMAP2 0029 { 0030 0031 class Session; 0032 struct Message; 0033 class AppendJobPrivate; 0034 0035 /** 0036 * Appends a message to a mailbox. 0037 * 0038 * This job can only be run when the session is in the 0039 * authenticated (or selected) state. 0040 * 0041 * If the server supports ACLs, the user will need the 0042 * Acl::Insert right on the mailbox. 0043 */ 0044 class KIMAP2_EXPORT AppendJob : public Job 0045 { 0046 Q_OBJECT 0047 Q_DECLARE_PRIVATE(AppendJob) 0048 0049 friend class SessionPrivate; 0050 0051 public: 0052 AppendJob(Session *session); 0053 virtual ~AppendJob(); 0054 0055 /** 0056 * Set the mailbox to append the message to. 0057 * 0058 * If the mailbox does not exist, it will not automatically 0059 * be created and the command will fail. 0060 * 0061 * @param mailBox the (unquoted) name of the mailbox 0062 */ 0063 void setMailBox(const QString &mailBox); 0064 /** 0065 * The mailbox that the message will be appended to. 0066 */ 0067 QString mailBox() const; 0068 0069 /** 0070 * Set the flags that should be applied to the appended message. 0071 * 0072 * @param flags a list of flags 0073 */ 0074 void setFlags(const QList<QByteArray> &flags); 0075 /** 0076 * The flags that will be set on the appended message. 0077 */ 0078 QList<QByteArray> flags() const; 0079 0080 /** 0081 * Set the internal date that should be applied to the appended message. 0082 * 0083 * This is the date/time the IMAP server should set internally for the appended message. 0084 * See http://tools.ietf.org/html/rfc3501#section-6.3.11 0085 * 0086 * If this is not set, the server will use the current date/time. 0087 * 0088 * @param internalDate the internal date 0089 * 0090 * @since 4.13 0091 */ 0092 void setInternalDate(const QDateTime &internalDate); 0093 0094 /** 0095 * The internal date that will be set on the appended message. 0096 * 0097 * @since 4.13 0098 */ 0099 QDateTime internalDate() const; 0100 0101 /** 0102 * The content of the message. 0103 * 0104 * This should be in RFC-2822 format, although some required header 0105 * lines may be omitted in certain cases, for example when appending 0106 * to a Drafts folder. 0107 * 0108 * @param content usually an RFC-2822 message 0109 */ 0110 void setContent(const QByteArray &content); 0111 /** 0112 * The content that the message will have. 0113 */ 0114 QByteArray content() const; 0115 0116 /** 0117 * The UID of the new message. 0118 * 0119 * This will be zero if it is unknown. 0120 * 0121 * The UID will not be known until the job has been successfully 0122 * executed, and it will only be known at all if the server 0123 * supports the UIDPLUS extension (RFC 4315). 0124 */ 0125 qint64 uid() const; 0126 0127 protected: 0128 void doStart() Q_DECL_OVERRIDE; 0129 void handleResponse(const Message &response) Q_DECL_OVERRIDE; 0130 }; 0131 0132 } 0133 0134 #endif