-rw-r--r-- | kabc/plugins/opie/resourceopie.cpp | 39 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.h | 10 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 49 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.h | 10 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 30 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.h | 10 | ||||
-rw-r--r-- | kabc/resource.cpp | 15 | ||||
-rw-r--r-- | kabc/resource.h | 11 | ||||
-rw-r--r-- | kabc/tmpaddressbook.cpp | 14 |
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 | |||
@@ -74,32 +74,33 @@ ResourceOpie::ResourceOpie( const KConfig *config, bool syncable ) | |||
74 | if ( cfg ) { | 74 | if ( cfg ) { |
75 | fileName = cfg->readEntry( "FileName", fileName ); | 75 | fileName = cfg->readEntry( "FileName", fileName ); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | init( fileName ); | 79 | init( fileName ); |
80 | } | 80 | } |
81 | 81 | ||
82 | ResourceOpie::ResourceOpie( const QString &fileName, bool syncable ) | 82 | ResourceOpie::ResourceOpie( const QString &fileName, bool syncable ) |
83 | : Resource( 0, syncable ) | 83 | : Resource( 0, syncable ) |
84 | { | 84 | { |
85 | init( fileName ); | 85 | init( fileName ); |
86 | } | 86 | } |
87 | 87 | ||
88 | void ResourceOpie::init( const QString &fileName ) | 88 | void 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() ) ); |
93 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 94 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
94 | 95 | ||
95 | setFileName( fileName ); | 96 | setFileName( fileName ); |
96 | } | 97 | } |
97 | 98 | ||
98 | ResourceOpie::~ResourceOpie() | 99 | ResourceOpie::~ResourceOpie() |
99 | { | 100 | { |
100 | if (mConverter != 0) | 101 | if (mConverter != 0) |
101 | delete mConverter; | 102 | delete mConverter; |
102 | 103 | ||
103 | if(mAccess != 0) | 104 | if(mAccess != 0) |
104 | delete mAccess; | 105 | delete mAccess; |
105 | } | 106 | } |
@@ -241,33 +242,37 @@ bool ResourceOpie::save( Ticket *ticket ) | |||
241 | 242 | ||
242 | } | 243 | } |
243 | 244 | ||
244 | bool ResourceOpie::lock( const QString &lockfileName ) | 245 | bool ResourceOpie::lock( const QString &lockfileName ) |
245 | { | 246 | { |
246 | qDebug("ResourceOpie::lock: %s", fileName().latin1()); | 247 | qDebug("ResourceOpie::lock: %s", fileName().latin1()); |
247 | 248 | ||
248 | kdDebug(5700) << "ResourceOpie::lock()" << endl; | 249 | kdDebug(5700) << "ResourceOpie::lock()" << endl; |
249 | 250 | ||
250 | QString fn = lockfileName; | 251 | QString fn = lockfileName; |
251 | 252 | ||
252 | KURL url(fn); | 253 | KURL url(fn); |
253 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 254 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
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 ); |
261 | 266 | ||
262 | url = lockUniqueName; | 267 | url = lockUniqueName; |
263 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | 268 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); |
264 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | 269 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); |
265 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | 270 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; |
266 | 271 | ||
267 | // Create unique file | 272 | // Create unique file |
268 | QFile file( mLockUniqueName ); | 273 | QFile file( mLockUniqueName ); |
269 | file.open( IO_WriteOnly ); | 274 | file.open( IO_WriteOnly ); |
270 | file.close(); | 275 | file.close(); |
271 | 276 | ||
272 | // Create lock file | 277 | // Create lock file |
273 | int result = 0; | 278 | int result = 0; |
@@ -327,49 +332,17 @@ void ResourceOpie::fileChanged() | |||
327 | load(); | 332 | load(); |
328 | addressBook()->emitAddressBookChanged(); | 333 | addressBook()->emitAddressBookChanged(); |
329 | } | 334 | } |
330 | 335 | ||
331 | void ResourceOpie::removeAddressee( const Addressee &addr ) | 336 | void ResourceOpie::removeAddressee( const Addressee &addr ) |
332 | { | 337 | { |
333 | } | 338 | } |
334 | 339 | ||
335 | void ResourceOpie::cleanUp() | 340 | void ResourceOpie::cleanUp() |
336 | { | 341 | { |
337 | // qDebug("ResourceOpie::cleanup() %s", mFileName.latin1()); | 342 | // qDebug("ResourceOpie::cleanup() %s", mFileName.latin1()); |
338 | 343 | ||
339 | unlock( fileName() ); | 344 | unlock( fileName() ); |
340 | } | 345 | } |
341 | 346 | ||
342 | 347 | ||
343 | /** | ||
344 | * This method returns the number of elements that are currently in the resource. | ||
345 | */ | ||
346 | int 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 | */ | ||
363 | bool 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 | |||
@@ -109,42 +109,32 @@ public: | |||
109 | * Remove a addressee from its source. | 109 | * Remove a addressee from its source. |
110 | * This method is mainly called by KABC::AddressBook. | 110 | * This method is mainly called by KABC::AddressBook. |
111 | */ | 111 | */ |
112 | virtual void removeAddressee( const Addressee& addr ); | 112 | virtual void removeAddressee( const Addressee& addr ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Set name of file to be used for saving. | 115 | * Set name of file to be used for saving. |
116 | */ | 116 | */ |
117 | virtual void setFileName( const QString & ); | 117 | virtual void setFileName( const QString & ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * This method is called by an error handler if the application | 120 | * This method is called by an error handler if the application |
121 | * crashed | 121 | * crashed |
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 | ||
136 | protected slots: | 126 | protected slots: |
137 | void fileChanged(); | 127 | void fileChanged(); |
138 | 128 | ||
139 | protected: | 129 | protected: |
140 | void init( const QString &fileName ); | 130 | void init( const QString &fileName ); |
141 | 131 | ||
142 | bool lock( const QString &fileName ); | 132 | bool lock( const QString &fileName ); |
143 | void unlock( const QString &fileName ); | 133 | void unlock( const QString &fileName ); |
144 | 134 | ||
145 | private: | 135 | private: |
146 | OContactAccess* mAccess; | 136 | OContactAccess* mAccess; |
147 | OpieConverter* mConverter; | 137 | OpieConverter* mConverter; |
148 | 138 | ||
149 | QString mLockUniqueName; | 139 | QString mLockUniqueName; |
150 | 140 | ||
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 | |||
@@ -220,33 +220,37 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
220 | return true; | 220 | return true; |
221 | } | 221 | } |
222 | 222 | ||
223 | bool ResourceQtopia::lock( const QString &lockfileName ) | 223 | bool ResourceQtopia::lock( const QString &lockfileName ) |
224 | { | 224 | { |
225 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); | 225 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); |
226 | 226 | ||
227 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; | 227 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; |
228 | 228 | ||
229 | QString fn = lockfileName; | 229 | QString fn = 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 ); |
243 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | 247 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); |
244 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | 248 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; |
245 | 249 | ||
246 | // Create unique file | 250 | // Create unique file |
247 | QFile file( mLockUniqueName ); | 251 | QFile file( mLockUniqueName ); |
248 | file.open( IO_WriteOnly ); | 252 | file.open( IO_WriteOnly ); |
249 | file.close(); | 253 | file.close(); |
250 | 254 | ||
251 | // Create lock file | 255 | // Create lock file |
252 | int result = 0; | 256 | int result = 0; |
@@ -299,60 +303,17 @@ void ResourceQtopia::fileChanged() | |||
299 | QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); | 303 | QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); |
300 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { | 304 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { |
301 | load(); | 305 | load(); |
302 | addressBook()->emitAddressBookChanged(); | 306 | addressBook()->emitAddressBookChanged(); |
303 | } | 307 | } |
304 | } | 308 | } |
305 | 309 | ||
306 | void ResourceQtopia::removeAddressee( const Addressee &addr ) | 310 | void ResourceQtopia::removeAddressee( const Addressee &addr ) |
307 | { | 311 | { |
308 | } | 312 | } |
309 | 313 | ||
310 | void ResourceQtopia::cleanUp() | 314 | void 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 | */ | ||
320 | int 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 | */ | ||
340 | bool 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 | |||
@@ -109,42 +109,32 @@ public: | |||
109 | * Remove a addressee from its source. | 109 | * Remove a addressee from its source. |
110 | * This method is mainly called by KABC::AddressBook. | 110 | * This method is mainly called by KABC::AddressBook. |
111 | */ | 111 | */ |
112 | virtual void removeAddressee( const Addressee& addr ); | 112 | virtual void removeAddressee( const Addressee& addr ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Set name of file to be used for saving. | 115 | * Set name of file to be used for saving. |
116 | */ | 116 | */ |
117 | virtual void setFileName( const QString & ); | 117 | virtual void setFileName( const QString & ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * This method is called by an error handler if the application | 120 | * This method is called by an error handler if the application |
121 | * crashed | 121 | * crashed |
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 | protected slots: | 125 | protected slots: |
136 | void fileChanged(); | 126 | void fileChanged(); |
137 | 127 | ||
138 | protected: | 128 | protected: |
139 | void init( const QString &fileName ); | 129 | void init( const QString &fileName ); |
140 | 130 | ||
141 | bool lock( const QString &fileName ); | 131 | bool lock( const QString &fileName ); |
142 | void unlock( const QString &fileName ); | 132 | void unlock( const QString &fileName ); |
143 | 133 | ||
144 | private: | 134 | private: |
145 | AddressBookAccess* mAccess; | 135 | AddressBookAccess* mAccess; |
146 | QtopiaConverter* mConverter; | 136 | QtopiaConverter* mConverter; |
147 | 137 | ||
148 | QString mLockUniqueName; | 138 | QString mLockUniqueName; |
149 | 139 | ||
150 | KDirWatch mDirWatch; | 140 | KDirWatch mDirWatch; |
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 | |||
@@ -236,33 +236,38 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
236 | return true; | 236 | return true; |
237 | } | 237 | } |
238 | 238 | ||
239 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 239 | 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 ); |
265 | file.close(); | 270 | file.close(); |
266 | 271 | ||
267 | // Create lock file | 272 | // Create lock file |
268 | int result = 0; | 273 | int result = 0; |
@@ -315,41 +320,18 @@ void ResourceSharpDTM::fileChanged() | |||
315 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); | 320 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); |
316 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { | 321 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { |
317 | load(); | 322 | load(); |
318 | addressBook()->emitAddressBookChanged(); | 323 | addressBook()->emitAddressBookChanged(); |
319 | } | 324 | } |
320 | } | 325 | } |
321 | 326 | ||
322 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) | 327 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) |
323 | { | 328 | { |
324 | } | 329 | } |
325 | 330 | ||
326 | void ResourceSharpDTM::cleanUp() | 331 | void 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 | */ | ||
334 | int 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 | */ | ||
346 | bool 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 | |||
@@ -109,42 +109,32 @@ public: | |||
109 | * Remove a addressee from its source. | 109 | * Remove a addressee from its source. |
110 | * This method is mainly called by KABC::AddressBook. | 110 | * This method is mainly called by KABC::AddressBook. |
111 | */ | 111 | */ |
112 | virtual void removeAddressee( const Addressee& addr ); | 112 | virtual void removeAddressee( const Addressee& addr ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Set name of file to be used for saving. | 115 | * Set name of file to be used for saving. |
116 | */ | 116 | */ |
117 | virtual void setFileName( const QString & ); | 117 | virtual void setFileName( const QString & ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * This method is called by an error handler if the application | 120 | * This method is called by an error handler if the application |
121 | * crashed | 121 | * crashed |
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 | ||
136 | protected slots: | 126 | protected slots: |
137 | void fileChanged(); | 127 | void fileChanged(); |
138 | 128 | ||
139 | protected: | 129 | protected: |
140 | void init( const QString &fileName ); | 130 | void init( const QString &fileName ); |
141 | 131 | ||
142 | bool lock( const QString &fileName ); | 132 | bool lock( const QString &fileName ); |
143 | void unlock( const QString &fileName ); | 133 | void unlock( const QString &fileName ); |
144 | 134 | ||
145 | private: | 135 | private: |
146 | SlZDataBase* mAccess; | 136 | SlZDataBase* mAccess; |
147 | SharpDTMConverter* mConverter; | 137 | SharpDTMConverter* mConverter; |
148 | 138 | ||
149 | QString mLockUniqueName; | 139 | QString mLockUniqueName; |
150 | 140 | ||
diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 9632a3f..2f03927 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp | |||
@@ -100,47 +100,32 @@ Ticket *Resource::createTicket( Resource *resource ) | |||
100 | 100 | ||
101 | void Resource::removeAddressee( const Addressee& ) | 101 | void Resource::removeAddressee( const Addressee& ) |
102 | { | 102 | { |
103 | // do nothing | 103 | // do nothing |
104 | } | 104 | } |
105 | 105 | ||
106 | void Resource::cleanUp() | 106 | void Resource::cleanUp() |
107 | { | 107 | { |
108 | // do nothing | 108 | // do nothing |
109 | } | 109 | } |
110 | 110 | ||
111 | bool Resource::isSyncable() const | 111 | bool Resource::isSyncable() const |
112 | { | 112 | { |
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 | */ | ||
119 | int Resource::count() const | ||
120 | { | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * This method removes all elements from the resource!! (Not from the addressbook) | ||
126 | */ | ||
127 | bool Resource::clear() | ||
128 | { | ||
129 | return false; | ||
130 | } | ||
131 | 116 | ||
132 | QString Resource::fileName() const | 117 | QString Resource::fileName() const |
133 | { | 118 | { |
134 | return mFileName; | 119 | return mFileName; |
135 | } | 120 | } |
136 | 121 | ||
137 | void Resource::setFileName( const QString &fileName ) | 122 | void Resource::setFileName( const QString &fileName ) |
138 | { | 123 | { |
139 | mFileName = fileName; | 124 | mFileName = fileName; |
140 | } | 125 | } |
141 | 126 | ||
142 | /** | 127 | /** |
143 | * Set the name of resource.You can override this method, | 128 | * Set the name of resource.You can override this method, |
144 | * but also remember to call Resource::setResourceName(). | 129 | * but also remember to call Resource::setResourceName(). |
145 | */ | 130 | */ |
146 | void Resource::setResourceName( const QString &name ) | 131 | void Resource::setResourceName( const QString &name ) |
diff --git a/kabc/resource.h b/kabc/resource.h index db806a6..7d42f81 100644 --- a/kabc/resource.h +++ b/kabc/resource.h | |||
@@ -116,43 +116,32 @@ public: | |||
116 | */ | 116 | */ |
117 | virtual bool save( Ticket *ticket ); | 117 | virtual bool save( Ticket *ticket ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Removes a addressee from resource. This method is mainly | 120 | * Removes a addressee from resource. This method is mainly |
121 | * used by record-based resources like LDAP or SQL. | 121 | * used by record-based resources like LDAP or SQL. |
122 | */ | 122 | */ |
123 | virtual void removeAddressee( const Addressee& addr ); | 123 | virtual void removeAddressee( const Addressee& addr ); |
124 | 124 | ||
125 | 125 | ||
126 | /** | 126 | /** |
127 | * This method is called by an error handler if the application | 127 | * This method is called by an error handler if the application |
128 | * crashed | 128 | * crashed |
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 | */ |
146 | virtual void setFileName( const QString & ); | 135 | virtual void setFileName( const QString & ); |
147 | 136 | ||
148 | /** | 137 | /** |
149 | * Return name of file used for loading and saving the address book. | 138 | * Return name of file used for loading and saving the address book. |
150 | */ | 139 | */ |
151 | virtual QString fileName() const; | 140 | virtual QString fileName() const; |
152 | 141 | ||
153 | 142 | ||
154 | virtual bool isSyncable() const; | 143 | virtual bool isSyncable() const; |
155 | 144 | ||
156 | /** | 145 | /** |
157 | * Set the name of resource.You can override this method, | 146 | * Set the name of resource.You can override this method, |
158 | * but also remember to call Resource::setResourceName(). | 147 | * but also remember to call Resource::setResourceName(). |
diff --git a/kabc/tmpaddressbook.cpp b/kabc/tmpaddressbook.cpp index e6699df..ca47ca4 100644 --- a/kabc/tmpaddressbook.cpp +++ b/kabc/tmpaddressbook.cpp | |||
@@ -11,34 +11,46 @@ | |||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | 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 | ||
30 | using namespace KABC; | 31 | using namespace KABC; |
31 | 32 | ||
33 | #include "resource.h" | ||
34 | |||
32 | TmpAddressBook::TmpAddressBook() | 35 | TmpAddressBook::TmpAddressBook() |
33 | : AddressBook(0, "tmpcontact") | 36 | : AddressBook(0, "tmpcontact") |
34 | { | 37 | { |
35 | } | 38 | } |
36 | 39 | ||
37 | TmpAddressBook::TmpAddressBook( const QString &config ) | 40 | TmpAddressBook::TmpAddressBook( const QString &config ) |
38 | : AddressBook( config, "tmpcontact" ) | 41 | : AddressBook( config, "tmpcontract" ) |
39 | { | 42 | { |
40 | } | 43 | } |
41 | 44 | ||
42 | TmpAddressBook::~TmpAddressBook() | 45 | TmpAddressBook::~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 | |||