Commit 274ab848 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Prepare to restore settings as async

parent 64d753ba
Pipeline #42638 canceled with stage
......@@ -15,6 +15,7 @@ set(accountwizard_srcs
transport.cpp
configfile.cpp
ldap.cpp
restoreldapsettingsjob.cpp
identity.cpp
setupispdb.cpp
setupautoconfigkolabmail.cpp
......
......@@ -72,7 +72,7 @@ void Ldap::create()
KConfig *c = config();
KConfigGroup group = c->group(QStringLiteral("LDAP"));
bool hasMyServer = false;
int selHosts = group.readEntry("NumSelectedHosts", 0);
const int selHosts = group.readEntry("NumSelectedHosts", 0);
for (int i = 0; i < selHosts && !hasMyServer; ++i) {
if (group.readEntry(QStringLiteral("SelectedHost%1").arg(i), QString()) == host) {
hasMyServer = true;
......@@ -136,8 +136,8 @@ void Ldap::destroy()
if (m_entry >= 0) {
KConfig *c = config();
KConfigGroup group = c->group(QStringLiteral("LDAP"));
int cSelHosts = group.readEntry(QStringLiteral("NumSelectedHosts"), 0);
int cHosts = group.readEntry(QStringLiteral("NumHosts"), 0);
const int cSelHosts = group.readEntry(QStringLiteral("NumSelectedHosts"), 0);
const int cHosts = group.readEntry(QStringLiteral("NumHosts"), 0);
QVector<KLDAP::LdapServer> selHosts;
QVector<KLDAP::LdapServer> hosts;
for (int i = 0; i < cSelHosts; ++i) {
......
/*
SPDX-FileCopyrightText: 2010-2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "restoreldapsettingsjob.h"
#include <KLDAP/LdapClientSearchConfigWriteConfigJob>
#include <KConfigGroup>
#include <KConfig>
#include <QDebug>
RestoreLdapSettingsJob::RestoreLdapSettingsJob(QObject *parent)
: QObject(parent)
{
}
RestoreLdapSettingsJob::~RestoreLdapSettingsJob()
{
}
void RestoreLdapSettingsJob::start()
{
if (!canStart()) {
deleteLater();
qWarning() << "Impossible to start RestoreLdapSettingsJob";
Q_EMIT restoreDone();
return;
}
//TODO
deleteLater();
}
KConfig *RestoreLdapSettingsJob::config() const
{
return mConfig;
}
void RestoreLdapSettingsJob::setConfig(KConfig *config)
{
mConfig = config;
}
bool RestoreLdapSettingsJob::canStart() const
{
return (mConfig != nullptr);
}
/*
SPDX-FileCopyrightText: 2010-2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef RESTORELDAPSETTINGSJOB_H
#define RESTORELDAPSETTINGSJOB_H
#include <QObject>
#include <KLDAP/LdapServer>
class KConfig;
class RestoreLdapSettingsJob : public QObject
{
Q_OBJECT
public:
explicit RestoreLdapSettingsJob(QObject *parent = nullptr);
~RestoreLdapSettingsJob() override;
void start();
KConfig *config() const;
void setConfig(KConfig *config);
Q_REQUIRED_RESULT bool canStart() const;
Q_SIGNALS:
void restoreDone();
private:
QVector<KLDAP::LdapServer> mSelHosts;
QVector<KLDAP::LdapServer> mHosts;
KConfig *mConfig = nullptr;
};
#endif // RESTORELDAPSETTINGSJOB_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