-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 @@ -2670,6 +2670,6 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo 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(); @@ -2710,5 +2710,5 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo } } - fullDateRange = true; // debug only! + // fullDateRange = true; // debug only! if ( fullDateRange ) mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); @@ -2919,5 +2919,31 @@ bool KABCore::syncAB(QString filename, int mode) 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 ) { @@ -2928,4 +2954,6 @@ bool KABCore::syncAB(QString filename, int mode) if ( KABPrefs::instance()->mWriteBackFile ) { + if ( external ) + abLocal.removeDeletedAddressees(); qDebug("saving remote AB "); abLocal.saveAB(); |