resourceldapkio.h

00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
00004     Copyright (c) 2004 Szombathelyi György <gyurco@freemail.hu>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library 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 GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KABC_RESOURCELDAP_H
00023 #define KABC_RESOURCELDAP_H
00024 
00025 #include <kabc/resource.h>
00026 #include <kabc/ldif.h>
00027 #include <kio/job.h>
00028 
00029 class KConfig;
00030 
00031 namespace KABC {
00032 
00033 class KABC_EXPORT ResourceLDAPKIO : public Resource
00034 {
00035   Q_OBJECT
00036 
00037   public:
00038     enum CachePolicy{ Cache_No, Cache_NoConnection, Cache_Always };
00039 
00040     ResourceLDAPKIO( const KConfig* );
00041     virtual ~ResourceLDAPKIO();
00045     virtual void init();
00046     
00047     virtual void writeConfig( KConfig* );
00048 
00049     virtual bool doOpen();
00050     virtual void doClose();
00051 
00052     virtual Ticket *requestSaveTicket();
00053     virtual void releaseSaveTicket( Ticket* );
00054 
00055     virtual bool readOnly() const { return Resource::readOnly(); }
00056     virtual void setReadOnly( bool value );
00057 
00058     virtual bool load();
00059     virtual bool asyncLoad();
00060     virtual bool save( Ticket * ticket );
00061     virtual bool asyncSave( Ticket * ticket );
00062 
00063     virtual void removeAddressee( const Addressee& addr );
00064 
00065     void setUser( const QString &user );
00066     QString user() const;
00067 
00068     void setPassword( const QString &password );
00069     QString password() const;
00070     
00071     void setRealm( const QString &realm );
00072     QString realm() const;
00073     
00074     void setBindDN( const QString &binddn );
00075     QString bindDN() const;
00076 
00077     void setDn( const QString &dn );
00078     QString dn() const;
00079 
00080     void setHost( const QString &host );
00081     QString host() const;
00082 
00083     void setPort( int port );
00084     int port() const;
00085 
00086     void setVer( int ver );
00087     int ver() const;
00088     
00089     void setSizeLimit( int sizelimit );
00090     int sizeLimit();
00091     
00092     void setTimeLimit( int timelimit );
00093     int timeLimit();
00094 
00095     void setFilter( const QString &filter );
00096     QString filter() const;
00097 
00098     void setIsAnonymous( bool value );
00099     bool isAnonymous() const;
00100 
00101     void setAttributes( const QMap<QString, QString> &attributes );
00102     QMap<QString, QString> attributes() const;
00103     
00104     void setRDNPrefix( int value );
00105     int RDNPrefix() const;
00106 
00107     void setIsTLS( bool value );
00108     bool isTLS() const ;
00109     
00110     void setIsSSL( bool value );
00111     bool isSSL() const;
00112     
00113     void setIsSubTree( bool value );
00114     bool isSubTree() const ;
00115 
00116     void setIsSASL( bool value );
00117     bool isSASL() const ;
00118 
00119     void setMech( const QString &mech );
00120     QString mech() const;
00121 
00122     void setCachePolicy( int pol );
00123     int cachePolicy() const;
00124 
00125     void setAutoCache( bool value );
00126     bool autoCache();
00127     
00128     QString cacheDst() const;
00129     
00130 protected slots:
00131     void entries( KIO::Job*, const KIO::UDSEntryList& );
00132     void data( KIO::Job*, const QByteArray& );
00133     void result( KIO::Job* );
00134     void listResult( KIO::Job* );
00135     void syncLoadSaveResult( KIO::Job* );
00136     void saveResult( KIO::Job* );
00137     void saveData( KIO::Job*, QByteArray& );
00138     void loadCacheResult( KIO::Job* );
00139   
00140   private:
00141     QString mUser;
00142     QString mPassword;
00143     QString mDn;
00144     QString mHost;
00145     QString mFilter;
00146     int mPort;
00147     bool mAnonymous;
00148     QMap<QString, QString> mAttributes;
00149 
00150     KURL mLDAPUrl;
00151     int mGetCounter; //KDE 4: remove
00152     bool mErrorOccured; //KDE 4: remove
00153     QString mErrorMsg;
00154     QMap<KIO::Job*, QByteArray> mJobMap; //KDE 4: remove
00155 
00156     KIO::Job *loadFromCache();
00157     void createCache();
00158     void activateCache();
00159     void enter_loop();
00160     QCString addEntry( const QString &attr, const QString &value, bool mod );
00161     QString findUid( const QString &uid );
00162     bool AddresseeToLDIF( QByteArray &ldif, const Addressee &addr, 
00163       const QString &olddn );
00164     
00165     class ResourceLDAPKIOPrivate;
00166     ResourceLDAPKIOPrivate *d;
00167 };
00168 
00169 }
00170 
00171 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys