ldapcontrol.h 3.26 KB
Newer Older
1 2 3
/*
  This file is part of libkldap.
  Copyright (c) 2004-2006 Szombathelyi György <gyurco@freemail.hu>
Allen Winter's avatar
Allen Winter committed
4

5 6 7 8
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General  Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.
Allen Winter's avatar
Allen Winter committed
9

10 11 12 13
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.
Allen Winter's avatar
Allen Winter committed
14

15 16 17 18 19 20 21 22 23
  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301, USA.
*/

#ifndef KLDAP_LDAPCONTROL_H
#define KLDAP_LDAPCONTROL_H

Laurent Montel's avatar
Laurent Montel committed
24 25 26
#include <QString>
#include <QVector>
#include <QSharedDataPointer>
27
class LdapControlPrivate;
28

29
#include "kldap_export.h"
30

31 32
// clazy:excludeall=copyable-polymorphic

Laurent Montel's avatar
Laurent Montel committed
33 34
namespace KLDAP
{
35

36
class LdapControl;
Laurent Montel's avatar
Laurent Montel committed
37
typedef QVector<LdapControl> LdapControls;
38

Allen Winter's avatar
Allen Winter committed
39 40 41 42 43 44
/**
  @brief
  This class represents an LDAP Control
*/
class KLDAP_EXPORT LdapControl
{
Laurent Montel's avatar
Laurent Montel committed
45
public:
Allen Winter's avatar
Allen Winter committed
46 47 48 49 50 51 52
    /**
     * Creates an empty control.
     */
    LdapControl();
    /**
     * Creates a control with the given OID, value and criticality.
     */
Laurent Montel's avatar
Laurent Montel committed
53
    LdapControl(const QString &oid, const QByteArray &value, bool critical = false);
Allen Winter's avatar
Allen Winter committed
54

Laurent Montel's avatar
Laurent Montel committed
55 56
    LdapControl(const LdapControl &that);
    LdapControl &operator= (const LdapControl &that);
Allen Winter's avatar
Allen Winter committed
57 58 59 60 61 62 63
    /**
     * Destroys the control object.
     */
    virtual ~LdapControl();
    /**
     * Sets the control's OID, value and criticality.
     */
Laurent Montel's avatar
Laurent Montel committed
64 65
    void setControl(const QString &oid, const QByteArray &value,
                    bool critical = false);
Allen Winter's avatar
Allen Winter committed
66 67 68
    /**
     * Sets the control's OID.
     */
Laurent Montel's avatar
Laurent Montel committed
69
    void setOid(const QString &oid);
Allen Winter's avatar
Allen Winter committed
70 71 72
    /**
     * Sets the control's value.
     */
Laurent Montel's avatar
Laurent Montel committed
73
    void setValue(const QByteArray &value);
Allen Winter's avatar
Allen Winter committed
74 75 76
    /**
     * Sets the control's criticality.
     */
Laurent Montel's avatar
Laurent Montel committed
77
    void setCritical(bool critical);
Allen Winter's avatar
Allen Winter committed
78 79 80 81 82 83 84 85 86 87 88 89
    /**
     * Returns the control's OID.
     */
    QString oid() const;
    /**
     * Returns the control's value.
     */
    QByteArray value() const;
    /**
     * Returns the control's criticality.
     */
    bool critical() const;
90

Allen Winter's avatar
Allen Winter committed
91 92 93 94 95
    /**
     * Parses a paging results control, which the server returned.
     * Puts the server's cookie into @p cookie, and returns the estimated
     * result set size. If the OID is not the page control's OID, or the
     * value cannot be decoded, returns -1.
Kevin Krammer's avatar
Kevin Krammer committed
96
     * @param cookie the cookie to hold server's cookie
Allen Winter's avatar
Allen Winter committed
97
     */
Laurent Montel's avatar
Laurent Montel committed
98
    int parsePageControl(QByteArray &cookie) const;
Allen Winter's avatar
Allen Winter committed
99
    /**
100
     * Creates a paging search control.
Allen Winter's avatar
Allen Winter committed
101
     */
Laurent Montel's avatar
Laurent Montel committed
102
    static LdapControl createPageControl(int pagesize, const QByteArray &cookie = QByteArray());
103

104 105 106 107
    /**
     * Inserts a unique control against a list of controls.
     * If the control already exists in the list is is updated, otherwise
     * it is appended to the list.
Kevin Krammer's avatar
Kevin Krammer committed
108 109
     * @param list the current list of controls
     * @param ctrl the control to insert
110 111
     * @since 4.4
     */
Laurent Montel's avatar
Laurent Montel committed
112
    static void insert(LdapControls &list, const LdapControl &ctrl);
113

Laurent Montel's avatar
Laurent Montel committed
114
private:
115
    QSharedDataPointer<LdapControlPrivate> d;
Allen Winter's avatar
Allen Winter committed
116
};
117 118

}
Allen Winter's avatar
Allen Winter committed
119

120
#endif