File indexing completed on 2024-12-15 04:50:15
0001 /* 0002 This file is part of libkldap. 0003 SPDX-FileCopyrightText: 2004-2006 Szombathelyi György <gyurco@freemail.hu> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <QList> 0011 #include <QSharedDataPointer> 0012 #include <QString> 0013 class LdapControlPrivate; 0014 0015 #include "kldap_core_export.h" 0016 0017 // clazy:excludeall=copyable-polymorphic 0018 0019 namespace KLDAPCore 0020 { 0021 class LdapControl; 0022 using LdapControls = QList<LdapControl>; 0023 0024 /** 0025 @brief 0026 This class represents an LDAP Control 0027 */ 0028 class KLDAP_CORE_EXPORT LdapControl 0029 { 0030 public: 0031 /** 0032 * Creates an empty control. 0033 */ 0034 LdapControl(); 0035 /** 0036 * Creates a control with the given OID, value and criticality. 0037 */ 0038 LdapControl(const QString &oid, const QByteArray &value, bool critical = false); 0039 0040 LdapControl(const LdapControl &that); 0041 LdapControl &operator=(const LdapControl &that); 0042 /** 0043 * Destroys the control object. 0044 */ 0045 ~LdapControl(); 0046 /** 0047 * Sets the control's OID, value and criticality. 0048 */ 0049 void setControl(const QString &oid, const QByteArray &value, bool critical = false); 0050 /** 0051 * Sets the control's OID. 0052 */ 0053 void setOid(const QString &oid); 0054 /** 0055 * Sets the control's value. 0056 */ 0057 void setValue(const QByteArray &value); 0058 /** 0059 * Sets the control's criticality. 0060 */ 0061 void setCritical(bool critical); 0062 /** 0063 * Returns the control's OID. 0064 */ 0065 [[nodiscard]] QString oid() const; 0066 /** 0067 * Returns the control's value. 0068 */ 0069 [[nodiscard]] QByteArray value() const; 0070 /** 0071 * Returns the control's criticality. 0072 */ 0073 [[nodiscard]] bool critical() const; 0074 0075 /** 0076 * Parses a paging results control, which the server returned. 0077 * Puts the server's cookie into @p cookie, and returns the estimated 0078 * result set size. If the OID is not the page control's OID, or the 0079 * value cannot be decoded, returns -1. 0080 * @param cookie the cookie to hold server's cookie 0081 */ 0082 [[nodiscard]] int parsePageControl(QByteArray &cookie) const; 0083 /** 0084 * Creates a paging search control. 0085 */ 0086 [[nodiscard]] static LdapControl createPageControl(int pagesize, const QByteArray &cookie = QByteArray()); 0087 0088 /** 0089 * Inserts a unique control against a list of controls. 0090 * If the control already exists in the list is is updated, otherwise 0091 * it is appended to the list. 0092 * @param list the current list of controls 0093 * @param ctrl the control to insert 0094 * @since 4.4 0095 */ 0096 static void insert(LdapControls &list, const LdapControl &ctrl); 0097 0098 private: 0099 QSharedDataPointer<LdapControlPrivate> d; 0100 }; 0101 }