Diffstat (limited to 'kabc/plugins/sharpdtm/resourcesharpdtm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 15 |
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 | |||
@@ -51,13 +51,13 @@ $Id$ | |||
51 | 51 | ||
52 | #include "syncprefwidget.h" | 52 | #include "syncprefwidget.h" |
53 | 53 | ||
54 | #include "stdaddressbook.h" | 54 | #include "stdaddressbook.h" |
55 | 55 | ||
56 | #include "sharpdtmconverter.h" | 56 | #include "sharpdtmconverter.h" |
57 | 57 | //#define ALLOW_LOCKING | |
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | extern "C" | 59 | extern "C" |
60 | { | 60 | { |
61 | void *init_microkabc_sharpdtm() | 61 | void *init_microkabc_sharpdtm() |
62 | { | 62 | { |
63 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>(); | 63 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>(); |
@@ -102,23 +102,24 @@ void ResourceSharpDTM::writeConfig( KConfig *config ) | |||
102 | { | 102 | { |
103 | Resource::writeConfig( config ); | 103 | Resource::writeConfig( config ); |
104 | } | 104 | } |
105 | 105 | ||
106 | Ticket *ResourceSharpDTM::requestSaveTicket() | 106 | Ticket *ResourceSharpDTM::requestSaveTicket() |
107 | { | 107 | { |
108 | kdDebug(5700) << "ResourceSharpDTM::requestSaveTicket()" << endl; | 108 | |
109 | 109 | ||
110 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); | 110 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); |
111 | 111 | ||
112 | if ( !addressBook() ) return 0; | 112 | if ( !addressBook() ) return 0; |
113 | 113 | ||
114 | #ifdef ALLOW_LOCKING | ||
114 | if ( !lock( fileName() ) ) { | 115 | if ( !lock( fileName() ) ) { |
115 | kdDebug(5700) << "ResourceSharpDTM::requestSaveTicket(): Unable to lock file '" | 116 | qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); |
116 | << fileName() << "'" << endl; | ||
117 | return 0; | 117 | return 0; |
118 | } | 118 | } |
119 | #endif | ||
119 | return createTicket( this ); | 120 | return createTicket( this ); |
120 | } | 121 | } |
121 | 122 | ||
122 | 123 | ||
123 | bool ResourceSharpDTM::doOpen() | 124 | bool ResourceSharpDTM::doOpen() |
124 | { | 125 | { |
@@ -237,12 +238,13 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
237 | 238 | ||
238 | return true; | 239 | return true; |
239 | } | 240 | } |
240 | 241 | ||
241 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 242 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
242 | { | 243 | { |
244 | #ifdef ALLOW_LOCKING | ||
243 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); | 245 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); |
244 | 246 | ||
245 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; | 247 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; |
246 | 248 | ||
247 | QString fn = lockfileName; | 249 | QString fn = lockfileName; |
248 | 250 | ||
@@ -282,25 +284,30 @@ bool ResourceSharpDTM::lock( const QString &lockfileName ) | |||
282 | return true; | 284 | return true; |
283 | } | 285 | } |
284 | 286 | ||
285 | // TODO: check stat | 287 | // TODO: check stat |
286 | 288 | ||
287 | return false; | 289 | return false; |
290 | #else | ||
291 | return true; | ||
292 | #endif | ||
288 | } | 293 | } |
289 | 294 | ||
290 | void ResourceSharpDTM::unlock( const QString &fileName ) | 295 | void ResourceSharpDTM::unlock( const QString &fileName ) |
291 | { | 296 | { |
297 | #ifdef ALLOW_LOCKING | ||
292 | qDebug("ResourceSharpDTM::unlock() %s", fileName.latin1()); | 298 | qDebug("ResourceSharpDTM::unlock() %s", fileName.latin1()); |
293 | 299 | ||
294 | QString fn = fileName; | 300 | QString fn = fileName; |
295 | KURL url(fn); | 301 | KURL url(fn); |
296 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 302 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
297 | 303 | ||
298 | QFile::remove( lockName ); | 304 | QFile::remove( lockName ); |
299 | QFile::remove( mLockUniqueName ); | 305 | QFile::remove( mLockUniqueName ); |
300 | addressBook()->emitAddressBookUnlocked(); | 306 | addressBook()->emitAddressBookUnlocked(); |
307 | #endif | ||
301 | } | 308 | } |
302 | 309 | ||
303 | void ResourceSharpDTM::setFileName( const QString &newFileName ) | 310 | void ResourceSharpDTM::setFileName( const QString &newFileName ) |
304 | { | 311 | { |
305 | mDirWatch.stopScan(); | 312 | mDirWatch.stopScan(); |
306 | mDirWatch.removeFile( fileName() ); | 313 | mDirWatch.removeFile( fileName() ); |