summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
Unidiff
Diffstat (limited to 'kabc/plugins/sharpdtm/resourcesharpdtm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 14f272d..70c3718 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -240,25 +240,30 @@ bool ResourceSharpDTM::lock( const QString &lockfileName )
240{ 240{
241 qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); 241 qDebug("ResourceSharpDTM::lock: %s", fileName().latin1());
242 242
243 kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; 243 kdDebug(5700) << "ResourceSharpDTM::lock()" << endl;
244 244
245 QString fn = lockfileName; 245 QString fn = lockfileName;
246 246
247 KURL url(fn); 247 KURL url(fn);
248 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 248 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
249 249
250 kdDebug(5700) << "-- lock name: " << lockName << endl; 250 kdDebug(5700) << "-- lock name: " << lockName << endl;
251 251
252 if (QFile::exists( lockName )) return false; 252 if (QFile::exists( lockName ))
253 {
254 qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName());
255 return false;
256 }
257
253 258
254 QString lockUniqueName; 259 QString lockUniqueName;
255 lockUniqueName = fn + KApplication::randomString( 8 ); 260 lockUniqueName = fn + KApplication::randomString( 8 );
256 261
257 url = lockUniqueName; 262 url = lockUniqueName;
258//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 263//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
259 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 264 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
260 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 265 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
261 266
262 // Create unique file 267 // Create unique file
263 QFile file( mLockUniqueName ); 268 QFile file( mLockUniqueName );
264 file.open( IO_WriteOnly ); 269 file.open( IO_WriteOnly );
@@ -319,37 +324,14 @@ void ResourceSharpDTM::fileChanged()
319 } 324 }
320} 325}
321 326
322void ResourceSharpDTM::removeAddressee( const Addressee &addr ) 327void ResourceSharpDTM::removeAddressee( const Addressee &addr )
323{ 328{
324} 329}
325 330
326void ResourceSharpDTM::cleanUp() 331void ResourceSharpDTM::cleanUp()
327{ 332{
328 unlock( fileName() ); 333 unlock( fileName() );
329} 334}
330 335
331/**
332 * This method returns the number of elements that are currently in the resource.
333 */
334int ResourceSharpDTM::count() const
335{
336 if (mAccess != 0)
337 return mAccess->count();
338 else
339 return 0;
340}
341
342
343/**
344 * This method removes all elements from the resource!! (Not from the addressbook)
345 */
346bool ResourceSharpDTM::clear()
347{
348 if (mAccess != 0)
349 return mAccess->deleteCard(0, SlZDataBase::AllCard );
350 else
351 return false;
352}
353
354 336
355 337