Commit c2bc4fc1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Load as async here

parent c4f2ef23
Pipeline #42576 canceled with stage
......@@ -54,6 +54,7 @@ set(kldap_LIB_widgets_SRCS
widgets/ldapclientsearchconfigwriteconfigjob.cpp
widgets/ldapwidgetitem_p.cpp
widgets/ldapwidgetitemreadconfigserverjob.cpp
widgets/ldapsearchclientreadconfigserverjob.cpp
)
set(kldap_LIB_SRCS
......
......@@ -12,6 +12,7 @@
#include "ldapclientsearch.h"
#include "ldapclientsearchconfig.h"
#include "ldapclient_debug.h"
#include "ldapsearchclientreadconfigserverjob.h"
#include "ldapclient.h"
......@@ -160,15 +161,15 @@ void LdapClientSearch::Private::readConfig()
mNoLDAPLookup = true;
} else {
for (int j = 0; j < numHosts; ++j) {
//Move as async
auto *ldapClient = new LdapClient(j, q);
KLDAP::LdapServer server;
mClientSearchConfig->readConfig(server, config, j, true);
if (!server.host().isEmpty()) {
mNoLDAPLookup = false;
}
ldapClient->setServer(server);
auto job = new LdapSearchClientReadConfigServerJob;
job->setCurrentIndex(j);
job->setActive(true);
job->setConfig(config);
job->setLdapClient(ldapClient);
job->start();
mNoLDAPLookup = false;
readWeighForClient(ldapClient, config, j);
ldapClient->setAttributes(mAttributes);
......
/*
* SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "ldapsearchclientreadconfigserverjob.h"
#include "ldapclient.h"
#include "ldapclientsearchconfigreadconfigjob.h"
using namespace KLDAP;
LdapSearchClientReadConfigServerJob::LdapSearchClientReadConfigServerJob(QObject *parent)
: QObject(parent)
{
}
LdapSearchClientReadConfigServerJob::~LdapSearchClientReadConfigServerJob()
{
}
void LdapSearchClientReadConfigServerJob::start()
{
auto job = new LdapClientSearchConfigReadConfigJob(this);
connect(job, &LdapClientSearchConfigReadConfigJob::configLoaded, this, &LdapSearchClientReadConfigServerJob::slotConfigLoaded);
job->setActive(mActive);
job->setConfig(mConfig);
job->setServerIndex(mCurrentIndex);
job->start();
}
void LdapSearchClientReadConfigServerJob::slotConfigLoaded(const KLDAP::LdapServer &server)
{
mLdapClient->setServer(server);
deleteLater();
}
LdapClient *LdapSearchClientReadConfigServerJob::ldapClient() const
{
return mLdapClient;
}
void LdapSearchClientReadConfigServerJob::setLdapClient(LdapClient *ldapClient)
{
mLdapClient = ldapClient;
}
int LdapSearchClientReadConfigServerJob::currentIndex() const
{
return mCurrentIndex;
}
void LdapSearchClientReadConfigServerJob::setCurrentIndex(int currentIndex)
{
mCurrentIndex = currentIndex;
}
bool LdapSearchClientReadConfigServerJob::active() const
{
return mActive;
}
void LdapSearchClientReadConfigServerJob::setActive(bool active)
{
mActive = active;
}
KConfigGroup LdapSearchClientReadConfigServerJob::config() const
{
return mConfig;
}
void LdapSearchClientReadConfigServerJob::setConfig(const KConfigGroup &config)
{
mConfig = config;
}
/*
* SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef LDAPSEARCHCLIENTREADCONFIGSERVERJOB_H
#define LDAPSEARCHCLIENTREADCONFIGSERVERJOB_H
#include <QObject>
#include <KConfigGroup>
namespace KLDAP {
class LdapClient;
class LdapServer;
class LdapSearchClientReadConfigServerJob : public QObject
{
Q_OBJECT
public:
explicit LdapSearchClientReadConfigServerJob(QObject *parent = nullptr);
~LdapSearchClientReadConfigServerJob() override;
void start();
Q_REQUIRED_RESULT int currentIndex() const;
void setCurrentIndex(int currentIndex);
Q_REQUIRED_RESULT bool active() const;
void setActive(bool active);
Q_REQUIRED_RESULT KConfigGroup config() const;
void setConfig(const KConfigGroup &config);
LdapClient *ldapClient() const;
void setLdapClient(LdapClient *ldapClient);
private:
void slotConfigLoaded(const KLDAP::LdapServer &server);
LdapClient *mLdapClient = nullptr;
KConfigGroup mConfig;
int mCurrentIndex = -1;
bool mActive = false;
};
}
#endif // LDAPSEARCHCLIENTREADCONFIGSERVERJOB_H
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