7#include "ldapclientsearchconfigwriteconfigjob.h"
8#include "ldap_core_debug.h"
10#include "kldapcore/ldapdn.h"
11#include <qt6keychain/keychain.h>
12using namespace QKeychain;
14using namespace KLDAPCore;
15LdapClientSearchConfigWriteConfigJob::LdapClientSearchConfigWriteConfigJob(
QObject *parent)
20LdapClientSearchConfigWriteConfigJob::~LdapClientSearchConfigWriteConfigJob() =
default;
22bool LdapClientSearchConfigWriteConfigJob::canStart()
const
24 return mServerIndex != -1 && mConfig.
isValid();
27void LdapClientSearchConfigWriteConfigJob::writeLdapClientConfigFinished()
33void LdapClientSearchConfigWriteConfigJob::start()
37 writeLdapClientConfigFinished();
43bool LdapClientSearchConfigWriteConfigJob::active()
const
48void LdapClientSearchConfigWriteConfigJob::setActive(
bool newActive)
53int LdapClientSearchConfigWriteConfigJob::serverIndex()
const
58void LdapClientSearchConfigWriteConfigJob::setServerIndex(
int newServerIndex)
60 mServerIndex = newServerIndex;
63KConfigGroup LdapClientSearchConfigWriteConfigJob::config()
const
68void LdapClientSearchConfigWriteConfigJob::setConfig(
const KConfigGroup &newConfig)
73void LdapClientSearchConfigWriteConfigJob::writeConfig()
77 prefix = QStringLiteral(
"Selected");
80 mConfig.
writeEntry(prefix + QStringLiteral(
"Host%1").arg(mServerIndex), mServer.
host());
81 mConfig.
writeEntry(prefix + QStringLiteral(
"Port%1").arg(mServerIndex), mServer.
port());
82 mConfig.
writeEntry(prefix + QStringLiteral(
"Base%1").arg(mServerIndex), mServer.
baseDn().toString());
83 mConfig.
writeEntry(prefix + QStringLiteral(
"User%1").arg(mServerIndex), mServer.
user());
84 mConfig.
writeEntry(prefix + QStringLiteral(
"Bind%1").arg(mServerIndex), mServer.
bindDn());
86 const QString passwordEntry = prefix + QStringLiteral(
"PwdBind%1").
arg(mServerIndex);
89 auto writeJob =
new WritePasswordJob(QStringLiteral(
"ldapclient"),
this);
90 connect(writeJob, &Job::finished,
this, [](QKeychain::Job *baseJob) {
91 if (baseJob->error()) {
92 qCWarning(LDAP_CORE_LOG) <<
"Error writing password using QKeychain:" << baseJob->errorString();
95 writeJob->setKey(passwordEntry);
96 writeJob->setTextData(password);
100 mConfig.
writeEntry(prefix + QStringLiteral(
"TimeLimit%1").arg(mServerIndex), mServer.
timeLimit());
101 mConfig.
writeEntry(prefix + QStringLiteral(
"SizeLimit%1").arg(mServerIndex), mServer.
sizeLimit());
102 mConfig.
writeEntry(prefix + QStringLiteral(
"PageSize%1").arg(mServerIndex), mServer.
pageSize());
103 mConfig.
writeEntry(prefix + QStringLiteral(
"Version%1").arg(mServerIndex), mServer.
version());
104 mConfig.
readEntry(prefix + QStringLiteral(
"Activities%1").arg(mServerIndex), mServer.activities());
105 mConfig.
readEntry(prefix + QStringLiteral(
"EnabledActivities%1").arg(mServerIndex), mServer.enablePlasmaActivities());
109 case KLDAPCore::LdapServer::TLS:
110 tmp = QStringLiteral(
"TLS");
112 case KLDAPCore::LdapServer::SSL:
113 tmp = QStringLiteral(
"SSL");
116 tmp = QStringLiteral(
"None");
118 mConfig.
writeEntry(prefix + QStringLiteral(
"Security%1").arg(mServerIndex), tmp);
119 switch (mServer.
auth()) {
120 case KLDAPCore::LdapServer::Simple:
121 tmp = QStringLiteral(
"Simple");
123 case KLDAPCore::LdapServer::SASL:
124 tmp = QStringLiteral(
"SASL");
127 tmp = QStringLiteral(
"Anonymous");
129 mConfig.
writeEntry(prefix + QStringLiteral(
"Auth%1").arg(mServerIndex), tmp);
130 mConfig.
writeEntry(prefix + QStringLiteral(
"Mech%1").arg(mServerIndex), mServer.
mech());
132 if (mServer.completionWeight() > -1) {
133 mConfig.
writeEntry(prefix + QStringLiteral(
"CompletionWeight%1").arg(mServerIndex), mServer.completionWeight());
147#include "moc_ldapclientsearchconfigwriteconfigjob.cpp"
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
A class that contains LDAP server connection settings.
Security security() const
Returns the security mode of the LDAP connection.
QString filter() const
Returns the filter string of the LDAP connection.
LdapDN baseDn() const
Returns the baseDn of the LDAP connection.
int timeLimit() const
Returns the time limit of the LDAP connection.
QString password() const
Returns the password of the LDAP connection.
QString bindDn() const
Returns the bindDn of the LDAP connection.
int version() const
Returns the protocol version of the LDAP connection.
int port() const
Returns the port of the LDAP connection.
int sizeLimit() const
Returns the size limit of the LDAP connection.
QString host() const
Returns the host of the LDAP connection.
int pageSize() const
Returns the page size of the LDAP connection.
QString user() const
Returns the user of the LDAP connection.
Auth auth() const
Returns the authentication method of the LDAP connection.
QString mech() const
Returns the mech of the LDAP connection.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
bool isEmpty() const const
QString trimmed() const const