Libksieve

vacationhelperjob.cpp
1 /*
2  Copyright (C) 2013-2020 Laurent Montel <[email protected]>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "vacationhelperjob.h"
19 #include "kmanagesieve/sievejob.h"
20 
21 using namespace KSieveUi;
22 
23 VacationHelperJob::VacationHelperJob(const QUrl &url, QObject *parent)
24  : QObject(parent)
25  , mUrl(url)
26 {
27 }
28 
29 VacationHelperJob::~VacationHelperJob()
30 {
31  killJob();
32 }
33 
34 void VacationHelperJob::killJob()
35 {
36  if (mSieveJob) {
37  mSieveJob->kill();
38  mSieveJob = nullptr;
39  }
40 }
41 
42 void VacationHelperJob::searchActiveJob()
43 {
44  killJob();
45 
46  if (!mUrl.isValid()) {
47  Q_EMIT resourceHasNotSieveSupport();
48  } else {
49  mSieveJob = KManageSieve::SieveJob::list(mUrl);
50 
51  connect(mSieveJob, &KManageSieve::SieveJob::gotList, this, &VacationHelperJob::slotGetScriptList);
52  }
53 }
54 
55 void VacationHelperJob::slotGetScriptList(KManageSieve::SieveJob *job, bool success, const QStringList &scriptList, const QString &activeScript)
56 {
57  mSieveJob = nullptr;
58  if (success) {
59  const QStringList caps = job->sieveCapabilities();
60  Q_EMIT scriptListResult(scriptList, activeScript, caps.contains(QLatin1String("include")));
61  } else {
62  Q_EMIT canNotGetScriptList();
63  }
64 }
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
QStringList sieveCapabilities() const
Returns the sieve capabilities of the IMAP server.
Definition: sievejob.cpp:264
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
A job to manage sieve scripts.
Definition: sievejob.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 23:06:35 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.