KIMAP2

movejob.h
1/*
2 Copyright (c) 2016 Daniel Vrátil <dvratil@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 KIMAP2_MOVE_H_
21#define KIMAP2_MOVE_H_
22
23#include "kimap2_export.h"
24
25#include "job.h"
26#include "imapset.h"
27
28namespace KIMAP2 {
29
30class MoveJobPrivate;
31
32/**
33 * Moves messages from current mailbox to another
34 *
35 * Note that move functionality is not specified in the base IMAP
36 * protocol and is defined as an extension in RFC6851. That means
37 * that the MoveJob can only be used when the server lists "MOVE"
38 * in response to CAPABILITY command.
39 *
40 * Unlike the traditional emulation of moving messages, i.e. COPY + STORE + EXPUNGE,
41 * MOVE guarantees the transaction to be atomic on the server.
42 *
43 * @since 5.4
44 */
45class KIMAP2_EXPORT MoveJob : public Job
46{
47 Q_OBJECT
48 Q_DECLARE_PRIVATE(MoveJob)
49
50 friend class SessionPrivate;
51
52public:
53 explicit MoveJob(Session *session);
54 virtual ~MoveJob();
55
56 /**
57 * Set the destination mailbox
58 *
59 * If the mailbox does not exist, the server should not create
60 * it automatically and the job should fail. Note, however,
61 * that a conforming server may create the mailbox automatically.
62 *
63 * @param mailBox the (unquoted) name of the mailbox where the
64 * messages should be moved to
65 */
66 void setMailBox(const QString &mailbox);
67 /**
68 * The destination mailbox
69 */
70 QString mailBox() const;
71
72 /**
73 * Sets the messages to be moved,
74 *
75 * If sequence numbers are given, isUidBased() should be false. If UIDs
76 * are given, isUidBased() should be true.
77 *
78 * @param set the sequence numbers or UIDs of the messages to be moved
79 */
80 void setSequenceSet(const ImapSet &set);
81 /**
82 * The messages that will be moved.
83 *
84 * isUidBased() can be used to check whether the ImapSet contains
85 * sequence numbers or UIDs.
86 *
87 * @return the sequence numbers or UIDs of the messages to be moved
88 */
89 ImapSet sequenceSet() const;
90
91 /**
92 * Set how the sequence set should be interpreted.
93 *
94 * @param uidBased if @c true the argument to setSequenceSet will be
95 * interpreted as UIDs, if @c false it will be interpreted
96 * as sequence numbers
97 */
98 void setUidBased(bool uidBased);
99 /**
100 * How to interpret the sequence set.
101 *
102 * @return if @c true the result of sequenceSet() should be
103 * interpreted as UIDs, if @c false it should be interpreted
104 * as sequence numbers
105 */
106 bool isUidBased() const;
107
108 /**
109 * The UIDs of the moved messages in the destination mailbox.
110 *
111 * This will be an empty set if no messages have been moved yet
112 * or if the server does not support the UIDPLUS extension.
113 */
114 ImapSet resultingUids() const;
115
116protected:
117 void doStart() Q_DECL_OVERRIDE;
118 void handleResponse(const KIMAP2::Message &response) Q_DECL_OVERRIDE;
119};
120
121}
122#endif
Represents a set of natural numbers (1->∞) in a as compact as possible form.
Definition imapset.h:142
Moves messages from current mailbox to another.
Definition movejob.h:46
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:56:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.