1 | /* |
2 | This file is part of libkldap. |
3 | Copyright (c) 2004-2006 Szombathelyi György <gyurco@freemail.hu> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef KLDAP_LDAPCONFIGWIDGET_H |
22 | #define KLDAP_LDAPCONFIGWIDGET_H |
23 | |
24 | #include <QtCore/QString> |
25 | #include <QWidget> |
26 | |
27 | #include "ldapdn.h" |
28 | #include "kldap_export.h" |
29 | #include "ldapobject.h" |
30 | #include "ldapserver.h" |
31 | #include "ldapurl.h" |
32 | |
33 | namespace KLDAP { |
34 | |
35 | class LdapSearch; |
36 | |
37 | /** |
38 | @brief LDAP Configuration widget |
39 | |
40 | This class can be used to query the user for LDAP connection parameters. |
41 | It's KConfigXT compatible, using widget names starting with kcfg_ |
42 | */ |
43 | |
44 | class KLDAP_EXPORT LdapConfigWidget : public QWidget |
45 | { |
46 | Q_OBJECT |
47 | Q_FLAGS( WinFlags ) |
48 | Q_ENUMS( Security ) |
49 | Q_ENUMS( Auth ) |
50 | Q_PROPERTY( WinFlags features READ features WRITE setFeatures ) |
51 | Q_PROPERTY( QString user READ user WRITE setUser ) |
52 | Q_PROPERTY( QString bindDn READ bindDn WRITE setBindDn ) |
53 | Q_PROPERTY( QString realm READ realm WRITE setRealm ) |
54 | Q_PROPERTY( QString password READ password WRITE setPassword ) |
55 | Q_PROPERTY( QString host READ host WRITE setHost ) |
56 | Q_PROPERTY( int port READ port WRITE setPort ) |
57 | Q_PROPERTY( int version READ version WRITE setVersion ) |
58 | Q_PROPERTY( LdapDN dn READ dn WRITE setDn ) |
59 | Q_PROPERTY( QString filter READ filter WRITE setFilter ) |
60 | Q_PROPERTY( QString mech READ mech WRITE setMech ) |
61 | Q_PROPERTY( Security security READ security WRITE setSecurity ) |
62 | Q_PROPERTY( Auth auth READ auth WRITE setAuth ) |
63 | Q_PROPERTY( int sizeLimit READ sizeLimit WRITE setSizeLimit ) |
64 | Q_PROPERTY( int timeLimit READ timeLimit WRITE setTimeLimit ) |
65 | Q_PROPERTY( int pageSize READ pageSize WRITE setPageSize ) |
66 | |
67 | public: |
68 | |
69 | enum WinFlag { |
70 | W_USER = 0x1, |
71 | W_BINDDN = 0x2, |
72 | W_REALM = 0x4, |
73 | W_PASS = 0x8, |
74 | W_HOST = 0x10, |
75 | W_PORT = 0x20, |
76 | W_VER = 0x40, |
77 | W_DN = 0x80, |
78 | W_FILTER = 0x100, |
79 | W_SECBOX = 0x200, |
80 | W_AUTHBOX = 0x400, |
81 | W_TIMELIMIT = 0x800, |
82 | W_SIZELIMIT = 0x1000, |
83 | W_PAGESIZE = 0x2000, |
84 | W_ALL = 0x2fff |
85 | }; |
86 | |
87 | typedef enum { |
88 | None, SSL, TLS |
89 | } Security; |
90 | typedef enum { |
91 | Anonymous, Simple, SASL |
92 | } Auth; |
93 | |
94 | Q_DECLARE_FLAGS( WinFlags, WinFlag ) |
95 | |
96 | /** Constructs an empty configuration widget. |
97 | * You need to call setFlags() after this. |
98 | * @param parent the QWidget parent |
99 | * @param fl the window flags to set |
100 | */ |
101 | explicit LdapConfigWidget( QWidget *parent = 0, Qt::WindowFlags fl = 0 ); |
102 | /** Constructs a configuration widget */ |
103 | explicit LdapConfigWidget( WinFlags flags, QWidget *parent = 0, |
104 | Qt::WindowFlags fl = 0 ); |
105 | /** Destructs a configuration widget */ |
106 | virtual ~LdapConfigWidget(); |
107 | |
108 | /** Sets the user name. Kconfig widget name: kcfg_ldapuser |
109 | * @param user the user name to set |
110 | */ |
111 | void setUser( const QString &user ); |
112 | /** Gets the user name. Kconfig widget name: kcfg_ldapuser */ |
113 | QString user() const; |
114 | |
115 | /** Sets the password. Kconfig widget name: kcfg_ldappassword |
116 | * @param password the password to set |
117 | */ |
118 | void setPassword( const QString &password ); |
119 | /** Gets the password. Kconfig widget name: kcfg_ldappassword */ |
120 | QString password() const; |
121 | |
122 | /** |
123 | * Sets the bind dn. |
124 | * Kconfig widget name: kcfg_ldapbinddn |
125 | * @param binddn the LDAP Bind DN to set |
126 | */ |
127 | void setBindDn( const QString &binddn ); |
128 | /** Gets the bind dn. Kconfig widget name: kcfg_ldapbinddn*/ |
129 | QString bindDn() const; |
130 | |
131 | /** Sets the SASL realm. Kconfig widget name: kcfg_ldaprealm |
132 | * @param realm the SASL realm to set |
133 | */ |
134 | void setRealm( const QString &realm ); |
135 | /** Gets the SASL realm. Kconfig widget name: kcfg_ldaprealm */ |
136 | QString realm() const; |
137 | |
138 | /** Sets the host name. Kconfig widget name: kcfg_ldaphost |
139 | * @param host the LDAP host to set |
140 | */ |
141 | void setHost( const QString &host ); |
142 | /** Gets the host name. Kconfig widget name: kcfg_ldaphost */ |
143 | QString host() const; |
144 | |
145 | /** Sets the LDAP port. Kconfig widget name: kcfg_ldapport |
146 | * @param port the LDAP port to set |
147 | */ |
148 | void setPort( int port ); |
149 | /** Gets the LDAP port. Kconfig widget name: kcfg_ldapport */ |
150 | int port() const; |
151 | |
152 | /** Sets the LDAP protocol version. Kconfig widget name: kcfg_ldapver |
153 | * @param version the LDAP protocol version to set |
154 | */ |
155 | void setVersion( int version ); |
156 | /** Gets the LDAP protocol version. Kconfig widget name: kcfg_ldapver */ |
157 | int version() const; |
158 | |
159 | /** Sets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn |
160 | * @param dn the LDAP Base DN to set |
161 | */ |
162 | void setDn( const LdapDN &dn ); |
163 | /** Gets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn */ |
164 | LdapDN dn() const; |
165 | |
166 | /** Sets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter |
167 | * @param filter the LDAP Filter to set |
168 | */ |
169 | void setFilter( const QString &filter ); |
170 | /** Gets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter */ |
171 | QString filter() const; |
172 | |
173 | /** Sets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech |
174 | * @param mech the SASL Mechanism to set |
175 | */ |
176 | void setMech( const QString &mech ); |
177 | /** Gets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech */ |
178 | QString mech() const; |
179 | |
180 | /** |
181 | * Sets the security type (None, SSL, TLS). |
182 | * Kconfig widget names: kcfg_ldapnosec, kcfg_ldaptls, kcfg_ldapssl |
183 | * @param security the security type to set |
184 | */ |
185 | void setSecurity( Security security ); |
186 | /** |
187 | * Returns the security type. |
188 | * Kconfig widget names: kcfg_ldapnosec, kcfg_ldaptls, kcfg_ldapssl |
189 | * @param security the security type to set |
190 | */ |
191 | Security security() const; |
192 | |
193 | /** |
194 | * Sets the authentication type (Anonymous, Simple, SASL). |
195 | * Kconfig widget names: kcfg_ldapanon, kcfg_ldapsimple, kcfg_ldapsasl |
196 | * @param auth the authentication type to set |
197 | */ |
198 | void setAuth( Auth auth ); |
199 | /** |
200 | * Returns the authentication type. |
201 | * Kconfig widget names: kcfg_ldapanon, kcfg_ldapsimple, kcfg_ldapsasl |
202 | * @param auth the authentication type to set |
203 | */ |
204 | Auth auth() const; |
205 | |
206 | /** |
207 | * Sets the size limit. |
208 | * KConfig widget name: kcfg_ldapsizelimit |
209 | * @param sizelimit the size limit to set |
210 | */ |
211 | void setSizeLimit( int sizelimit ); |
212 | /** |
213 | * Returns the size limit. |
214 | * KConfig widget name: kcfg_ldapsizelimit |
215 | */ |
216 | int sizeLimit() const; |
217 | |
218 | /** |
219 | * Sets the time limit. |
220 | * KConfig widget name: kcfg_ldaptimelimit |
221 | * @param timelimit the time limit to set |
222 | */ |
223 | void setTimeLimit( int timelimit ); |
224 | /** |
225 | * Returns the time limit. |
226 | * KConfig widget name: kcfg_ldaptimelimit |
227 | */ |
228 | int timeLimit() const; |
229 | |
230 | /** |
231 | * Sets the page size. |
232 | * KConfig widget name: kcfg_ldappagesize |
233 | * @param pagesize the page size to set |
234 | */ |
235 | void setPageSize( int pagesize ); |
236 | /** |
237 | * Returns the page size. |
238 | * KConfig widget name: kcfg_ldappagesize |
239 | */ |
240 | int pageSize() const; |
241 | |
242 | WinFlags features() const; |
243 | void setFeatures( WinFlags features ); |
244 | |
245 | /** |
246 | * Returns a LDAP Url constructed from the settings given. |
247 | * Extensions are filled for use in the LDAP ioslave |
248 | */ |
249 | LdapUrl url() const; |
250 | /** |
251 | * Set up the widget via an LDAP Url. |
252 | * @param url the LDAP Url to set |
253 | */ |
254 | void setUrl( const LdapUrl &url ); |
255 | |
256 | /** |
257 | * Returns an LdapServer object constructed from the settings given. |
258 | */ |
259 | LdapServer server() const; |
260 | /** |
261 | * Set up the widget via an LdapServer object. |
262 | * @param server the LdapServer object to set |
263 | */ |
264 | void setServer( const LdapServer &server ); |
265 | |
266 | Q_SIGNALS: |
267 | /** |
268 | * @since 4.13 |
269 | */ |
270 | void hostNameChanged(const QString &); |
271 | |
272 | private: |
273 | class Private; |
274 | Private *const d; |
275 | |
276 | Q_PRIVATE_SLOT( d, void setLDAPPort() ) |
277 | Q_PRIVATE_SLOT( d, void setLDAPSPort() ) |
278 | Q_PRIVATE_SLOT( d, void setAnonymous( bool ) ) |
279 | Q_PRIVATE_SLOT( d, void setSimple( bool ) ) |
280 | Q_PRIVATE_SLOT( d, void setSASL( bool ) ) |
281 | Q_PRIVATE_SLOT( d, void queryDNClicked() ) |
282 | Q_PRIVATE_SLOT( d, void queryMechClicked() ) |
283 | Q_PRIVATE_SLOT( d, void loadData( KLDAP::LdapSearch*, const KLDAP::LdapObject& ) ) |
284 | Q_PRIVATE_SLOT( d, void loadResult( KLDAP::LdapSearch* ) ) |
285 | }; |
286 | |
287 | Q_DECLARE_OPERATORS_FOR_FLAGS( LdapConfigWidget::WinFlags ) |
288 | |
289 | } |
290 | |
291 | #endif |
292 | |