KIMAP

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

KDE's Doxygen guidelines are available online.