File indexing completed on 2024-05-12 05:17:12
0001 /* 0002 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "kimap_export.h" 0010 0011 #include "job.h" 0012 #include <QDateTime> 0013 0014 namespace KIMAP 0015 { 0016 class Session; 0017 struct Response; 0018 class AppendJobPrivate; 0019 0020 /** 0021 * Appends a message to a mailbox. 0022 * 0023 * This job can only be run when the session is in the 0024 * authenticated (or selected) state. 0025 * 0026 * If the server supports ACLs, the user will need the 0027 * Acl::Insert right on the mailbox. 0028 */ 0029 class KIMAP_EXPORT AppendJob : public Job 0030 { 0031 Q_OBJECT 0032 Q_DECLARE_PRIVATE(AppendJob) 0033 0034 friend class SessionPrivate; 0035 0036 public: 0037 explicit AppendJob(Session *session); 0038 ~AppendJob() override; 0039 0040 /** 0041 * Set the mailbox to append the message to. 0042 * 0043 * If the mailbox does not exist, it will not automatically 0044 * be created and the command will fail. 0045 * 0046 * @param mailBox the (unquoted) name of the mailbox 0047 */ 0048 void setMailBox(const QString &mailBox); 0049 /** 0050 * The mailbox that the message will be appended to. 0051 */ 0052 [[nodiscard]] QString mailBox() const; 0053 0054 /** 0055 * Set the flags that should be applied to the appended message. 0056 * 0057 * @param flags a list of flags 0058 */ 0059 void setFlags(const QList<QByteArray> &flags); 0060 /** 0061 * The flags that will be set on the appended message. 0062 */ 0063 [[nodiscard]] QList<QByteArray> flags() const; 0064 0065 /** 0066 * Set the internal date that should be applied to the appended message. 0067 * 0068 * This is the date/time the IMAP server should set internally for the appended message. 0069 * See https://tools.ietf.org/html/rfc3501#section-6.3.11 0070 * 0071 * If this is not set, the server will use the current date/time. 0072 * 0073 * @param internalDate the internal date 0074 * 0075 * @since 4.13 0076 */ 0077 void setInternalDate(const QDateTime &internalDate); 0078 0079 /** 0080 * The internal date that will be set on the appended message. 0081 * 0082 * @since 4.13 0083 */ 0084 [[nodiscard]] QDateTime internalDate() const; 0085 0086 /** 0087 * The content of the message. 0088 * 0089 * This should be in RFC-2822 format, although some required header 0090 * lines may be omitted in certain cases, for example when appending 0091 * to a Drafts folder. 0092 * 0093 * @param content usually an RFC-2822 message 0094 */ 0095 void setContent(const QByteArray &content); 0096 /** 0097 * The content that the message will have. 0098 */ 0099 [[nodiscard]] QByteArray content() const; 0100 0101 /** 0102 * The UID of the new message. 0103 * 0104 * This will be zero if it is unknown. 0105 * 0106 * The UID will not be known until the job has been successfully 0107 * executed, and it will only be known at all if the server 0108 * supports the UIDPLUS extension (RFC 4315). 0109 */ 0110 [[nodiscard]] qint64 uid() const; 0111 0112 protected: 0113 void doStart() override; 0114 void handleResponse(const Response &response) override; 0115 }; 0116 0117 }