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_LDAPCONTROL_H |
22 | #define KLDAP_LDAPCONTROL_H |
23 | |
24 | #include <QtCore/QString> |
25 | #include <QtCore/QList> |
26 | #include <QtCore/QSharedDataPointer> |
27 | |
28 | #include "kldap_export.h" |
29 | |
30 | namespace KLDAP { |
31 | |
32 | class LdapControl; |
33 | typedef QList<LdapControl> LdapControls; |
34 | |
35 | /** |
36 | @brief |
37 | This class represents an LDAP Control |
38 | */ |
39 | class KLDAP_EXPORT LdapControl |
40 | { |
41 | public: |
42 | /** |
43 | * Creates an empty control. |
44 | */ |
45 | LdapControl(); |
46 | /** |
47 | * Creates a control with the given OID, value and criticality. |
48 | */ |
49 | LdapControl( QString &oid, QByteArray &value, bool critical = false ); |
50 | |
51 | LdapControl( const LdapControl &that ); |
52 | LdapControl &operator= ( const LdapControl &that ); |
53 | /** |
54 | * Destroys the control object. |
55 | */ |
56 | virtual ~LdapControl(); |
57 | /** |
58 | * Sets the control's OID, value and criticality. |
59 | */ |
60 | void setControl( const QString &oid, const QByteArray &value, |
61 | bool critical = false ); |
62 | /** |
63 | * Sets the control's OID. |
64 | */ |
65 | void setOid( const QString &oid ); |
66 | /** |
67 | * Sets the control's value. |
68 | */ |
69 | void setValue( const QByteArray &value ); |
70 | /** |
71 | * Sets the control's criticality. |
72 | */ |
73 | void setCritical( bool critical ); |
74 | /** |
75 | * Returns the control's OID. |
76 | */ |
77 | QString oid() const; |
78 | /** |
79 | * Returns the control's value. |
80 | */ |
81 | QByteArray value() const; |
82 | /** |
83 | * Returns the control's criticality. |
84 | */ |
85 | bool critical() const; |
86 | |
87 | /** |
88 | * Parses a paging results control, which the server returned. |
89 | * Puts the server's cookie into @p cookie, and returns the estimated |
90 | * result set size. If the OID is not the page control's OID, or the |
91 | * value cannot be decoded, returns -1. |
92 | * @param cookie the cookie to hold server's cookie |
93 | */ |
94 | int parsePageControl( QByteArray &cookie ) const; |
95 | /** |
96 | * Creates a paging search control. |
97 | */ |
98 | static LdapControl createPageControl( int pagesize, const QByteArray &cookie = QByteArray() ); |
99 | |
100 | /** |
101 | * Inserts a unique control against a list of controls. |
102 | * If the control already exists in the list is is updated, otherwise |
103 | * it is appended to the list. |
104 | * @param list the current list of controls |
105 | * @param ctrl the control to insert |
106 | * @since 4.4 |
107 | */ |
108 | static void insert( LdapControls &list, const LdapControl &ctrl ); |
109 | |
110 | private: |
111 | class Private; |
112 | QSharedDataPointer<Private> d; |
113 | }; |
114 | |
115 | } |
116 | |
117 | #endif |
118 | |