-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 @@ -2668,10 +2668,10 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo int take; Addressee addresseeL; Addressee addresseeRSync; Addressee addresseeLSync; - KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); - KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); + // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); + //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); bool fullDateRange = false; local->resetTempSyncStat(); mLastAddressbookSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastAddressbookSync;; @@ -2708,9 +2708,9 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo fullDateRange = true; qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); } } - fullDateRange = true; // debug only! + // fullDateRange = true; // debug only! if ( fullDateRange ) mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); else mLastAddressbookSync = addresseeLSync.revision(); @@ -2917,17 +2917,45 @@ bool KABCore::syncAB(QString filename, int mode) AddressBook abLocal(filename,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB loaded %s mode %d",filename.latin1(), mode ); - AddressBook::Iterator it; + bool external = false; + Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); + if ( ! lse.isEmpty() ) { + if ( lse.familyName().left(4) == "!E: " ) + external = true; + } else { + bool found = false; + QDateTime dt( QDate( 2004,1,1)); + AddressBook::Iterator it; + for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { + if ( (*it).revision() != dt ) { + found = true; + break; + } + } + external = ! found; + } + + if ( external ) { + mGlobalSyncMode = SYNC_MODE_EXTERNAL; + AddressBook::Iterator it; + for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { + (*it).setID( mCurrentSyncDevice, (*it).uid() ); + (*it).computeCsum( mCurrentSyncDevice ); + } + } + //AddressBook::Iterator it; //QStringList vcards; //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { // qDebug("Name %s ", (*it).familyName().latin1()); //} syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); if ( syncOK ) { if ( KABPrefs::instance()->mWriteBackFile ) { + if ( external ) + abLocal.removeDeletedAddressees(); qDebug("saving remote AB "); abLocal.saveAB(); } } |