Libksieve

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

KDE's Doxygen guidelines are available online.