• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • @topname@
  • Sitemap
  • Contact Us
 

kabc

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 class LdapClient;
00039 typedef QValueList<QByteArray> LdapAttrValue;
00040 typedef QMap<QString,LdapAttrValue > LdapAttrMap;
00041 
00049 class KABC_EXPORT LdapObject
00050 {
00051   public:
00052     LdapObject()
00053       : dn( QString::null ), client( 0 ) {}
00054     explicit LdapObject( const QString& _dn, LdapClient* _cl ) : dn( _dn ), client( _cl ) {}
00055     LdapObject( const LdapObject& that ) { assign( that ); }
00056 
00057     LdapObject& operator=( const LdapObject& that )
00058     {
00059       assign( that );
00060       return *this;
00061     }
00062 
00063     QString toString() const;
00064 
00065     void clear();
00066 
00067     QString dn;
00068     LdapAttrMap attrs;
00069     LdapClient* client;
00070 
00071   protected:
00072     void assign( const LdapObject& that );
00073 
00074   private:
00075     //class LdapObjectPrivate* d;
00076 };
00077 
00085 class KABC_EXPORT LdapClient : public QObject
00086 {
00087   Q_OBJECT
00088 
00089   public:
00090     LdapClient( QObject* parent = 0, const char* name = 0 );
00091     virtual ~LdapClient();
00092 
00094     bool isActive() const { return mActive; }
00095 
00096   signals:
00098     void done();
00099 
00101     void error( const QString& );
00102 
00106     void result( const KABC::LdapObject& );
00107 
00108   public slots:
00112     void setHost( const QString& host );
00113     QString host() const { return mHost; }
00114 
00119     void setPort( const QString& port );
00120     QString port() const { return mPort; }
00121 
00125     void setBase( const QString& base );
00126     QString base() const { return mBase; }
00127 
00131     void setBindDN( const QString& bindDN );
00132     QString bindDN() const;
00133 
00137     void setPwdBindDN( const QString& pwdBindDN );
00138     QString pwdBindDN() const;
00139 
00144     void setAttrs( const QStringList& attrs );
00145     QStringList attrs() const { return mAttrs; }
00146 
00147     void setScope( const QString scope ) { mScope = scope; }
00148 
00152     void startQuery( const QString& filter );
00153 
00157     void cancelQuery();
00158 
00159   protected slots:
00160     void slotData( KIO::Job*, const QByteArray &data );
00161     void slotInfoMessage( KIO::Job*, const QString &info );
00162     void slotDone();
00163 
00164   protected:
00165     void startParseLDIF();
00166     void parseLDIF( const QByteArray& data );
00167     void endParseLDIF();
00168 
00169     QString mHost;
00170     QString mPort;
00171     QString mBase;
00172     QString mScope;
00173     QStringList mAttrs;
00174 
00175     QGuardedPtr<KIO::SimpleJob> mJob;
00176     bool mActive;
00177 
00178     LdapObject mCurrentObject;
00179     QCString mBuf;
00180     QCString mLastAttrName;
00181     QCString mLastAttrValue;
00182     bool mIsBase64;
00183 
00184   private:
00185     class LdapClientPrivate;
00186     LdapClientPrivate* d;
00187 };
00188 
00192 struct LdapResult {
00193   QString name;     
00194   QString email;    
00195   int clientNumber; 
00196 };
00197 typedef QValueList<LdapResult> LdapResultList;
00198 
00199 
00207 class KABC_EXPORT LdapSearch : public QObject
00208 {
00209   Q_OBJECT
00210 
00211   public:
00212     LdapSearch();
00213 
00214     void startSearch( const QString& txt );
00215     void cancelSearch();
00216     bool isAvailable() const;
00217 
00218   signals:
00221     void searchData( const QStringList& );
00224     void searchData( const KABC::LdapResultList& );
00225     void searchDone();
00226 
00227   private slots:
00228     void slotLDAPResult( const KABC::LdapObject& );
00229     void slotLDAPError( const QString& );
00230     void slotLDAPDone();
00231     void slotDataTimer();
00232 
00233   private:
00234     void finish();
00235     void makeSearchData( QStringList& ret, LdapResultList& resList );
00236     QValueList< LdapClient* > mClients;
00237     QString mSearchText;
00238     QTimer mDataTimer;
00239     int mActiveClients;
00240     bool mNoLDAPLookup;
00241     QValueList< LdapObject > mResults;
00242 
00243   private:
00244     class LdapSearchPrivate* d;
00245 };
00246 
00247 }
00248 #endif // KABC_LDAPCLIENT_H

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

@topname@

Skip menu "@topname@"
  •     kdnssd-avahi
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for @topname@ by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal