-rw-r--r-- | kaddressbook/kabcore.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index cc8eb52..8776b53 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2669,8 +2669,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2669 | Addressee addresseeL; | 2669 | Addressee addresseeL; |
2670 | Addressee addresseeRSync; | 2670 | Addressee addresseeRSync; |
2671 | Addressee addresseeLSync; | 2671 | Addressee addresseeLSync; |
2672 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2672 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2673 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2673 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2674 | bool fullDateRange = false; | 2674 | bool fullDateRange = false; |
2675 | local->resetTempSyncStat(); | 2675 | local->resetTempSyncStat(); |
2676 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2676 | mLastAddressbookSync = QDateTime::currentDateTime(); |
@@ -2709,7 +2709,7 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2709 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2709 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2710 | } | 2710 | } |
2711 | } | 2711 | } |
2712 | fullDateRange = true; // debug only! | 2712 | // fullDateRange = true; // debug only! |
2713 | if ( fullDateRange ) | 2713 | if ( fullDateRange ) |
2714 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2714 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2715 | else | 2715 | else |
@@ -2918,7 +2918,33 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | ||
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | ||
2923 | if ( ! lse.isEmpty() ) { | ||
2924 | if ( lse.familyName().left(4) == "!E: " ) | ||
2925 | external = true; | ||
2926 | } else { | ||
2927 | bool found = false; | ||
2928 | QDateTime dt( QDate( 2004,1,1)); | ||
2921 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | ||
2931 | if ( (*it).revision() != dt ) { | ||
2932 | found = true; | ||
2933 | break; | ||
2934 | } | ||
2935 | } | ||
2936 | external = ! found; | ||
2937 | } | ||
2938 | |||
2939 | if ( external ) { | ||
2940 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | ||
2941 | AddressBook::Iterator it; | ||
2942 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | ||
2943 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | ||
2944 | (*it).computeCsum( mCurrentSyncDevice ); | ||
2945 | } | ||
2946 | } | ||
2947 | //AddressBook::Iterator it; | ||
2922 | //QStringList vcards; | 2948 | //QStringList vcards; |
2923 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2949 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2924 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2950 | // qDebug("Name %s ", (*it).familyName().latin1()); |
@@ -2927,6 +2953,8 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2927 | if ( syncOK ) { | 2953 | if ( syncOK ) { |
2928 | if ( KABPrefs::instance()->mWriteBackFile ) | 2954 | if ( KABPrefs::instance()->mWriteBackFile ) |
2929 | { | 2955 | { |
2956 | if ( external ) | ||
2957 | abLocal.removeDeletedAddressees(); | ||
2930 | qDebug("saving remote AB "); | 2958 | qDebug("saving remote AB "); |
2931 | abLocal.saveAB(); | 2959 | abLocal.saveAB(); |
2932 | } | 2960 | } |