summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia/resourceqtopia.cpp
Unidiff
Diffstat (limited to 'kabc/plugins/qtopia/resourceqtopia.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp49
1 files changed, 5 insertions, 44 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 4a35f19..242e0c6 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -230,13 +230,17 @@ bool ResourceQtopia::lock( const QString &lockfileName )
230 230
231 KURL url(fn); 231 KURL url(fn);
232 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 232 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
233 233
234 kdDebug(5700) << "-- lock name: " << lockName << endl; 234 kdDebug(5700) << "-- lock name: " << lockName << endl;
235 235
236 if (QFile::exists( lockName )) return false; 236 if (QFile::exists( lockName ))
237 {
238 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName());
239 return false;
240 }
237 241
238 QString lockUniqueName; 242 QString lockUniqueName;
239 lockUniqueName = fn + KApplication::randomString( 8 ); 243 lockUniqueName = fn + KApplication::randomString( 8 );
240 244
241 url = lockUniqueName; 245 url = lockUniqueName;
242//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 246//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
@@ -309,50 +313,7 @@ void ResourceQtopia::removeAddressee( const Addressee &addr )
309 313
310void ResourceQtopia::cleanUp() 314void ResourceQtopia::cleanUp()
311{ 315{
312 unlock( fileName() ); 316 unlock( fileName() );
313} 317}
314 318
315
316
317/**
318 * This method returns the number of elements that are currently in the resource.
319 */
320int ResourceQtopia::count() const
321{
322 if (mAccess != 0)
323 {
324 int counter = 0;
325 AddressBookIterator it2(*mAccess);
326 for (it2.toFirst(); it2.current(); ++it2) {
327 counter++;
328 }
329
330 return counter;
331 }
332 else
333 return 0;
334}
335
336
337/**
338 * This method removes all elements from the resource!! (Not from the addressbook)
339 */
340bool ResourceQtopia::clear()
341{
342 if (mAccess != 0)
343 {
344 AddressBookIterator it2(*mAccess);
345 for (it2.toFirst(); it2.current(); ++it2) {
346 mAccess->removeContact(*it2.current());
347 }
348 return true;
349 }
350 else
351 return false;
352}
353
354
355
356
357
358//US #include "resourceqtopia.moc" 319//US #include "resourceqtopia.moc"