author | zautrix <zautrix> | 2005-01-17 12:47:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-17 12:47:46 (UTC) |
commit | 214b82c86bd5365d7a5fc786c8c9c7231ec6dc77 (patch) (unidiff) | |
tree | 9b6052411933ccd1a15428c8f747f0143db4690d | |
parent | ba5e5a22ad492f798b2626026cc1838b731e055b (diff) | |
download | kdepimpi-214b82c86bd5365d7a5fc786c8c9c7231ec6dc77.zip kdepimpi-214b82c86bd5365d7a5fc786c8c9c7231ec6dc77.tar.gz kdepimpi-214b82c86bd5365d7a5fc786c8c9c7231ec6dc77.tar.bz2 |
small cal fix
-rw-r--r-- | korganizer/calendarview.cpp | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 685bb60..da1edea 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -863,128 +863,130 @@ Event* CalendarView::getLastSyncEvent() | |||
863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
864 | if (!lse) { | 864 | if (!lse) { |
865 | lse = new Event(); | 865 | lse = new Event(); |
866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
867 | QString sum = ""; | 867 | QString sum = ""; |
868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
869 | sum = "E: "; | 869 | sum = "E: "; |
870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
871 | lse->setDtStart( mLastCalendarSync ); | 871 | lse->setDtStart( mLastCalendarSync ); |
872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
873 | lse->setCategories( i18n("SyncEvent") ); | 873 | lse->setCategories( i18n("SyncEvent") ); |
874 | lse->setReadOnly( true ); | 874 | lse->setReadOnly( true ); |
875 | mCalendar->addEvent( lse ); | 875 | mCalendar->addEvent( lse ); |
876 | } | 876 | } |
877 | 877 | ||
878 | return lse; | 878 | return lse; |
879 | 879 | ||
880 | } | 880 | } |
881 | 881 | ||
882 | // we check, if the to delete event has a id for a profile | 882 | // we check, if the to delete event has a id for a profile |
883 | // if yes, we set this id in the profile to delete | 883 | // if yes, we set this id in the profile to delete |
884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
885 | { | 885 | { |
886 | if ( lastSync.count() == 0 ) { | 886 | if ( lastSync.count() == 0 ) { |
887 | //qDebug(" lastSync.count() == 0"); | 887 | //qDebug(" lastSync.count() == 0"); |
888 | return; | 888 | return; |
889 | } | 889 | } |
890 | if ( toDelete->type() == "Journal" ) | 890 | if ( toDelete->type() == "Journal" ) |
891 | return; | 891 | return; |
892 | 892 | ||
893 | Event* eve = lastSync.first(); | 893 | Event* eve = lastSync.first(); |
894 | 894 | ||
895 | while ( eve ) { | 895 | while ( eve ) { |
896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
897 | if ( !id.isEmpty() ) { | 897 | if ( !id.isEmpty() ) { |
898 | QString des = eve->description(); | 898 | QString des = eve->description(); |
899 | QString pref = "e"; | 899 | QString pref = "e"; |
900 | if ( toDelete->type() == "Todo" ) | 900 | if ( toDelete->type() == "Todo" ) |
901 | pref = "t"; | 901 | pref = "t"; |
902 | des += pref+ id + ","; | 902 | des += pref+ id + ","; |
903 | eve->setReadOnly( false ); | 903 | eve->setReadOnly( false ); |
904 | eve->setDescription( des ); | 904 | eve->setDescription( des ); |
905 | //qDebug("setdes %s ", des.latin1()); | 905 | //qDebug("setdes %s ", des.latin1()); |
906 | eve->setReadOnly( true ); | 906 | eve->setReadOnly( true ); |
907 | } | 907 | } |
908 | eve = lastSync.next(); | 908 | eve = lastSync.next(); |
909 | } | 909 | } |
910 | 910 | ||
911 | } | 911 | } |
912 | void CalendarView::checkExternalId( Incidence * inc ) | 912 | void CalendarView::checkExternalId( Incidence * inc ) |
913 | { | 913 | { |
914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
915 | checkExternSyncEvent( lastSync, inc ); | 915 | checkExternSyncEvent( lastSync, inc ); |
916 | 916 | ||
917 | } | 917 | } |
918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
919 | { | 919 | { |
920 | bool syncOK = true; | 920 | bool syncOK = true; |
921 | int addedEvent = 0; | 921 | int addedEvent = 0; |
922 | int addedEventR = 0; | 922 | int addedEventR = 0; |
923 | int deletedEventR = 0; | 923 | int deletedEventR = 0; |
924 | int deletedEventL = 0; | 924 | int deletedEventL = 0; |
925 | int changedLocal = 0; | 925 | int changedLocal = 0; |
926 | int changedRemote = 0; | 926 | int changedRemote = 0; |
927 | int filteredIN = 0; | ||
928 | int filteredOUT = 0; | ||
927 | //QPtrList<Event> el = local->rawEvents(); | 929 | //QPtrList<Event> el = local->rawEvents(); |
928 | Event* eventR; | 930 | Event* eventR; |
929 | QString uid; | 931 | QString uid; |
930 | int take; | 932 | int take; |
931 | Event* eventL; | 933 | Event* eventL; |
932 | Event* eventRSync; | 934 | Event* eventRSync; |
933 | Event* eventLSync; | 935 | Event* eventLSync; |
934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 936 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 937 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
936 | bool fullDateRange = false; | 938 | bool fullDateRange = false; |
937 | local->resetTempSyncStat(); | 939 | local->resetTempSyncStat(); |
938 | mLastCalendarSync = QDateTime::currentDateTime(); | 940 | mLastCalendarSync = QDateTime::currentDateTime(); |
939 | if ( mSyncManager->syncWithDesktop() ) { | 941 | if ( mSyncManager->syncWithDesktop() ) { |
940 | remote->resetPilotStat(1); | 942 | remote->resetPilotStat(1); |
941 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 943 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
942 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 944 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
943 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 945 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
944 | } else { | 946 | } else { |
945 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 947 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
946 | } | 948 | } |
947 | } | 949 | } |
948 | QDateTime modifiedCalendar = mLastCalendarSync; | 950 | QDateTime modifiedCalendar = mLastCalendarSync; |
949 | eventLSync = getLastSyncEvent(); | 951 | eventLSync = getLastSyncEvent(); |
950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 952 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
951 | if ( eventR ) { | 953 | if ( eventR ) { |
952 | eventRSync = (Event*) eventR->clone(); | 954 | eventRSync = (Event*) eventR->clone(); |
953 | remote->deleteEvent(eventR ); | 955 | remote->deleteEvent(eventR ); |
954 | 956 | ||
955 | } else { | 957 | } else { |
956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 958 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
957 | eventRSync = (Event*)eventLSync->clone(); | 959 | eventRSync = (Event*)eventLSync->clone(); |
958 | } else { | 960 | } else { |
959 | fullDateRange = true; | 961 | fullDateRange = true; |
960 | eventRSync = new Event(); | 962 | eventRSync = new Event(); |
961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 963 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 964 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | 965 | eventRSync->setDtStart( mLastCalendarSync ); |
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 966 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
965 | eventRSync->setCategories( i18n("SyncEvent") ); | 967 | eventRSync->setCategories( i18n("SyncEvent") ); |
966 | } | 968 | } |
967 | } | 969 | } |
968 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 970 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
969 | fullDateRange = true; | 971 | fullDateRange = true; |
970 | 972 | ||
971 | if ( ! fullDateRange ) { | 973 | if ( ! fullDateRange ) { |
972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 974 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
973 | 975 | ||
974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 976 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 977 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
976 | fullDateRange = true; | 978 | fullDateRange = true; |
977 | } | 979 | } |
978 | } | 980 | } |
979 | if ( mSyncManager->syncWithDesktop() ) { | 981 | if ( mSyncManager->syncWithDesktop() ) { |
980 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 982 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
981 | } | 983 | } |
982 | if ( fullDateRange ) | 984 | if ( fullDateRange ) |
983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 985 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
984 | else | 986 | else |
985 | mLastCalendarSync = eventLSync->dtStart(); | 987 | mLastCalendarSync = eventLSync->dtStart(); |
986 | // for resyncing if own file has changed | 988 | // for resyncing if own file has changed |
987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 989 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
988 | mLastCalendarSync = loadedFileVersion; | 990 | mLastCalendarSync = loadedFileVersion; |
989 | //qDebug("setting mLastCalendarSync "); | 991 | //qDebug("setting mLastCalendarSync "); |
990 | } | 992 | } |
@@ -1040,246 +1042,250 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1042 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1043 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1042 | else | 1044 | else |
1043 | idS = inR->IDStr(); | 1045 | idS = inR->IDStr(); |
1044 | remote->deleteIncidence( inR ); | 1046 | remote->deleteIncidence( inR ); |
1045 | inR = inL->clone(); | 1047 | inR = inL->clone(); |
1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1048 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1049 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1048 | inR->setIDStr( idS ); | 1050 | inR->setIDStr( idS ); |
1049 | remote->addIncidence( inR ); | 1051 | remote->addIncidence( inR ); |
1050 | if ( mSyncManager->syncWithDesktop() ) | 1052 | if ( mSyncManager->syncWithDesktop() ) |
1051 | inR->setPilotId( 2 ); | 1053 | inR->setPilotId( 2 ); |
1052 | ++changedRemote; | 1054 | ++changedRemote; |
1053 | } else {// take remote ********************** | 1055 | } else {// take remote ********************** |
1054 | idS = inL->IDStr(); | 1056 | idS = inL->IDStr(); |
1055 | int pid = inL->pilotId(); | 1057 | int pid = inL->pilotId(); |
1056 | local->deleteIncidence( inL ); | 1058 | local->deleteIncidence( inL ); |
1057 | inL = inR->clone(); | 1059 | inL = inR->clone(); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1060 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inL->setPilotId( pid ); | 1061 | inL->setPilotId( pid ); |
1060 | inL->setIDStr( idS ); | 1062 | inL->setIDStr( idS ); |
1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1063 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1064 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1065 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1064 | } | 1066 | } |
1065 | local->addIncidence( inL ); | 1067 | local->addIncidence( inL ); |
1066 | ++changedLocal; | 1068 | ++changedLocal; |
1067 | } | 1069 | } |
1068 | } | 1070 | } |
1069 | } else { // no conflict ********** add or delete remote | 1071 | } else { // no conflict ********** add or delete remote |
1070 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1072 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1073 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1072 | QString des = eventLSync->description(); | 1074 | QString des = eventLSync->description(); |
1073 | QString pref = "e"; | 1075 | QString pref = "e"; |
1074 | if ( inR->type() == "Todo" ) | 1076 | if ( inR->type() == "Todo" ) |
1075 | pref = "t"; | 1077 | pref = "t"; |
1076 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1078 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1077 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1079 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1078 | //remote->deleteIncidence( inR ); | 1080 | //remote->deleteIncidence( inR ); |
1079 | ++deletedEventR; | 1081 | ++deletedEventR; |
1080 | } else { | 1082 | } else { |
1081 | inR->setLastModified( modifiedCalendar ); | 1083 | inR->setLastModified( modifiedCalendar ); |
1082 | inL = inR->clone(); | 1084 | inL = inR->clone(); |
1083 | inL->setIDStr( ":" ); | 1085 | inL->setIDStr( ":" ); |
1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1086 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1087 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1086 | local->addIncidence( inL ); | 1088 | local->addIncidence( inL ); |
1087 | ++addedEvent; | 1089 | ++addedEvent; |
1088 | 1090 | ||
1089 | } | 1091 | } |
1090 | } else { | 1092 | } else { |
1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1093 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1092 | inR->setLastModified( modifiedCalendar ); | 1094 | inR->setLastModified( modifiedCalendar ); |
1093 | inL = inR->clone(); | 1095 | inL = inR->clone(); |
1094 | inL->setIDStr( ":" ); | 1096 | inL->setIDStr( ":" ); |
1095 | local->addIncidence( inL ); | 1097 | local->addIncidence( inL ); |
1096 | ++addedEvent; | 1098 | ++addedEvent; |
1097 | 1099 | ||
1098 | } else { | 1100 | } else { |
1099 | checkExternSyncEvent(eventRSyncSharp, inR); | 1101 | checkExternSyncEvent(eventRSyncSharp, inR); |
1100 | remote->deleteIncidence( inR ); | 1102 | remote->deleteIncidence( inR ); |
1101 | ++deletedEventR; | 1103 | ++deletedEventR; |
1102 | } | 1104 | } |
1103 | } | 1105 | } |
1106 | } else { | ||
1107 | ++filteredIN; | ||
1104 | } | 1108 | } |
1105 | } | 1109 | } |
1106 | } | 1110 | } |
1107 | inR = er.next(); | 1111 | inR = er.next(); |
1108 | } | 1112 | } |
1109 | QPtrList<Incidence> el = local->rawIncidences(); | 1113 | QPtrList<Incidence> el = local->rawIncidences(); |
1110 | inL = el.first(); | 1114 | inL = el.first(); |
1111 | modulo = (el.count()/10)+1; | 1115 | modulo = (el.count()/10)+1; |
1112 | bar.setCaption (i18n("Add / remove events") ); | 1116 | bar.setCaption (i18n("Add / remove events") ); |
1113 | bar.setTotalSteps ( el.count() ) ; | 1117 | bar.setTotalSteps ( el.count() ) ; |
1114 | bar.show(); | 1118 | bar.show(); |
1115 | incCounter = 0; | 1119 | incCounter = 0; |
1116 | 1120 | ||
1117 | while ( inL ) { | 1121 | while ( inL ) { |
1118 | 1122 | ||
1119 | qApp->processEvents(); | 1123 | qApp->processEvents(); |
1120 | if ( ! bar.isVisible() ) | 1124 | if ( ! bar.isVisible() ) |
1121 | return false; | 1125 | return false; |
1122 | if ( incCounter % modulo == 0 ) | 1126 | if ( incCounter % modulo == 0 ) |
1123 | bar.setProgress( incCounter ); | 1127 | bar.setProgress( incCounter ); |
1124 | ++incCounter; | 1128 | ++incCounter; |
1125 | uid = inL->uid(); | 1129 | uid = inL->uid(); |
1126 | bool skipIncidence = false; | 1130 | bool skipIncidence = false; |
1127 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1131 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1128 | skipIncidence = true; | 1132 | skipIncidence = true; |
1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1133 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1130 | skipIncidence = true; | 1134 | skipIncidence = true; |
1131 | if ( filterOUT && ! filterOUT->filterCalendarItem( inL ) ){ | ||
1132 | skipIncidence = true; | ||
1133 | } | ||
1134 | if ( !skipIncidence ) { | 1135 | if ( !skipIncidence ) { |
1135 | inR = remote->incidence( uid ); | 1136 | inR = remote->incidence( uid ); |
1136 | if ( ! inR ) { // no conflict ********** add or delete local | 1137 | if ( ! inR ) { |
1137 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1138 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1138 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1139 | // no conflict ********** add or delete local |
1139 | checkExternSyncEvent(eventLSyncSharp, inL); | 1140 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1140 | local->deleteIncidence( inL ); | 1141 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1141 | ++deletedEventL; | 1142 | checkExternSyncEvent(eventLSyncSharp, inL); |
1142 | } else { | 1143 | local->deleteIncidence( inL ); |
1143 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1144 | ++deletedEventL; |
1144 | inL->removeID(mCurrentSyncDevice ); | 1145 | } else { |
1145 | ++addedEventR; | 1146 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1146 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1147 | inL->removeID(mCurrentSyncDevice ); |
1147 | inL->setLastModified( modifiedCalendar ); | 1148 | ++addedEventR; |
1148 | inR = inL->clone(); | 1149 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1149 | inR->setIDStr( ":" ); | 1150 | inL->setLastModified( modifiedCalendar ); |
1150 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1151 | inR = inL->clone(); |
1151 | remote->addIncidence( inR ); | 1152 | inR->setIDStr( ":" ); |
1153 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | ||
1154 | remote->addIncidence( inR ); | ||
1155 | } | ||
1152 | } | 1156 | } |
1153 | } | ||
1154 | } else { | ||
1155 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | ||
1156 | checkExternSyncEvent(eventLSyncSharp, inL); | ||
1157 | local->deleteIncidence( inL ); | ||
1158 | ++deletedEventL; | ||
1159 | } else { | 1157 | } else { |
1160 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1158 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1161 | ++addedEventR; | 1159 | checkExternSyncEvent(eventLSyncSharp, inL); |
1162 | inL->setLastModified( modifiedCalendar ); | 1160 | local->deleteIncidence( inL ); |
1163 | inR = inL->clone(); | 1161 | ++deletedEventL; |
1164 | inR->setIDStr( ":" ); | 1162 | } else { |
1165 | remote->addIncidence( inR ); | 1163 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1164 | ++addedEventR; | ||
1165 | inL->setLastModified( modifiedCalendar ); | ||
1166 | inR = inL->clone(); | ||
1167 | inR->setIDStr( ":" ); | ||
1168 | remote->addIncidence( inR ); | ||
1169 | } | ||
1166 | } | 1170 | } |
1167 | } | 1171 | } |
1172 | } else { | ||
1173 | ++filteredOUT; | ||
1168 | } | 1174 | } |
1169 | } | 1175 | } |
1170 | } | 1176 | } |
1171 | inL = el.next(); | 1177 | inL = el.next(); |
1172 | } | 1178 | } |
1173 | int delFut = 0; | 1179 | int delFut = 0; |
1174 | int remRem = 0; | 1180 | int remRem = 0; |
1175 | if ( mSyncManager->mWriteBackInFuture ) { | 1181 | if ( mSyncManager->mWriteBackInFuture ) { |
1176 | er = remote->rawIncidences(); | 1182 | er = remote->rawIncidences(); |
1177 | remRem = er.count(); | 1183 | remRem = er.count(); |
1178 | inR = er.first(); | 1184 | inR = er.first(); |
1179 | QDateTime dt; | 1185 | QDateTime dt; |
1180 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1186 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1181 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1187 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1182 | while ( inR ) { | 1188 | while ( inR ) { |
1183 | if ( inR->type() == "Todo" ) { | 1189 | if ( inR->type() == "Todo" ) { |
1184 | Todo * t = (Todo*)inR; | 1190 | Todo * t = (Todo*)inR; |
1185 | if ( t->hasDueDate() ) | 1191 | if ( t->hasDueDate() ) |
1186 | dt = t->dtDue(); | 1192 | dt = t->dtDue(); |
1187 | else | 1193 | else |
1188 | dt = cur.addSecs( 62 ); | 1194 | dt = cur.addSecs( 62 ); |
1189 | } | 1195 | } |
1190 | else if (inR->type() == "Event" ) { | 1196 | else if (inR->type() == "Event" ) { |
1191 | bool ok; | 1197 | bool ok; |
1192 | dt = inR->getNextOccurence( cur, &ok ); | 1198 | dt = inR->getNextOccurence( cur, &ok ); |
1193 | if ( !ok ) | 1199 | if ( !ok ) |
1194 | dt = cur.addSecs( -62 ); | 1200 | dt = cur.addSecs( -62 ); |
1195 | } | 1201 | } |
1196 | else | 1202 | else |
1197 | dt = inR->dtStart(); | 1203 | dt = inR->dtStart(); |
1198 | if ( dt < cur || dt > end ) { | 1204 | if ( dt < cur || dt > end ) { |
1199 | remote->deleteIncidence( inR ); | 1205 | remote->deleteIncidence( inR ); |
1200 | ++delFut; | 1206 | ++delFut; |
1201 | } | 1207 | } |
1202 | inR = er.next(); | 1208 | inR = er.next(); |
1203 | } | 1209 | } |
1204 | } | 1210 | } |
1205 | bar.hide(); | 1211 | bar.hide(); |
1206 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1212 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1207 | eventLSync->setReadOnly( false ); | 1213 | eventLSync->setReadOnly( false ); |
1208 | eventLSync->setDtStart( mLastCalendarSync ); | 1214 | eventLSync->setDtStart( mLastCalendarSync ); |
1209 | eventRSync->setDtStart( mLastCalendarSync ); | 1215 | eventRSync->setDtStart( mLastCalendarSync ); |
1210 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1216 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1211 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1217 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1212 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1218 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1213 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1219 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1214 | eventLSync->setReadOnly( true ); | 1220 | eventLSync->setReadOnly( true ); |
1215 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1221 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); |
1216 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1222 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1217 | remote->addEvent( eventRSync ); | 1223 | remote->addEvent( eventRSync ); |
1218 | else | 1224 | else |
1219 | delete eventRSync; | 1225 | delete eventRSync; |
1220 | QString mes; | 1226 | QString mes; |
1221 | 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 ); | 1227 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1222 | QString delmess; | 1228 | QString delmess; |
1223 | if ( delFut ) { | 1229 | if ( delFut ) { |
1224 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1230 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1225 | mes += delmess; | 1231 | mes += delmess; |
1226 | } | 1232 | } |
1227 | mes = i18n("Local calendar changed!\n") +mes; | 1233 | mes = i18n("Local calendar changed!\n") +mes; |
1228 | mCalendar->checkAlarmForIncidence( 0, true ); | 1234 | mCalendar->checkAlarmForIncidence( 0, true ); |
1229 | qDebug( mes ); | 1235 | qDebug( mes ); |
1230 | if ( mSyncManager->mShowSyncSummary ) { | 1236 | if ( mSyncManager->mShowSyncSummary ) { |
1231 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1237 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1232 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1238 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1233 | qDebug("cancelled "); | 1239 | qDebug("cancelled "); |
1234 | return false; | 1240 | return false; |
1235 | } | 1241 | } |
1236 | } | 1242 | } |
1237 | return syncOK; | 1243 | return syncOK; |
1238 | } | 1244 | } |
1239 | 1245 | ||
1240 | void CalendarView::setSyncDevice( QString s ) | 1246 | void CalendarView::setSyncDevice( QString s ) |
1241 | { | 1247 | { |
1242 | mCurrentSyncDevice= s; | 1248 | mCurrentSyncDevice= s; |
1243 | } | 1249 | } |
1244 | void CalendarView::setSyncName( QString s ) | 1250 | void CalendarView::setSyncName( QString s ) |
1245 | { | 1251 | { |
1246 | mCurrentSyncName= s; | 1252 | mCurrentSyncName= s; |
1247 | } | 1253 | } |
1248 | bool CalendarView::syncCalendar(QString filename, int mode) | 1254 | bool CalendarView::syncCalendar(QString filename, int mode) |
1249 | { | 1255 | { |
1250 | //qDebug("syncCalendar %s ", filename.latin1()); | 1256 | //qDebug("syncCalendar %s ", filename.latin1()); |
1251 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1257 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1252 | CalendarLocal* calendar = new CalendarLocal(); | 1258 | CalendarLocal* calendar = new CalendarLocal(); |
1253 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1259 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1254 | FileStorage* storage = new FileStorage( calendar ); | 1260 | FileStorage* storage = new FileStorage( calendar ); |
1255 | bool syncOK = false; | 1261 | bool syncOK = false; |
1256 | storage->setFileName( filename ); | 1262 | storage->setFileName( filename ); |
1257 | // qDebug("loading ... "); | 1263 | // qDebug("loading ... "); |
1258 | if ( storage->load() ) { | 1264 | if ( storage->load() ) { |
1259 | getEventViewerDialog()->setSyncMode( true ); | 1265 | getEventViewerDialog()->setSyncMode( true ); |
1260 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1266 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1261 | getEventViewerDialog()->setSyncMode( false ); | 1267 | getEventViewerDialog()->setSyncMode( false ); |
1262 | if ( syncOK ) { | 1268 | if ( syncOK ) { |
1263 | if ( mSyncManager->mWriteBackFile ) | 1269 | if ( mSyncManager->mWriteBackFile ) |
1264 | { | 1270 | { |
1265 | storage->setSaveFormat( new ICalFormat() ); | 1271 | storage->setSaveFormat( new ICalFormat() ); |
1266 | storage->save(); | 1272 | storage->save(); |
1267 | } | 1273 | } |
1268 | } | 1274 | } |
1269 | setModified( true ); | 1275 | setModified( true ); |
1270 | } | 1276 | } |
1271 | delete storage; | 1277 | delete storage; |
1272 | delete calendar; | 1278 | delete calendar; |
1273 | if ( syncOK ) | 1279 | if ( syncOK ) |
1274 | updateView(); | 1280 | updateView(); |
1275 | return syncOK; | 1281 | return syncOK; |
1276 | } | 1282 | } |
1277 | 1283 | ||
1278 | void CalendarView::syncExternal( int mode ) | 1284 | void CalendarView::syncExternal( int mode ) |
1279 | { | 1285 | { |
1280 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1286 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1281 | 1287 | ||
1282 | qApp->processEvents(); | 1288 | qApp->processEvents(); |
1283 | CalendarLocal* calendar = new CalendarLocal(); | 1289 | CalendarLocal* calendar = new CalendarLocal(); |
1284 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1290 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1285 | bool syncOK = false; | 1291 | bool syncOK = false; |