summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp15
-rw-r--r--kabc/addressbook.h3
2 files changed, 13 insertions, 5 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 9332e21..6e8d027 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -436,201 +436,208 @@ Ticket *AddressBook::requestSaveTicket( Resource *resource )
436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
437 if ( (*it) == resource ) { 437 if ( (*it) == resource ) {
438 if ( (*it)->readOnly() || !(*it)->isOpen() ) 438 if ( (*it)->readOnly() || !(*it)->isOpen() )
439 return 0; 439 return 0;
440 else 440 else
441 return (*it)->requestSaveTicket(); 441 return (*it)->requestSaveTicket();
442 } 442 }
443 } 443 }
444 444
445 return 0; 445 return 0;
446} 446}
447 447
448void AddressBook::insertAddressee( const Addressee &a ) 448void AddressBook::insertAddressee( const Addressee &a )
449{ 449{
450 Addressee::List::Iterator it; 450 Addressee::List::Iterator it;
451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
452 if ( a.uid() == (*it).uid() ) { 452 if ( a.uid() == (*it).uid() ) {
453 bool changed = false; 453 bool changed = false;
454 Addressee addr = a; 454 Addressee addr = a;
455 if ( addr != (*it) ) 455 if ( addr != (*it) )
456 changed = true; 456 changed = true;
457 457
458 (*it) = a; 458 (*it) = a;
459 if ( (*it).resource() == 0 ) 459 if ( (*it).resource() == 0 )
460 (*it).setResource( standardResource() ); 460 (*it).setResource( standardResource() );
461 461
462 if ( changed ) { 462 if ( changed ) {
463 (*it).setRevision( QDateTime::currentDateTime() ); 463 (*it).setRevision( QDateTime::currentDateTime() );
464 (*it).setChanged( true ); 464 (*it).setChanged( true );
465 } 465 }
466 466
467 return; 467 return;
468 } 468 }
469 } 469 }
470 d->mAddressees.append( a ); 470 d->mAddressees.append( a );
471 Addressee& addr = d->mAddressees.last(); 471 Addressee& addr = d->mAddressees.last();
472 if ( addr.resource() == 0 ) 472 if ( addr.resource() == 0 )
473 addr.setResource( standardResource() ); 473 addr.setResource( standardResource() );
474 474
475 addr.setChanged( true ); 475 addr.setChanged( true );
476} 476}
477 477
478void AddressBook::removeAddressee( const Addressee &a ) 478void AddressBook::removeAddressee( const Addressee &a )
479{ 479{
480 Iterator it; 480 Iterator it;
481 for ( it = begin(); it != end(); ++it ) { 481 for ( it = begin(); it != end(); ++it ) {
482 if ( a.uid() == (*it).uid() ) { 482 if ( a.uid() == (*it).uid() ) {
483 removeAddressee( it ); 483 removeAddressee( it );
484 return; 484 return;
485 } 485 }
486 } 486 }
487} 487}
488 488
489void AddressBook::removeAddressee( const Iterator &it ) 489void AddressBook::removeAddressee( const Iterator &it )
490{ 490{
491 d->mRemovedAddressees.append( (*it) ); 491 d->mRemovedAddressees.append( (*it) );
492 d->mAddressees.remove( it.d->mIt ); 492 d->mAddressees.remove( it.d->mIt );
493} 493}
494 494
495AddressBook::Iterator AddressBook::find( const Addressee &a ) 495AddressBook::Iterator AddressBook::find( const Addressee &a )
496{ 496{
497 Iterator it; 497 Iterator it;
498 for ( it = begin(); it != end(); ++it ) { 498 for ( it = begin(); it != end(); ++it ) {
499 if ( a.uid() == (*it).uid() ) { 499 if ( a.uid() == (*it).uid() ) {
500 return it; 500 return it;
501 } 501 }
502 } 502 }
503 return end(); 503 return end();
504} 504}
505 505
506Addressee AddressBook::findByUid( const QString &uid ) 506Addressee AddressBook::findByUid( const QString &uid )
507{ 507{
508 Iterator it; 508 Iterator it;
509 for ( it = begin(); it != end(); ++it ) { 509 for ( it = begin(); it != end(); ++it ) {
510 if ( uid == (*it).uid() ) { 510 if ( uid == (*it).uid() ) {
511 return *it; 511 return *it;
512 } 512 }
513 } 513 }
514 return Addressee(); 514 return Addressee();
515} 515}
516Addressee::List AddressBook::getExternLastSyncAddressees() 516Addressee::List AddressBook::getExternLastSyncAddressees()
517{ 517{
518 Addressee::List results; 518 Addressee::List results;
519 519
520 Iterator it; 520 Iterator it;
521 for ( it = begin(); it != end(); ++it ) { 521 for ( it = begin(); it != end(); ++it ) {
522 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) { 522 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) {
523 if ( (*it).familyName().left(3) == "E: " ) 523 if ( (*it).familyName().left(3) == "E: " )
524 results.append( *it ); 524 results.append( *it );
525 } 525 }
526 } 526 }
527 527
528 return results; 528 return results;
529} 529}
530void AddressBook::resetTempSyncStat() 530void AddressBook::resetTempSyncStat()
531{ 531{
532 532 Iterator it;
533
534 Iterator it;
535 for ( it = begin(); it != end(); ++it ) { 533 for ( it = begin(); it != end(); ++it ) {
536 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 534 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
537 } 535 }
538 536
539} 537}
540 538
539QStringList AddressBook:: uidList()
540{
541 QStringList results;
542 Iterator it;
543 for ( it = begin(); it != end(); ++it ) {
544 results.append( (*it).uid() );
545 }
546 return results;
547}
541 548
542 549
543Addressee::List AddressBook::allAddressees() 550Addressee::List AddressBook::allAddressees()
544{ 551{
545 return d->mAddressees; 552 return d->mAddressees;
546} 553}
547 554
548Addressee::List AddressBook::findByName( const QString &name ) 555Addressee::List AddressBook::findByName( const QString &name )
549{ 556{
550 Addressee::List results; 557 Addressee::List results;
551 558
552 Iterator it; 559 Iterator it;
553 for ( it = begin(); it != end(); ++it ) { 560 for ( it = begin(); it != end(); ++it ) {
554 if ( name == (*it).realName() ) { 561 if ( name == (*it).realName() ) {
555 results.append( *it ); 562 results.append( *it );
556 } 563 }
557 } 564 }
558 565
559 return results; 566 return results;
560} 567}
561 568
562Addressee::List AddressBook::findByEmail( const QString &email ) 569Addressee::List AddressBook::findByEmail( const QString &email )
563{ 570{
564 Addressee::List results; 571 Addressee::List results;
565 QStringList mailList; 572 QStringList mailList;
566 573
567 Iterator it; 574 Iterator it;
568 for ( it = begin(); it != end(); ++it ) { 575 for ( it = begin(); it != end(); ++it ) {
569 mailList = (*it).emails(); 576 mailList = (*it).emails();
570 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 577 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
571 if ( email == (*ite) ) { 578 if ( email == (*ite) ) {
572 results.append( *it ); 579 results.append( *it );
573 } 580 }
574 } 581 }
575 } 582 }
576 583
577 return results; 584 return results;
578} 585}
579 586
580Addressee::List AddressBook::findByCategory( const QString &category ) 587Addressee::List AddressBook::findByCategory( const QString &category )
581{ 588{
582 Addressee::List results; 589 Addressee::List results;
583 590
584 Iterator it; 591 Iterator it;
585 for ( it = begin(); it != end(); ++it ) { 592 for ( it = begin(); it != end(); ++it ) {
586 if ( (*it).hasCategory( category) ) { 593 if ( (*it).hasCategory( category) ) {
587 results.append( *it ); 594 results.append( *it );
588 } 595 }
589 } 596 }
590 597
591 return results; 598 return results;
592} 599}
593 600
594void AddressBook::dump() const 601void AddressBook::dump() const
595{ 602{
596 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 603 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
597 604
598 ConstIterator it; 605 ConstIterator it;
599 for( it = begin(); it != end(); ++it ) { 606 for( it = begin(); it != end(); ++it ) {
600 (*it).dump(); 607 (*it).dump();
601 } 608 }
602 609
603 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 610 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
604} 611}
605 612
606QString AddressBook::identifier() 613QString AddressBook::identifier()
607{ 614{
608 QStringList identifier; 615 QStringList identifier;
609 616
610 617
611 KRES::Manager<Resource>::ActiveIterator it; 618 KRES::Manager<Resource>::ActiveIterator it;
612 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 619 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
613 if ( !(*it)->identifier().isEmpty() ) 620 if ( !(*it)->identifier().isEmpty() )
614 identifier.append( (*it)->identifier() ); 621 identifier.append( (*it)->identifier() );
615 } 622 }
616 623
617 return identifier.join( ":" ); 624 return identifier.join( ":" );
618} 625}
619 626
620Field::List AddressBook::fields( int category ) 627Field::List AddressBook::fields( int category )
621{ 628{
622 if ( d->mAllFields.isEmpty() ) { 629 if ( d->mAllFields.isEmpty() ) {
623 d->mAllFields = Field::allFields(); 630 d->mAllFields = Field::allFields();
624 } 631 }
625 632
626 if ( category == Field::All ) return d->mAllFields; 633 if ( category == Field::All ) return d->mAllFields;
627 634
628 Field::List result; 635 Field::List result;
629 Field::List::ConstIterator it; 636 Field::List::ConstIterator it;
630 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 637 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
631 if ( (*it)->category() & category ) result.append( *it ); 638 if ( (*it)->category() & category ) result.append( *it );
632 } 639 }
633 640
634 return result; 641 return result;
635} 642}
636 643
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 05225f9..650a638 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -197,137 +197,138 @@ class AddressBook : public QObject
197 object, if the address book does not contain an entry with this id. 197 object, if the address book does not contain an entry with this id.
198 */ 198 */
199 Addressee findByUid( const QString & ); 199 Addressee findByUid( const QString & );
200 200
201 201
202 /** 202 /**
203 Returns a list of all addressees in the address book. This list can 203 Returns a list of all addressees in the address book. This list can
204 be sorted with @ref KABC::AddresseeList for example. 204 be sorted with @ref KABC::AddresseeList for example.
205 */ 205 */
206 Addressee::List allAddressees(); 206 Addressee::List allAddressees();
207 207
208 /** 208 /**
209 Find all entries with the specified name in the address book. Returns 209 Find all entries with the specified name in the address book. Returns
210 an empty list, if no entries could be found. 210 an empty list, if no entries could be found.
211 */ 211 */
212 Addressee::List findByName( const QString & ); 212 Addressee::List findByName( const QString & );
213 213
214 /** 214 /**
215 Find all entries with the specified email address in the address book. 215 Find all entries with the specified email address in the address book.
216 Returns an empty list, if no entries could be found. 216 Returns an empty list, if no entries could be found.
217 */ 217 */
218 Addressee::List findByEmail( const QString & ); 218 Addressee::List findByEmail( const QString & );
219 219
220 /** 220 /**
221 Find all entries wich have the specified category in the address book. 221 Find all entries wich have the specified category in the address book.
222 Returns an empty list, if no entries could be found. 222 Returns an empty list, if no entries could be found.
223 */ 223 */
224 Addressee::List findByCategory( const QString & ); 224 Addressee::List findByCategory( const QString & );
225 225
226 /** 226 /**
227 Return a string identifying this addressbook. 227 Return a string identifying this addressbook.
228 */ 228 */
229 virtual QString identifier(); 229 virtual QString identifier();
230 230
231 /** 231 /**
232 Used for debug output. 232 Used for debug output.
233 */ 233 */
234 void dump() const; 234 void dump() const;
235 235
236 void emitAddressBookLocked() { emit addressBookLocked( this ); } 236 void emitAddressBookLocked() { emit addressBookLocked( this ); }
237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
238 void emitAddressBookChanged() { emit addressBookChanged( this ); } 238 void emitAddressBookChanged() { emit addressBookChanged( this ); }
239 239
240 /** 240 /**
241 Return list of all Fields known to the address book which are associated 241 Return list of all Fields known to the address book which are associated
242 with the given field category. 242 with the given field category.
243 */ 243 */
244 Field::List fields( int category = Field::All ); 244 Field::List fields( int category = Field::All );
245 245
246 /** 246 /**
247 Add custom field to address book. 247 Add custom field to address book.
248 248
249 @param label User visible label of the field. 249 @param label User visible label of the field.
250 @param category Ored list of field categories. 250 @param category Ored list of field categories.
251 @param key Identifier used as key for reading and writing the field. 251 @param key Identifier used as key for reading and writing the field.
252 @param app String used as application key for reading and writing 252 @param app String used as application key for reading and writing
253 the field. 253 the field.
254 */ 254 */
255 bool addCustomField( const QString &label, int category = Field::All, 255 bool addCustomField( const QString &label, int category = Field::All,
256 const QString &key = QString::null, 256 const QString &key = QString::null,
257 const QString &app = QString::null ); 257 const QString &app = QString::null );
258 258
259 259
260 /** 260 /**
261 Add address book resource. 261 Add address book resource.
262 */ 262 */
263 bool addResource( Resource * ); 263 bool addResource( Resource * );
264 264
265 /** 265 /**
266 Remove address book resource. 266 Remove address book resource.
267 */ 267 */
268 bool removeResource( Resource * ); 268 bool removeResource( Resource * );
269 269
270 /** 270 /**
271 Return pointer list of all resources. 271 Return pointer list of all resources.
272 */ 272 */
273 QPtrList<Resource> resources(); 273 QPtrList<Resource> resources();
274 274
275 /** 275 /**
276 Set the @p ErrorHandler, that is used by @ref error() to 276 Set the @p ErrorHandler, that is used by @ref error() to
277 provide gui-independend error messages. 277 provide gui-independend error messages.
278 */ 278 */
279 void setErrorHandler( ErrorHandler * ); 279 void setErrorHandler( ErrorHandler * );
280 280
281 /** 281 /**
282 Shows gui independend error messages. 282 Shows gui independend error messages.
283 */ 283 */
284 void error( const QString& ); 284 void error( const QString& );
285 285
286 /** 286 /**
287 Query all resources to clean up their lock files 287 Query all resources to clean up their lock files
288 */ 288 */
289 void cleanUp(); 289 void cleanUp();
290 290
291 // sync stuff 291 // sync stuff
292 Addressee::List getExternLastSyncAddressees(); 292 Addressee::List getExternLastSyncAddressees();
293 void resetTempSyncStat(); 293 void resetTempSyncStat();
294 QStringList uidList();
294 295
295 296
296 signals: 297 signals:
297 /** 298 /**
298 Emitted, when the address book has changed on disk. 299 Emitted, when the address book has changed on disk.
299 */ 300 */
300 void addressBookChanged( AddressBook * ); 301 void addressBookChanged( AddressBook * );
301 302
302 /** 303 /**
303 Emitted, when the address book has been locked for writing. 304 Emitted, when the address book has been locked for writing.
304 */ 305 */
305 void addressBookLocked( AddressBook * ); 306 void addressBookLocked( AddressBook * );
306 307
307 /** 308 /**
308 Emitted, when the address book has been unlocked. 309 Emitted, when the address book has been unlocked.
309 */ 310 */
310 void addressBookUnlocked( AddressBook * ); 311 void addressBookUnlocked( AddressBook * );
311 312
312 protected: 313 protected:
313 void deleteRemovedAddressees(); 314 void deleteRemovedAddressees();
314 void setStandardResource( Resource * ); 315 void setStandardResource( Resource * );
315 Resource *standardResource(); 316 Resource *standardResource();
316 KRES::Manager<Resource> *resourceManager(); 317 KRES::Manager<Resource> *resourceManager();
317 318
318 void init(const QString &config, const QString &family); 319 void init(const QString &config, const QString &family);
319 320
320 private: 321 private:
321//US QPtrList<Resource> mDummy; // Remove in KDE 4 322//US QPtrList<Resource> mDummy; // Remove in KDE 4
322 323
323 324
324 struct AddressBookData; 325 struct AddressBookData;
325 AddressBookData *d; 326 AddressBookData *d;
326}; 327};
327 328
328QDataStream &operator<<( QDataStream &, const AddressBook & ); 329QDataStream &operator<<( QDataStream &, const AddressBook & );
329QDataStream &operator>>( QDataStream &, AddressBook & ); 330QDataStream &operator>>( QDataStream &, AddressBook & );
330 331
331} 332}
332 333
333#endif 334#endif