Diffstat (limited to 'kabc/plugins/dir/resourcedir.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index fac06a1..7d96cb7 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp @@ -59,6 +59,8 @@ $Id$ #include "resourcedir.h" #include "syncprefwidget.h" +//#define ALLOW_LOCKING + using namespace KABC; extern "C" @@ -136,16 +138,17 @@ void ResourceDir::writeConfig( KConfig *config ) Ticket *ResourceDir::requestSaveTicket() { - kdDebug(5700) << "ResourceDir::requestSaveTicket()" << endl; + if ( !addressBook() ) return 0; - +#ifdef ALLOW_LOCKING if ( !lock( mPath ) ) { - kdDebug(5700) << "ResourceDir::requestSaveTicket(): Unable to lock path '" - << mPath << "'" << endl; + return 0; } +#endif return createTicket( this ); + } @@ -178,8 +181,6 @@ void ResourceDir::doClose() bool ResourceDir::load() { - kdDebug(5700) << "ResourceDir::load(): '" << mPath << "'" << endl; - QDir dir( mPath ); QStringList files = dir.entryList( QDir::Files ); @@ -205,8 +206,6 @@ bool ResourceDir::load() bool ResourceDir::save( Ticket *ticket ) { - kdDebug(5700) << "ResourceDir::save(): '" << mPath << "'" << endl; - AddressBook::Iterator it; bool ok = true; @@ -232,15 +231,15 @@ bool ResourceDir::save( Ticket *ticket ) mDirWatch.startScan(); delete ticket; +#ifdef ALLOW_LOCKING unlock( mPath ); - +#endif return ok; } bool ResourceDir::lock( const QString &path ) { - kdDebug(5700) << "ResourceDir::lock()" << endl; - +#ifdef ALLOW_LOCKING QString p = path; //US change the implementation how the lockfilename is getting created //US p.replace( QRegExp("/"), "_" ); @@ -249,8 +248,6 @@ bool ResourceDir::lock( const QString &path ) QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); - kdDebug(5700) << "-- lock name: " << lockName << endl; - if ( QFile::exists( lockName ) ) return false; QString lockUniqueName; @@ -260,8 +257,6 @@ bool ResourceDir::lock( const QString &path ) //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 ); @@ -281,10 +276,14 @@ bool ResourceDir::lock( const QString &path ) // TODO: check stat return false; +#else + return true; +#endif } void ResourceDir::unlock( const QString &path ) { +#ifdef ALLOW_LOCKING QString p = path; //US change the implementation how the lockfilename is getting created //US p.replace( QRegExp( "/" ), "_" ); @@ -295,6 +294,9 @@ void ResourceDir::unlock( const QString &path ) ::unlink( QFile::encodeName( lockName ) ); QFile::remove( mLockUniqueName ); addressBook()->emitAddressBookUnlocked(); +#else + return; +#endif } void ResourceDir::setPath( const QString &path ) |