summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-09-18 18:46:29 (UTC)
committer zautrix <zautrix>2004-09-18 18:46:29 (UTC)
commitec8099bf369e5b8327ca6cfd78b34366353e3abf (patch) (unidiff)
tree551c515124f7b1c47b2860803efa3922f494f938 /kaddressbook
parent3f16c7aa0ab6badf304c537a6981ece743138821 (diff)
downloadkdepimpi-ec8099bf369e5b8327ca6cfd78b34366353e3abf.zip
kdepimpi-ec8099bf369e5b8327ca6cfd78b34366353e3abf.tar.gz
kdepimpi-ec8099bf369e5b8327ca6cfd78b34366353e3abf.tar.bz2
More AB sync
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 74c10d2..b1a951c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2607,169 +2607,172 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
2607 2607
2608 switch( mode ) { 2608 switch( mode ) {
2609 case SYNC_PREF_LOCAL: 2609 case SYNC_PREF_LOCAL:
2610 if ( lastSync > remote->revision() ) 2610 if ( lastSync > remote->revision() )
2611 return 1; 2611 return 1;
2612 if ( lastSync > local->revision() ) 2612 if ( lastSync > local->revision() )
2613 return 2; 2613 return 2;
2614 return 1; 2614 return 1;
2615 break; 2615 break;
2616 case SYNC_PREF_REMOTE: 2616 case SYNC_PREF_REMOTE:
2617 if ( lastSync > remote->revision() ) 2617 if ( lastSync > remote->revision() )
2618 return 1; 2618 return 1;
2619 if ( lastSync > local->revision() ) 2619 if ( lastSync > local->revision() )
2620 return 2; 2620 return 2;
2621 return 2; 2621 return 2;
2622 break; 2622 break;
2623 case SYNC_PREF_NEWEST: 2623 case SYNC_PREF_NEWEST:
2624 if ( local->revision() > remote->revision() ) 2624 if ( local->revision() > remote->revision() )
2625 return 1; 2625 return 1;
2626 else 2626 else
2627 return 2; 2627 return 2;
2628 break; 2628 break;
2629 case SYNC_PREF_ASK: 2629 case SYNC_PREF_ASK:
2630 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); 2630 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() );
2631 if ( lastSync > remote->revision() ) 2631 if ( lastSync > remote->revision() )
2632 return 1; 2632 return 1;
2633 if ( lastSync > local->revision() ) 2633 if ( lastSync > local->revision() )
2634 return 2; 2634 return 2;
2635 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); 2635 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() );
2636 localIsNew = local->revision() >= remote->revision(); 2636 localIsNew = local->revision() >= remote->revision();
2637#if 0 2637#if 0
2638 if ( localIsNew ) 2638 if ( localIsNew )
2639 getEventViewerDialog()->setColorMode( 1 ); 2639 getEventViewerDialog()->setColorMode( 1 );
2640 else 2640 else
2641 getEventViewerDialog()->setColorMode( 2 ); 2641 getEventViewerDialog()->setColorMode( 2 );
2642 getEventViewerDialog()->setIncidence(local); 2642 getEventViewerDialog()->setIncidence(local);
2643 if ( localIsNew ) 2643 if ( localIsNew )
2644 getEventViewerDialog()->setColorMode( 2 ); 2644 getEventViewerDialog()->setColorMode( 2 );
2645 else 2645 else
2646 getEventViewerDialog()->setColorMode( 1 ); 2646 getEventViewerDialog()->setColorMode( 1 );
2647 getEventViewerDialog()->addIncidence(remote); 2647 getEventViewerDialog()->addIncidence(remote);
2648 getEventViewerDialog()->setColorMode( 0 ); 2648 getEventViewerDialog()->setColorMode( 0 );
2649 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 2649 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
2650 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 2650 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
2651 getEventViewerDialog()->showMe(); 2651 getEventViewerDialog()->showMe();
2652 result = getEventViewerDialog()->executeS( localIsNew ); 2652 result = getEventViewerDialog()->executeS( localIsNew );
2653#endif 2653#endif
2654 qDebug("conflict! ************************************** "); 2654 qDebug("conflict! ************************************** ");
2655 result = 1; 2655 {
2656 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2657 result = acd.executeD(localIsNew);
2656 return result; 2658 return result;
2657 2659 }
2658 break; 2660 break;
2659 case SYNC_PREF_FORCE_LOCAL: 2661 case SYNC_PREF_FORCE_LOCAL:
2660 return 1; 2662 return 1;
2661 break; 2663 break;
2662 case SYNC_PREF_FORCE_REMOTE: 2664 case SYNC_PREF_FORCE_REMOTE:
2663 return 2; 2665 return 2;
2664 break; 2666 break;
2665 2667
2666 default: 2668 default:
2667 // SYNC_PREF_TAKE_BOTH not implemented 2669 // SYNC_PREF_TAKE_BOTH not implemented
2668 break; 2670 break;
2669 } 2671 }
2670 return 0; 2672 return 0;
2671} 2673}
2672bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2674bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2673{ 2675{
2674 bool syncOK = true; 2676 bool syncOK = true;
2675 int addedAddressee = 0; 2677 int addedAddressee = 0;
2676 int addedAddresseeR = 0; 2678 int addedAddresseeR = 0;
2677 int deletedAddresseeR = 0; 2679 int deletedAddresseeR = 0;
2678 int deletedAddresseeL = 0; 2680 int deletedAddresseeL = 0;
2679 int changedLocal = 0; 2681 int changedLocal = 0;
2680 int changedRemote = 0; 2682 int changedRemote = 0;
2681 //QPtrList<Addressee> el = local->rawAddressees(); 2683 //QPtrList<Addressee> el = local->rawAddressees();
2682 Addressee addresseeR; 2684 Addressee addresseeR;
2683 QString uid; 2685 QString uid;
2684 int take; 2686 int take;
2685 Addressee addresseeL; 2687 Addressee addresseeL;
2686 Addressee addresseeRSync; 2688 Addressee addresseeRSync;
2687 Addressee addresseeLSync; 2689 Addressee addresseeLSync;
2688 KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2690 KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2689 KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2691 KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2690 bool fullDateRange = false; 2692 bool fullDateRange = false;
2691 local->resetTempSyncStat(); 2693 local->resetTempSyncStat();
2692 mLastAddressbookSync = QDateTime::currentDateTime(); 2694 mLastAddressbookSync = QDateTime::currentDateTime();
2693 QDateTime modifiedCalendar = mLastAddressbookSync;; 2695 QDateTime modifiedCalendar = mLastAddressbookSync;;
2694 addresseeLSync = getLastSyncAddressee(); 2696 addresseeLSync = getLastSyncAddressee();
2695 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2697 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2696 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2698 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2697 if ( !addresseeR.isEmpty() ) { 2699 if ( !addresseeR.isEmpty() ) {
2698 addresseeRSync = addresseeR; 2700 addresseeRSync = addresseeR;
2699 remote->removeAddressee(addresseeR ); 2701 remote->removeAddressee(addresseeR );
2700 2702
2701 } else { 2703 } else {
2702 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2704 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2703 addresseeRSync = addresseeLSync ; 2705 addresseeRSync = addresseeLSync ;
2704 } else { 2706 } else {
2705 qDebug("FULLDATE 1"); 2707 qDebug("FULLDATE 1");
2706 fullDateRange = true; 2708 fullDateRange = true;
2707 Addressee newAdd; 2709 Addressee newAdd;
2708 addresseeRSync = newAdd; 2710 addresseeRSync = newAdd;
2709 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2711 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2710 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2712 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2711 addresseeRSync.setRevision( mLastAddressbookSync ); 2713 addresseeRSync.setRevision( mLastAddressbookSync );
2712 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2714 addresseeRSync.setCategories( i18n("SyncAddressee") );
2713 } 2715 }
2714 } 2716 }
2715 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2717 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2716 qDebug("FULLDATE 2"); 2718 qDebug("FULLDATE 2");
2717 fullDateRange = true; 2719 fullDateRange = true;
2718 } 2720 }
2719 if ( ! fullDateRange ) { 2721 if ( ! fullDateRange ) {
2720 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2722 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2721 2723
2722 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2724 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2723 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2725 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2724 fullDateRange = true; 2726 fullDateRange = true;
2725 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2727 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2726 } 2728 }
2727 } 2729 }
2730 fullDateRange = true; // debug only!
2728 if ( fullDateRange ) 2731 if ( fullDateRange )
2729 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2732 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2730 else 2733 else
2731 mLastAddressbookSync = addresseeLSync.revision(); 2734 mLastAddressbookSync = addresseeLSync.revision();
2732 // for resyncing if own file has changed 2735 // for resyncing if own file has changed
2733 // PENDING fixme later when implemented 2736 // PENDING fixme later when implemented
2734#if 0 2737#if 0
2735 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2738 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2736 mLastAddressbookSync = loadedFileVersion; 2739 mLastAddressbookSync = loadedFileVersion;
2737 qDebug("setting mLastAddressbookSync "); 2740 qDebug("setting mLastAddressbookSync ");
2738 } 2741 }
2739#endif 2742#endif
2740 2743
2741 //qDebug("*************************** "); 2744 //qDebug("*************************** ");
2742 qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2745 qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2743 QStringList er = remote->uidList(); 2746 QStringList er = remote->uidList();
2744 Addressee inR ;//= er.first(); 2747 Addressee inR ;//= er.first();
2745 Addressee inL; 2748 Addressee inL;
2746 QProgressBar bar( er.count(),0 ); 2749 QProgressBar bar( er.count(),0 );
2747 bar.setCaption (i18n("Syncing - close to abort!") ); 2750 bar.setCaption (i18n("Syncing - close to abort!") );
2748 2751
2749 int w = 300; 2752 int w = 300;
2750 if ( QApplication::desktop()->width() < 320 ) 2753 if ( QApplication::desktop()->width() < 320 )
2751 w = 220; 2754 w = 220;
2752 int h = bar.sizeHint().height() ; 2755 int h = bar.sizeHint().height() ;
2753 int dw = QApplication::desktop()->width(); 2756 int dw = QApplication::desktop()->width();
2754 int dh = QApplication::desktop()->height(); 2757 int dh = QApplication::desktop()->height();
2755 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2758 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2756 bar.show(); 2759 bar.show();
2757 int modulo = (er.count()/10)+1; 2760 int modulo = (er.count()/10)+1;
2758 int incCounter = 0; 2761 int incCounter = 0;
2759 while ( incCounter < er.count()) { 2762 while ( incCounter < er.count()) {
2760 if ( ! bar.isVisible() ) 2763 if ( ! bar.isVisible() )
2761 return false; 2764 return false;
2762 if ( incCounter % modulo == 0 ) 2765 if ( incCounter % modulo == 0 )
2763 bar.setProgress( incCounter ); 2766 bar.setProgress( incCounter );
2764 uid = er[ incCounter ]; 2767 uid = er[ incCounter ];
2765 bool skipIncidence = false; 2768 bool skipIncidence = false;
2766 if ( uid.left(19) == QString("last-syncAddressee-") ) 2769 if ( uid.left(19) == QString("last-syncAddressee-") )
2767 skipIncidence = true; 2770 skipIncidence = true;
2768 QString idS; 2771 QString idS;
2769 qApp->processEvents(); 2772 qApp->processEvents();
2770 if ( !skipIncidence ) { 2773 if ( !skipIncidence ) {
2771 inL = local->findByUid( uid ); 2774 inL = local->findByUid( uid );
2772 inR = remote->findByUid( uid ); 2775 inR = remote->findByUid( uid );
2773 //inL.setResource( 0 ); 2776 //inL.setResource( 0 );
2774 //inR.setResource( 0 ); 2777 //inR.setResource( 0 );
2775 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2778 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars