summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 86dc7c2..17b9ba2 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -549,28 +549,27 @@ void AddressBook::removeAddressee( const Addressee &a )
549 549
550 if ( found ) 550 if ( found )
551 removeAddressee( it2 ); 551 removeAddressee( it2 );
552 552
553} 553}
554 554
555void AddressBook::removeDeletedAddressees() 555void AddressBook::removeSyncAddressees( bool removeDeleted )
556{ 556{
557 deleteRemovedAddressees();
558 Iterator it = begin(); 557 Iterator it = begin();
559 Iterator it2 ; 558 Iterator it2 ;
560 QDateTime dt ( QDate( 2004,1,1) ); 559 QDateTime dt ( QDate( 2004,1,1) );
561 while ( it != end() ) { 560 while ( it != end() ) {
562 (*it).setRevision( dt ); 561 (*it).setRevision( dt );
563 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 562 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
564 (*it).setIDStr(""); 563 (*it).setIDStr("");
565 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 564 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
566 it2 = it; 565 it2 = it;
567 //qDebug("removing %s ",(*it).uid().latin1() ); 566 //qDebug("removing %s ",(*it).uid().latin1() );
568 ++it; 567 ++it;
569 removeAddressee( it2 ); 568 removeAddressee( it2 );
570 } else { 569 } else {
571 //qDebug("skipping %s ",(*it).uid().latin1() ); 570 //qDebug("skipping %s ",(*it).uid().latin1() );
572 ++it; 571 ++it;
573 } 572 }
574 } 573 }
575 deleteRemovedAddressees(); 574 deleteRemovedAddressees();
576} 575}
@@ -614,29 +613,38 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
614} 613}
615void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 614void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
616{ 615{
617 qDebug("AddressBook::postExternSync "); 616 qDebug("AddressBook::postExternSync ");
618 AddressBook::Iterator it; 617 AddressBook::Iterator it;
619 for ( it = begin(); it != end(); ++it ) { 618 for ( it = begin(); it != end(); ++it ) {
619 qDebug("check uid %s ", (*it).uid().latin1() );
620 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 620 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
621 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 621 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
622 Addressee ad = aBook->findByUid( ( (*it).uid() )); 622 Addressee ad = aBook->findByUid( ( (*it).uid() ));
623 if ( ad.isEmpty() ) { 623 if ( ad.isEmpty() ) {
624 qDebug("ERROR ad empty "); 624 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
625 } else { 625 } else {
626 (*it).computeCsum( csd ); 626 (*it).computeCsum( csd );
627 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 627 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
628 ad.setID( csd, (*it).externalUID() ); 628 ad.setID( csd, (*it).externalUID() );
629 ad.setCsum( csd, (*it).getCsum( csd ) ); 629 ad.setCsum( csd, (*it).getCsum( csd ) );
630 aBook->insertAddressee( ad ); 630 aBook->insertAddressee( ad );
631 } 631 }
632 } 632 }
633 } 633 }
634} 634}
635 635
636 636bool AddressBook::containsExternalUid( const QString& uid )
637{
638 Iterator it;
639 for ( it = begin(); it != end(); ++it ) {
640 if ( uid == (*it).externalUID( ) )
641 return true;
642 }
643 return false;
644}
637Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 645Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
638{ 646{
639 Iterator it; 647 Iterator it;
640 for ( it = begin(); it != end(); ++it ) { 648 for ( it = begin(); it != end(); ++it ) {
641 if ( uid == (*it).getID( profile ) ) 649 if ( uid == (*it).getID( profile ) )
642 return (*it); 650 return (*it);
@@ -650,12 +658,19 @@ void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
650 for ( it = begin(); it != end(); ++it ) { 658 for ( it = begin(); it != end(); ++it ) {
651 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 659 ad = aBook->findByExternUid( (*it).externalUID(), profile );
652 if ( !ad.isEmpty() ) { 660 if ( !ad.isEmpty() ) {
653 (*it).mergeContact( ad ); 661 (*it).mergeContact( ad );
654 } 662 }
655 } 663 }
664#if 0
665 // test only
666 for ( it = begin(); it != end(); ++it ) {
667
668 qDebug("uid %s ", (*it).uid().latin1());
669 }
670#endif
656} 671}
657 672
658#if 0 673#if 0
659Addressee::List AddressBook::getExternLastSyncAddressees() 674Addressee::List AddressBook::getExternLastSyncAddressees()
660{ 675{
661 Addressee::List results; 676 Addressee::List results;