-rw-r--r-- | kaddressbook/kabcore.cpp | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index aa04631..a480baf 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2791,24 +2791,26 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i } bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) { bool syncOK = true; int addedAddressee = 0; int addedAddresseeR = 0; int deletedAddresseeR = 0; int deletedAddresseeL = 0; int changedLocal = 0; int changedRemote = 0; + int filteredIN = 0; + int filteredOUT = 0; QString mCurrentSyncName = syncManager->getCurrentSyncName(); QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); //QPtrList<Addressee> el = local->rawAddressees(); Addressee addresseeR; QString uid; int take; Addressee addresseeL; Addressee addresseeRSync; Addressee addresseeLSync; // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); @@ -2980,88 +2982,91 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { inR.setRevision( modifiedCalendar ); remote->insertAddressee( inR, false ); inR.setResource( 0 ); local->insertAddressee( inR, false ); ++addedAddressee; } else { // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); remote->removeAddressee( inR ); ++deletedAddresseeR; } } + } else { + ++filteredIN; } } } ++incCounter; } er.clear(); QStringList el = local->uidList(); modulo = (el.count()/10)+1; syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); incCounter = 0; while ( incCounter < el.count()) { qApp->processEvents(); if (syncManager->isProgressBarCanceled()) return false; if ( incCounter % modulo == 0 ) syncManager->showProgressBar(incCounter); uid = el[ incCounter ]; bool skipIncidence = false; if ( uid.left(19) == QString("last-syncAddressee-") ) skipIncidence = true; - if ( ! skipIncidence ) { - inL = local->findByUid( uid ); - if ( (!filterOUT.name().isEmpty()) && (! filterOUT.filterAddressee( inL ) ) ) - skipIncidence = true; - } if ( !skipIncidence ) { + inL = local->findByUid( uid ); if ( !inL.resource() || inL.resource()->includeInSync() ) { inR = remote->findByUid( uid ); - if ( inR.isEmpty() ) { // no conflict ********** add or delete local - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { - // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); - local->removeAddressee( inL ); - ++deletedAddresseeL; - } else { - if ( ! syncManager->mWriteBackExistingOnly ) { - inL.removeID(mCurrentSyncDevice ); - ++addedAddresseeR; - inL.setRevision( modifiedCalendar ); - local->insertAddressee( inL, false ); - inR = inL; - inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); - inR.setResource( 0 ); - remote->insertAddressee( inR, false ); + if ( inR.isEmpty() ){ + if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { + // no conflict ********** add or delete local + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { + // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); + local->removeAddressee( inL ); + ++deletedAddresseeL; + } else { + if ( ! syncManager->mWriteBackExistingOnly ) { + inL.removeID(mCurrentSyncDevice ); + ++addedAddresseeR; + inL.setRevision( modifiedCalendar ); + local->insertAddressee( inL, false ); + inR = inL; + inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); + inR.setResource( 0 ); + remote->insertAddressee( inR, false ); + } } - } - } else { - if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { - //qDebug("data %s ", inL.revision().toString().latin1()); - // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); - local->removeAddressee( inL ); - ++deletedAddresseeL; } else { - if ( ! syncManager->mWriteBackExistingOnly ) { - ++addedAddresseeR; - inL.setRevision( modifiedCalendar ); - local->insertAddressee( inL, false ); - inR = inL; - inR.setIDStr( ":" ); - inR.setResource( 0 ); - remote->insertAddressee( inR, false ); + if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { + //qDebug("data %s ", inL.revision().toString().latin1()); + // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); + local->removeAddressee( inL ); + ++deletedAddresseeL; + } else { + if ( ! syncManager->mWriteBackExistingOnly ) { + ++addedAddresseeR; + inL.setRevision( modifiedCalendar ); + local->insertAddressee( inL, false ); + inR = inL; + inR.setIDStr( ":" ); + inR.setResource( 0 ); + remote->insertAddressee( inR, false ); + } } } + } else { + ++filteredOUT; } } } } ++incCounter; } el.clear(); syncManager->hideProgressBar(); mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); // get rid of micro seconds QTime t = mLastAddressbookSync.time(); mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); @@ -3071,25 +3076,25 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); addresseeRSync.setNote( "" ) ; addresseeLSync.setNote( "" ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->insertAddressee( addresseeRSync, false ); local->insertAddressee( addresseeLSync, false ); QString mes; - mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); + mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); qDebug( mes ); mes = i18n("Local addressbook changed!\n") +mes; if ( syncManager->mShowSyncSummary ) { if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, i18n("KA/Pi Synchronization"),i18n("Write back"))) { qDebug("cancelled "); return false; } } return syncOK; } |