author | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
commit | b01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (unidiff) | |
tree | c0e79d45242a764b49470d07a9c95be156c121cc /korganizer | |
parent | 3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff) | |
download | kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2 |
more AB sync
-rw-r--r-- | korganizer/calendarview.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0c75632..8e83723 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -697,159 +697,161 @@ void CalendarView::confSync() | |||
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | QDateTime localMod = local->lastModified(); | ||
730 | QDateTime remoteMod = remote->lastModified(); | ||
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 731 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 732 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 733 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | //if ( remCh ) | 734 | //if ( remCh ) |
733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 735 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 736 | locCh = ( localMod > mLastCalendarSync ); |
735 | if ( !remCh && ! locCh ) { | 737 | if ( !remCh && ! locCh ) { |
736 | //qDebug("both not changed "); | 738 | //qDebug("both not changed "); |
737 | lastSync = local->lastModified().addDays(1); | 739 | lastSync = localMod.addDays(1); |
738 | if ( mode <= SYNC_PREF_ASK ) | 740 | if ( mode <= SYNC_PREF_ASK ) |
739 | return 0; | 741 | return 0; |
740 | } else { | 742 | } else { |
741 | if ( locCh ) { | 743 | if ( locCh ) { |
742 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 744 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
743 | lastSync = local->lastModified().addDays( -1 ); | 745 | lastSync = localMod.addDays( -1 ); |
744 | if ( !remCh ) | 746 | if ( !remCh ) |
745 | remote->setLastModified( lastSync.addDays( -1 ) ); | 747 | remoteMod = ( lastSync.addDays( -1 ) ); |
746 | } else { | 748 | } else { |
747 | //qDebug(" not loc changed "); | 749 | //qDebug(" not loc changed "); |
748 | lastSync = local->lastModified().addDays( 1 ); | 750 | lastSync = localMod.addDays( 1 ); |
749 | if ( remCh ) | 751 | if ( remCh ) |
750 | remote->setLastModified( lastSync.addDays( 1 ) ); | 752 | remoteMod =( lastSync.addDays( 1 ) ); |
751 | 753 | ||
752 | } | 754 | } |
753 | } | 755 | } |
754 | full = true; | 756 | full = true; |
755 | if ( mode < SYNC_PREF_ASK ) | 757 | if ( mode < SYNC_PREF_ASK ) |
756 | mode = SYNC_PREF_ASK; | 758 | mode = SYNC_PREF_ASK; |
757 | } else { | 759 | } else { |
758 | if ( local->lastModified() == remote->lastModified() ) | 760 | if ( localMod == remoteMod ) |
759 | if ( local->revision() == remote->revision() ) | 761 | if ( local->revision() == remote->revision() ) |
760 | return 0; | 762 | return 0; |
761 | 763 | ||
762 | } | 764 | } |
763 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 765 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
764 | 766 | ||
765 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 767 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
766 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 768 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
767 | //full = true; //debug only | 769 | //full = true; //debug only |
768 | if ( full ) { | 770 | if ( full ) { |
769 | bool equ = false; | 771 | bool equ = false; |
770 | if ( local->type() == "Event" ) { | 772 | if ( local->type() == "Event" ) { |
771 | equ = (*((Event*) local) == *((Event*) remote)); | 773 | equ = (*((Event*) local) == *((Event*) remote)); |
772 | } | 774 | } |
773 | else if ( local->type() =="Todo" ) | 775 | else if ( local->type() =="Todo" ) |
774 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 776 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
775 | else if ( local->type() =="Journal" ) | 777 | else if ( local->type() =="Journal" ) |
776 | equ = (*((Journal*) local) == *((Journal*) remote)); | 778 | equ = (*((Journal*) local) == *((Journal*) remote)); |
777 | if ( equ ) { | 779 | if ( equ ) { |
778 | //qDebug("equal "); | 780 | //qDebug("equal "); |
779 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 781 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
780 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 782 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
781 | } | 783 | } |
782 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 784 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
783 | return 0; | 785 | return 0; |
784 | 786 | ||
785 | }//else //debug only | 787 | }//else //debug only |
786 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 788 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
787 | } | 789 | } |
788 | int result; | 790 | int result; |
789 | bool localIsNew; | 791 | bool localIsNew; |
790 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 792 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
791 | 793 | ||
792 | if ( full && mode < SYNC_PREF_NEWEST ) | 794 | if ( full && mode < SYNC_PREF_NEWEST ) |
793 | mode = SYNC_PREF_ASK; | 795 | mode = SYNC_PREF_ASK; |
794 | 796 | ||
795 | switch( mode ) { | 797 | switch( mode ) { |
796 | case SYNC_PREF_LOCAL: | 798 | case SYNC_PREF_LOCAL: |
797 | if ( lastSync > remote->lastModified() ) | 799 | if ( lastSync > remoteMod ) |
798 | return 1; | 800 | return 1; |
799 | if ( lastSync > local->lastModified() ) | 801 | if ( lastSync > localMod ) |
800 | return 2; | 802 | return 2; |
801 | return 1; | 803 | return 1; |
802 | break; | 804 | break; |
803 | case SYNC_PREF_REMOTE: | 805 | case SYNC_PREF_REMOTE: |
804 | if ( lastSync > remote->lastModified() ) | 806 | if ( lastSync > remoteMod ) |
805 | return 1; | 807 | return 1; |
806 | if ( lastSync > local->lastModified() ) | 808 | if ( lastSync > localMod ) |
807 | return 2; | 809 | return 2; |
808 | return 2; | 810 | return 2; |
809 | break; | 811 | break; |
810 | case SYNC_PREF_NEWEST: | 812 | case SYNC_PREF_NEWEST: |
811 | if ( local->lastModified() > remote->lastModified() ) | 813 | if ( localMod > remoteMod ) |
812 | return 1; | 814 | return 1; |
813 | else | 815 | else |
814 | return 2; | 816 | return 2; |
815 | break; | 817 | break; |
816 | case SYNC_PREF_ASK: | 818 | case SYNC_PREF_ASK: |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 819 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | if ( lastSync > remote->lastModified() ) | 820 | if ( lastSync > remoteMod ) |
819 | return 1; | 821 | return 1; |
820 | if ( lastSync > local->lastModified() ) | 822 | if ( lastSync > localMod ) |
821 | return 2; | 823 | return 2; |
822 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 824 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
823 | localIsNew = local->lastModified() >= remote->lastModified(); | 825 | localIsNew = localMod >= remoteMod; |
824 | if ( localIsNew ) | 826 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
826 | else | 828 | else |
827 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
828 | getEventViewerDialog()->setIncidence(local); | 830 | getEventViewerDialog()->setIncidence(local); |
829 | if ( localIsNew ) | 831 | if ( localIsNew ) |
830 | getEventViewerDialog()->setColorMode( 2 ); | 832 | getEventViewerDialog()->setColorMode( 2 ); |
831 | else | 833 | else |
832 | getEventViewerDialog()->setColorMode( 1 ); | 834 | getEventViewerDialog()->setColorMode( 1 ); |
833 | getEventViewerDialog()->addIncidence(remote); | 835 | getEventViewerDialog()->addIncidence(remote); |
834 | getEventViewerDialog()->setColorMode( 0 ); | 836 | getEventViewerDialog()->setColorMode( 0 ); |
835 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 837 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
836 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 838 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
837 | getEventViewerDialog()->showMe(); | 839 | getEventViewerDialog()->showMe(); |
838 | result = getEventViewerDialog()->executeS( localIsNew ); | 840 | result = getEventViewerDialog()->executeS( localIsNew ); |
839 | return result; | 841 | return result; |
840 | 842 | ||
841 | break; | 843 | break; |
842 | case SYNC_PREF_FORCE_LOCAL: | 844 | case SYNC_PREF_FORCE_LOCAL: |
843 | return 1; | 845 | return 1; |
844 | break; | 846 | break; |
845 | case SYNC_PREF_FORCE_REMOTE: | 847 | case SYNC_PREF_FORCE_REMOTE: |
846 | return 2; | 848 | return 2; |
847 | break; | 849 | break; |
848 | 850 | ||
849 | default: | 851 | default: |
850 | // SYNC_PREF_TAKE_BOTH not implemented | 852 | // SYNC_PREF_TAKE_BOTH not implemented |
851 | break; | 853 | break; |
852 | } | 854 | } |
853 | return 0; | 855 | return 0; |
854 | } | 856 | } |
855 | Event* CalendarView::getLastSyncEvent() | 857 | Event* CalendarView::getLastSyncEvent() |