author | zautrix <zautrix> | 2004-10-28 11:37:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-28 11:37:28 (UTC) |
commit | af21c3d45173ece8492850b8c2c5019e7c25d59c (patch) (unidiff) | |
tree | 52e60b226372bbe37987df07495b02de321410fe /korganizer | |
parent | 01cd4ef94b8604532181c390e9abd560aebaf372 (diff) | |
download | kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.zip kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.tar.gz kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.tar.bz2 |
dtm sync fixes
-rw-r--r-- | korganizer/calendarview.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 4667918..4e29d6f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -955,217 +955,219 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local ********************** |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncManager->syncWithDesktop() ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else { | 1033 | } else {// take remote ********************** |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncManager->syncWithDesktop() ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict | 1049 | } else { // no conflict ********** add or delete remote |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | ||
1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | ||
1063 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1064 | ++addedEvent; | 1066 | ++addedEvent; |
1065 | } | 1067 | } |
1066 | } else { | 1068 | } else { |
1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1068 | inR->setLastModified( modifiedCalendar ); | 1070 | inR->setLastModified( modifiedCalendar ); |
1069 | inL = inR->clone(); | 1071 | inL = inR->clone(); |
1070 | inL->setIDStr( ":" ); | 1072 | inL->setIDStr( ":" ); |
1071 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1072 | ++addedEvent; | 1074 | ++addedEvent; |
1073 | } else { | 1075 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1076 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1077 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1078 | ++deletedEventR; |
1077 | } | 1079 | } |
1078 | } | 1080 | } |
1079 | } | 1081 | } |
1080 | } | 1082 | } |
1081 | inR = er.next(); | 1083 | inR = er.next(); |
1082 | } | 1084 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1085 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1086 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1087 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1088 | bar.setCaption (i18n("Add / remove events") ); |
1087 | bar.setTotalSteps ( el.count() ) ; | 1089 | bar.setTotalSteps ( el.count() ) ; |
1088 | bar.show(); | 1090 | bar.show(); |
1089 | incCounter = 0; | 1091 | incCounter = 0; |
1090 | 1092 | ||
1091 | while ( inL ) { | 1093 | while ( inL ) { |
1092 | 1094 | ||
1093 | qApp->processEvents(); | 1095 | qApp->processEvents(); |
1094 | if ( ! bar.isVisible() ) | 1096 | if ( ! bar.isVisible() ) |
1095 | return false; | 1097 | return false; |
1096 | if ( incCounter % modulo == 0 ) | 1098 | if ( incCounter % modulo == 0 ) |
1097 | bar.setProgress( incCounter ); | 1099 | bar.setProgress( incCounter ); |
1098 | ++incCounter; | 1100 | ++incCounter; |
1099 | uid = inL->uid(); | 1101 | uid = inL->uid(); |
1100 | bool skipIncidence = false; | 1102 | bool skipIncidence = false; |
1101 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1103 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1102 | skipIncidence = true; | 1104 | skipIncidence = true; |
1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1104 | skipIncidence = true; | 1106 | skipIncidence = true; |
1105 | if ( !skipIncidence ) { | 1107 | if ( !skipIncidence ) { |
1106 | inR = remote->incidence( uid ); | 1108 | inR = remote->incidence( uid ); |
1107 | if ( ! inR ) { | 1109 | if ( ! inR ) { // no conflict ********** add or delete local |
1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1110 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1111 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1112 | ++deletedEventL; | 1114 | ++deletedEventL; |
1113 | } else { | 1115 | } else { |
1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1116 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1115 | inL->removeID(mCurrentSyncDevice ); | 1117 | inL->removeID(mCurrentSyncDevice ); |
1116 | ++addedEventR; | 1118 | ++addedEventR; |
1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1118 | inL->setLastModified( modifiedCalendar ); | 1120 | inL->setLastModified( modifiedCalendar ); |
1119 | inR = inL->clone(); | 1121 | inR = inL->clone(); |
1120 | inR->setIDStr( ":" ); | 1122 | inR->setIDStr( ":" ); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1123 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1124 | remote->addIncidence( inR ); |
1123 | } | 1125 | } |
1124 | } | 1126 | } |
1125 | } else { | 1127 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1128 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1129 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1130 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1131 | ++deletedEventL; |
1130 | } else { | 1132 | } else { |
1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1133 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1134 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1135 | inL->setLastModified( modifiedCalendar ); |
1134 | inR = inL->clone(); | 1136 | inR = inL->clone(); |
1135 | inR->setIDStr( ":" ); | 1137 | inR->setIDStr( ":" ); |
1136 | remote->addIncidence( inR ); | 1138 | remote->addIncidence( inR ); |
1137 | } | 1139 | } |
1138 | } | 1140 | } |
1139 | } | 1141 | } |
1140 | } | 1142 | } |
1141 | } | 1143 | } |
1142 | inL = el.next(); | 1144 | inL = el.next(); |
1143 | } | 1145 | } |
1144 | int delFut = 0; | 1146 | int delFut = 0; |
1145 | int remRem = 0; | 1147 | int remRem = 0; |
1146 | if ( mSyncManager->mWriteBackInFuture ) { | 1148 | if ( mSyncManager->mWriteBackInFuture ) { |
1147 | er = remote->rawIncidences(); | 1149 | er = remote->rawIncidences(); |
1148 | remRem = er.count(); | 1150 | remRem = er.count(); |
1149 | inR = er.first(); | 1151 | inR = er.first(); |
1150 | QDateTime dt; | 1152 | QDateTime dt; |
1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1153 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1154 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1153 | while ( inR ) { | 1155 | while ( inR ) { |
1154 | if ( inR->type() == "Todo" ) { | 1156 | if ( inR->type() == "Todo" ) { |
1155 | Todo * t = (Todo*)inR; | 1157 | Todo * t = (Todo*)inR; |
1156 | if ( t->hasDueDate() ) | 1158 | if ( t->hasDueDate() ) |
1157 | dt = t->dtDue(); | 1159 | dt = t->dtDue(); |
1158 | else | 1160 | else |
1159 | dt = cur.addSecs( 62 ); | 1161 | dt = cur.addSecs( 62 ); |
1160 | } | 1162 | } |
1161 | else if (inR->type() == "Event" ) { | 1163 | else if (inR->type() == "Event" ) { |
1162 | bool ok; | 1164 | bool ok; |
1163 | dt = inR->getNextOccurence( cur, &ok ); | 1165 | dt = inR->getNextOccurence( cur, &ok ); |
1164 | if ( !ok ) | 1166 | if ( !ok ) |
1165 | dt = cur.addSecs( -62 ); | 1167 | dt = cur.addSecs( -62 ); |
1166 | } | 1168 | } |
1167 | else | 1169 | else |
1168 | dt = inR->dtStart(); | 1170 | dt = inR->dtStart(); |
1169 | if ( dt < cur || dt > end ) { | 1171 | if ( dt < cur || dt > end ) { |
1170 | remote->deleteIncidence( inR ); | 1172 | remote->deleteIncidence( inR ); |
1171 | ++delFut; | 1173 | ++delFut; |