Commit 5f324464 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement async job

parent 132fd0b2
Pipeline #41463 failed with stage
in 12 minutes and 35 seconds
......@@ -5,6 +5,8 @@
*/
#include "searchserverwithvacationsupportjob.h"
#include "util/findaccountinfojob.h"
using namespace KSieveUi;
SearchServerWithVacationSupportJob::SearchServerWithVacationSupportJob(QObject *parent)
......@@ -18,7 +20,49 @@ SearchServerWithVacationSupportJob::~SearchServerWithVacationSupportJob()
}
void SearchServerWithVacationSupportJob::sendAccountList()
{
Q_EMIT searchServerWithVacationSupportFinished(mAccountList);
deleteLater();
}
void SearchServerWithVacationSupportJob::start()
{
//TODO
if (!canStart()) {
sendAccountList();
return;
}
const QVector<KSieveUi::SieveImapInstance> instances = KSieveUi::Util::sieveImapInstances();
for (const KSieveUi::SieveImapInstance &instance : instances) {
if (instance.status() == KSieveUi::SieveImapInstance::Broken) {
continue;
}
mListInstances << instance.identifier();
}
//TODO search info.
}
bool SearchServerWithVacationSupportJob::canStart() const
{
return mPasswordProvider && !mIdentifier.isEmpty();
}
QString SearchServerWithVacationSupportJob::identifier() const
{
return mIdentifier;
}
void SearchServerWithVacationSupportJob::setIdentifier(const QString &newIdentifier)
{
mIdentifier = newIdentifier;
}
SieveImapPasswordProvider *SearchServerWithVacationSupportJob::passwordProvider() const
{
return mPasswordProvider;
}
void SearchServerWithVacationSupportJob::setPasswordProvider(SieveImapPasswordProvider *newProvider)
{
mPasswordProvider = newProvider;
}
......@@ -7,9 +7,12 @@
#ifndef SEARCHSERVERWITHVACATIONSUPPORTJOB_H
#define SEARCHSERVERWITHVACATIONSUPPORTJOB_H
#include <QMap>
#include <QObject>
#include "util_p.h"
#include "ksieveui_export.h"
namespace KSieveUi {
class SieveImapPasswordProvider;
class KSIEVEUI_EXPORT SearchServerWithVacationSupportJob : public QObject
{
Q_OBJECT
......@@ -17,6 +20,24 @@ public:
explicit SearchServerWithVacationSupportJob(QObject *parent = nullptr);
~SearchServerWithVacationSupportJob() override;
void start();
Q_REQUIRED_RESULT bool canStart() const;
Q_REQUIRED_RESULT QString identifier() const;
void setIdentifier(const QString &newIdentifier);
SieveImapPasswordProvider *passwordProvider() const;
void setPasswordProvider(SieveImapPasswordProvider *newProvider);
Q_SIGNALS:
void searchServerWithVacationSupportFinished(const QMap<QString, KSieveUi::Util::AccountInfo> &info);
private:
void sendAccountList();
QString mIdentifier;
QStringList mListInstances;
QMap<QString, KSieveUi::Util::AccountInfo> mAccountList;
SieveImapPasswordProvider *mPasswordProvider = nullptr;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment