author | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
commit | afa28a62314117555d6b32291188eedd1a576284 (patch) (side-by-side diff) | |
tree | ea97a247de30a7a34480bc395e1996ab99247361 /kaddressbook | |
parent | e0d8e062c9d8092e47dcadd88b30614ebff43c0c (diff) | |
download | kdepimpi-afa28a62314117555d6b32291188eedd1a576284.zip kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.gz kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.bz2 |
more AB sync
-rw-r--r-- | kaddressbook/kabcore.cpp | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d6482fb..b3d88de 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2753,5 +2753,5 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo if ( uid.left(19) == QString("last-syncAddressee-") ) skipIncidence = true; - QString idS; + QString idS,OidS; qApp->processEvents(); if ( !skipIncidence ) { @@ -2769,4 +2769,6 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); local->insertAddressee( inL, false ); + idS = inR.externalUID(); + OidS = inR.originalExternalUID(); } else @@ -2775,10 +2777,14 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo inR = inL; inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); - if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + inR.setOriginalExternalUID( OidS ); + inR.setExternalUID( idS ); + } else { inR.setIDStr( idS ); + } inR.setResource( 0 ); remote->insertAddressee( inR , false); ++changedRemote; - } else { + } else { // take == 2 take remote idS = inL.IDStr(); local->removeAddressee( inL ); @@ -2855,5 +2861,5 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo local->insertAddressee( inL, false ); inR = inL; - inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); + inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); inR.setResource( 0 ); remote->insertAddressee( inR, false ); @@ -2920,4 +2926,15 @@ bool KABCore::syncAB(QString filename, int mode) qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); bool external = false; + + if ( filename.right(4) == ".xml") { + 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 ); + + } else { Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); if ( ! lse.isEmpty() ) { @@ -2946,4 +2963,5 @@ bool KABCore::syncAB(QString filename, int mode) } } + } //AddressBook::Iterator it; //QStringList vcards; @@ -2951,14 +2969,31 @@ bool KABCore::syncAB(QString filename, int mode) // qDebug("Name %s ", (*it).familyName().latin1()); //} - if ( filename.right(4) == ".xml") - abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); if ( syncOK ) { if ( KABPrefs::instance()->mWriteBackFile ) { - if ( external ) + if ( external && filename.right(4) != ".xml") abLocal.removeDeletedAddressees(); qDebug("Saving remote AB "); abLocal.saveAB(); + if ( external && filename.right(4) == ".xml") { + // 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 ); + } + } + } + } } } |