From 2cfda2af7cba3c9aff2d7722421b5d33b7f56cb6 Mon Sep 17 00:00:00 2001 From: zautrix Date: Wed, 13 Oct 2004 14:23:28 +0000 Subject: more sync fixes --- (limited to 'kaddressbook/kabcore.cpp') diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index ea34be2..47ed858 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2551,48 +2551,50 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo //inL.setResource( 0 ); //inR.setResource( 0 ); if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars - if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { - //qDebug("take %d %s ", take, inL.summary().latin1()); - if ( take == 3 ) - return false; - if ( take == 1 ) {// take local - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); - inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); - local->insertAddressee( inL, false ); - idS = inR.externalUID(); - OidS = inR.originalExternalUID(); - } - else - idS = inR.IDStr(); - remote->removeAddressee( inR ); - inR = inL; - inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - inR.setOriginalExternalUID( OidS ); - inR.setExternalUID( idS ); - } else { - inR.setIDStr( idS ); - } - inR.setResource( 0 ); - remote->insertAddressee( inR , false); - ++changedRemote; - } else { // take == 2 take remote - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - if ( inR.revision().date().year() < 2004 ) - inR.setRevision( modifiedCalendar ); - } - idS = inL.IDStr(); - local->removeAddressee( inL ); - inL = inR; - inL.setIDStr( idS ); - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); - inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); + if ( !inL.resource() || inL.resource()->includeInSync() ) { + if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { + //qDebug("take %d %s ", take, inL.summary().latin1()); + if ( take == 3 ) + return false; + if ( take == 1 ) {// take local + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); + inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); + local->insertAddressee( inL, false ); + idS = inR.externalUID(); + OidS = inR.originalExternalUID(); + } + else + idS = inR.IDStr(); + remote->removeAddressee( inR ); + inR = inL; + inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + inR.setOriginalExternalUID( OidS ); + inR.setExternalUID( idS ); + } else { + inR.setIDStr( idS ); + } + inR.setResource( 0 ); + remote->insertAddressee( inR , false); + ++changedRemote; + } else { // take == 2 take remote + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + if ( inR.revision().date().year() < 2004 ) + inR.setRevision( modifiedCalendar ); + } + idS = inL.IDStr(); + local->removeAddressee( inL ); + inL = inR; + inL.setIDStr( idS ); + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); + inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); + } + inL.setResource( 0 ); + local->insertAddressee( inL , false ); + ++changedLocal; } - inL.setResource( 0 ); - local->insertAddressee( inL , false ); - ++changedLocal; } } } else { // no conflict @@ -2645,38 +2647,40 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo skipIncidence = true; if ( !skipIncidence ) { inL = local->findByUid( uid ); - inR = remote->findByUid( uid ); - if ( inR.isEmpty() ) { - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { - // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); - local->removeAddressee( inL ); - ++deletedAddresseeL; - } else { - if ( ! syncManager->mWriteBackExistingOnly ) { - inL.removeID(mCurrentSyncDevice ); - ++addedAddresseeR; - inL.setRevision( modifiedCalendar ); - local->insertAddressee( inL, false ); - inR = inL; - inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); - inR.setResource( 0 ); - remote->insertAddressee( inR, false ); + if ( !inL.resource() || inL.resource()->includeInSync() ) { + inR = remote->findByUid( uid ); + if ( inR.isEmpty() ) { + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { + // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); + local->removeAddressee( inL ); + ++deletedAddresseeL; + } else { + if ( ! syncManager->mWriteBackExistingOnly ) { + inL.removeID(mCurrentSyncDevice ); + ++addedAddresseeR; + inL.setRevision( modifiedCalendar ); + local->insertAddressee( inL, false ); + inR = inL; + inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); + inR.setResource( 0 ); + remote->insertAddressee( inR, false ); + } } - } - } else { - if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { - // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); - local->removeAddressee( inL ); - ++deletedAddresseeL; } else { - if ( ! syncManager->mWriteBackExistingOnly ) { - ++addedAddresseeR; - inL.setRevision( modifiedCalendar ); - local->insertAddressee( inL, false ); - inR = inL; - inR.setResource( 0 ); - remote->insertAddressee( inR, false ); + if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { + // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); + local->removeAddressee( inL ); + ++deletedAddresseeL; + } else { + if ( ! syncManager->mWriteBackExistingOnly ) { + ++addedAddresseeR; + inL.setRevision( modifiedCalendar ); + local->insertAddressee( inL, false ); + inR = inL; + inR.setResource( 0 ); + remote->insertAddressee( inR, false ); + } } } } -- cgit v0.9.0.2