Commit 82d17387 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Load as async

parent b35d68f5
......@@ -6,6 +6,7 @@
#include "restoreldapsettingsjob.h"
#include <KLDAP/LdapClientSearchConfigWriteConfigJob>
#include <KLDAP/LdapClientSearchConfigReadConfigJob>
#include <KLDAP/LdapClientSearchConfig>
#include <KConfigGroup>
#include <KConfig>
......@@ -33,15 +34,23 @@ void RestoreLdapSettingsJob::start()
restore();
}
void RestoreLdapSettingsJob::slotConfigSelectedHostLoaded(const KLDAP::LdapServer &server)
{
mSelHosts.append(server);
mCurrentIndex++;
loadNextSelectHostSettings();
}
void RestoreLdapSettingsJob::loadNextSelectHostSettings()
{
if (mCurrentIndex < mNumSelHosts) {
if (mCurrentIndex != mEntry) {
KLDAP::LdapServer server;
mClientSearchConfig->readConfig(server, mCurrentGroup, mCurrentIndex, true);
mSelHosts.append(server);
mCurrentIndex++;
loadNextSelectHostSettings(); //Move async
auto job = new KLDAP::LdapClientSearchConfigReadConfigJob(this);
connect(job, &KLDAP::LdapClientSearchConfigReadConfigJob::configLoaded, this, &RestoreLdapSettingsJob::slotConfigSelectedHostLoaded);
job->setActive(true);
job->setConfig(mCurrentGroup);
job->setServerIndex(mCurrentIndex);
job->start();
} else {
mCurrentIndex++;
loadNextSelectHostSettings();
......@@ -53,14 +62,22 @@ void RestoreLdapSettingsJob::loadNextSelectHostSettings()
}
}
void RestoreLdapSettingsJob::slotConfigHostLoaded(const KLDAP::LdapServer &server)
{
mHosts.append(server);
mCurrentIndex++;
loadNextHostSettings();
}
void RestoreLdapSettingsJob::loadNextHostSettings()
{
if (mCurrentIndex < mNumHosts) {
KLDAP::LdapServer server;
mClientSearchConfig->readConfig(server, mCurrentGroup, mCurrentIndex, false);
mHosts.append(server);
mCurrentIndex++;
loadNextHostSettings(); //Move async
auto job = new KLDAP::LdapClientSearchConfigReadConfigJob(this);
connect(job, &KLDAP::LdapClientSearchConfigReadConfigJob::configLoaded, this, &RestoreLdapSettingsJob::slotConfigHostLoaded);
job->setActive(false);
job->setConfig(mCurrentGroup);
job->setServerIndex(mCurrentIndex);
job->start();
} else {
saveLdapSettings();
}
......
......@@ -34,6 +34,8 @@ public:
Q_SIGNALS:
void restoreDone();
private:
void slotConfigSelectedHostLoaded(const KLDAP::LdapServer &server);
void slotConfigHostLoaded(const KLDAP::LdapServer &server);
void restore();
void saveLdapSettings();
void restoreSettingsDone();
......
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