author | zautrix <zautrix> | 2004-09-12 17:18:27 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 17:18:27 (UTC) |
commit | bc4153a99e205f43d0144e2e910730dd1a14d402 (patch) (unidiff) | |
tree | 16aeb28cd765539bac6e85e714478f31a7b93bac /korganizer | |
parent | a222c2f7369eeefd19454c973c0cc48300f72bec (diff) | |
download | kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.zip kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.gz kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.bz2 |
added missing sync featute
-rw-r--r-- | korganizer/calendarview.cpp | 53 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 6 |
3 files changed, 47 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index db07713..cfd9290 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -708,135 +708,139 @@ void CalendarView::confSync() | |||
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 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 730 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | if ( remCh ) | ||
733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | ||
732 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
733 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
734 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
735 | //qDebug("both not changed "); | 737 | qDebug("both not changed "); |
736 | lastSync = local->lastModified().addDays(1); | 738 | lastSync = local->lastModified().addDays(1); |
737 | } else { | 739 | } else { |
738 | if ( locCh ) { | 740 | if ( locCh ) { |
739 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); | 741 | qDebug("loc changed %d", local->revision() ); |
740 | lastSync = local->lastModified().addDays( -1 ); | 742 | lastSync = local->lastModified().addDays( -1 ); |
741 | if ( !remCh ) | 743 | if ( !remCh ) |
742 | remote->setLastModified( lastSync.addDays( -1 ) ); | 744 | remote->setLastModified( lastSync.addDays( -1 ) ); |
743 | } else { | 745 | } else { |
744 | //qDebug(" not loc changed "); | 746 | qDebug(" not loc changed "); |
745 | lastSync = local->lastModified().addDays( 1 ); | 747 | lastSync = local->lastModified().addDays( 1 ); |
746 | if ( remCh ) | 748 | if ( remCh ) |
747 | remote->setLastModified( lastSync.addDays( 1 ) ); | 749 | remote->setLastModified( lastSync.addDays( 1 ) ); |
748 | 750 | ||
749 | } | 751 | } |
750 | } | 752 | } |
751 | full = true; | 753 | full = true; |
752 | if ( mode < SYNC_PREF_ASK ) | 754 | if ( mode < SYNC_PREF_ASK ) |
753 | mode = SYNC_PREF_ASK; | 755 | mode = SYNC_PREF_ASK; |
754 | } else { | 756 | } else { |
755 | if ( local->lastModified() == remote->lastModified() ) | 757 | if ( local->lastModified() == remote->lastModified() ) |
756 | if ( local->revision() == remote->revision() ) | 758 | if ( local->revision() == remote->revision() ) |
757 | return 0; | 759 | return 0; |
758 | 760 | ||
759 | } | 761 | } |
760 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
761 | 763 | ||
762 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
763 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
764 | //full = true; //debug only | 766 | //full = true; //debug only |
765 | if ( full ) { | 767 | if ( full ) { |
766 | bool equ = false; | 768 | bool equ = false; |
767 | if ( local->type() == "Event" ) { | 769 | if ( local->type() == "Event" ) { |
768 | equ = (*((Event*) local) == *((Event*) remote)); | 770 | equ = (*((Event*) local) == *((Event*) remote)); |
769 | } | 771 | } |
770 | else if ( local->type() =="Todo" ) | 772 | else if ( local->type() =="Todo" ) |
771 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 773 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
772 | else if ( local->type() =="Journal" ) | 774 | else if ( local->type() =="Journal" ) |
773 | equ = (*((Journal*) local) == *((Journal*) remote)); | 775 | equ = (*((Journal*) local) == *((Journal*) remote)); |
774 | if ( equ ) { | 776 | if ( equ ) { |
775 | //qDebug("equal "); | 777 | //qDebug("equal "); |
776 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
777 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
778 | } | 780 | } |
779 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
780 | return 0; | 782 | return 0; |
781 | 783 | ||
782 | }//else //debug only | 784 | }//else //debug only |
783 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
784 | } | 786 | } |
785 | int result; | 787 | int result; |
786 | bool localIsNew; | 788 | bool localIsNew; |
789 | qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | ||
790 | |||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 791 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 792 | mode = SYNC_PREF_ASK; |
789 | 793 | ||
790 | switch( mode ) { | 794 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 795 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remote->lastModified() ) | 796 | if ( lastSync > remote->lastModified() ) |
793 | return 1; | 797 | return 1; |
794 | if ( lastSync > local->lastModified() ) | 798 | if ( lastSync > local->lastModified() ) |
795 | return 2; | 799 | return 2; |
796 | return 1; | 800 | return 1; |
797 | break; | 801 | break; |
798 | case SYNC_PREF_REMOTE: | 802 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remote->lastModified() ) | 803 | if ( lastSync > remote->lastModified() ) |
800 | return 1; | 804 | return 1; |
801 | if ( lastSync > local->lastModified() ) | 805 | if ( lastSync > local->lastModified() ) |
802 | return 2; | 806 | return 2; |
803 | return 2; | 807 | return 2; |
804 | break; | 808 | break; |
805 | case SYNC_PREF_NEWEST: | 809 | case SYNC_PREF_NEWEST: |
806 | if ( local->lastModified() > remote->lastModified() ) | 810 | if ( local->lastModified() > remote->lastModified() ) |
807 | return 1; | 811 | return 1; |
808 | else | 812 | else |
809 | return 2; | 813 | return 2; |
810 | break; | 814 | break; |
811 | case SYNC_PREF_ASK: | 815 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
813 | if ( lastSync > remote->lastModified() ) | 817 | if ( lastSync > remote->lastModified() ) |
814 | return 1; | 818 | return 1; |
815 | if ( lastSync > local->lastModified() ) | 819 | if ( lastSync > local->lastModified() ) |
816 | return 2; | 820 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
818 | localIsNew = local->lastModified() > remote->lastModified(); | 822 | localIsNew = local->lastModified() >= remote->lastModified(); |
819 | if ( localIsNew ) | 823 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 824 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 825 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 826 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 827 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 828 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 830 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 831 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 832 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 833 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 836 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 837 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 838 | return result; |
835 | 839 | ||
836 | break; | 840 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 841 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 842 | return 1; |
839 | break; | 843 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 844 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 845 | return 2; |
842 | break; | 846 | break; |
@@ -921,63 +925,67 @@ void CalendarView::checkExternalId( Incidence * inc ) | |||
921 | 925 | ||
922 | } | 926 | } |
923 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 927 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
924 | { | 928 | { |
925 | bool syncOK = true; | 929 | bool syncOK = true; |
926 | int addedEvent = 0; | 930 | int addedEvent = 0; |
927 | int addedEventR = 0; | 931 | int addedEventR = 0; |
928 | int deletedEventR = 0; | 932 | int deletedEventR = 0; |
929 | int deletedEventL = 0; | 933 | int deletedEventL = 0; |
930 | int changedLocal = 0; | 934 | int changedLocal = 0; |
931 | int changedRemote = 0; | 935 | int changedRemote = 0; |
932 | //QPtrList<Event> el = local->rawEvents(); | 936 | //QPtrList<Event> el = local->rawEvents(); |
933 | Event* eventR; | 937 | Event* eventR; |
934 | QString uid; | 938 | QString uid; |
935 | int take; | 939 | int take; |
936 | Event* eventL; | 940 | Event* eventL; |
937 | Event* eventRSync; | 941 | Event* eventRSync; |
938 | Event* eventLSync; | 942 | Event* eventLSync; |
939 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 943 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
940 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
941 | bool fullDateRange = false; | 945 | bool fullDateRange = false; |
942 | local->resetTempSyncStat(); | 946 | local->resetTempSyncStat(); |
943 | mLastCalendarSync = QDateTime::currentDateTime(); | 947 | mLastCalendarSync = QDateTime::currentDateTime(); |
944 | QDateTime modifiedCalendar = mLastCalendarSync;; | 948 | QDateTime modifiedCalendar = mLastCalendarSync;; |
949 | eventLSync = getLastSyncEvent(); | ||
945 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
946 | if ( eventR ) { | 951 | if ( eventR ) { |
947 | eventRSync = (Event*) eventR->clone(); | 952 | eventRSync = (Event*) eventR->clone(); |
948 | remote->deleteEvent(eventR ); | 953 | remote->deleteEvent(eventR ); |
949 | 954 | ||
950 | } else { | 955 | } else { |
951 | fullDateRange = true; | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
952 | eventRSync = new Event(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
953 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 958 | } else { |
954 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 959 | fullDateRange = true; |
955 | eventRSync->setDtStart( mLastCalendarSync ); | 960 | eventRSync = new Event(); |
956 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
957 | eventRSync->setCategories( i18n("SyncEvent") ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | ||
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | ||
965 | eventRSync->setCategories( i18n("SyncEvent") ); | ||
966 | } | ||
958 | } | 967 | } |
959 | eventLSync = getLastSyncEvent(); | ||
960 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
961 | fullDateRange = true; | 969 | fullDateRange = true; |
962 | 970 | ||
963 | if ( ! fullDateRange ) { | 971 | if ( ! fullDateRange ) { |
964 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
965 | 973 | ||
966 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
967 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
968 | fullDateRange = true; | 976 | fullDateRange = true; |
969 | } | 977 | } |
970 | } | 978 | } |
971 | if ( fullDateRange ) | 979 | if ( fullDateRange ) |
972 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 980 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
973 | else | 981 | else |
974 | mLastCalendarSync = eventLSync->dtStart(); | 982 | mLastCalendarSync = eventLSync->dtStart(); |
975 | // for resyncing if own file has changed | 983 | // for resyncing if own file has changed |
976 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
977 | mLastCalendarSync = loadedFileVersion; | 985 | mLastCalendarSync = loadedFileVersion; |
978 | qDebug("setting mLastCalendarSync "); | 986 | qDebug("setting mLastCalendarSync "); |
979 | } | 987 | } |
980 | //qDebug("*************************** "); | 988 | //qDebug("*************************** "); |
981 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
982 | QPtrList<Incidence> er = remote->rawIncidences(); | 990 | QPtrList<Incidence> er = remote->rawIncidences(); |
983 | Incidence* inR = er.first(); | 991 | Incidence* inR = er.first(); |
@@ -1095,49 +1103,68 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1095 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1096 | inL->removeID(mCurrentSyncDevice ); | 1104 | inL->removeID(mCurrentSyncDevice ); |
1097 | ++addedEventR; | 1105 | ++addedEventR; |
1098 | inL->setLastModified( modifiedCalendar ); | 1106 | inL->setLastModified( modifiedCalendar ); |
1099 | remote->addIncidence( inL->clone() ); | 1107 | remote->addIncidence( inL->clone() ); |
1100 | } | 1108 | } |
1101 | } | 1109 | } |
1102 | } else { | 1110 | } else { |
1103 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1104 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1105 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1106 | ++deletedEventL; | 1114 | ++deletedEventL; |
1107 | } else { | 1115 | } else { |
1108 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1109 | ++addedEventR; | 1117 | ++addedEventR; |
1110 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1111 | remote->addIncidence( inL->clone() ); | 1119 | remote->addIncidence( inL->clone() ); |
1112 | } | 1120 | } |
1113 | } | 1121 | } |
1114 | } | 1122 | } |
1115 | } | 1123 | } |
1116 | } | 1124 | } |
1117 | inL = el.next(); | 1125 | inL = el.next(); |
1118 | } | 1126 | } |
1119 | 1127 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | |
1128 | er = remote->rawIncidences(); | ||
1129 | inR = er.first(); | ||
1130 | QDateTime dt; | ||
1131 | QDateTime cur = QDateTime::currentDateTime(); | ||
1132 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | ||
1133 | while ( inR ) { | ||
1134 | if ( inR->type() == "Todo" ) { | ||
1135 | Todo * t = (Todo*)inR; | ||
1136 | if ( t->hasDueDate() ) | ||
1137 | dt = t->dtDue(); | ||
1138 | else | ||
1139 | dt = cur.addSecs( 62 ); | ||
1140 | } | ||
1141 | else dt = inR->dtStart(); | ||
1142 | if ( dt < cur || dt > end ) | ||
1143 | remote->deleteIncidence( inR ); | ||
1144 | inR = er.next(); | ||
1145 | } | ||
1146 | } | ||
1120 | bar.hide(); | 1147 | bar.hide(); |
1121 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1148 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1122 | eventLSync->setReadOnly( false ); | 1149 | eventLSync->setReadOnly( false ); |
1123 | eventLSync->setDtStart( mLastCalendarSync ); | 1150 | eventLSync->setDtStart( mLastCalendarSync ); |
1124 | eventRSync->setDtStart( mLastCalendarSync ); | 1151 | eventRSync->setDtStart( mLastCalendarSync ); |
1125 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1152 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1126 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1153 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1127 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1154 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1128 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1155 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1129 | eventLSync->setReadOnly( true ); | 1156 | eventLSync->setReadOnly( true ); |
1130 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1157 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1131 | remote->addEvent( eventRSync ); | 1158 | remote->addEvent( eventRSync ); |
1132 | QString mes; | 1159 | QString mes; |
1133 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1160 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1134 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1161 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1135 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1162 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1136 | } | 1163 | } |
1137 | qDebug( mes ); | 1164 | qDebug( mes ); |
1138 | mCalendar->checkAlarmForIncidence( 0, true ); | 1165 | mCalendar->checkAlarmForIncidence( 0, true ); |
1139 | return syncOK; | 1166 | return syncOK; |
1140 | } | 1167 | } |
1141 | 1168 | ||
1142 | void CalendarView::setSyncDevice( QString s ) | 1169 | void CalendarView::setSyncDevice( QString s ) |
1143 | { | 1170 | { |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 446fe2e..a9ac52f 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -178,48 +178,49 @@ class KOPrefs : public KPimPrefs | |||
178 | bool mShowIconDay1; | 178 | bool mShowIconDay1; |
179 | bool mShowIconDay5; | 179 | bool mShowIconDay5; |
180 | bool mShowIconDay7; | 180 | bool mShowIconDay7; |
181 | bool mShowIconMonth; | 181 | bool mShowIconMonth; |
182 | bool mShowIconTodoview; | 182 | bool mShowIconTodoview; |
183 | bool mShowIconBackFast; | 183 | bool mShowIconBackFast; |
184 | bool mShowIconBack; | 184 | bool mShowIconBack; |
185 | bool mShowIconToday; | 185 | bool mShowIconToday; |
186 | bool mShowIconForward; | 186 | bool mShowIconForward; |
187 | bool mShowIconForwardFast; | 187 | bool mShowIconForwardFast; |
188 | bool mShowIconWhatsThis; | 188 | bool mShowIconWhatsThis; |
189 | bool mShowIconNextDays; | 189 | bool mShowIconNextDays; |
190 | bool mShowIconNext; | 190 | bool mShowIconNext; |
191 | bool mShowIconJournal; | 191 | bool mShowIconJournal; |
192 | 192 | ||
193 | bool mShowIconStretch; | 193 | bool mShowIconStretch; |
194 | 194 | ||
195 | bool mToolBarHor; | 195 | bool mToolBarHor; |
196 | bool mToolBarUp; | 196 | bool mToolBarUp; |
197 | bool mToolBarMiniIcons; | 197 | bool mToolBarMiniIcons; |
198 | 198 | ||
199 | bool mAskForQuit; | 199 | bool mAskForQuit; |
200 | bool mUsePassWd; | 200 | bool mUsePassWd; |
201 | bool mWriteBackFile; | 201 | bool mWriteBackFile; |
202 | int mWriteBackInFuture; | ||
202 | bool mAskForPreferences; | 203 | bool mAskForPreferences; |
203 | bool mShowSyncSummary; | 204 | bool mShowSyncSummary; |
204 | bool mShowSyncEvents; | 205 | bool mShowSyncEvents; |
205 | bool mShowTodoInAgenda; | 206 | bool mShowTodoInAgenda; |
206 | bool mWriteBackExistingOnly; | 207 | bool mWriteBackExistingOnly; |
207 | 208 | ||
208 | QString mRemoteIP; | 209 | QString mRemoteIP; |
209 | QString mRemoteUser; | 210 | QString mRemoteUser; |
210 | QString mRemotePassWd; | 211 | QString mRemotePassWd; |
211 | QString mRemoteFile; | 212 | QString mRemoteFile; |
212 | QString mLocalTempFile; | 213 | QString mLocalTempFile; |
213 | QString mPhoneDevice; | 214 | QString mPhoneDevice; |
214 | QString mPhoneConnection; | 215 | QString mPhoneConnection; |
215 | QString mPhoneModel; | 216 | QString mPhoneModel; |
216 | 217 | ||
217 | int mLastSyncTime; | 218 | int mLastSyncTime; |
218 | int mSyncAlgoPrefs; | 219 | int mSyncAlgoPrefs; |
219 | int mRingSyncAlgoPrefs; | 220 | int mRingSyncAlgoPrefs; |
220 | QStringList mSyncProfileNames; | 221 | QStringList mSyncProfileNames; |
221 | QStringList mExternSyncProfiles; | 222 | QStringList mExternSyncProfiles; |
222 | QString mLocalMachineName; | 223 | QString mLocalMachineName; |
223 | void setCategoryColor(QString cat,const QColor & color); | 224 | void setCategoryColor(QString cat,const QColor & color); |
224 | QColor *categoryColor(QString cat); | 225 | QColor *categoryColor(QString cat); |
225 | 226 | ||
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index d8aa43a..aa30b52 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -893,48 +893,51 @@ void MainWindow::fillSyncMenu() | |||
893 | syncMenu->setItemEnabled( false , 1000 ); | 893 | syncMenu->setItemEnabled( false , 1000 ); |
894 | } | 894 | } |
895 | mView->setupExternSyncProfiles(); | 895 | mView->setupExternSyncProfiles(); |
896 | } | 896 | } |
897 | 897 | ||
898 | int MainWindow::ringSync() | 898 | int MainWindow::ringSync() |
899 | { | 899 | { |
900 | int syncedProfiles = 0; | 900 | int syncedProfiles = 0; |
901 | int i; | 901 | int i; |
902 | QTime timer; | 902 | QTime timer; |
903 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 903 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
904 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 904 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
905 | KSyncProfile* temp = new KSyncProfile (); | 905 | KSyncProfile* temp = new KSyncProfile (); |
906 | KOPrefs::instance()->mAskForPreferences = false; | 906 | KOPrefs::instance()->mAskForPreferences = false; |
907 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 907 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
908 | mCurrentSyncProfile = i; | 908 | mCurrentSyncProfile = i; |
909 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 909 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
910 | temp->readConfig(&config); | 910 | temp->readConfig(&config); |
911 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 911 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
912 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 912 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
913 | ++syncedProfiles; | 913 | ++syncedProfiles; |
914 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 914 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
915 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 915 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
916 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 916 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
917 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
918 | if ( temp->getWriteBackFuture() ) | ||
919 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
917 | KOPrefs::instance()->mShowSyncSummary = false; | 920 | KOPrefs::instance()->mShowSyncSummary = false; |
918 | mView->setSyncDevice(syncProfileNames[i] ); | 921 | mView->setSyncDevice(syncProfileNames[i] ); |
919 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 922 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
920 | if ( i == 0 ) { | 923 | if ( i == 0 ) { |
921 | syncSharp(); | 924 | syncSharp(); |
922 | } else { | 925 | } else { |
923 | if ( temp->getIsLocalFileSync() ) { | 926 | if ( temp->getIsLocalFileSync() ) { |
924 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 927 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
925 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 928 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
926 | } else { | 929 | } else { |
927 | if ( temp->getIsPhoneSync() ) { | 930 | if ( temp->getIsPhoneSync() ) { |
928 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 931 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
929 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 932 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
930 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 933 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
931 | syncPhone(); | 934 | syncPhone(); |
932 | } else | 935 | } else |
933 | syncRemote( temp, false ); | 936 | syncRemote( temp, false ); |
934 | 937 | ||
935 | } | 938 | } |
936 | } | 939 | } |
937 | timer.start(); | 940 | timer.start(); |
938 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 941 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
939 | while ( timer.elapsed () < 2000 ) { | 942 | while ( timer.elapsed () < 2000 ) { |
940 | qApp->processEvents(); | 943 | qApp->processEvents(); |
@@ -996,48 +999,51 @@ void MainWindow::slotSyncMenu( int action ) | |||
996 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 999 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
997 | //confSync(); | 1000 | //confSync(); |
998 | 1001 | ||
999 | return; | 1002 | return; |
1000 | } | 1003 | } |
1001 | if ( action == 1 ) { | 1004 | if ( action == 1 ) { |
1002 | multiSync( true ); | 1005 | multiSync( true ); |
1003 | return; | 1006 | return; |
1004 | } | 1007 | } |
1005 | 1008 | ||
1006 | if (mBlockSaveFlag) | 1009 | if (mBlockSaveFlag) |
1007 | return; | 1010 | return; |
1008 | mBlockSaveFlag = true; | 1011 | mBlockSaveFlag = true; |
1009 | mCurrentSyncProfile = action - 1000 ; | 1012 | mCurrentSyncProfile = action - 1000 ; |
1010 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1013 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1011 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1014 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1012 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1015 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1013 | KSyncProfile* temp = new KSyncProfile (); | 1016 | KSyncProfile* temp = new KSyncProfile (); |
1014 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1017 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1015 | temp->readConfig(&config); | 1018 | temp->readConfig(&config); |
1016 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1019 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1017 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1020 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1018 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1021 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1019 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1022 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1023 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
1024 | if ( temp->getWriteBackFuture() ) | ||
1025 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
1020 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1026 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1021 | if ( action == 1000 ) { | 1027 | if ( action == 1000 ) { |
1022 | syncSharp(); | 1028 | syncSharp(); |
1023 | 1029 | ||
1024 | } else if ( action == 1001 ) { | 1030 | } else if ( action == 1001 ) { |
1025 | syncLocalFile(); | 1031 | syncLocalFile(); |
1026 | 1032 | ||
1027 | } else if ( action == 1002 ) { | 1033 | } else if ( action == 1002 ) { |
1028 | quickSyncLocalFile(); | 1034 | quickSyncLocalFile(); |
1029 | 1035 | ||
1030 | } else if ( action >= 1003 ) { | 1036 | } else if ( action >= 1003 ) { |
1031 | if ( temp->getIsLocalFileSync() ) { | 1037 | if ( temp->getIsLocalFileSync() ) { |
1032 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1038 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1033 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1039 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1034 | } else { | 1040 | } else { |
1035 | if ( temp->getIsPhoneSync() ) { | 1041 | if ( temp->getIsPhoneSync() ) { |
1036 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1042 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1037 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1043 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1038 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1044 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1039 | syncPhone(); | 1045 | syncPhone(); |
1040 | } else | 1046 | } else |
1041 | syncRemote( temp ); | 1047 | syncRemote( temp ); |
1042 | 1048 | ||
1043 | } | 1049 | } |