kabc Library API Documentation

resource.h

00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef KABC_RESOURCE_H
00022 #define KABC_RESOURCE_H
00023 
00024 #include <kresources/resource.h>
00025 
00026 #include "addressbook.h"
00027 #include "plugin.h"
00028 
00029 namespace KABC {
00030 
00037 class Ticket
00038 {
00039     friend class Resource;
00040 
00041   public:
00042     ~Ticket();
00043 
00044     Resource *resource();
00045 
00046   private:
00047     Ticket( Resource *resource );
00048 
00049     Resource *mResource;
00050 };
00051 
00055 class Resource : public KRES::Resource
00056 {
00057   Q_OBJECT
00058 
00059   public:
00060 
00068     class Iterator
00069     {
00070       public:
00071         Iterator();
00072         Iterator( const Iterator & );
00073         virtual ~Iterator();
00074 
00075         virtual Iterator &operator=( const Iterator & );
00076         virtual const Addressee &operator*() const;
00077         virtual Addressee &operator*();
00078         virtual Iterator &operator++();
00079         virtual Iterator &operator++( int );
00080         virtual Iterator &operator--();
00081         virtual Iterator &operator--( int );
00082         virtual bool operator==( const Iterator &it );
00083         virtual bool operator!=( const Iterator &it );
00084 
00085         struct IteratorData;
00086         IteratorData *d;
00087     };
00088 
00094     class ConstIterator
00095     {
00096       public:
00097         ConstIterator();
00098         ConstIterator( const ConstIterator & );
00099         ConstIterator( const Iterator & );
00100         virtual ~ConstIterator();
00101 
00102         virtual ConstIterator &operator=( const ConstIterator & );
00103         virtual const Addressee &operator*() const ;
00104         virtual ConstIterator &operator++();
00105         virtual ConstIterator &operator++( int );
00106         virtual ConstIterator &operator--();
00107         virtual ConstIterator &operator--( int );
00108         virtual bool operator==( const ConstIterator &it );
00109         virtual bool operator!=( const ConstIterator &it );
00110 
00111         struct ConstIteratorData;
00112         ConstIteratorData *d;
00113     };
00114 
00121     Resource( const KConfig *config );
00122 
00126     virtual ~Resource();
00127 
00132     virtual ConstIterator begin() const;
00133 
00138     virtual Iterator begin();
00139 
00144     virtual ConstIterator end() const;
00145 
00150     virtual Iterator end();
00151 
00155     AddressBook *addressBook();
00156 
00160     virtual void writeConfig( KConfig *config );
00161 
00167     virtual Ticket *requestSaveTicket() = 0;
00168 
00173     virtual void releaseSaveTicket( Ticket* ) = 0;
00174 
00180     virtual bool load() = 0;
00181 
00191     virtual bool asyncLoad();
00192 
00196     virtual void insertAddressee( const Addressee& );
00197 
00201     virtual void removeAddressee( const Addressee& addr );
00202 
00210     virtual bool save( Ticket *ticket ) = 0;
00211 
00223     virtual bool asyncSave( Ticket *ticket );
00224 
00232     virtual Addressee findByUid( const QString &uid );
00233 
00240     virtual Addressee::List findByName( const QString &name );
00241 
00248     virtual Addressee::List findByEmail( const QString &email );
00249 
00256     virtual Addressee::List findByCategory( const QString &category );
00257 
00261     virtual void clear();
00262 
00268     void setAddressBook( AddressBook* );
00269 
00270   signals:
00277     void loadingFinished( Resource *resource );
00278 
00286     void loadingError( Resource *resource, const QString &msg );
00287 
00294     void savingFinished( Resource *resource );
00295 
00303     void savingError( Resource *resource, const QString &msg );
00304 
00305   protected:
00306     Ticket *createTicket( Resource * );
00307     Addressee::Map mAddrMap;
00308 
00309   private:
00310     AddressBook *mAddressBook;
00311 
00312     class ResourcePrivate;
00313     ResourcePrivate *d;
00314 };
00315 
00316 }
00317 
00318 #endif
KDE Logo
This file is part of the documentation for kabc Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Apr 21 18:44:44 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003