Diffstat (limited to 'kabc/plugins/file/resourcefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
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$ | |||
53 | #include "resourcefile.h" | 53 | #include "resourcefile.h" |
54 | #include "syncprefwidget.h" | 54 | #include "syncprefwidget.h" |
55 | 55 | ||
56 | //#define ALLOW_LOCKING | ||
56 | 57 | ||
57 | using namespace KABC; | 58 | using namespace KABC; |
58 | 59 | ||
@@ -147,11 +148,12 @@ Ticket *ResourceFile::requestSaveTicket() | |||
147 | 148 | ||
148 | if ( !addressBook() ) return 0; | 149 | if ( !addressBook() ) return 0; |
149 | 150 | ||
151 | #ifdef ALLOW_LOCKING | ||
150 | if ( !lock( mFileName ) ) { | 152 | if ( !lock( mFileName ) ) { |
151 | kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" | 153 | qDebug("unablt to lock file "); |
152 | << mFileName << "'" << endl; | ||
153 | return 0; | 154 | return 0; |
154 | } | 155 | } |
156 | #endif | ||
155 | return createTicket( this ); | 157 | return createTicket( this ); |
156 | } | 158 | } |
157 | 159 | ||
@@ -246,13 +248,16 @@ bool ResourceFile::save( Ticket *ticket ) | |||
246 | mDirWatch.startScan(); | 248 | mDirWatch.startScan(); |
247 | 249 | ||
248 | delete ticket; | 250 | delete ticket; |
251 | #ifdef ALLOW_LOCKING | ||
249 | unlock( mFileName ); | 252 | unlock( mFileName ); |
253 | #endif | ||
250 | 254 | ||
251 | return ok; | 255 | return ok; |
252 | } | 256 | } |
253 | 257 | ||
254 | bool ResourceFile::lock( const QString &fileName ) | 258 | bool ResourceFile::lock( const QString &fileName ) |
255 | { | 259 | { |
260 | #ifdef ALLOW_LOCKING | ||
256 | 261 | ||
257 | 262 | ||
258 | QString fn = fileName; | 263 | QString fn = fileName; |
@@ -295,10 +300,14 @@ bool ResourceFile::lock( const QString &fileName ) | |||
295 | // TODO: check stat | 300 | // TODO: check stat |
296 | 301 | ||
297 | return false; | 302 | return false; |
303 | #else | ||
304 | return true; | ||
305 | #endif | ||
298 | } | 306 | } |
299 | 307 | ||
300 | void ResourceFile::unlock( const QString &fileName ) | 308 | void ResourceFile::unlock( const QString &fileName ) |
301 | { | 309 | { |
310 | #ifdef ALLOW_LOCKING | ||
302 | QString fn = fileName; | 311 | QString fn = fileName; |
303 | //US change the implementation how the lockfilename is getting created | 312 | //US change the implementation how the lockfilename is getting created |
304 | //US fn.replace( QRegExp( "/" ), "_" ); | 313 | //US fn.replace( QRegExp( "/" ), "_" ); |
@@ -310,6 +319,9 @@ void ResourceFile::unlock( const QString &fileName ) | |||
310 | QFile::remove( lockName ); | 319 | QFile::remove( lockName ); |
311 | QFile::remove( mLockUniqueName ); | 320 | QFile::remove( mLockUniqueName ); |
312 | addressBook()->emitAddressBookUnlocked(); | 321 | addressBook()->emitAddressBookUnlocked(); |
322 | #else | ||
323 | return; | ||
324 | #endif | ||
313 | } | 325 | } |
314 | 326 | ||
315 | void ResourceFile::setFileName( const QString &fileName ) | 327 | void ResourceFile::setFileName( const QString &fileName ) |