summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
authorzautrix <zautrix>2004-09-11 23:25:03 (UTC)
committer zautrix <zautrix>2004-09-11 23:25:03 (UTC)
commit0a2900e71fd3d80393d67c81aab3aae19d2d680c (patch) (side-by-side diff)
tree1f2926eca6bee600819932603eaaf28c7f267d6b /kabc/plugins/sharpdtm/resourcesharpdtm.cpp
parenta040c9d56282dae396b02627fafb602e44323837 (diff)
downloadkdepimpi-0a2900e71fd3d80393d67c81aab3aae19d2d680c.zip
kdepimpi-0a2900e71fd3d80393d67c81aab3aae19d2d680c.tar.gz
kdepimpi-0a2900e71fd3d80393d67c81aab3aae19d2d680c.tar.bz2
Bugfixes
Diffstat (limited to 'kabc/plugins/sharpdtm/resourcesharpdtm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp15
1 files changed, 11 insertions, 4 deletions
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
@@ -45,25 +45,25 @@ $Id$
#include <sl/slzdb.h>
#include "resourcesharpdtmconfig.h"
#include "resourcesharpdtm.h"
#include "syncprefwidget.h"
#include "stdaddressbook.h"
#include "sharpdtmconverter.h"
-
+//#define ALLOW_LOCKING
using namespace KABC;
extern "C"
{
void *init_microkabc_sharpdtm()
{
return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>();
}
}
ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable )
: Resource( config, syncable ), mConverter (0)
{
@@ -96,35 +96,36 @@ ResourceSharpDTM::~ResourceSharpDTM()
if(mAccess != 0)
delete mAccess;
}
void ResourceSharpDTM::writeConfig( KConfig *config )
{
Resource::writeConfig( 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 );
}
bool ResourceSharpDTM::doOpen()
{
qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1());
// the last parameter in the SlZDataBase constructor means "readonly"
mAccess = new SlZDataBase(fileName(),
SlZDataBase::addressbookItems(),
NULL, true);
@@ -231,24 +232,25 @@ bool ResourceSharpDTM::save( Ticket *ticket )
//US mAccess->save();
mDirWatch.startScan();
delete ticket;
unlock( fileName() );
return true;
}
bool ResourceSharpDTM::lock( const QString &lockfileName )
{
+#ifdef ALLOW_LOCKING
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 ))
@@ -276,37 +278,42 @@ bool ResourceSharpDTM::lock( const QString &lockfileName )
#ifndef _WIN32_
result = ::link( QFile::encodeName( mLockUniqueName ),
QFile::encodeName( lockName ) );
#endif
if ( result == 0 ) {
addressBook()->emitAddressBookLocked();
return true;
}
// 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;
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
QFile::remove( lockName );
QFile::remove( mLockUniqueName );
addressBook()->emitAddressBookUnlocked();
+#endif
}
void ResourceSharpDTM::setFileName( const QString &newFileName )
{
mDirWatch.stopScan();
mDirWatch.removeFile( fileName() );
Resource::setFileName( newFileName );
mDirWatch.addFile( fileName() );
mDirWatch.startScan();