Libksieve

vacationhelperjob.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only
5*/
6
7#include "vacationhelperjob.h"
8#include "kmanagesieve/sievejob.h"
9
10using namespace KSieveCore;
11
12VacationHelperJob::VacationHelperJob(const QUrl &url, QObject *parent)
13 : QObject(parent)
14 , mUrl(url)
15{
16}
17
18VacationHelperJob::~VacationHelperJob()
19{
20 killJob();
21}
22
23void VacationHelperJob::killJob()
24{
25 if (mSieveJob) {
26 mSieveJob->kill();
27 mSieveJob = nullptr;
28 }
29}
30
31void 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
44void 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(QLatin1StringView("include")));
50 } else {
51 Q_EMIT canNotGetScriptList();
52 }
53}
54
55#include "moc_vacationhelperjob.cpp"
A job to manage sieve scripts.
Definition sievejob.h:31
void kill(KJob::KillVerbosity verbosity=KJob::Quietly)
Kills the sieve job.
Definition sievejob.cpp:246
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.
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:09:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.