-rw-r--r-- | kaddressbook/kabcore.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index cc8eb52..8776b53 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2666,14 +2666,14 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2666 | Addressee addresseeR; | 2666 | Addressee addresseeR; |
2667 | QString uid; | 2667 | QString uid; |
2668 | int take; | 2668 | int take; |
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(); |
2677 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2677 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2678 | addresseeLSync = getLastSyncAddressee(); | 2678 | addresseeLSync = getLastSyncAddressee(); |
2679 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2679 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
@@ -2706,13 +2706,13 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2706 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2706 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2707 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2707 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2708 | fullDateRange = true; | 2708 | fullDateRange = true; |
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 |
2716 | mLastAddressbookSync = addresseeLSync.revision(); | 2716 | mLastAddressbookSync = addresseeLSync.revision(); |
2717 | // for resyncing if own file has changed | 2717 | // for resyncing if own file has changed |
2718 | // PENDING fixme later when implemented | 2718 | // PENDING fixme later when implemented |
@@ -2915,21 +2915,49 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
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 | AddressBook::Iterator it; | 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)); | ||
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()); |
2925 | //} | 2951 | //} |
2926 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2952 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, 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 | } |
2933 | } | 2961 | } |
2934 | setModified(); | 2962 | setModified(); |
2935 | 2963 | ||