Commit 2fa181c0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add canStart() method

parent af22110a
Pipeline #42855 passed with stage
in 8 minutes and 24 seconds
......@@ -7,6 +7,7 @@
#include "ldapsearchclientreadconfigserverjob.h"
#include "ldapclient.h"
#include "ldapclientsearchconfigreadconfigjob.h"
#include "ldapclient_debug.h"
using namespace KLDAP;
LdapSearchClientReadConfigServerJob::LdapSearchClientReadConfigServerJob(QObject *parent)
: QObject(parent)
......@@ -21,6 +22,11 @@ LdapSearchClientReadConfigServerJob::~LdapSearchClientReadConfigServerJob()
void LdapSearchClientReadConfigServerJob::start()
{
if (!canStart()) {
qCWarning(LDAPCLIENT_LOG) << " Impossible to start LdapSearchClientReadConfigServerJob";
deleteLater();
return;
}
auto job = new LdapClientSearchConfigReadConfigJob(this);
connect(job, &LdapClientSearchConfigReadConfigJob::configLoaded, this, &LdapSearchClientReadConfigServerJob::slotConfigLoaded);
job->setActive(mActive);
......@@ -29,6 +35,11 @@ void LdapSearchClientReadConfigServerJob::start()
job->start();
}
bool LdapSearchClientReadConfigServerJob::canStart() const
{
return mCurrentIndex != -1 && mConfig.isValid();
}
void LdapSearchClientReadConfigServerJob::slotConfigLoaded(const KLDAP::LdapServer &server)
{
mLdapClient->setServer(server);
......
......@@ -20,6 +20,7 @@ public:
~LdapSearchClientReadConfigServerJob() override;
void start();
Q_REQUIRED_RESULT bool canStart() const;
Q_REQUIRED_RESULT int currentIndex() const;
void setCurrentIndex(int currentIndex);
......
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