Libksieve

sievejob.h
1/* -*- c++ -*-
2 sievejob.h
3
4 SPDX-FileCopyrightText: 2002 Marc Mutz <mutz@kde.org>
5
6 SPDX-License-Identifier: GPL-2.0-only
7*/
8
9#pragma once
10
11#include "kmanagesieve_export.h"
12
13#include <QObject>
14#include <QStringList>
15
16#include <KJob>
17
18#include <QUrl>
19
20namespace KManageSieve
21{
22class Session;
23
24/**
25 * @short A job to manage sieve scripts.
26 *
27 * This class provides functionality to manage sieve scripts
28 * on an IMAP server.
29 */
30class KMANAGESIEVE_EXPORT SieveJob : public QObject
31{
32 Q_OBJECT
33
34public:
35 /**
36 * Stores a sieve script on an IMAP server.
37 *
38 * @param destination The sieve URL that describes the destination.
39 * @param script The raw sieve script.
40 * @param makeActive If @c true, the script will be marked as active.
41 * @param wasActive If @c true, the script will be marked as inactive.
42 */
43 static SieveJob *put(const QUrl &destination, const QString &script, bool makeActive, bool wasActive);
44
45 /**
46 * Gets a sieve script from an IMAP server.
47 *
48 * @param source The sieve URL that describes the source.
49 */
50 static SieveJob *get(const QUrl &source);
51
52 /**
53 * Lists all available scripts at the given sieve @p url.
54 */
55 static SieveJob *list(const QUrl &url);
56
57 /**
58 * Deletes the script with the given sieve @p url.
59 */
60 static SieveJob *del(const QUrl &url);
61
62 /**
63 * Activates the script with the given sieve @p url.
64 */
65 static SieveJob *activate(const QUrl &url);
66
67 /**
68 * Deactivates the script with the given sieve @p url.
69 */
70 static SieveJob *deactivate(const QUrl &url);
71
72 /**
73 * Rename the script with the given sieve @p url and new name @p newName.
74 * Not supported by all sieve server
75 */
76 static SieveJob *rename(const QUrl &url, const QString &newName);
77
78 /**
79 * Check the script with the given sieve @p url.
80 * Not supported by all sieve server
81 */
82 static SieveJob *check(const QUrl &url, const QString &script);
83
84 /**
85 * Kills the sieve job.
86 */
87 void kill(KJob::KillVerbosity verbosity = KJob::Quietly);
88
89 /**
90 * Returns the sieve capabilities of the IMAP server.
91 */
92 [[nodiscard]] QStringList sieveCapabilities() const;
93
94 /**
95 * Returns whether the requested sieve script exists on
96 * the IMAP server.
97 */
98 [[nodiscard]] bool fileExists() const;
99
100 /**
101 * A human-readable error message.
102 */
103 [[nodiscard]] QString errorString() const;
104
105Q_SIGNALS:
106 /**
107 * This signal is emitted when a get job has finished.
108 *
109 * @param job The job that has finished
110 * @param success Whether the job was successfully.
111 * @param script The downloaded sieve script.
112 * @param active Whether the script is active on the server.
113 */
114 void gotScript(KManageSieve::SieveJob *job, bool success, const QString &script, bool active);
115
116 /**
117 * This signal is emitted when a list job has finished.
118 *
119 * @param job The job that has finished.
120 * @param success Whether the job was successfully.
121 * @param scriptList The list of script filenames on the server.
122 * @param activeScript The filename of the active script, or an
123 * empty string if no script is active.
124 */
125 void gotList(KManageSieve::SieveJob *job, bool success, const QStringList &scriptList, const QString &activeScript);
126
127 /**
128 * This signal is emitted for all kind of jobs when they have finished.
129 *
130 * @param job The job that has finished.
131 * @param success Whether the job was successfully.
132 * @param script The script the action was about.
133 * @param active The filename of the active script, or an
134 * @param active Whether the script is active on the server.
135 */
136 void result(KManageSieve::SieveJob *job, bool success, const QString &script, bool active);
137
138 /**
139 * This signal is emitted for each result entry of a list job.
140 *
141 * @param job The job the result belongs to.
142 * @param filename The filename of the sieve script on the server.
143 * @param active Whether the script is active on the server.
144 */
145 void item(KManageSieve::SieveJob *job, const QString &filename, bool active);
146
147private:
148 Q_DISABLE_COPY(SieveJob)
149 KMANAGESIEVE_NO_EXPORT void setErrorMessage(const QString &str);
150
151 //@cond PRIVATE
152 explicit SieveJob(QObject *parent = nullptr);
153 ~SieveJob() override;
154
155 class Private;
156 Private *const d;
157 friend class Session;
158 //@endcond
159};
160}
A network session with a manage sieve server.
Definition session.h:35
A job to manage sieve scripts.
Definition sievejob.h:31
void result(KManageSieve::SieveJob *job, bool success, const QString &script, bool active)
This signal is emitted for all kind of jobs when they have finished.
void item(KManageSieve::SieveJob *job, const QString &filename, bool active)
This signal is emitted for each result entry of a list job.
void gotList(KManageSieve::SieveJob *job, bool success, const QStringList &scriptList, const QString &activeScript)
This signal is emitted when a list job has finished.
void gotScript(KManageSieve::SieveJob *job, bool success, const QString &script, bool active)
This signal is emitted when a get job has finished.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.