File indexing completed on 2024-05-12 05:17:21

0001 /*
0002     Copyright (c) 2009 Andras Mantia <amantia@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_COPYJOB_H
0021 #define KIMAP2_COPYJOB_H
0022 
0023 #include "kimap2_export.h"
0024 
0025 #include "job.h"
0026 #include "imapset.h"
0027 
0028 namespace KIMAP2
0029 {
0030 
0031 class Session;
0032 struct Message;
0033 class CopyJobPrivate;
0034 
0035 /**
0036  * Copies one or more messages to another mailbox.
0037  *
0038  * This job can only be run when the session is in the selected state.
0039  *
0040  * If the server supports ACLs, the user will need the
0041  * Acl::Insert right on the target mailbox.
0042  * In order to preserve message flags, the user may also need
0043  * some combination of Acl::DeleteMessage,
0044  * Acl::KeepSeen and Acl::Write on the
0045  * target mailbox.
0046  */
0047 class KIMAP2_EXPORT CopyJob : public Job
0048 {
0049     Q_OBJECT
0050     Q_DECLARE_PRIVATE(CopyJob)
0051 
0052     friend class SessionPrivate;
0053 
0054 public:
0055     explicit CopyJob(Session *session);
0056     virtual ~CopyJob();
0057 
0058     /**
0059      * Sets the destination mailbox.
0060      *
0061      * If the mailbox does not exist, the server should not create
0062      * it automatically and the job should fail.  Note, however,
0063      * that a conforming server may create the mailbox automatically.
0064      *
0065      * @param mailBox  the (unquoted) name of the mailbox where the
0066      *                 messages should be copied to
0067      */
0068     void setMailBox(const QString &mailBox);
0069     /**
0070      * The destination mailbox
0071      */
0072     QString mailBox() const;
0073 
0074     /**
0075      * Sets the messages to be copied
0076      *
0077      * If sequence numbers are given, isUidBased() should be false.  If UIDs
0078      * are given, isUidBased() should be true.
0079      *
0080      * RFC 3501 is unclear as to what should happen if invalid sequence numbers
0081      * are passed.  If non-existent UIDs are passed, they will be ignored.
0082      *
0083      * @param set  the sequence numbers or UIDs of the messages to be copied
0084      */
0085     void setSequenceSet(const ImapSet &set);
0086     /**
0087      * The messages that will be copied.
0088      *
0089      * isUidBased() can be used to check whether the ImapSet contains
0090      * sequence numbers or UIDs.
0091      *
0092      * @return  the sequence numbers or UIDs of the messages to be copied
0093      */
0094     ImapSet sequenceSet() const;
0095 
0096     /**
0097      * Set how the sequence set should be interpreted.
0098      *
0099      * @param uidBased  if @c true the argument to setSequenceSet will be
0100      *                  interpreted as UIDs, if @c false it will be interpreted
0101      *                  as sequence numbers
0102      */
0103     void setUidBased(bool uidBased);
0104     /**
0105      * How to interpret the sequence set.
0106      *
0107      * @return  if @c true the result of sequenceSet() should be
0108      *          interpreted as UIDs, if @c false it should be interpreted
0109      *          as sequence numbers
0110      */
0111     bool isUidBased() const;
0112 
0113     /**
0114      * The UIDs of the new copies of the messages
0115      *
0116      * This will be an empty set if no messages have been copied yet
0117      * or if the server does not support the UIDPLUS extension.
0118      */
0119     ImapSet resultingUids() const;
0120 
0121 protected:
0122     void doStart() Q_DECL_OVERRIDE;
0123     void handleResponse(const Message &response) Q_DECL_OVERRIDE;
0124 };
0125 
0126 }
0127 
0128 #endif