-rw-r--r-- | kabc/plugins/opie/resourceopie.cpp | 39 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.h | 10 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 49 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.h | 10 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 30 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.h | 10 | ||||
-rw-r--r-- | kabc/resource.cpp | 15 | ||||
-rw-r--r-- | kabc/resource.h | 11 | ||||
-rw-r--r-- | kabc/tmpaddressbook.cpp | 14 |
9 files changed, 30 insertions, 158 deletions
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp index 5559827..9dfd473 100644 --- a/kabc/plugins/opie/resourceopie.cpp +++ b/kabc/plugins/opie/resourceopie.cpp @@ -88,4 +88,5 @@ ResourceOpie::ResourceOpie( const QString &fileName, bool syncable ) void ResourceOpie::init( const QString &fileName ) { + qDebug("ResourceOpie::init()"); connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); @@ -255,5 +256,9 @@ bool ResourceOpie::lock( const QString &lockfileName ) kdDebug(5700) << "-- lock name: " << lockName << endl; - if (QFile::exists( lockName )) return false; + if (QFile::exists( lockName )) + { + qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); + return false; + } QString lockUniqueName; @@ -341,35 +346,3 @@ void ResourceOpie::cleanUp() -/** - * This method returns the number of elements that are currently in the resource. - */ -int ResourceOpie::count() const -{ - qDebug("ResourceOpie::count: %x", mAccess); - - if (mAccess != 0) - { - OContactAccess::List contactList = mAccess->allRecords(); - return contactList.count(); - } - else - return 0; -} - - -/** - * This method removes all elements from the resource!! (Not from the addressbook) - */ -bool ResourceOpie::clear() -{ - if (mAccess != 0) { - mAccess->clear(); - return true; - } - else - return false; -} - - - //US #include "resourceopie.moc" diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h index ca30fee..d5b4ebd 100644 --- a/kabc/plugins/opie/resourceopie.h +++ b/kabc/plugins/opie/resourceopie.h @@ -123,14 +123,4 @@ public: 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(); - protected slots: diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 4a35f19..242e0c6 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp @@ -234,5 +234,9 @@ bool ResourceQtopia::lock( const QString &lockfileName ) kdDebug(5700) << "-- lock name: " << lockName << endl; - if (QFile::exists( lockName )) return false; + if (QFile::exists( lockName )) + { + qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); + return false; + } QString lockUniqueName; @@ -313,46 +317,3 @@ void ResourceQtopia::cleanUp() } - - -/** - * This method returns the number of elements that are currently in the resource. - */ -int ResourceQtopia::count() const -{ - if (mAccess != 0) - { - int counter = 0; - AddressBookIterator it2(*mAccess); - for (it2.toFirst(); it2.current(); ++it2) { - counter++; - } - - return counter; - } - else - return 0; -} - - -/** - * This method removes all elements from the resource!! (Not from the addressbook) - */ -bool ResourceQtopia::clear() -{ - if (mAccess != 0) - { - AddressBookIterator it2(*mAccess); - for (it2.toFirst(); it2.current(); ++it2) { - mAccess->removeContact(*it2.current()); - } - return true; - } - else - return false; -} - - - - - //US #include "resourceqtopia.moc" diff --git a/kabc/plugins/qtopia/resourceqtopia.h b/kabc/plugins/qtopia/resourceqtopia.h index 90ab1f4..eace280 100644 --- a/kabc/plugins/qtopia/resourceqtopia.h +++ b/kabc/plugins/qtopia/resourceqtopia.h @@ -123,14 +123,4 @@ public: 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(); - protected slots: void fileChanged(); diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 14f272d..70c3718 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp @@ -250,5 +250,10 @@ bool ResourceSharpDTM::lock( const QString &lockfileName ) kdDebug(5700) << "-- lock name: " << lockName << endl; - if (QFile::exists( lockName )) return false; + if (QFile::exists( lockName )) + { + qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); + return false; + } + QString lockUniqueName; @@ -329,27 +334,4 @@ void ResourceSharpDTM::cleanUp() } -/** - * This method returns the number of elements that are currently in the resource. - */ -int ResourceSharpDTM::count() const -{ - if (mAccess != 0) - return mAccess->count(); - else - return 0; -} - - -/** - * This method removes all elements from the resource!! (Not from the addressbook) - */ -bool ResourceSharpDTM::clear() -{ - if (mAccess != 0) - return mAccess->deleteCard(0, SlZDataBase::AllCard ); - else - return false; -} - diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.h b/kabc/plugins/sharpdtm/resourcesharpdtm.h index 60d38a1..f386e69 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.h +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.h @@ -123,14 +123,4 @@ public: 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(); - protected slots: diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 9632a3f..2f03927 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp @@ -114,19 +114,4 @@ bool Resource::isSyncable() const } -/** - * 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 diff --git a/kabc/resource.h b/kabc/resource.h index db806a6..7d42f81 100644 --- a/kabc/resource.h +++ b/kabc/resource.h @@ -130,15 +130,4 @@ public: 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. diff --git a/kabc/tmpaddressbook.cpp b/kabc/tmpaddressbook.cpp index e6699df..ca47ca4 100644 --- a/kabc/tmpaddressbook.cpp +++ b/kabc/tmpaddressbook.cpp @@ -25,4 +25,5 @@ Copyright (c) 2004 Ulf Schenk $Id$ */ +#include <qptrlist.h> #include "tmpaddressbook.h" @@ -30,4 +31,6 @@ $Id$ using namespace KABC; +#include "resource.h" + TmpAddressBook::TmpAddressBook() : AddressBook(0, "tmpcontact") @@ -36,5 +39,5 @@ TmpAddressBook::TmpAddressBook() TmpAddressBook::TmpAddressBook( const QString &config ) - : AddressBook( config, "tmpcontact" ) + : AddressBook( config, "tmpcontract" ) { } @@ -42,3 +45,12 @@ TmpAddressBook::TmpAddressBook( const QString &config ) TmpAddressBook::~TmpAddressBook() { + //remove all possible resources. This should cleanup the configfile. + QPtrList<KABC::Resource> mResources = resources(); + + QPtrListIterator<KABC::Resource> it(mResources); + for ( ; it.current(); ++it ) { + KABC::Resource *res = it.current(); + removeResource(res); + } } + |