Commit 651c1c18 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Implement async job

parent 5f324464
Pipeline #41464 failed with stage
in 12 minutes and 35 seconds
...@@ -37,9 +37,49 @@ void SearchServerWithVacationSupportJob::start() ...@@ -37,9 +37,49 @@ void SearchServerWithVacationSupportJob::start()
if (instance.status() == KSieveUi::SieveImapInstance::Broken) { if (instance.status() == KSieveUi::SieveImapInstance::Broken) {
continue; continue;
} }
mListInstances << instance.identifier(); mServerSieveInfos.insert(instance.name(), instance.identifier());
}
searchNextInfo();
}
void SearchServerWithVacationSupportJob::searchNextInfo()
{
mSieveServerMapIterator = mServerSieveInfos.constBegin();
if (mSieveServerMapIterator != mServerSieveInfos.constEnd()) {
slotSearchSieveScript(mSieveServerMapIterator.key(), mSieveServerMapIterator.value());
} else {
sendAccountList();
}
}
void SearchServerWithVacationSupportJob::slotSearchSieveScript(const QString &name, const QString &identifier)
{
FindAccountInfoJob *job = new FindAccountInfoJob(this);
connect(job, &FindAccountInfoJob::findAccountInfoFinished, this, &SearchServerWithVacationSupportJob::slotFindAccountInfoFinished);
job->setIdentifier(identifier);
job->setProperty("serverName", name);
job->setProvider(mPasswordProvider);
job->start();
}
void SearchServerWithVacationSupportJob::slotFindAccountInfoFinished(const KSieveUi::Util::AccountInfo &info)
{
const QUrl url = info.sieveUrl;
if (!url.isEmpty()) {
const QString serverName = sender()->property("serverName").toString();
mAccountList.insert(serverName, info);
}
searchNextServerSieve();
}
void SearchServerWithVacationSupportJob::searchNextServerSieve()
{
++mSieveServerMapIterator;
if(mSieveServerMapIterator != mServerSieveInfos.constEnd()) {
slotSearchSieveScript(mSieveServerMapIterator.key(), mSieveServerMapIterator.value());
} else {
sendAccountList();
} }
//TODO search info.
} }
bool SearchServerWithVacationSupportJob::canStart() const bool SearchServerWithVacationSupportJob::canStart() const
......
...@@ -33,9 +33,18 @@ Q_SIGNALS: ...@@ -33,9 +33,18 @@ Q_SIGNALS:
void searchServerWithVacationSupportFinished(const QMap<QString, KSieveUi::Util::AccountInfo> &info); void searchServerWithVacationSupportFinished(const QMap<QString, KSieveUi::Util::AccountInfo> &info);
private: private:
void slotFindAccountInfoFinished(const KSieveUi::Util::AccountInfo &info);
void sendAccountList(); void sendAccountList();
void searchNextInfo();
void slotSearchSieveScript(const QString &name, const QString &identifier);
void searchNextServerSieve();
QString mIdentifier; QString mIdentifier;
QStringList mListInstances;
QMap<QString, QString>::const_iterator mSieveServerMapIterator;
//name, identifier
QMap<QString, QString> mServerSieveInfos;
//Result
QMap<QString, KSieveUi::Util::AccountInfo> mAccountList; QMap<QString, KSieveUi::Util::AccountInfo> mAccountList;
SieveImapPasswordProvider *mPasswordProvider = nullptr; 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