Libksieve

checkkolabkep14supportjob.cpp
1 /*
2  * SPDX-FileCopyrightText: 2015 Sandro KnauƟ <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 #include "checkkolabkep14supportjob.h"
8 #include "util/util_p.h"
9 #include <kmanagesieve/sievejob.h>
10 
11 #include "libksieve_debug.h"
12 
13 using namespace KSieveUi;
14 
15 class KSieveUi::CheckKolabKep14SupportJobPrivate
16 {
17 public:
18  CheckKolabKep14SupportJobPrivate()
19  {
20  }
21 
22  QStringList mAvailableScripts;
23  QString mServerName;
24  QUrl mUrl;
25  KManageSieve::SieveJob *mSieveJob = nullptr;
26  bool mKolabKep14Support = false;
27 };
28 
29 CheckKolabKep14SupportJob::CheckKolabKep14SupportJob(QObject *parent)
30  : QObject(parent)
31  , d(new CheckKolabKep14SupportJobPrivate)
32 {
33 }
34 
35 CheckKolabKep14SupportJob::~CheckKolabKep14SupportJob()
36 {
37 }
38 
39 void CheckKolabKep14SupportJob::start()
40 {
41  if (d->mUrl.isEmpty()) {
42  qCWarning(LIBKSIEVE_LOG) << " server url is empty";
43  deleteLater();
44  return;
45  }
46  d->mSieveJob = KManageSieve::SieveJob::list(d->mUrl);
47  connect(d->mSieveJob, &KManageSieve::SieveJob::gotList, this, &CheckKolabKep14SupportJob::slotCheckKep14Support);
48 }
49 
50 void CheckKolabKep14SupportJob::setServerUrl(const QUrl &url)
51 {
52  d->mUrl = url;
53 }
54 
55 QUrl CheckKolabKep14SupportJob::serverUrl() const
56 {
57  return d->mUrl;
58 }
59 
60 void CheckKolabKep14SupportJob::setServerName(const QString &name)
61 {
62  d->mServerName = name;
63 }
64 
65 QString CheckKolabKep14SupportJob::serverName() const
66 {
67  return d->mServerName;
68 }
69 
70 QStringList CheckKolabKep14SupportJob::availableScripts() const
71 {
72  return d->mAvailableScripts;
73 }
74 
75 bool CheckKolabKep14SupportJob::hasKep14Support() const
76 {
77  return d->mKolabKep14Support;
78 }
79 
80 void CheckKolabKep14SupportJob::slotCheckKep14Support(KManageSieve::SieveJob *job,
81  bool success,
82  const QStringList &availableScripts,
83  const QString &activeScript)
84 {
85  if (!success) {
86  Q_EMIT result(this, false);
87  return;
88  }
89 
90  d->mKolabKep14Support = Util::hasKep14Support(job->sieveCapabilities(), availableScripts, activeScript);
91  d->mAvailableScripts = availableScripts;
92  Q_EMIT result(this, true);
93 }
int result() const const
QStringList sieveCapabilities() const
Returns the sieve capabilities of the IMAP server.
Definition: sievejob.cpp:254
void deleteLater()
void gotList(KManageSieve::SieveJob *job, bool success, const QStringList &scriptList, const QString &activeScript)
This signal is emitted when a list job has finished.
static SieveJob * list(const QUrl &url)
Lists all available scripts at the given sieve url.
Definition: sievejob.cpp:314
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
A job to manage sieve scripts.
Definition: sievejob.h:37
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Apr 15 2021 23:09:37 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.