author | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
commit | b01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (unidiff) | |
tree | c0e79d45242a764b49470d07a9c95be156c121cc /kaddressbook | |
parent | 3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff) | |
download | kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2 |
more AB sync
-rw-r--r-- | kaddressbook/kabcore.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 8f3ca9b..f8683e7 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2551,2 +2551,4 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | QDateTime localMod = local->revision(); | ||
2553 | QDateTime remoteMod = remote->revision(); | ||
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2554 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
@@ -2555,7 +2557,7 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2555 | 2557 | ||
2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2558 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2559 | locCh = ( localMod > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2560 | if ( !remCh && ! locCh ) { |
2559 | //qDebug("both not changed "); | 2561 | qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2562 | lastSync = localMod.addDays(1); |
2561 | if ( mode <= SYNC_PREF_ASK ) | 2563 | if ( mode <= SYNC_PREF_ASK ) |
@@ -2564,11 +2566,11 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2564 | if ( locCh ) { | 2566 | if ( locCh ) { |
2565 | //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2567 | qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2566 | lastSync = local->revision().addDays( -1 ); | 2568 | lastSync = localMod.addDays( -1 ); |
2567 | if ( !remCh ) | 2569 | if ( !remCh ) |
2568 | remote->setRevision( lastSync.addDays( -1 ) ); | 2570 | remoteMod =( lastSync.addDays( -1 ) ); |
2569 | } else { | 2571 | } else { |
2570 | //qDebug(" not loc changed "); | 2572 | //qDebug(" not loc changed "); |
2571 | lastSync = local->revision().addDays( 1 ); | 2573 | lastSync = localMod.addDays( 1 ); |
2572 | if ( remCh ) | 2574 | if ( remCh ) |
2573 | remote->setRevision( lastSync.addDays( 1 ) ); | 2575 | remoteMod =( lastSync.addDays( 1 ) ); |
2574 | 2576 | ||
@@ -2580,3 +2582,3 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2580 | } else { | 2582 | } else { |
2581 | if ( local->revision() == remote->revision() ) | 2583 | if ( localMod == remoteMod ) |
2582 | return 0; | 2584 | return 0; |
@@ -2586,3 +2588,3 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2586 | 2588 | ||
2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2589 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2590 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
@@ -2611,5 +2613,5 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2611 | case SYNC_PREF_LOCAL: | 2613 | case SYNC_PREF_LOCAL: |
2612 | if ( lastSync > remote->revision() ) | 2614 | if ( lastSync > remoteMod ) |
2613 | return 1; | 2615 | return 1; |
2614 | if ( lastSync > local->revision() ) | 2616 | if ( lastSync > localMod ) |
2615 | return 2; | 2617 | return 2; |
@@ -2618,5 +2620,5 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2618 | case SYNC_PREF_REMOTE: | 2620 | case SYNC_PREF_REMOTE: |
2619 | if ( lastSync > remote->revision() ) | 2621 | if ( lastSync > remoteMod ) |
2620 | return 1; | 2622 | return 1; |
2621 | if ( lastSync > local->revision() ) | 2623 | if ( lastSync > localMod ) |
2622 | return 2; | 2624 | return 2; |
@@ -2625,3 +2627,3 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2625 | case SYNC_PREF_NEWEST: | 2627 | case SYNC_PREF_NEWEST: |
2626 | if ( local->revision() > remote->revision() ) | 2628 | if ( localMod > remoteMod ) |
2627 | return 1; | 2629 | return 1; |
@@ -2631,8 +2633,8 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2631 | case SYNC_PREF_ASK: | 2633 | case SYNC_PREF_ASK: |
2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2634 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2633 | if ( lastSync > remote->revision() ) | 2635 | if ( lastSync > remoteMod ) |
2634 | return 1; | 2636 | return 1; |
2635 | if ( lastSync > local->revision() ) | 2637 | if ( lastSync > localMod ) |
2636 | return 2; | 2638 | return 2; |
2637 | localIsNew = local->revision() >= remote->revision(); | 2639 | localIsNew = localMod >= remoteMod; |
2638 | //qDebug("conflict! ************************************** "); | 2640 | //qDebug("conflict! ************************************** "); |
@@ -2788,2 +2790,6 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2788 | } else { // take == 2 take remote | 2790 | } else { // take == 2 take remote |
2791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | ||
2792 | if ( inR.revision().date().year() < 2004 ) | ||
2793 | inR.setRevision( modifiedCalendar ); | ||
2794 | } | ||
2789 | idS = inL.IDStr(); | 2795 | idS = inL.IDStr(); |
@@ -2927,5 +2933,6 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2927 | bool external = false; | 2933 | bool external = false; |
2928 | 2934 | bool isXML = false; | |
2929 | if ( filename.right(4) == ".xml") { | 2935 | if ( filename.right(4) == ".xml") { |
2930 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2936 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2937 | isXML = true; | ||
2931 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2938 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
@@ -2938,6 +2945,5 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2938 | bool found = false; | 2945 | bool found = false; |
2939 | QDateTime dt( QDate( 2004,1,1)); | ||
2940 | AddressBook::Iterator it; | 2946 | AddressBook::Iterator it; |
2941 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2947 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2942 | if ( (*it).revision() != dt ) { | 2948 | if ( (*it).revision().date().year() > 2003 ) { |
2943 | found = true; | 2949 | found = true; |
@@ -2968,7 +2974,7 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2968 | { | 2974 | { |
2969 | if ( external && filename.right(4) != ".xml") | 2975 | if ( external ) |
2970 | abLocal.removeDeletedAddressees(); | 2976 | abLocal.removeSyncAddressees( !isXML); |
2971 | qDebug("Saving remote AB "); | 2977 | qDebug("Saving remote AB "); |
2972 | abLocal.saveAB(); | 2978 | abLocal.saveAB(); |
2973 | if ( external && filename.right(4) == ".xml") { | 2979 | if ( isXML ) { |
2974 | // afterwrite processing | 2980 | // afterwrite processing |