author | ulf69 <ulf69> | 2004-08-03 20:49:15 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-03 20:49:15 (UTC) |
commit | be52d7d03e57620919b23cb0cbb33ac22d0920e0 (patch) (side-by-side diff) | |
tree | 34e8e29a221c828424126694f865d702c7635f97 /kabc/plugins/sharpdtm | |
parent | d5358380edce9a2c39f3eea4df741a148338880c (diff) | |
download | kdepimpi-be52d7d03e57620919b23cb0cbb33ac22d0920e0.zip kdepimpi-be52d7d03e57620919b23cb0cbb33ac22d0920e0.tar.gz kdepimpi-be52d7d03e57620919b23cb0cbb33ac22d0920e0.tar.bz2 |
hopefully last modifications of resource based export/import functionality
for opie, qtopia and sharpdtm
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 30 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.h | 10 |
2 files changed, 6 insertions, 34 deletions
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 @@ -236,33 +236,38 @@ bool ResourceSharpDTM::save( Ticket *ticket ) return true; } bool ResourceSharpDTM::lock( const QString &lockfileName ) { qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; QString fn = lockfileName; KURL url(fn); QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 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; lockUniqueName = fn + KApplication::randomString( 8 ); url = lockUniqueName; //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; // Create unique file QFile file( mLockUniqueName ); file.open( IO_WriteOnly ); file.close(); // Create lock file int result = 0; @@ -315,41 +320,18 @@ void ResourceSharpDTM::fileChanged() QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { load(); addressBook()->emitAddressBookChanged(); } } void ResourceSharpDTM::removeAddressee( const Addressee &addr ) { } void ResourceSharpDTM::cleanUp() { unlock( fileName() ); } -/** - * 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 @@ -109,42 +109,32 @@ public: * Remove a addressee from its source. * This method is mainly called by KABC::AddressBook. */ virtual void removeAddressee( const Addressee& addr ); /** * Set name of file to be used for saving. */ virtual void setFileName( const QString & ); /** * 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(); - protected slots: void fileChanged(); protected: void init( const QString &fileName ); bool lock( const QString &fileName ); void unlock( const QString &fileName ); private: SlZDataBase* mAccess; SharpDTMConverter* mConverter; QString mLockUniqueName; |