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 | 87 |
1 files changed, 61 insertions, 26 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d6482fb..b3d88de 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2754,3 +2754,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo skipIncidence = true; - QString idS; + QString idS,OidS; qApp->processEvents(); @@ -2770,2 +2770,4 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo local->insertAddressee( inL, false ); + idS = inR.externalUID(); + OidS = inR.originalExternalUID(); } @@ -2776,4 +2778,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo 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 ); @@ -2781,3 +2787,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo ++changedRemote; - } else { + } else { // take == 2 take remote idS = inL.IDStr(); @@ -2856,3 +2862,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo inR = inL; - inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); + inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); inR.setResource( 0 ); @@ -2921,21 +2927,4 @@ bool KABCore::syncAB(QString filename, int mode) bool external = false; - Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); - if ( ! lse.isEmpty() ) { - if ( lse.familyName().left(4) == "!E: " ) - external = true; - } else { - bool found = false; - QDateTime dt( QDate( 2004,1,1)); - AddressBook::Iterator it; - for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { - if ( (*it).revision() != dt ) { - found = true; - break; - } - } - external = ! found; - } - if ( external ) { - qDebug("Setting vcf mode to external "); + if ( filename.right(4) == ".xml") { mGlobalSyncMode = SYNC_MODE_EXTERNAL; @@ -2943,5 +2932,34 @@ bool KABCore::syncAB(QString filename, int mode) for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { - (*it).setID( mCurrentSyncDevice, (*it).uid() ); + (*it).setID( mCurrentSyncDevice, (*it).externalUID() ); (*it).computeCsum( mCurrentSyncDevice ); } + abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); + + } else { + Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); + if ( ! lse.isEmpty() ) { + if ( lse.familyName().left(4) == "!E: " ) + external = true; + } else { + bool found = false; + QDateTime dt( QDate( 2004,1,1)); + AddressBook::Iterator it; + for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { + if ( (*it).revision() != dt ) { + found = true; + break; + } + } + external = ! found; + } + + if ( external ) { + qDebug("Setting vcf mode to external "); + mGlobalSyncMode = SYNC_MODE_EXTERNAL; + AddressBook::Iterator it; + for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { + (*it).setID( mCurrentSyncDevice, (*it).uid() ); + (*it).computeCsum( mCurrentSyncDevice ); + } + } } @@ -2952,4 +2970,2 @@ bool KABCore::syncAB(QString filename, int mode) //} - if ( filename.right(4) == ".xml") - abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); @@ -2958,3 +2974,3 @@ bool KABCore::syncAB(QString filename, int mode) { - if ( external ) + if ( external && filename.right(4) != ".xml") abLocal.removeDeletedAddressees(); @@ -2962,2 +2978,21 @@ bool KABCore::syncAB(QString filename, int mode) 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 ); + } + } + } + } } |