-rw-r--r-- | kabc/addressbook.cpp | 32 | ||||
-rw-r--r-- | kabc/addressbook.h | 3 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 25 |
3 files changed, 37 insertions, 23 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 64832f1..86dc7c2 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -604,2 +604,34 @@ Addressee AddressBook::findByUid( const QString &uid ) } +void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) +{ + qDebug("AddressBook::preExternSync "); + AddressBook::Iterator it; + for ( it = begin(); it != end(); ++it ) { + (*it).setID( csd, (*it).externalUID() ); + (*it).computeCsum( csd ); + } + mergeAB( aBook ,csd ); +} +void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) +{ + qDebug("AddressBook::postExternSync "); + AddressBook::Iterator it; + for ( it = begin(); it != end(); ++it ) { + 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 "); + } else { + (*it).computeCsum( csd ); + if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) + ad.setID( csd, (*it).externalUID() ); + ad.setCsum( csd, (*it).getCsum( csd ) ); + aBook->insertAddressee( ad ); + } + } + } +} + + Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) diff --git a/kabc/addressbook.h b/kabc/addressbook.h index f40e015..157dc56 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -297,2 +297,5 @@ class AddressBook : public QObject Addressee findByExternUid( const QString& uid , const QString& profile ); + + void preExternSync( AddressBook* aBook, const QString& csd ); + void postExternSync( AddressBook* aBook, const QString& csd ); signals: diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b3d88de..8f3ca9b 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2930,9 +2930,3 @@ bool KABCore::syncAB(QString filename, int mode) mGlobalSyncMode = SYNC_MODE_EXTERNAL; - AddressBook::Iterator it; - for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { - (*it).setID( mCurrentSyncDevice, (*it).externalUID() ); - (*it).computeCsum( mCurrentSyncDevice ); - } - abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); - + abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); } else { @@ -2980,18 +2974,3 @@ bool KABCore::syncAB(QString filename, int mode) // afterwrite processing - AddressBook::Iterator it; - for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || - (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { - Addressee ad = mAddressBook->findByUid( ( (*it).uid() )); - if ( ad.isEmpty() ) { - qDebug("ERROR ad empty "); - } else { - (*it).computeCsum( mCurrentSyncDevice ); - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) - ad.setID( mCurrentSyncDevice, (*it).externalUID() ); - ad.setCsum( mCurrentSyncDevice, (*it).getCsum( mCurrentSyncDevice ) ); - mAddressBook->insertAddressee( ad ); - } - } - } + abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); } |