00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KABC_RESOURCELDAP_H
00023 #define KABC_RESOURCELDAP_H
00024
00025 #include <tdeabc/resource.h>
00026 #include <tdeabc/ldif.h>
00027 #include <tdeio/job.h>
00028
00029 class TDEConfig;
00030
00031 namespace TDEABC {
00032
00033 class KABC_EXPORT ResourceLDAPTDEIO : public Resource
00034 {
00035 Q_OBJECT
00036
00037 public:
00038 enum CachePolicy{ Cache_No, Cache_NoConnection, Cache_Always };
00039
00040 ResourceLDAPTDEIO( const TDEConfig* );
00041 virtual ~ResourceLDAPTDEIO();
00045 virtual void init();
00046
00047 virtual void writeConfig( TDEConfig* );
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 TQString &user );
00066 TQString user() const;
00067
00068 void setPassword( const TQString &password );
00069 TQString password() const;
00070
00071 void setRealm( const TQString &realm );
00072 TQString realm() const;
00073
00074 void setBindDN( const TQString &binddn );
00075 TQString bindDN() const;
00076
00077 void setDn( const TQString &dn );
00078 TQString dn() const;
00079
00080 void setHost( const TQString &host );
00081 TQString 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 TQString &filter );
00096 TQString filter() const;
00097
00098 void setIsAnonymous( bool value );
00099 bool isAnonymous() const;
00100
00101 void setAttributes( const TQMap<TQString, TQString> &attributes );
00102 TQMap<TQString, TQString> 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 TQString &mech );
00120 TQString mech() const;
00121
00122 void setCachePolicy( int pol );
00123 int cachePolicy() const;
00124
00125 void setAutoCache( bool value );
00126 bool autoCache();
00127
00128 TQString cacheDst() const;
00129
00130 protected slots:
00131 void entries( TDEIO::Job*, const TDEIO::UDSEntryList& );
00132 void data( TDEIO::Job*, const TQByteArray& );
00133 void result( TDEIO::Job* );
00134 void listResult( TDEIO::Job* );
00135 void syncLoadSaveResult( TDEIO::Job* );
00136 void saveResult( TDEIO::Job* );
00137 void saveData( TDEIO::Job*, TQByteArray& );
00138 void loadCacheResult( TDEIO::Job* );
00139
00140 private:
00141 TQString mUser;
00142 TQString mPassword;
00143 TQString mDn;
00144 TQString mHost;
00145 TQString mFilter;
00146 int mPort;
00147 bool mAnonymous;
00148 TQMap<TQString, TQString> mAttributes;
00149
00150 KURL mLDAPUrl;
00151 int mGetCounter;
00152 bool mErrorOccured;
00153 TQString mErrorMsg;
00154 TQMap<TDEIO::Job*, TQByteArray> mJobMap;
00155
00156 TDEIO::Job *loadFromCache();
00157 void createCache();
00158 void activateCache();
00159 void enter_loop();
00160 TQCString addEntry( const TQString &attr, const TQString &value, bool mod );
00161 TQString findUid( const TQString &uid );
00162 bool AddresseeToLDIF( TQByteArray &ldif, const Addressee &addr,
00163 const TQString &olddn );
00164
00165 class ResourceLDAPTDEIOPrivate;
00166 ResourceLDAPTDEIOPrivate *d;
00167 };
00168
00169 }
00170
00171 #endif