File indexing completed on 2024-11-24 04:49:54
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only 0005 */ 0006 0007 #include "vacationhelperjob.h" 0008 #include "kmanagesieve/sievejob.h" 0009 0010 using namespace KSieveCore; 0011 0012 VacationHelperJob::VacationHelperJob(const QUrl &url, QObject *parent) 0013 : QObject(parent) 0014 , mUrl(url) 0015 { 0016 } 0017 0018 VacationHelperJob::~VacationHelperJob() 0019 { 0020 killJob(); 0021 } 0022 0023 void VacationHelperJob::killJob() 0024 { 0025 if (mSieveJob) { 0026 mSieveJob->kill(); 0027 mSieveJob = nullptr; 0028 } 0029 } 0030 0031 void VacationHelperJob::searchActiveJob() 0032 { 0033 killJob(); 0034 0035 if (!mUrl.isValid()) { 0036 Q_EMIT resourceHasNotSieveSupport(); 0037 } else { 0038 mSieveJob = KManageSieve::SieveJob::list(mUrl); 0039 0040 connect(mSieveJob, &KManageSieve::SieveJob::gotList, this, &VacationHelperJob::slotGetScriptList); 0041 } 0042 } 0043 0044 void VacationHelperJob::slotGetScriptList(KManageSieve::SieveJob *job, bool success, const QStringList &scriptList, const QString &activeScript) 0045 { 0046 mSieveJob = nullptr; 0047 if (success) { 0048 const QStringList caps = job->sieveCapabilities(); 0049 Q_EMIT scriptListResult(scriptList, activeScript, caps.contains(QLatin1StringView("include"))); 0050 } else { 0051 Q_EMIT canNotGetScriptList(); 0052 } 0053 } 0054 0055 #include "moc_vacationhelperjob.cpp"