ldapclient.h
/* kldapclient.h - LDAP access
* Copyright (C) 2002 Klarälvdalens Datakonsult AB
*
* Author: Steffen Hansen <hansen@kde.org>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KABC_LDAPCLIENT_H
#define KABC_LDAPCLIENT_H
#include <qobject.h>
#include <qstring.h>
#include <qcstring.h>
#include <qstringlist.h>
#include <qmemarray.h>
#include <qguardedptr.h>
#include <qtimer.h>
#include <kio/job.h>
namespace KABC {
class LdapClient;
typedef QValueList<QByteArray> LdapAttrValue;
typedef QMap<QString,LdapAttrValue > LdapAttrMap;
class KABC_EXPORT LdapObject
{
public:
LdapObject()
: dn( QString::null ), client( 0 ) {}
explicit LdapObject( const QString& _dn, LdapClient* _cl ) : dn( _dn ), client( _cl ) {}
LdapObject( const LdapObject& that ) { assign( that ); }
LdapObject& operator=( const LdapObject& that )
{
assign( that );
return *this;
}
QString toString() const;
void clear();
QString dn;
LdapAttrMap attrs;
LdapClient* client;
protected:
void assign( const LdapObject& that );
private:
//class LdapObjectPrivate* d;
};
class KABC_EXPORT LdapClient : public QObject
{
Q_OBJECT
public:
LdapClient( QObject* parent = 0, const char* name = 0 );
virtual ~LdapClient();
bool isActive() const { return mActive; }
signals:
void done();
void error( const QString& );
void result( const KABC::LdapObject& );
public slots:
void setHost( const QString& host );
QString host() const { return mHost; }
void setPort( const QString& port );
QString port() const { return mPort; }
void setBase( const QString& base );
QString base() const { return mBase; }
void setBindDN( const QString& bindDN );
QString bindDN() const;
void setPwdBindDN( const QString& pwdBindDN );
QString pwdBindDN() const;
void setAttrs( const QStringList& attrs );
QStringList attrs() const { return mAttrs; }
void setScope( const QString scope ) { mScope = scope; }
void startQuery( const QString& filter );
void cancelQuery();
protected slots:
void slotData( KIO::Job*, const QByteArray &data );
void slotInfoMessage( KIO::Job*, const QString &info );
void slotDone();
protected:
void startParseLDIF();
void parseLDIF( const QByteArray& data );
void endParseLDIF();
QString mHost;
QString mPort;
QString mBase;
QString mScope;
QStringList mAttrs;
QGuardedPtr<KIO::SimpleJob> mJob;
bool mActive;
LdapObject mCurrentObject;
QCString mBuf;
QCString mLastAttrName;
QCString mLastAttrValue;
bool mIsBase64;
private:
class LdapClientPrivate;
LdapClientPrivate* d;
};
struct LdapResult {
QString name;
QString email;
int clientNumber;
};
typedef QValueList<LdapResult> LdapResultList;
class KABC_EXPORT LdapSearch : public QObject
{
Q_OBJECT
public:
LdapSearch();
void startSearch( const QString& txt );
void cancelSearch();
bool isAvailable() const;
signals:
void searchData( const QStringList& );
void searchData( const KABC::LdapResultList& );
void searchDone();
private slots:
void slotLDAPResult( const KABC::LdapObject& );
void slotLDAPError( const QString& );
void slotLDAPDone();
void slotDataTimer();
private:
void finish();
void makeSearchData( QStringList& ret, LdapResultList& resList );
QValueList< LdapClient* > mClients;
QString mSearchText;
QTimer mDataTimer;
int mActiveClients;
bool mNoLDAPLookup;
QValueList< LdapObject > mResults;
private:
class LdapSearchPrivate* d;
};
}
#endif // KABC_LDAPCLIENT_H
KABC::LdapObject
This class is internal.
Definition: ldapclient.h:49
KABC::LdapResult
Structure describing one result returned by a LDAP query.
Definition: ldapclient.h:192
KABC::LdapClient
This class is internal.
Definition: ldapclient.h:85
KABC::LdapClient::isActive
bool isActive() const
Definition: ldapclient.h:94
KABC::LdapResult::clientNumber
int clientNumber
for sorting
Definition: ldapclient.h:195
KABC::LdapResult::name
QString name
full name
Definition: ldapclient.h:193
KABC::LdapSearch
This class is internal.
Definition: ldapclient.h:207
KABC::LdapResult::email
QString email
email
Definition: ldapclient.h:194

KDE Home | KDE Accessibility Home | Description of Access Keys