-rw-r--r-- | kaddressbook/kabcore.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 16 |
2 files changed, 17 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index eba74a6..20b107e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2823,110 +2823,112 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2823 | lastSync = localMod.addDays( 1 ); | 2823 | lastSync = localMod.addDays( 1 ); |
2824 | if ( remCh ) { | 2824 | if ( remCh ) { |
2825 | //qDebug("rem changed "); | 2825 | //qDebug("rem changed "); |
2826 | remoteMod =( lastSync.addDays( 1 ) ); | 2826 | remoteMod =( lastSync.addDays( 1 ) ); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | } | 2829 | } |
2830 | } | 2830 | } |
2831 | full = true; | 2831 | full = true; |
2832 | if ( mode < SYNC_PREF_ASK ) | 2832 | if ( mode < SYNC_PREF_ASK ) |
2833 | mode = SYNC_PREF_ASK; | 2833 | mode = SYNC_PREF_ASK; |
2834 | } else { | 2834 | } else { |
2835 | if ( localMod == remoteMod ) | 2835 | if ( localMod == remoteMod ) |
2836 | return 0; | 2836 | return 0; |
2837 | 2837 | ||
2838 | } | 2838 | } |
2839 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2839 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2840 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2840 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2841 | //full = true; //debug only | 2841 | //full = true; //debug only |
2842 | if ( full ) { | 2842 | if ( full ) { |
2843 | bool equ = ( (*local) == (*remote) ); | 2843 | bool equ = ( (*local) == (*remote) ); |
2844 | if ( equ ) { | 2844 | if ( equ ) { |
2845 | //qDebug("equal "); | 2845 | //qDebug("equal "); |
2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2847 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2847 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2848 | } | 2848 | } |
2849 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2849 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2850 | return 0; | 2850 | return 0; |
2851 | 2851 | ||
2852 | }//else //debug only | 2852 | }//else //debug only |
2853 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2853 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2854 | } | 2854 | } |
2855 | int result; | 2855 | int result; |
2856 | bool localIsNew; | 2856 | bool localIsNew; |
2857 | //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() ); | 2857 | //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() ); |
2858 | 2858 | ||
2859 | if ( full && mode < SYNC_PREF_NEWEST ) | 2859 | if ( full && mode < SYNC_PREF_NEWEST ) |
2860 | mode = SYNC_PREF_ASK; | 2860 | mode = SYNC_PREF_ASK; |
2861 | 2861 | ||
2862 | switch( mode ) { | 2862 | switch( mode ) { |
2863 | case SYNC_PREF_LOCAL: | 2863 | case SYNC_PREF_LOCAL: |
2864 | if ( lastSync > remoteMod ) | 2864 | if ( lastSync > remoteMod ) |
2865 | return 1; | 2865 | return 1; |
2866 | if ( lastSync > localMod ) | 2866 | if ( lastSync > localMod ) |
2867 | return 2; | 2867 | return 2; |
2868 | return 1; | 2868 | return 1; |
2869 | break; | 2869 | break; |
2870 | case SYNC_PREF_REMOTE: | 2870 | case SYNC_PREF_REMOTE: |
2871 | if ( lastSync > remoteMod ) | ||
2872 | return 1; | ||
2873 | if ( lastSync > localMod ) | 2871 | if ( lastSync > localMod ) |
2874 | return 2; | 2872 | return 2; |
2873 | if ( lastSync > remoteMod ) | ||
2874 | return 1; | ||
2875 | return 2; | 2875 | return 2; |
2876 | break; | 2876 | break; |
2877 | case SYNC_PREF_NEWEST: | 2877 | case SYNC_PREF_NEWEST: |
2878 | if ( localMod > remoteMod ) | 2878 | if ( localMod > remoteMod ) |
2879 | return 1; | 2879 | return 1; |
2880 | else | 2880 | else |
2881 | return 2; | 2881 | return 2; |
2882 | break; | 2882 | break; |
2883 | case SYNC_PREF_ASK: | 2883 | case SYNC_PREF_ASK: |
2884 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2884 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2885 | if ( lastSync > remoteMod && lastSync > localMod) | ||
2886 | return 0; | ||
2885 | if ( lastSync > remoteMod ) | 2887 | if ( lastSync > remoteMod ) |
2886 | return 1; | 2888 | return 1; |
2887 | if ( lastSync > localMod ) { | 2889 | if ( lastSync > localMod ) { |
2888 | return 2; | 2890 | return 2; |
2889 | } | 2891 | } |
2890 | localIsNew = localMod >= remoteMod; | 2892 | localIsNew = localMod >= remoteMod; |
2891 | //qDebug("conflict! ************************************** "); | 2893 | //qDebug("conflict! ************************************** "); |
2892 | { | 2894 | { |
2893 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2895 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2894 | result = acd.executeD(localIsNew); | 2896 | result = acd.executeD(localIsNew); |
2895 | return result; | 2897 | return result; |
2896 | } | 2898 | } |
2897 | break; | 2899 | break; |
2898 | case SYNC_PREF_FORCE_LOCAL: | 2900 | case SYNC_PREF_FORCE_LOCAL: |
2899 | return 1; | 2901 | return 1; |
2900 | break; | 2902 | break; |
2901 | case SYNC_PREF_FORCE_REMOTE: | 2903 | case SYNC_PREF_FORCE_REMOTE: |
2902 | return 2; | 2904 | return 2; |
2903 | break; | 2905 | break; |
2904 | 2906 | ||
2905 | default: | 2907 | default: |
2906 | // SYNC_PREF_TAKE_BOTH not implemented | 2908 | // SYNC_PREF_TAKE_BOTH not implemented |
2907 | break; | 2909 | break; |
2908 | } | 2910 | } |
2909 | return 0; | 2911 | return 0; |
2910 | } | 2912 | } |
2911 | 2913 | ||
2912 | 2914 | ||
2913 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2915 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2914 | { | 2916 | { |
2915 | bool syncOK = true; | 2917 | bool syncOK = true; |
2916 | int addedAddressee = 0; | 2918 | int addedAddressee = 0; |
2917 | int addedAddresseeR = 0; | 2919 | int addedAddresseeR = 0; |
2918 | int deletedAddresseeR = 0; | 2920 | int deletedAddresseeR = 0; |
2919 | int deletedAddresseeL = 0; | 2921 | int deletedAddresseeL = 0; |
2920 | int changedLocal = 0; | 2922 | int changedLocal = 0; |
2921 | int changedRemote = 0; | 2923 | int changedRemote = 0; |
2922 | int filteredIN = 0; | 2924 | int filteredIN = 0; |
2923 | int filteredOUT = 0; | 2925 | int filteredOUT = 0; |
2924 | 2926 | ||
2925 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2927 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2926 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2928 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2927 | 2929 | ||
2928 | //QPtrList<Addressee> el = local->rawAddressees(); | 2930 | //QPtrList<Addressee> el = local->rawAddressees(); |
2929 | Addressee addresseeR; | 2931 | Addressee addresseeR; |
2930 | QString uid; | 2932 | QString uid; |
2931 | int take; | 2933 | int take; |
2932 | Addressee addresseeL; | 2934 | Addressee addresseeL; |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 76cce26..00ef145 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -771,122 +771,132 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
771 | if ( !remCh ) | 771 | if ( !remCh ) |
772 | remoteMod = ( lastSync.addDays( -1 ) ); | 772 | remoteMod = ( lastSync.addDays( -1 ) ); |
773 | } else { | 773 | } else { |
774 | //qDebug(" not loc changed "); | 774 | //qDebug(" not loc changed "); |
775 | lastSync = localMod.addDays( 1 ); | 775 | lastSync = localMod.addDays( 1 ); |
776 | if ( remCh ) | 776 | if ( remCh ) |
777 | remoteMod =( lastSync.addDays( 1 ) ); | 777 | remoteMod =( lastSync.addDays( 1 ) ); |
778 | 778 | ||
779 | } | 779 | } |
780 | } | 780 | } |
781 | full = true; | 781 | full = true; |
782 | if ( mode < SYNC_PREF_ASK ) | 782 | if ( mode < SYNC_PREF_ASK ) |
783 | mode = SYNC_PREF_ASK; | 783 | mode = SYNC_PREF_ASK; |
784 | } else { | 784 | } else { |
785 | if ( localMod == remoteMod ) | 785 | if ( localMod == remoteMod ) |
786 | // if ( local->revision() == remote->revision() ) | 786 | // if ( local->revision() == remote->revision() ) |
787 | return 0; | 787 | return 0; |
788 | 788 | ||
789 | } | 789 | } |
790 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 790 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
791 | 791 | ||
792 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 792 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
793 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 793 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
794 | //full = true; //debug only | 794 | //full = true; //debug only |
795 | if ( full ) { | 795 | if ( full ) { |
796 | bool equ = false; | 796 | bool equ = false; |
797 | if ( local->type() == "Event" ) { | 797 | if ( local->type() == "Event" ) { |
798 | equ = (*((Event*) local) == *((Event*) remote)); | 798 | equ = (*((Event*) local) == *((Event*) remote)); |
799 | } | 799 | } |
800 | else if ( local->type() =="Todo" ) | 800 | else if ( local->type() =="Todo" ) |
801 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 801 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
802 | else if ( local->type() =="Journal" ) | 802 | else if ( local->type() =="Journal" ) |
803 | equ = (*((Journal*) local) == *((Journal*) remote)); | 803 | equ = (*((Journal*) local) == *((Journal*) remote)); |
804 | if ( equ ) { | 804 | if ( equ ) { |
805 | //qDebug("equal "); | 805 | //qDebug("equal "); |
806 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 806 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
807 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 807 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
808 | } | 808 | } |
809 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 809 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
810 | return 0; | 810 | return 0; |
811 | 811 | ||
812 | }//else //debug only | 812 | }//else //debug only |
813 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 813 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
814 | } | 814 | } |
815 | int result; | 815 | int result; |
816 | bool localIsNew; | 816 | bool localIsNew; |
817 | //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() ); | 817 | //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() ); |
818 | 818 | ||
819 | |||
820 | // ************************************************ | ||
821 | // ************************************************ | ||
822 | // ************************************************ | ||
823 | // We may have that lastSync > remoteMod AND lastSync > localMod | ||
824 | // BUT remoteMod != localMod | ||
825 | |||
826 | |||
819 | if ( full && mode < SYNC_PREF_NEWEST ) | 827 | if ( full && mode < SYNC_PREF_NEWEST ) |
820 | mode = SYNC_PREF_ASK; | 828 | mode = SYNC_PREF_ASK; |
821 | 829 | ||
822 | switch( mode ) { | 830 | switch( mode ) { |
823 | case SYNC_PREF_LOCAL: | 831 | case SYNC_PREF_LOCAL: |
824 | if ( lastSync > remoteMod ) | 832 | if ( lastSync > remoteMod ) |
825 | return 1; | 833 | return 1; |
826 | if ( lastSync > localMod ) | 834 | if ( lastSync > localMod ) |
827 | return 2; | 835 | return 2; |
828 | return 1; | 836 | return 1; |
829 | break; | 837 | break; |
830 | case SYNC_PREF_REMOTE: | 838 | case SYNC_PREF_REMOTE: |
831 | if ( lastSync > remoteMod ) | ||
832 | return 1; | ||
833 | if ( lastSync > localMod ) | 839 | if ( lastSync > localMod ) |
834 | return 2; | 840 | return 2; |
841 | if ( lastSync > remoteMod ) | ||
842 | return 1; | ||
835 | return 2; | 843 | return 2; |
836 | break; | 844 | break; |
837 | case SYNC_PREF_NEWEST: | 845 | case SYNC_PREF_NEWEST: |
838 | if ( localMod > remoteMod ) | 846 | if ( localMod >= remoteMod ) |
839 | return 1; | 847 | return 1; |
840 | else | 848 | else |
841 | return 2; | 849 | return 2; |
842 | break; | 850 | break; |
843 | case SYNC_PREF_ASK: | 851 | case SYNC_PREF_ASK: |
844 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 852 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
853 | if ( lastSync > remoteMod && lastSync > localMod) | ||
854 | return 0; | ||
845 | if ( lastSync > remoteMod ) | 855 | if ( lastSync > remoteMod ) |
846 | return 1; | 856 | return 1; |
847 | if ( lastSync > localMod ) | 857 | if ( lastSync > localMod ) |
848 | return 2; | 858 | return 2; |
849 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 859 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
850 | localIsNew = localMod >= remoteMod; | 860 | localIsNew = localMod >= remoteMod; |
851 | if ( localIsNew ) | 861 | if ( localIsNew ) |
852 | getEventViewerDialog()->setColorMode( 1 ); | 862 | getEventViewerDialog()->setColorMode( 1 ); |
853 | else | 863 | else |
854 | getEventViewerDialog()->setColorMode( 2 ); | 864 | getEventViewerDialog()->setColorMode( 2 ); |
855 | getEventViewerDialog()->setIncidence(local); | 865 | getEventViewerDialog()->setIncidence(local); |
856 | if ( localIsNew ) | 866 | if ( localIsNew ) |
857 | getEventViewerDialog()->setColorMode( 2 ); | 867 | getEventViewerDialog()->setColorMode( 2 ); |
858 | else | 868 | else |
859 | getEventViewerDialog()->setColorMode( 1 ); | 869 | getEventViewerDialog()->setColorMode( 1 ); |
860 | getEventViewerDialog()->addIncidence(remote); | 870 | getEventViewerDialog()->addIncidence(remote); |
861 | getEventViewerDialog()->setColorMode( 0 ); | 871 | getEventViewerDialog()->setColorMode( 0 ); |
862 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 872 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
863 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 873 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
864 | getEventViewerDialog()->showMe(); | 874 | getEventViewerDialog()->showMe(); |
865 | result = getEventViewerDialog()->executeS( localIsNew ); | 875 | result = getEventViewerDialog()->executeS( localIsNew ); |
866 | return result; | 876 | return result; |
867 | 877 | ||
868 | break; | 878 | break; |
869 | case SYNC_PREF_FORCE_LOCAL: | 879 | case SYNC_PREF_FORCE_LOCAL: |
870 | return 1; | 880 | return 1; |
871 | break; | 881 | break; |
872 | case SYNC_PREF_FORCE_REMOTE: | 882 | case SYNC_PREF_FORCE_REMOTE: |
873 | return 2; | 883 | return 2; |
874 | break; | 884 | break; |
875 | 885 | ||
876 | default: | 886 | default: |
877 | // SYNC_PREF_TAKE_BOTH not implemented | 887 | // SYNC_PREF_TAKE_BOTH not implemented |
878 | break; | 888 | break; |
879 | } | 889 | } |
880 | return 0; | 890 | return 0; |
881 | } | 891 | } |
882 | Event* CalendarView::getLastSyncEvent() | 892 | Event* CalendarView::getLastSyncEvent() |
883 | { | 893 | { |
884 | Event* lse; | 894 | Event* lse; |
885 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 895 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
886 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 896 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
887 | if (!lse) { | 897 | if (!lse) { |
888 | lse = new Event(); | 898 | lse = new Event(); |
889 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 899 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
890 | QString sum = ""; | 900 | QString sum = ""; |
891 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 901 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
892 | sum = "E: "; | 902 | sum = "E: "; |