From b01b669d88fa195261d29ecf73b1c69e608a5ebc Mon Sep 17 00:00:00 2001 From: zautrix Date: Mon, 20 Sep 2004 00:12:42 +0000 Subject: more AB sync --- (limited to 'kabc/addressbook.cpp') diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 86dc7c2..17b9ba2 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -552,9 +552,8 @@ void AddressBook::removeAddressee( const Addressee &a ) } -void AddressBook::removeDeletedAddressees() +void AddressBook::removeSyncAddressees( bool removeDeleted ) { - deleteRemovedAddressees(); Iterator it = begin(); Iterator it2 ; QDateTime dt ( QDate( 2004,1,1) ); @@ -562,12 +561,12 @@ void AddressBook::removeDeletedAddressees() (*it).setRevision( dt ); (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); (*it).setIDStr(""); - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { + if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { it2 = it; //qDebug("removing %s ",(*it).uid().latin1() ); ++it; removeAddressee( it2 ); - } else { + } else { //qDebug("skipping %s ",(*it).uid().latin1() ); ++it; } @@ -617,11 +616,12 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) qDebug("AddressBook::postExternSync "); AddressBook::Iterator it; for ( it = begin(); it != end(); ++it ) { + qDebug("check uid %s ", (*it).uid().latin1() ); if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { Addressee ad = aBook->findByUid( ( (*it).uid() )); if ( ad.isEmpty() ) { - qDebug("ERROR ad empty "); + qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); } else { (*it).computeCsum( csd ); if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) @@ -633,7 +633,15 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) } } - +bool AddressBook::containsExternalUid( const QString& uid ) +{ + Iterator it; + for ( it = begin(); it != end(); ++it ) { + if ( uid == (*it).externalUID( ) ) + return true; + } + return false; +} Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) { Iterator it; @@ -653,6 +661,13 @@ void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) (*it).mergeContact( ad ); } } +#if 0 + // test only + for ( it = begin(); it != end(); ++it ) { + + qDebug("uid %s ", (*it).uid().latin1()); + } +#endif } #if 0 -- cgit v0.9.0.2