KLdap

ldapclientsearch.h
1/* kldapclient.h - LDAP access
2 * SPDX-FileCopyrightText: 2002 Klarälvdalens Datakonsult AB
3 * SPDX-FileContributor: Steffen Hansen <hansen@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#pragma once
9
10#include "kldap_core_export.h"
11
12#include <KLDAPCore/LdapObject>
13#include <QObject>
14#include <QStringList>
15
16namespace KLDAPCore
17{
18class LdapClient;
19/**
20 * Describes the result returned by an LdapClientSearch query.
21 *
22 * @since 4.14
23 */
26 const KLDAPCore::LdapClient *client = nullptr;
28};
29
30/**
31 * Describes the result returned by an LdapClientSearch query.
32 *
33 * @since 4.5
34 */
35struct LdapResult {
36 /**
37 * A list of LdapResult objects.
38 */
40
41 KLDAPCore::LdapDN dn;
42 QString name; ///< The full name of the contact.
43 QStringList email; ///< The list of emails of the contact.
44 int clientNumber; ///< The client the contact comes from (used for sorting in a ldap-only lookup).
45 int completionWeight; ///< The weight of the contact (used for sorting in a completion list).
46};
47
48/**
49 * @since 4.5
50 */
51class KLDAP_CORE_EXPORT LdapClientSearch : public QObject
52{
53 Q_OBJECT
54
55public:
56 /**
57 * Creates a new ldap client search object.
58 *
59 * @param parent The parent object.
60 */
61 explicit LdapClientSearch(QObject *parent = nullptr);
62
63 /**
64 * Creates a new ldap client search object.
65 *
66 * @param attr The attributes.
67 * @param parent The parent object.
68 */
69 explicit LdapClientSearch(const QStringList &attr, QObject *parent = nullptr);
70
71 /**
72 * Destroys the ldap client search object.
73 */
75
76 /**
77 * Starts the LDAP search on all configured LDAP clients with the given search @p query.
78 */
79 void startSearch(const QString &query);
80
81 /**
82 * Cancels the currently running search query.
83 */
84 void cancelSearch();
85
86 /**
87 * Returns whether LDAP search is possible at all.
88 *
89 * @note This method can return @c false if either no LDAP is configured
90 * or the system does not support the KIO LDAP protocol.
91 */
92 [[nodiscard]] bool isAvailable() const;
93
94 /**
95 * Updates the completion weights for the configured LDAP clients from
96 * the configuration file.
97 */
98 void updateCompletionWeights();
99
100 /**
101 * Returns the list of configured LDAP clients.
102 */
103 [[nodiscard]] QList<KLDAPCore::LdapClient *> clients() const;
104
105 /**
106 * Returns the filter for the Query
107 *
108 * @since 4.14
109 */
110 [[nodiscard]] QString filter() const;
111
112 /**
113 * Sets the filter for the Query
114 *
115 * @since 4.14
116 */
117 void setFilter(const QString &);
118
119 /**
120 * Returns the attributes, that are queried the LDAP Server.
121 *
122 * @since 4.14
123 */
124 [[nodiscard]] QStringList attributes() const;
125
126 /**
127 * Sets the attributes, that are queried the LDAP Server.
128 *
129 * @since 4.14
130 */
131 void setAttributes(const QStringList &);
132
133 [[nodiscard]] static QStringList defaultAttributes();
134
135Q_SIGNALS:
136 /**
137 * This signal is emitted whenever new contacts have been found
138 * during the lookup.
139 *
140 * @param results The contacts in the form "Full Name <email>"
141 */
142 void searchData(const QStringList &results);
143
144 /**
145 * This signal is emitted whenever new contacts have been found
146 * during the lookup.
147 *
148 * @param results The list of found contacts.
149 */
151
152 /**
153 * This signal is emitted whenever new contacts have been found
154 * during the lookup.
155 *
156 * @param results The list of found contacts.
157 */
159
160 /**
161 * This signal is emitted whenever the lookup is complete or the
162 * user has canceled the query.
163 */
165
166private:
167 //@cond PRIVATE
168 class LdapClientSearchPrivate;
169 std::unique_ptr<LdapClientSearchPrivate> const d;
170 //@endcond
171};
172}
173Q_DECLARE_TYPEINFO(KLDAPCore::LdapResult, Q_RELOCATABLE_TYPE);
174Q_DECLARE_TYPEINFO(KLDAPCore::LdapResultObject, Q_RELOCATABLE_TYPE);
void searchData(const KLDAPCore::LdapResultObject::List &results)
This signal is emitted whenever new contacts have been found during the lookup.
void searchData(const KLDAPCore::LdapResult::List &results)
This signal is emitted whenever new contacts have been found during the lookup.
void searchData(const QStringList &results)
This signal is emitted whenever new contacts have been found during the lookup.
~LdapClientSearch() override
Destroys the ldap client search object.
void searchDone()
This signal is emitted whenever the lookup is complete or the user has canceled the query.
An object that represents a configured LDAP server.
Definition ldapclient.h:29
This class represents an LDAP Object.
Definition ldapobject.h:31
Q_SCRIPTABLE bool setFilter(const QString &filter)
Describes the result returned by an LdapClientSearch query.
Describes the result returned by an LdapClientSearch query.
int clientNumber
The client the contact comes from (used for sorting in a ldap-only lookup).
QString name
The full name of the contact.
int completionWeight
The weight of the contact (used for sorting in a completion list).
QStringList email
The list of emails of the contact.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:14:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.