summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 8776b53..56f6af2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2525,9 +2525,9 @@ KABC::Addressee KABCore::getLastSyncAddressee()
2525 if (lse.isEmpty()) { 2525 if (lse.isEmpty()) {
2526 qDebug("Creating new last-syncAddressee "); 2526 qDebug("Creating new last-syncAddressee ");
2527 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2527 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2528 QString sum = ""; 2528 QString sum = "";
2529 if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 2529 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2530 sum = "E: "; 2530 sum = "E: ";
2531 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2531 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2532 lse.setRevision( mLastAddressbookSync ); 2532 lse.setRevision( mLastAddressbookSync );
2533 lse.setCategories( i18n("SyncEvent") ); 2533 lse.setCategories( i18n("SyncEvent") );
@@ -2551,17 +2551,19 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
2551 QDateTime lastSync = mLastAddressbookSync; 2551 QDateTime lastSync = mLastAddressbookSync;
2552 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2552 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2553 bool remCh, locCh; 2553 bool remCh, locCh;
2554 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2554 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2555 //if ( remCh ) 2555 if ( remCh )
2556 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2556 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2557 locCh = ( local->revision() > mLastAddressbookSync ); 2557 locCh = ( local->revision() > mLastAddressbookSync );
2558 if ( !remCh && ! locCh ) { 2558 if ( !remCh && ! locCh ) {
2559 //qDebug("both not changed "); 2559 qDebug("both not changed ");
2560 lastSync = local->revision().addDays(1); 2560 lastSync = local->revision().addDays(1);
2561 if ( mode <= SYNC_PREF_ASK )
2562 return 0;
2561 } else { 2563 } else {
2562 if ( locCh ) { 2564 if ( locCh ) {
2563 //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); 2565 qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1());
2564 lastSync = local->revision().addDays( -1 ); 2566 lastSync = local->revision().addDays( -1 );
2565 if ( !remCh ) 2567 if ( !remCh )
2566 remote->setRevision( lastSync.addDays( -1 ) ); 2568 remote->setRevision( lastSync.addDays( -1 ) );
2567 } else { 2569 } else {
@@ -2789,11 +2791,11 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2789 } 2791 }
2790 } else { // no conflict 2792 } else { // no conflict
2791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2793 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2792 QString des = addresseeLSync.note(); 2794 QString des = addresseeLSync.note();
2793 QString pref = "a"; 2795 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2794 if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2795 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2796 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2797 remote->insertAddressee( inR, false );
2796 ++deletedAddresseeR; 2798 ++deletedAddresseeR;
2797 } else { 2799 } else {
2798 inR.setRevision( modifiedCalendar ); 2800 inR.setRevision( modifiedCalendar );
2799 remote->insertAddressee( inR, false ); 2801 remote->insertAddressee( inR, false );
@@ -2819,16 +2821,15 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2819 } 2821 }
2820 ++incCounter; 2822 ++incCounter;
2821 } 2823 }
2822 er.clear(); 2824 er.clear();
2823 QStringList el = remote->uidList(); 2825 QStringList el = local->uidList();
2824 modulo = (el.count()/10)+1; 2826 modulo = (el.count()/10)+1;
2825 bar.setCaption (i18n("Add / remove addressees") ); 2827 bar.setCaption (i18n("Add / remove addressees") );
2826 bar.setTotalSteps ( el.count() ) ; 2828 bar.setTotalSteps ( el.count() ) ;
2827 bar.show(); 2829 bar.show();
2828 incCounter = 0; 2830 incCounter = 0;
2829 while ( incCounter < el.count()) { 2831 while ( incCounter < el.count()) {
2830
2831 qApp->processEvents(); 2832 qApp->processEvents();
2832 if ( ! bar.isVisible() ) 2833 if ( ! bar.isVisible() )
2833 return false; 2834 return false;
2834 if ( incCounter % modulo == 0 ) 2835 if ( incCounter % modulo == 0 )
@@ -2836,10 +2837,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2836 uid = el[ incCounter ]; 2837 uid = el[ incCounter ];
2837 bool skipIncidence = false; 2838 bool skipIncidence = false;
2838 if ( uid.left(19) == QString("last-syncAddressee-") ) 2839 if ( uid.left(19) == QString("last-syncAddressee-") )
2839 skipIncidence = true; 2840 skipIncidence = true;
2840 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2841 skipIncidence = true;
2842 if ( !skipIncidence ) { 2841 if ( !skipIncidence ) {
2843 inL = local->findByUid( uid ); 2842 inL = local->findByUid( uid );
2844 inR = remote->findByUid( uid ); 2843 inR = remote->findByUid( uid );
2845 if ( inR.isEmpty() ) { 2844 if ( inR.isEmpty() ) {
@@ -2850,10 +2849,9 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2850 ++deletedAddresseeL; 2849 ++deletedAddresseeL;
2851 } else { 2850 } else {
2852 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2851 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2853 inL.removeID(mCurrentSyncDevice ); 2852 inL.removeID(mCurrentSyncDevice );
2854 ++addedAddresseeR; 2853 ++addedAddresseeR;
2855 //qDebug("remote added Incidence %s ", inL.summary().latin1());
2856 inL.setRevision( modifiedCalendar ); 2854 inL.setRevision( modifiedCalendar );
2857 local->insertAddressee( inL, false ); 2855 local->insertAddressee( inL, false );
2858 inR = inL; 2856 inR = inL;
2859 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2857 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
@@ -2894,8 +2892,10 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2894 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2892 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2895 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2893 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2896 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2894 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2897 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2895 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2896 addresseeRSync.setNote( "" ) ;
2897 addresseeLSync.setNote( "" );
2898 2898
2899 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2899 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2900 remote->insertAddressee( addresseeRSync, false ); 2900 remote->insertAddressee( addresseeRSync, false );
2901 local->insertAddressee( addresseeLSync, false ); 2901 local->insertAddressee( addresseeLSync, false );
@@ -2936,8 +2936,9 @@ bool KABCore::syncAB(QString filename, int mode)
2936 external = ! found; 2936 external = ! found;
2937 } 2937 }
2938 2938
2939 if ( external ) { 2939 if ( external ) {
2940 qDebug("**********Setting vcf mode to external ");
2940 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2941 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2941 AddressBook::Iterator it; 2942 AddressBook::Iterator it;
2942 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2943 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2943 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2944 (*it).setID( mCurrentSyncDevice, (*it).uid() );