Libksieve

checkkolabkep14supportjob.cpp
1 /*
2  * Copyright (c) 2015 Sandro KnauƟ <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include "checkkolabkep14supportjob.h"
21 #include "util/util_p.h"
22 #include <kmanagesieve/sievejob.h>
23 
24 #include "libksieve_debug.h"
25 
26 using namespace KSieveUi;
27 
28 class KSieveUi::CheckKolabKep14SupportJobPrivate
29 {
30 public:
31  CheckKolabKep14SupportJobPrivate()
32  {
33  }
34 
35  QStringList mAvailableScripts;
36  QString mServerName;
37  QUrl mUrl;
38  KManageSieve::SieveJob *mSieveJob = nullptr;
39  bool mKolabKep14Support = false;
40 };
41 
42 CheckKolabKep14SupportJob::CheckKolabKep14SupportJob(QObject *parent)
43  : QObject(parent)
44  , d(new CheckKolabKep14SupportJobPrivate)
45 {
46 }
47 
48 CheckKolabKep14SupportJob::~CheckKolabKep14SupportJob()
49 {
50  delete d;
51 }
52 
53 void CheckKolabKep14SupportJob::start()
54 {
55  if (d->mUrl.isEmpty()) {
56  qCWarning(LIBKSIEVE_LOG) << " server url is empty";
57  deleteLater();
58  return;
59  }
60  d->mSieveJob = KManageSieve::SieveJob::list(d->mUrl);
61  connect(d->mSieveJob, &KManageSieve::SieveJob::gotList, this, &CheckKolabKep14SupportJob::slotCheckKep14Support);
62 }
63 
64 void CheckKolabKep14SupportJob::setServerUrl(const QUrl &url)
65 {
66  d->mUrl = url;
67 }
68 
69 QUrl CheckKolabKep14SupportJob::serverUrl() const
70 {
71  return d->mUrl;
72 }
73 
74 void CheckKolabKep14SupportJob::setServerName(const QString &name)
75 {
76  d->mServerName = name;
77 }
78 
79 QString CheckKolabKep14SupportJob::serverName() const
80 {
81  return d->mServerName;
82 }
83 
84 QStringList CheckKolabKep14SupportJob::availableScripts() const
85 {
86  return d->mAvailableScripts;
87 }
88 
89 bool CheckKolabKep14SupportJob::hasKep14Support() const
90 {
91  return d->mKolabKep14Support;
92 }
93 
94 void CheckKolabKep14SupportJob::slotCheckKep14Support(KManageSieve::SieveJob *job, bool success, const QStringList &availableScripts, const QString &activeScript)
95 {
96  if (!success) {
97  Q_EMIT result(this, false);
98  return;
99  }
100 
101  d->mKolabKep14Support = Util::hasKep14Support(job->sieveCapabilities(), availableScripts, activeScript);
102  d->mAvailableScripts = availableScripts;
103  Q_EMIT result(this, true);
104 }
int result() const const
QStringList sieveCapabilities() const
Returns the sieve capabilities of the IMAP server.
Definition: sievejob.cpp:264
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:324
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:41
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 1 2020 23:08:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.