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

Load as async

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