-rw-r--r-- | kaddressbook/kabcore.cpp | 146 |
1 files changed, 75 insertions, 71 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index ea34be2..47ed858 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2548,54 +2548,56 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2548 | if ( !skipIncidence ) { | 2548 | if ( !skipIncidence ) { |
2549 | inL = local->findByUid( uid ); | 2549 | inL = local->findByUid( uid ); |
2550 | inR = remote->findByUid( uid ); | 2550 | inR = remote->findByUid( uid ); |
2551 | //inL.setResource( 0 ); | 2551 | //inL.setResource( 0 ); |
2552 | //inR.setResource( 0 ); | 2552 | //inR.setResource( 0 ); |
2553 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2553 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2554 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2554 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2555 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2555 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2556 | if ( take == 3 ) | 2556 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2557 | return false; | 2557 | if ( take == 3 ) |
2558 | if ( take == 1 ) {// take local | 2558 | return false; |
2559 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2559 | if ( take == 1 ) {// take local |
2560 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2560 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2561 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2561 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2562 | local->insertAddressee( inL, false ); | 2562 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2563 | idS = inR.externalUID(); | 2563 | local->insertAddressee( inL, false ); |
2564 | OidS = inR.originalExternalUID(); | 2564 | idS = inR.externalUID(); |
2565 | } | 2565 | OidS = inR.originalExternalUID(); |
2566 | else | 2566 | } |
2567 | idS = inR.IDStr(); | 2567 | else |
2568 | remote->removeAddressee( inR ); | 2568 | idS = inR.IDStr(); |
2569 | inR = inL; | 2569 | remote->removeAddressee( inR ); |
2570 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2570 | inR = inL; |
2571 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2571 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2572 | inR.setOriginalExternalUID( OidS ); | 2572 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2573 | inR.setExternalUID( idS ); | 2573 | inR.setOriginalExternalUID( OidS ); |
2574 | } else { | 2574 | inR.setExternalUID( idS ); |
2575 | inR.setIDStr( idS ); | 2575 | } else { |
2576 | } | 2576 | inR.setIDStr( idS ); |
2577 | inR.setResource( 0 ); | 2577 | } |
2578 | remote->insertAddressee( inR , false); | 2578 | inR.setResource( 0 ); |
2579 | ++changedRemote; | 2579 | remote->insertAddressee( inR , false); |
2580 | } else { // take == 2 take remote | 2580 | ++changedRemote; |
2581 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2581 | } else { // take == 2 take remote |
2582 | if ( inR.revision().date().year() < 2004 ) | 2582 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2583 | inR.setRevision( modifiedCalendar ); | 2583 | if ( inR.revision().date().year() < 2004 ) |
2584 | } | 2584 | inR.setRevision( modifiedCalendar ); |
2585 | idS = inL.IDStr(); | 2585 | } |
2586 | local->removeAddressee( inL ); | 2586 | idS = inL.IDStr(); |
2587 | inL = inR; | 2587 | local->removeAddressee( inL ); |
2588 | inL.setIDStr( idS ); | 2588 | inL = inR; |
2589 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2589 | inL.setIDStr( idS ); |
2590 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2590 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2591 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2591 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2592 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | ||
2593 | } | ||
2594 | inL.setResource( 0 ); | ||
2595 | local->insertAddressee( inL , false ); | ||
2596 | ++changedLocal; | ||
2592 | } | 2597 | } |
2593 | inL.setResource( 0 ); | ||
2594 | local->insertAddressee( inL , false ); | ||
2595 | ++changedLocal; | ||
2596 | } | 2598 | } |
2597 | } | 2599 | } |
2598 | } else { // no conflict | 2600 | } else { // no conflict |
2599 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2601 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2600 | QString des = addresseeLSync.note(); | 2602 | QString des = addresseeLSync.note(); |
2601 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2603 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
@@ -2642,44 +2644,46 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2642 | uid = el[ incCounter ]; | 2644 | uid = el[ incCounter ]; |
2643 | bool skipIncidence = false; | 2645 | bool skipIncidence = false; |
2644 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2646 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2645 | skipIncidence = true; | 2647 | skipIncidence = true; |
2646 | if ( !skipIncidence ) { | 2648 | if ( !skipIncidence ) { |
2647 | inL = local->findByUid( uid ); | 2649 | inL = local->findByUid( uid ); |
2648 | inR = remote->findByUid( uid ); | 2650 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2649 | if ( inR.isEmpty() ) { | 2651 | inR = remote->findByUid( uid ); |
2650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2652 | if ( inR.isEmpty() ) { |
2651 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2653 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2652 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2654 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2653 | local->removeAddressee( inL ); | 2655 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2654 | ++deletedAddresseeL; | 2656 | local->removeAddressee( inL ); |
2655 | } else { | 2657 | ++deletedAddresseeL; |
2656 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2658 | } else { |
2657 | inL.removeID(mCurrentSyncDevice ); | 2659 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2658 | ++addedAddresseeR; | 2660 | inL.removeID(mCurrentSyncDevice ); |
2659 | inL.setRevision( modifiedCalendar ); | 2661 | ++addedAddresseeR; |
2660 | local->insertAddressee( inL, false ); | 2662 | inL.setRevision( modifiedCalendar ); |
2661 | inR = inL; | 2663 | local->insertAddressee( inL, false ); |
2662 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2664 | inR = inL; |
2663 | inR.setResource( 0 ); | 2665 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2664 | remote->insertAddressee( inR, false ); | 2666 | inR.setResource( 0 ); |
2667 | remote->insertAddressee( inR, false ); | ||
2668 | } | ||
2665 | } | 2669 | } |
2666 | } | ||
2667 | } else { | ||
2668 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | ||
2669 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | ||
2670 | local->removeAddressee( inL ); | ||
2671 | ++deletedAddresseeL; | ||
2672 | } else { | 2670 | } else { |
2673 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2671 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2674 | ++addedAddresseeR; | 2672 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2675 | inL.setRevision( modifiedCalendar ); | 2673 | local->removeAddressee( inL ); |
2676 | local->insertAddressee( inL, false ); | 2674 | ++deletedAddresseeL; |
2677 | inR = inL; | 2675 | } else { |
2678 | inR.setResource( 0 ); | 2676 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2679 | remote->insertAddressee( inR, false ); | 2677 | ++addedAddresseeR; |
2678 | inL.setRevision( modifiedCalendar ); | ||
2679 | local->insertAddressee( inL, false ); | ||
2680 | inR = inL; | ||
2681 | inR.setResource( 0 ); | ||
2682 | remote->insertAddressee( inR, false ); | ||
2683 | } | ||
2680 | } | 2684 | } |
2681 | } | 2685 | } |
2682 | } | 2686 | } |
2683 | } | 2687 | } |
2684 | } | 2688 | } |
2685 | ++incCounter; | 2689 | ++incCounter; |