• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

KLDAP Library

  • kldap
ldapcontrol.cpp
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#include "ldapcontrol.h"
22#include "ber.h"
23
24#include <QtCore/QSharedData>
25
26using namespace KLDAP;
27
28class LdapControl::Private : public QSharedData
29{
30 public:
31 Private()
32 {
33 mCritical = false;
34 }
35
36 Private( const Private &other )
37 : QSharedData( other )
38 {
39 mOid = other.mOid;
40 mValue = other.mValue;
41 mCritical = other.mCritical;
42 }
43
44 QString mOid;
45 QByteArray mValue;
46 bool mCritical;
47};
48
49LdapControl::LdapControl()
50 : d( new Private )
51{
52 setControl( QString(), QByteArray(), false );
53}
54
55LdapControl::LdapControl( QString &oid, QByteArray &value, bool critical )
56 : d( new Private )
57{
58 setControl( oid, value, critical );
59}
60
61LdapControl::LdapControl( const LdapControl &that )
62 : d( that.d )
63{
64 setControl( that.d->mOid, that.d->mValue, that.d->mCritical );
65}
66
67LdapControl &LdapControl::operator= ( const LdapControl &that )
68{
69 if ( this != &that ) {
70 d = that.d;
71 }
72
73 setControl( that.d->mOid, that.d->mValue, that.d->mCritical );
74
75 return *this;
76}
77
78LdapControl::~LdapControl()
79{
80}
81
82void LdapControl::setControl( const QString &oid, const QByteArray &value, bool critical )
83{
84 d->mOid = oid;
85 d->mValue = value;
86 d->mCritical = critical;
87}
88
89QString LdapControl::oid() const
90{
91 return d->mOid;
92}
93
94QByteArray LdapControl::value() const
95{
96 return d->mValue;
97}
98
99bool LdapControl::critical() const
100{
101 return d->mCritical;
102}
103
104void LdapControl::setOid( const QString &oid )
105{
106 d->mOid = oid;
107}
108
109void LdapControl::setValue( const QByteArray &value )
110{
111 d->mValue = value;
112}
113
114void LdapControl::setCritical( bool critical )
115{
116 d->mCritical = critical;
117}
118
119int LdapControl::parsePageControl( QByteArray &cookie ) const
120{
121 if ( d->mOid != QLatin1String("1.2.840.113556.1.4.319") ) {
122 return -1;
123 }
124
125 Ber ber( d->mValue );
126 int size;
127 if ( ber.scanf( QLatin1String("{iO}"), &size, &cookie ) == -1 ) {
128 return -1;
129 } else {
130 return size;
131 }
132}
133
134LdapControl LdapControl::createPageControl( int pagesize, const QByteArray &cookie )
135{
136 LdapControl control;
137 Ber ber;
138
139 ber.printf( QLatin1String("{iO}"), pagesize, &cookie );
140 control.setOid( QLatin1String("1.2.840.113556.1.4.319") );
141 control.setValue( ber.flatten() );
142 return control;
143}
144
145void LdapControl::insert( LdapControls &list, const LdapControl &ctrl )
146{
147 LdapControls::iterator it;
148 LdapControls::iterator endit = list.end();
149 const QString oid = ctrl.oid();
150
151 for ( it = list.begin(); it != endit; ++it ) {
152 if ( it->oid() == oid ) {
153 *it = ctrl;
154 return;
155 }
156 }
157 list.append( ctrl );
158}
KLDAP::Ber
This class allows encoding and decoding Qt structures using Basic Encoding Rules.
Definition: ber.h:35
KLDAP::Ber::flatten
QByteArray flatten() const
Returns the Ber object as a flat QByteArray.
Definition: ber.cpp:435
KLDAP::Ber::printf
int printf(const QString &format,...)
Appends the data with the specified format to the Ber object.
Definition: ber.cpp:441
KLDAP::LdapControl
This class represents an LDAP Control.
Definition: ldapcontrol.h:40
KLDAP::LdapControl::insert
static void insert(LdapControls &list, const LdapControl &ctrl)
Inserts a unique control against a list of controls.
Definition: ldapcontrol.cpp:145
KLDAP::LdapControl::setValue
void setValue(const QByteArray &value)
Sets the control's value.
Definition: ldapcontrol.cpp:109
KLDAP::LdapControl::critical
bool critical() const
Returns the control's criticality.
Definition: ldapcontrol.cpp:99
KLDAP::LdapControl::setOid
void setOid(const QString &oid)
Sets the control's OID.
Definition: ldapcontrol.cpp:104
KLDAP::LdapControl::oid
QString oid() const
Returns the control's OID.
Definition: ldapcontrol.cpp:89
KLDAP::LdapControl::setCritical
void setCritical(bool critical)
Sets the control's criticality.
Definition: ldapcontrol.cpp:114
KLDAP::LdapControl::~LdapControl
virtual ~LdapControl()
Destroys the control object.
Definition: ldapcontrol.cpp:78
KLDAP::LdapControl::parsePageControl
int parsePageControl(QByteArray &cookie) const
Parses a paging results control, which the server returned.
Definition: ldapcontrol.cpp:119
KLDAP::LdapControl::setControl
void setControl(const QString &oid, const QByteArray &value, bool critical=false)
Sets the control's OID, value and criticality.
Definition: ldapcontrol.cpp:82
KLDAP::LdapControl::LdapControl
LdapControl()
Creates an empty control.
Definition: ldapcontrol.cpp:49
KLDAP::LdapControl::createPageControl
static LdapControl createPageControl(int pagesize, const QByteArray &cookie=QByteArray())
Creates a paging search control.
Definition: ldapcontrol.cpp:134
KLDAP::LdapControl::value
QByteArray value() const
Returns the control's value.
Definition: ldapcontrol.cpp:94
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KLDAP Library

Skip menu "KLDAP Library"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal