author | ulf69 <ulf69> | 2004-08-02 18:33:07 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-02 18:33:07 (UTC) |
commit | 60a6886f06be31ec690df34dc8e3b8931c2d3bd7 (patch) (side-by-side diff) | |
tree | c4c7c15cfd3753a3342806a11fb8f5c20bb4f923 /kabc | |
parent | 863c4c3678e59ef125c08c00e9532ded5b540f67 (diff) | |
download | kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.zip kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.gz kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.bz2 |
added support for syncable resources
-rw-r--r-- | kabc/addressbook.cpp | 17 | ||||
-rw-r--r-- | kabc/addressbook.h | 6 | ||||
-rw-r--r-- | kabc/kabc.pro | 4 | ||||
-rw-r--r-- | kabc/kabcE.pro | 7 | ||||
-rw-r--r-- | kabc/resource.cpp | 63 | ||||
-rw-r--r-- | kabc/resource.h | 56 |
6 files changed, 135 insertions, 18 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 0838157..20310a0 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -216,15 +216,22 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) AddressBook::AddressBook() { - init(0); + init(0, "contact"); } AddressBook::AddressBook( const QString &config ) { - init(config); + init(config, "contact"); } -void AddressBook::init(const QString &config) +AddressBook::AddressBook( const QString &config, const QString &family ) +{ + init(config, family); + +} + +// the default family is "contact" +void AddressBook::init(const QString &config, const QString &family ) { d = new AddressBookData; if (config != 0) { @@ -237,7 +244,7 @@ void AddressBook::init(const QString &config) } //US d->mErrorHandler = 0; - d->mManager = new KRES::Manager<Resource>( "contact" ); + d->mManager = new KRES::Manager<Resource>( family, false ); d->mManager->readConfig( d->mConfig ); } @@ -541,8 +548,6 @@ QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) bool AddressBook::addResource( Resource *resource ) { - qDebug("AddressBook::addResource 1"); - if ( !resource->open() ) { kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; return false; diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 3a8e028..f89d7da 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -116,6 +116,7 @@ class AddressBook : public QObject */ AddressBook(); AddressBook( const QString &config ); + AddressBook( const QString &config, const QString &family ); virtual ~AddressBook(); /** @@ -308,12 +309,11 @@ class AddressBook : public QObject Resource *standardResource(); KRES::Manager<Resource> *resourceManager(); + void init(const QString &config, const QString &family); + private: //US QPtrList<Resource> mDummy; // Remove in KDE 4 -//US optimization - void init(const QString &config); - struct AddressBookData; AddressBookData *d; diff --git a/kabc/kabc.pro b/kabc/kabc.pro index a8cd695..10b092c 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro @@ -7,7 +7,7 @@ TARGET = microkabc include( ../variables.pri ) -INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat ../microkde/kdeui +INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui #LIBS += -lmicrokde -lldap LIBS += -L$(QPEDIR)/lib @@ -48,6 +48,7 @@ formats/vcardformatplugin2.h \ sound.h \ addressbook.h \ timezone.h \ + tmpaddressbook.h \ addressee.h \ addresseedialog.h \ vcardconverter.h \ @@ -157,6 +158,7 @@ formatfactory.cpp \ sound.cpp \ addressbook.cpp \ timezone.cpp \ + tmpaddressbook.cpp \ addressee.cpp \ addresseelist.cpp \ addresseedialog.cpp \ diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro index bc1c0ed..598d4fc 100644 --- a/kabc/kabcE.pro +++ b/kabc/kabcE.pro @@ -3,11 +3,12 @@ CONFIG += qt warn_on TARGET = microkabc -INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat $(QPEDIR)/include +INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat $(QPEDIR)/include OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR = $(QPEDIR)/lib LIBS += -lmicrokde +LIBS += -lmicrokdepim #LIBS += -lldap LIBS += -L$(QPEDIR)/lib DEFINES += KAB_EMBEDDED @@ -36,7 +37,9 @@ HEADERS = \ secrecy.h \ sound.h \ stdaddressbook.h \ + syncprefwidget.h \ timezone.h \ + tmpaddressbook.h \ vcardconverter.h \ vcard21parser.h \ vcardformatimpl.h \ @@ -138,7 +141,9 @@ SOURCES = \ secrecy.cpp \ sound.cpp \ stdaddressbook.cpp \ + syncprefwidget.cpp \ timezone.cpp \ + tmpaddressbook.cpp \ vcardconverter.cpp \ vcard21parser.cpp \ vcardformatimpl.cpp \ diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 9a1a5f8..9632a3f 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp @@ -27,24 +27,38 @@ $Id$ #include <kdebug.h> +#include <ksyncprofile.h> + #include "resource.h" using namespace KABC; -Resource::Resource( const KConfig *config ) - : KRES::Resource( config ), mAddressBook( 0 ) +Resource::Resource( const KConfig *config, bool syncable ) + : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) { + if(syncable == true) { + mSyncProfile = new KSyncProfile( identifier() ); + mSyncProfile->setName(resourceName()); + mSyncProfile->readConfig( (KConfig *)config ); + } } Resource::~Resource() { + if (mSyncProfile != 0) { + delete mSyncProfile; + } } void Resource::writeConfig( KConfig *config ) { KRES::Resource::writeConfig( config ); + + if(mSyncProfile != 0) + mSyncProfile->writeConfig( config ); } + void Resource::setAddressBook( AddressBook *ab ) { mAddressBook = ab; @@ -93,3 +107,48 @@ void Resource::cleanUp() { // do nothing } + +bool Resource::isSyncable() const +{ + return (mSyncProfile != 0); +} + +/** + * This method returns the number of elements that are currently in the resource. + */ +int Resource::count() const +{ + return 0; +} + +/** + * This method removes all elements from the resource!! (Not from the addressbook) + */ +bool Resource::clear() +{ + return false; +} + +QString Resource::fileName() const +{ + return mFileName; +} + +void Resource::setFileName( const QString &fileName ) +{ + mFileName = fileName; +} + +/** + * Set the name of resource.You can override this method, + * but also remember to call Resource::setResourceName(). + */ +void Resource::setResourceName( const QString &name ) +{ + KRES::Resource::setResourceName(name); + if(mSyncProfile != 0) { + mSyncProfile->setName( name ); + } + +} + diff --git a/kabc/resource.h b/kabc/resource.h index c363125..db806a6 100644 --- a/kabc/resource.h +++ b/kabc/resource.h @@ -30,8 +30,11 @@ $Id$ #include <kresources/resource.h> + #include "addressbook.h" +class KSyncProfile; + namespace KABC { /** @@ -57,11 +60,17 @@ class Ticket */ 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. @@ -88,10 +97,6 @@ public: */ 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 @@ -117,18 +122,59 @@ public: */ 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 |