• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.4 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 
26 using namespace KLDAP;
27 
28 class LdapControl::Private : public QSharedData
29 {
30  public:
31  Private()
32  {
33  }
34 
35  Private( const Private &other )
36  : QSharedData( other )
37  {
38  mOid = other.mOid;
39  mValue = other.mValue;
40  mCritical = other.mCritical;
41  }
42 
43  QString mOid;
44  QByteArray mValue;
45  bool mCritical;
46 };
47 
48 LdapControl::LdapControl()
49  : d( new Private )
50 {
51  setControl( QString(), QByteArray(), false );
52 }
53 
54 LdapControl::LdapControl( QString &oid, QByteArray &value, bool critical )
55  : d( new Private )
56 {
57  setControl( oid, value, critical );
58 }
59 
60 LdapControl::LdapControl( const LdapControl &that )
61  : d( that.d )
62 {
63  setControl( that.d->mOid, that.d->mValue, that.d->mCritical );
64 }
65 
66 LdapControl &LdapControl::operator= ( const LdapControl &that )
67 {
68  if ( this != &that ) {
69  d = that.d;
70  }
71 
72  setControl( that.d->mOid, that.d->mValue, that.d->mCritical );
73 
74  return *this;
75 }
76 
77 LdapControl::~LdapControl()
78 {
79 }
80 
81 void LdapControl::setControl( const QString &oid, const QByteArray &value, bool critical )
82 {
83  d->mOid = oid;
84  d->mValue = value;
85  d->mCritical = critical;
86 }
87 
88 QString LdapControl::oid() const
89 {
90  return d->mOid;
91 }
92 
93 QByteArray LdapControl::value() const
94 {
95  return d->mValue;
96 }
97 
98 bool LdapControl::critical() const
99 {
100  return d->mCritical;
101 }
102 
103 void LdapControl::setOid( const QString &oid )
104 {
105  d->mOid = oid;
106 }
107 
108 void LdapControl::setValue( const QByteArray &value )
109 {
110  d->mValue = value;
111 }
112 
113 void LdapControl::setCritical( bool critical )
114 {
115  d->mCritical = critical;
116 }
117 
118 int LdapControl::parsePageControl( QByteArray &cookie ) const
119 {
120  if ( d->mOid != "1.2.840.113556.1.4.319" ) {
121  return -1;
122  }
123 
124  Ber ber( d->mValue );
125  int size;
126  if ( ber.scanf( "{iO}", &size, &cookie ) == -1 ) {
127  return -1;
128  } else {
129  return size;
130  }
131 }
132 
133 LdapControl LdapControl::createPageControl( int pagesize, const QByteArray &cookie )
134 {
135  LdapControl control;
136  Ber ber;
137 
138  ber.printf( "{iO}", pagesize, &cookie );
139  control.setOid( "1.2.840.113556.1.4.319" );
140  control.setValue( ber.flatten() );
141  return control;
142 }
143 
144 void LdapControl::insert( LdapControls &list, const LdapControl &ctrl )
145 {
146  LdapControls::iterator it;
147  LdapControls::iterator endit = list.end();
148  const QString oid = ctrl.oid();
149 
150  for ( it = list.begin(); it != endit; ++it ) {
151  if ( it->oid() == oid ) {
152  *it = ctrl;
153  return;
154  }
155  }
156  list.append( ctrl );
157 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Dec 10 2012 13:48:00 by doxygen 1.8.1.2 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.9.4 API Reference

Skip menu "kdepimlibs-4.9.4 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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