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

KDE's Doxygen guidelines are available online.