File indexing completed on 2024-10-27 04:58:02

0001 /*
0002     SPDX-FileCopyrightText: 2010-2023 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 // This code was taken from kmail-account-wizard
0008 
0009 #pragma once
0010 
0011 #include "setupobject.h"
0012 #include <KLDAP/LdapServer>
0013 
0014 class LdapTest;
0015 class KConfig;
0016 
0017 namespace KLDAP
0018 {
0019 class LdapClientSearchConfig;
0020 }
0021 
0022 class Ldap : public SetupObject
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit Ldap(QObject *parent = nullptr);
0027     ~Ldap() override;
0028     void create() override;
0029     void destroy() override;
0030     void edit();
0031 public Q_SLOTS:
0032     Q_SCRIPTABLE void setUser(const QString &name);
0033     Q_SCRIPTABLE void setServer(const QString &server);
0034     Q_SCRIPTABLE void setAuthenticationMethod(const QString &meth);
0035     Q_SCRIPTABLE void setBindDn(const QString &bindDn);
0036     Q_SCRIPTABLE void setBaseDn(const QString &baseDn);
0037     Q_SCRIPTABLE void setPassword(const QString &password);
0038     Q_SCRIPTABLE void setPort(const int port);
0039     Q_SCRIPTABLE void setSecurity(const KLDAP::LdapServer::Security security);
0040     Q_SCRIPTABLE void setSaslMech(const QString &saslmech);
0041     Q_SCRIPTABLE void setRealm(const QString &realm);
0042     Q_SCRIPTABLE void setVersion(const int version);
0043     Q_SCRIPTABLE void setPageSize(const int pageSize);
0044     Q_SCRIPTABLE void setTimeLimit(const int timeLimit);
0045     Q_SCRIPTABLE void setSizeLimit(const int sizeLimit);
0046     Q_SCRIPTABLE void setEditMode(const bool editMode);
0047 
0048 protected:
0049     virtual KConfig *config() const;
0050 
0051     KLDAP::LdapClientSearchConfig *const m_clientSearchConfig;
0052 
0053 private:
0054     friend class LdapTest;
0055     void slotRestoreDone();
0056     QString securityString();
0057 
0058     QString m_user;
0059     QString m_server;
0060     QString m_bindDn;
0061     QString m_authMethod;
0062     QString m_password;
0063     QString m_mech;
0064     QString m_realm;
0065     QString m_baseDn;
0066     int m_port = 389;
0067     KLDAP::LdapServer::Security m_security = KLDAP::LdapServer::None;
0068     int m_version = 3;
0069     int m_pageSize = 0;
0070     int m_timeLimit = 0;
0071     int m_sizeLimit = 0;
0072     int m_entry = -1;
0073     bool m_editMode = false;
0074 };
0075