Libksieve

checkkolabkep14supportjob.cpp
1/*
2 * SPDX-FileCopyrightText: 2015 Sandro Knauß <knauss@kolabsys.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#include "checkkolabkep14supportjob.h"
8#include "kmanagesieve/sievejob.h"
9#include "util/util.h"
10
11#include "libksievecore_debug.h"
12
13using namespace KSieveCore;
14
15class KSieveCore::CheckKolabKep14SupportJobPrivate
16{
17public:
18 CheckKolabKep14SupportJobPrivate() = default;
19
20 QStringList mAvailableScripts;
21 QString mServerName;
22 QUrl mUrl;
23 KManageSieve::SieveJob *mSieveJob = nullptr;
24 bool mKolabKep14Support = false;
25};
26
27CheckKolabKep14SupportJob::CheckKolabKep14SupportJob(QObject *parent)
28 : QObject(parent)
29 , d(new CheckKolabKep14SupportJobPrivate)
30{
31}
32
33CheckKolabKep14SupportJob::~CheckKolabKep14SupportJob() = default;
34
35void CheckKolabKep14SupportJob::start()
36{
37 if (d->mUrl.isEmpty()) {
38 qCWarning(LIBKSIEVECORE_LOG) << " server url is empty";
40 return;
41 }
42 d->mSieveJob = KManageSieve::SieveJob::list(d->mUrl);
43 connect(d->mSieveJob, &KManageSieve::SieveJob::gotList, this, &CheckKolabKep14SupportJob::slotCheckKep14Support);
44}
45
46void CheckKolabKep14SupportJob::setServerUrl(const QUrl &url)
47{
48 d->mUrl = url;
49}
50
51QUrl CheckKolabKep14SupportJob::serverUrl() const
52{
53 return d->mUrl;
54}
55
56void CheckKolabKep14SupportJob::setServerName(const QString &name)
57{
58 d->mServerName = name;
59}
60
61QString CheckKolabKep14SupportJob::serverName() const
62{
63 return d->mServerName;
64}
65
66QStringList CheckKolabKep14SupportJob::availableScripts() const
67{
68 return d->mAvailableScripts;
69}
70
71bool CheckKolabKep14SupportJob::hasKep14Support() const
72{
73 return d->mKolabKep14Support;
74}
75
76void CheckKolabKep14SupportJob::slotCheckKep14Support(KManageSieve::SieveJob *job,
77 bool success,
78 const QStringList &availableScripts,
79 const QString &activeScript)
80{
81 if (!success) {
82 Q_EMIT result(this, false);
83 return;
84 }
85
86 d->mKolabKep14Support = Util::hasKep14Support(job->sieveCapabilities(), availableScripts, activeScript);
87 d->mAvailableScripts = availableScripts;
88 Q_EMIT result(this, true);
89}
90
91#include "moc_checkkolabkep14supportjob.cpp"
A job to manage sieve scripts.
Definition sievejob.h:31
QStringList sieveCapabilities() const
Returns the sieve capabilities of the IMAP server.
Definition sievejob.cpp:254
static SieveJob * list(const QUrl &url)
Lists all available scripts at the given sieve url.
Definition sievejob.cpp:314
void gotList(KManageSieve::SieveJob *job, bool success, const QStringList &scriptList, const QString &activeScript)
This signal is emitted when a list job has finished.
KSIEVECORE_EXPORT bool hasKep14Support(const QStringList &sieveCapabilities, const QStringList &availableScripts, const QString &activeScript)
Checks if a server has KEP:14 support.
Definition util.cpp:63
QString name(StandardAction id)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
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.