-rw-r--r-- | kabc/resource.h | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/kabc/resource.h b/kabc/resource.h index c363125..db806a6 100644 --- a/kabc/resource.h +++ b/kabc/resource.h @@ -21,26 +21,29 @@ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KABC_RESOURCE_H #define KABC_RESOURCE_H #include <kresources/resource.h> + #include "addressbook.h" +class KSyncProfile; + namespace KABC { /** * @short Helper class for handling coordinated save of address books. * * This class is used as helper class for saving address book. * @see requestSaveTicket(), save(). */ class Ticket { friend class Resource; public: @@ -48,29 +51,35 @@ class Ticket private: Ticket( Resource *resource ) : mResource( resource ) {} Resource *mResource; }; /** * @internal */ class Resource : public KRES::Resource { +private: + /** + * make this constructor private to force everybody to use the other one + */ + Resource( const KConfig *config); + public: /** * Constructor */ - Resource( const KConfig *config ); + Resource( const KConfig *config, bool syncable ); /** * Destructor. */ virtual ~Resource(); /** * Sets the address book of the resource. */ void setAddressBook( AddressBook* ); /** @@ -79,28 +88,24 @@ public: AddressBook *addressBook(); /** * Writes the resource specific config to file. */ virtual void writeConfig( KConfig *config ); /** * Open the resource and returns if it was successfully */ virtual bool doOpen(); - /** - * Close the resource and returns if it was successfully - */ - virtual void doClose(); /** * Request a ticket, you have to pass through @ref save() to * allow locking. */ virtual Ticket *requestSaveTicket(); /** * Load all addressees to the addressbook */ virtual bool load(); @@ -108,27 +113,68 @@ public: * Save all addressees to the addressbook. * * @param ticket The ticket you get by @ref requestSaveTicket() */ virtual bool save( Ticket *ticket ); /** * Removes a addressee from resource. This method is mainly * used by record-based resources like LDAP or SQL. */ virtual void removeAddressee( const Addressee& addr ); + /** * This method is called by an error handler if the application * crashed */ virtual void cleanUp(); + + /** + * This method returns the number of elements that are currently in the resource. + */ + virtual int count() const; + + /** + * This method removes all elements from the resource!! (Not from the addressbook) + */ + virtual bool clear(); + + /** + * Set name of file to be used for saving. + */ + virtual void setFileName( const QString & ); + + /** + * Return name of file used for loading and saving the address book. + */ + virtual QString fileName() const; + + + virtual bool isSyncable() const; + + /** + * Set the name of resource.You can override this method, + * but also remember to call Resource::setResourceName(). + */ + virtual void setResourceName( const QString &name ); + + + protected: Ticket *createTicket( Resource * ); + virtual void doClose(); private: AddressBook *mAddressBook; + KSyncProfile *mSyncProfile; + QString mFileName; + }; + } + + + #endif |