summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-08-03 20:49:15 (UTC)
committer ulf69 <ulf69>2004-08-03 20:49:15 (UTC)
commitbe52d7d03e57620919b23cb0cbb33ac22d0920e0 (patch) (unidiff)
tree34e8e29a221c828424126694f865d702c7635f97 /kabc
parentd5358380edce9a2c39f3eea4df741a148338880c (diff)
downloadkdepimpi-be52d7d03e57620919b23cb0cbb33ac22d0920e0.zip
kdepimpi-be52d7d03e57620919b23cb0cbb33ac22d0920e0.tar.gz
kdepimpi-be52d7d03e57620919b23cb0cbb33ac22d0920e0.tar.bz2
hopefully last modifications of resource based export/import functionality
for opie, qtopia and sharpdtm
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/opie/resourceopie.cpp39
-rw-r--r--kabc/plugins/opie/resourceopie.h10
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp49
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.h10
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp30
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.h10
-rw-r--r--kabc/resource.cpp15
-rw-r--r--kabc/resource.h11
-rw-r--r--kabc/tmpaddressbook.cpp14
9 files changed, 30 insertions, 158 deletions
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 5559827..9dfd473 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -87,6 +87,7 @@ ResourceOpie::ResourceOpie( const QString &fileName, bool syncable )
87 87
88void ResourceOpie::init( const QString &fileName ) 88void ResourceOpie::init( const QString &fileName )
89{ 89{
90 qDebug("ResourceOpie::init()");
90 91
91 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 92 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
92 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 93 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
@@ -254,7 +255,11 @@ bool ResourceOpie::lock( const QString &lockfileName )
254 255
255 kdDebug(5700) << "-- lock name: " << lockName << endl; 256 kdDebug(5700) << "-- lock name: " << lockName << endl;
256 257
257 if (QFile::exists( lockName )) return false; 258 if (QFile::exists( lockName ))
259 {
260 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1());
261 return false;
262 }
258 263
259 QString lockUniqueName; 264 QString lockUniqueName;
260 lockUniqueName = fn + KApplication::randomString( 8 ); 265 lockUniqueName = fn + KApplication::randomString( 8 );
@@ -340,36 +345,4 @@ void ResourceOpie::cleanUp()
340} 345}
341 346
342 347
343/**
344 * This method returns the number of elements that are currently in the resource.
345 */
346int ResourceOpie::count() const
347{
348 qDebug("ResourceOpie::count: %x", mAccess);
349
350 if (mAccess != 0)
351 {
352 OContactAccess::List contactList = mAccess->allRecords();
353 return contactList.count();
354 }
355 else
356 return 0;
357}
358
359
360/**
361 * This method removes all elements from the resource!! (Not from the addressbook)
362 */
363bool ResourceOpie::clear()
364{
365 if (mAccess != 0) {
366 mAccess->clear();
367 return true;
368 }
369 else
370 return false;
371}
372
373
374
375//US #include "resourceopie.moc" 348//US #include "resourceopie.moc"
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h
index ca30fee..d5b4ebd 100644
--- a/kabc/plugins/opie/resourceopie.h
+++ b/kabc/plugins/opie/resourceopie.h
@@ -122,16 +122,6 @@ public:
122 */ 122 */
123 virtual void cleanUp(); 123 virtual void cleanUp();
124 124
125 /**
126 * This method returns the number of elements that are currently in the resource.
127 */
128 virtual int count() const;
129
130 /**
131 * This method removes all elements from the resource!! (Not from the addressbook)
132 */
133 virtual bool clear();
134
135 125
136protected slots: 126protected slots:
137 void fileChanged(); 127 void fileChanged();
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
@@ -233,7 +233,11 @@ bool ResourceQtopia::lock( const QString &lockfileName )
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 );
@@ -312,47 +316,4 @@ void ResourceQtopia::cleanUp()
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"
diff --git a/kabc/plugins/qtopia/resourceqtopia.h b/kabc/plugins/qtopia/resourceqtopia.h
index 90ab1f4..eace280 100644
--- a/kabc/plugins/qtopia/resourceqtopia.h
+++ b/kabc/plugins/qtopia/resourceqtopia.h
@@ -122,16 +122,6 @@ public:
122 */ 122 */
123 virtual void cleanUp(); 123 virtual void cleanUp();
124 124
125 /**
126 * This method returns the number of elements that are currently in the resource.
127 */
128 virtual int count() const;
129
130 /**
131 * This method removes all elements from the resource!! (Not from the addressbook)
132 */
133 virtual bool clear();
134
135protected slots: 125protected slots:
136 void fileChanged(); 126 void fileChanged();
137 127
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
@@ -249,7 +249,12 @@ bool ResourceSharpDTM::lock( const QString &lockfileName )
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 );
@@ -328,28 +333,5 @@ void ResourceSharpDTM::cleanUp()
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
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.h b/kabc/plugins/sharpdtm/resourcesharpdtm.h
index 60d38a1..f386e69 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.h
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.h
@@ -122,16 +122,6 @@ public:
122 */ 122 */
123 virtual void cleanUp(); 123 virtual void cleanUp();
124 124
125 /**
126 * This method returns the number of elements that are currently in the resource.
127 */
128 virtual int count() const;
129
130 /**
131 * This method removes all elements from the resource!! (Not from the addressbook)
132 */
133 virtual bool clear();
134
135 125
136protected slots: 126protected slots:
137 void fileChanged(); 127 void fileChanged();
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
index 9632a3f..2f03927 100644
--- a/kabc/resource.cpp
+++ b/kabc/resource.cpp
@@ -113,21 +113,6 @@ bool Resource::isSyncable() const
113 return (mSyncProfile != 0); 113 return (mSyncProfile != 0);
114} 114}
115 115
116/**
117 * This method returns the number of elements that are currently in the resource.
118 */
119int Resource::count() const
120{
121 return 0;
122}
123
124/**
125 * This method removes all elements from the resource!! (Not from the addressbook)
126 */
127bool Resource::clear()
128{
129 return false;
130}
131 116
132QString Resource::fileName() const 117QString Resource::fileName() const
133{ 118{
diff --git a/kabc/resource.h b/kabc/resource.h
index db806a6..7d42f81 100644
--- a/kabc/resource.h
+++ b/kabc/resource.h
@@ -129,17 +129,6 @@ public:
129 */ 129 */
130 virtual void cleanUp(); 130 virtual void cleanUp();
131 131
132
133 /**
134 * This method returns the number of elements that are currently in the resource.
135 */
136 virtual int count() const;
137
138 /**
139 * This method removes all elements from the resource!! (Not from the addressbook)
140 */
141 virtual bool clear();
142
143 /** 132 /**
144 * Set name of file to be used for saving. 133 * Set name of file to be used for saving.
145 */ 134 */
diff --git a/kabc/tmpaddressbook.cpp b/kabc/tmpaddressbook.cpp
index e6699df..ca47ca4 100644
--- a/kabc/tmpaddressbook.cpp
+++ b/kabc/tmpaddressbook.cpp
@@ -24,21 +24,33 @@ Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27#include <qptrlist.h>
27 28
28#include "tmpaddressbook.h" 29#include "tmpaddressbook.h"
29 30
30using namespace KABC; 31using namespace KABC;
31 32
33#include "resource.h"
34
32TmpAddressBook::TmpAddressBook() 35TmpAddressBook::TmpAddressBook()
33 : AddressBook(0, "tmpcontact") 36 : AddressBook(0, "tmpcontact")
34{ 37{
35} 38}
36 39
37TmpAddressBook::TmpAddressBook( const QString &config ) 40TmpAddressBook::TmpAddressBook( const QString &config )
38 : AddressBook( config, "tmpcontact" ) 41 : AddressBook( config, "tmpcontract" )
39{ 42{
40} 43}
41 44
42TmpAddressBook::~TmpAddressBook() 45TmpAddressBook::~TmpAddressBook()
43{ 46{
47 //remove all possible resources. This should cleanup the configfile.
48 QPtrList<KABC::Resource> mResources = resources();
49
50 QPtrListIterator<KABC::Resource> it(mResources);
51 for ( ; it.current(); ++it ) {
52 KABC::Resource *res = it.current();
53 removeResource(res);
54 }
44} 55}
56