home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / resourceldapkio.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-01-15  |  4.4 KB  |  172 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
  4.     Copyright (c) 2004 Szombathelyi Gy├╢rgy <gyurco@freemail.hu>
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20. */
  21.  
  22. #ifndef KABC_RESOURCELDAP_H
  23. #define KABC_RESOURCELDAP_H
  24.  
  25. #include <kabc/resource.h>
  26. #include <kabc/ldif.h>
  27. #include <kio/job.h>
  28.  
  29. class KConfig;
  30.  
  31. namespace KABC {
  32.  
  33. class KABC_EXPORT ResourceLDAPKIO : public Resource
  34. {
  35.   Q_OBJECT
  36.  
  37.   public:
  38.     enum CachePolicy{ Cache_No, Cache_NoConnection, Cache_Always };
  39.  
  40.     ResourceLDAPKIO( const KConfig* );
  41.     virtual ~ResourceLDAPKIO();
  42.     /**
  43.      *  Call this after you used one of the set... methods 
  44.      */
  45.     virtual void init();
  46.     
  47.     virtual void writeConfig( KConfig* );
  48.  
  49.     virtual bool doOpen();
  50.     virtual void doClose();
  51.  
  52.     virtual Ticket *requestSaveTicket();
  53.     virtual void releaseSaveTicket( Ticket* );
  54.  
  55.     virtual bool readOnly() const { return Resource::readOnly(); }
  56.     virtual void setReadOnly( bool value );
  57.  
  58.     virtual bool load();
  59.     virtual bool asyncLoad();
  60.     virtual bool save( Ticket * ticket );
  61.     virtual bool asyncSave( Ticket * ticket );
  62.  
  63.     virtual void removeAddressee( const Addressee& addr );
  64.  
  65.     void setUser( const QString &user );
  66.     QString user() const;
  67.  
  68.     void setPassword( const QString &password );
  69.     QString password() const;
  70.     
  71.     void setRealm( const QString &realm );
  72.     QString realm() const;
  73.     
  74.     void setBindDN( const QString &binddn );
  75.     QString bindDN() const;
  76.  
  77.     void setDn( const QString &dn );
  78.     QString dn() const;
  79.  
  80.     void setHost( const QString &host );
  81.     QString host() const;
  82.  
  83.     void setPort( int port );
  84.     int port() const;
  85.  
  86.     void setVer( int ver );
  87.     int ver() const;
  88.     
  89.     void setSizeLimit( int sizelimit );
  90.     int sizeLimit();
  91.     
  92.     void setTimeLimit( int timelimit );
  93.     int timeLimit();
  94.  
  95.     void setFilter( const QString &filter );
  96.     QString filter() const;
  97.  
  98.     void setIsAnonymous( bool value );
  99.     bool isAnonymous() const;
  100.  
  101.     void setAttributes( const QMap<QString, QString> &attributes );
  102.     QMap<QString, QString> attributes() const;
  103.     
  104.     void setRDNPrefix( int value );
  105.     int RDNPrefix() const;
  106.  
  107.     void setIsTLS( bool value );
  108.     bool isTLS() const ;
  109.     
  110.     void setIsSSL( bool value );
  111.     bool isSSL() const;
  112.     
  113.     void setIsSubTree( bool value );
  114.     bool isSubTree() const ;
  115.  
  116.     void setIsSASL( bool value );
  117.     bool isSASL() const ;
  118.  
  119.     void setMech( const QString &mech );
  120.     QString mech() const;
  121.  
  122.     void setCachePolicy( int pol );
  123.     int cachePolicy() const;
  124.  
  125.     void setAutoCache( bool value );
  126.     bool autoCache();
  127.     
  128.     QString cacheDst() const;
  129.     
  130. protected slots:
  131.     void entries( KIO::Job*, const KIO::UDSEntryList& );
  132.     void data( KIO::Job*, const QByteArray& );
  133.     void result( KIO::Job* );
  134.     void listResult( KIO::Job* );
  135.     void syncLoadSaveResult( KIO::Job* );
  136.     void saveResult( KIO::Job* );
  137.     void saveData( KIO::Job*, QByteArray& );
  138.     void loadCacheResult( KIO::Job* );
  139.   
  140.   private:
  141.     QString mUser;
  142.     QString mPassword;
  143.     QString mDn;
  144.     QString mHost;
  145.     QString mFilter;
  146.     int mPort;
  147.     bool mAnonymous;
  148.     QMap<QString, QString> mAttributes;
  149.  
  150.     KURL mLDAPUrl;
  151.     int mGetCounter; //KDE 4: remove
  152.     bool mErrorOccured; //KDE 4: remove
  153.     QString mErrorMsg;
  154.     QMap<KIO::Job*, QByteArray> mJobMap; //KDE 4: remove
  155.  
  156.     KIO::Job *loadFromCache();
  157.     void createCache();
  158.     void activateCache();
  159.     void enter_loop();
  160.     QCString addEntry( const QString &attr, const QString &value, bool mod );
  161.     QString findUid( const QString &uid );
  162.     bool AddresseeToLDIF( QByteArray &ldif, const Addressee &addr, 
  163.       const QString &olddn );
  164.     
  165.     class ResourceLDAPKIOPrivate;
  166.     ResourceLDAPKIOPrivate *d;
  167. };
  168.  
  169. }
  170.  
  171. #endif
  172.