From 0a2900e71fd3d80393d67c81aab3aae19d2d680c Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 11 Sep 2004 23:25:03 +0000 Subject: Bugfixes --- 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 ) diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index fa6bc49..17263ae 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp @@ -53,6 +53,7 @@ $Id$ #include "resourcefile.h" #include "syncprefwidget.h" +//#define ALLOW_LOCKING using namespace KABC; @@ -147,11 +148,12 @@ Ticket *ResourceFile::requestSaveTicket() if ( !addressBook() ) return 0; +#ifdef ALLOW_LOCKING if ( !lock( mFileName ) ) { - kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" - << mFileName << "'" << endl; + qDebug("unablt to lock file "); return 0; } +#endif return createTicket( this ); } @@ -246,13 +248,16 @@ bool ResourceFile::save( Ticket *ticket ) mDirWatch.startScan(); delete ticket; +#ifdef ALLOW_LOCKING unlock( mFileName ); +#endif return ok; } bool ResourceFile::lock( const QString &fileName ) { +#ifdef ALLOW_LOCKING QString fn = fileName; @@ -295,10 +300,14 @@ bool ResourceFile::lock( const QString &fileName ) // TODO: check stat return false; +#else + return true; +#endif } void ResourceFile::unlock( const QString &fileName ) { +#ifdef ALLOW_LOCKING QString fn = fileName; //US change the implementation how the lockfilename is getting created //US fn.replace( QRegExp( "/" ), "_" ); @@ -310,6 +319,9 @@ void ResourceFile::unlock( const QString &fileName ) QFile::remove( lockName ); QFile::remove( mLockUniqueName ); addressBook()->emitAddressBookUnlocked(); +#else + return; +#endif } void ResourceFile::setFileName( const QString &fileName ) diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 8a795e9..867bc07 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp @@ -54,7 +54,7 @@ $Id$ #include "stdaddressbook.h" #include "sharpdtmconverter.h" - +//#define ALLOW_LOCKING using namespace KABC; extern "C" { @@ -105,17 +105,18 @@ void ResourceSharpDTM::writeConfig( KConfig *config ) Ticket *ResourceSharpDTM::requestSaveTicket() { - kdDebug(5700) << "ResourceSharpDTM::requestSaveTicket()" << endl; + qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); if ( !addressBook() ) return 0; +#ifdef ALLOW_LOCKING if ( !lock( fileName() ) ) { - kdDebug(5700) << "ResourceSharpDTM::requestSaveTicket(): Unable to lock file '" - << fileName() << "'" << endl; + qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); return 0; } +#endif return createTicket( this ); } @@ -240,6 +241,7 @@ bool ResourceSharpDTM::save( Ticket *ticket ) bool ResourceSharpDTM::lock( const QString &lockfileName ) { +#ifdef ALLOW_LOCKING qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; @@ -285,10 +287,14 @@ bool ResourceSharpDTM::lock( const QString &lockfileName ) // TODO: check stat return false; +#else + return true; +#endif } void ResourceSharpDTM::unlock( const QString &fileName ) { +#ifdef ALLOW_LOCKING qDebug("ResourceSharpDTM::unlock() %s", fileName.latin1()); QString fn = fileName; @@ -298,6 +304,7 @@ void ResourceSharpDTM::unlock( const QString &fileName ) QFile::remove( lockName ); QFile::remove( mLockUniqueName ); addressBook()->emitAddressBookUnlocked(); +#endif } void ResourceSharpDTM::setFileName( const QString &newFileName ) diff --git a/kmicromail/accountitem.h b/kmicromail/accountitem.h index faf919d..4c92bfc 100644 --- a/kmicromail/accountitem.h +++ b/kmicromail/accountitem.h @@ -1,9 +1,11 @@ #ifndef __ACCOUNT_ITEM #define __ACCOUNT_ITEM + #include #include #include +#include class POP3wrapper; class RecMail; -- cgit v0.9.0.2