-rw-r--r-- | kabc/addressbook.cpp | 19 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 |
4 files changed, 26 insertions, 13 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 9b196b5..5774c36 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -875,4 +875,11 @@ void AddressBook::removeSyncAddressees( bool removeDeleted ) } else { //qDebug("skipping %s ",(*it).uid().latin1() ); + if ( removeDeleted ) { + // we have no postprocessing in the resource, we have to do it here + // we have to compute csum for all, because it could be the first sync + (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); + + + } ++it; } @@ -918,10 +925,10 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool i mergeAB( aBook ,csd, isSubset ); } -void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) +void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) { //qDebug("AddressBook::postExternSync "); AddressBook::Iterator it; for ( it = begin(); it != end(); ++it ) { - // qDebug("check uid %s ", (*it).uid().latin1() ); + //qDebug("check uid %s ", (*it).uid().latin1() ); if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { @@ -930,7 +937,11 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); } else { + (*it).setIDStr(":"); (*it).computeCsum( csd ); - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) - ad.setID( csd, (*it).externalUID() ); + if ( setID ) { + if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) + ad.setID( csd, (*it).externalUID() ); + } else + ad.setID( csd, "_" ); ad.setCsum( csd, (*it).getCsum( csd ) ); aBook->insertAddressee( ad ); diff --git a/kabc/addressbook.h b/kabc/addressbook.h index f124dc9..75f8b51 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -308,5 +308,5 @@ class AddressBook : public QObject void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); - void postExternSync( AddressBook* aBook, const QString& csd ); + void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); signals: /** diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index a660a9d..d5a110a 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -267,5 +267,5 @@ void Addressee::computeCsum(const QString &dev) } uint cs = getCsum4List(l); - // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); + //qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); setCsum( dev, QString::number (cs )); } diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index ea87929..b0cb986 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2514,10 +2514,10 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo mLastAddressbookSync = QDateTime::currentDateTime(); if ( syncManager->syncWithDesktop() ) { - remote->removeSyncInfo( QString());//remove all info + // remote->removeSyncInfo( QString());//remove all info if ( KSyncManager::mRequestedSyncEvent.isValid() ) { mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); } else { - qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); + qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); } } @@ -2621,5 +2621,6 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo inR.setExternalUID( idS ); if ( syncManager->syncWithDesktop() ) - inR.setIDStr( "changed" ); + inR.setIDStr("changed" ); + //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); } else { inR.setIDStr( idS ); @@ -2813,7 +2814,7 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) if ( ! abLocal.saveAB()) qDebug("Error writing back AB to file "); - if ( isXML ) { + if ( external ) { // afterwrite processing - abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); + abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); } } @@ -2831,4 +2832,5 @@ void KABCore::removeSyncInfo( QString syncProfile) qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); mAddressBook->removeSyncInfo( syncProfile ); + setModified(); } @@ -2853,5 +2855,5 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) abLocal.removeSyncAddressees( false ); abLocal.saveAB(); - abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); + abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); } } @@ -2892,5 +2894,5 @@ bool KABCore::syncPhone() abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); - abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); + abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); } } |