Libksieve

vacationhelperjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 
7 #include "vacationhelperjob.h"
8 #include "kmanagesieve/sievejob.h"
9 
10 using namespace KSieveUi;
11 
12 VacationHelperJob::VacationHelperJob(const QUrl &url, QObject *parent)
13  : QObject(parent)
14  , mUrl(url)
15 {
16 }
17 
18 VacationHelperJob::~VacationHelperJob()
19 {
20  killJob();
21 }
22 
23 void VacationHelperJob::killJob()
24 {
25  if (mSieveJob) {
26  mSieveJob->kill();
27  mSieveJob = nullptr;
28  }
29 }
30 
31 void VacationHelperJob::searchActiveJob()
32 {
33  killJob();
34 
35  if (!mUrl.isValid()) {
36  Q_EMIT resourceHasNotSieveSupport();
37  } else {
38  mSieveJob = KManageSieve::SieveJob::list(mUrl);
39 
40  connect(mSieveJob, &KManageSieve::SieveJob::gotList, this, &VacationHelperJob::slotGetScriptList);
41  }
42 }
43 
44 void VacationHelperJob::slotGetScriptList(KManageSieve::SieveJob *job, bool success, const QStringList &scriptList, const QString &activeScript)
45 {
46  mSieveJob = nullptr;
47  if (success) {
48  const QStringList caps = job->sieveCapabilities();
49  Q_EMIT scriptListResult(scriptList, activeScript, caps.contains(QLatin1String("include")));
50  } else {
51  Q_EMIT canNotGetScriptList();
52  }
53 }
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
QStringList sieveCapabilities() const
Returns the sieve capabilities of the IMAP server.
Definition: sievejob.cpp:254
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
A job to manage sieve scripts.
Definition: sievejob.h:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Apr 17 2021 23:09:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.