kabc Library API Documentation

ldapclient.h

00001 /* kldapclient.h - LDAP access 00002 * Copyright (C) 2002 Klarälvdalens Datakonsult AB 00003 * 00004 * Author: Steffen Hansen <hansen@kde.org> 00005 * 00006 * This file is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This file is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00019 */ 00020 00021 00022 #ifndef KABC_LDAPCLIENT_H 00023 #define KABC_LDAPCLIENT_H 00024 00025 00026 #include <qobject.h> 00027 #include <qstring.h> 00028 #include <qcstring.h> 00029 #include <qstringlist.h> 00030 #include <qmemarray.h> 00031 #include <qguardedptr.h> 00032 #include <qtimer.h> 00033 00034 #include <kio/job.h> 00035 00036 namespace KABC { 00037 00038 typedef QValueList<QByteArray> LdapAttrValue; 00039 typedef QMap<QString,LdapAttrValue > LdapAttrMap; 00040 00048 class LdapObject 00049 { 00050 public: 00051 LdapObject() 00052 : dn( QString::null ) {}; 00053 explicit LdapObject( QString _dn ) : dn( _dn ) {}; 00054 LdapObject( const LdapObject& that ) { assign( that ); } 00055 00056 LdapObject& operator=( const LdapObject& that ) 00057 { 00058 assign( that ); 00059 return *this; 00060 } 00061 00062 QString toString() const; 00063 00064 void clear(); 00065 00066 QString dn; 00067 LdapAttrMap attrs; 00068 00069 protected: 00070 void assign( const LdapObject& that ); 00071 00072 private: 00073 class LdapObjectPrivate* d; 00074 }; 00075 00083 class LdapClient : public QObject 00084 { 00085 Q_OBJECT 00086 00087 public: 00088 LdapClient( QObject* parent = 0, const char* name = 0 ); 00089 virtual ~LdapClient(); 00090 00092 bool isActive() const { return mActive; } 00093 00094 signals: 00096 void done(); 00097 00099 void error( const QString& ); 00100 00104 void result( const KABC::LdapObject& ); 00105 00106 public slots: 00110 void setHost( const QString& host ); 00111 QString host() const { return mHost; } 00112 00117 void setPort( const QString& port ); 00118 QString port() const { return mPort; } 00119 00123 void setBase( const QString& base ); 00124 QString base() const { return mBase; } 00125 00129 void setBindDN( const QString& bindDN ); 00130 QString bindDN() const; 00131 00135 void setPwdBindDN( const QString& pwdBindDN ); 00136 QString pwdBindDN() const; 00137 00142 void setAttrs( const QStringList& attrs ); 00143 QStringList attrs() const { return mAttrs; } 00144 00145 void setScope( const QString scope ) { mScope = scope; } 00146 00150 void startQuery( const QString& filter ); 00151 00155 void cancelQuery(); 00156 00157 protected slots: 00158 void slotData( KIO::Job*, const QByteArray &data ); 00159 void slotInfoMessage( KIO::Job*, const QString &info ); 00160 void slotDone(); 00161 00162 protected: 00163 void startParseLDIF(); 00164 void parseLDIF( const QByteArray& data ); 00165 void endParseLDIF(); 00166 00167 QString mHost; 00168 QString mPort; 00169 QString mBase; 00170 QString mScope; 00171 QStringList mAttrs; 00172 00173 QGuardedPtr<KIO::SimpleJob> mJob; 00174 bool mActive; 00175 00176 LdapObject mCurrentObject; 00177 QCString mBuf; 00178 QCString mLastAttrName; 00179 QCString mLastAttrValue; 00180 bool mIsBase64; 00181 00182 private: 00183 class LdapClientPrivate; 00184 LdapClientPrivate* d; 00185 }; 00186 00187 00195 class LdapSearch : public QObject 00196 { 00197 Q_OBJECT 00198 00199 public: 00200 LdapSearch(); 00201 00202 void startSearch( const QString& txt ); 00203 void cancelSearch(); 00204 bool isAvailable() const; 00205 00206 signals: 00207 void searchData( const QStringList& ); 00208 void searchDone(); 00209 00210 private slots: 00211 void slotLDAPResult( const KABC::LdapObject& ); 00212 void slotLDAPError( const QString& ); 00213 void slotLDAPDone(); 00214 void slotDataTimer(); 00215 00216 private: 00217 void finish(); 00218 QStringList makeSearchData(); 00219 QValueList< LdapClient* > mClients; 00220 QString mSearchText; 00221 QTimer mDataTimer; 00222 int mActiveClients; 00223 bool mNoLDAPLookup; 00224 QValueList< LdapObject > mResults; 00225 00226 private: 00227 class LdapSearchPrivate* d; 00228 }; 00229 00230 } 00231 #endif // KABC_LDAPCLIENT_H
KDE Logo
This file is part of the documentation for kabc Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 20 09:50:09 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003