author | zautrix <zautrix> | 2004-10-15 14:26:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-15 14:26:07 (UTC) |
commit | 4f276d80bd977401d656851515474cc00c661e5b (patch) (unidiff) | |
tree | 0d3a747bef0431ef791b69876f5bda554f9ca83f /korganizer | |
parent | c2fb960297c4b08980921c818a4d347057732390 (diff) | |
download | kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.zip kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.gz kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.bz2 |
many phone and sync fixes
-rw-r--r-- | korganizer/calendarview.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3e0a27d..e4a11f5 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1085,142 +1085,144 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1085 | if ( ! bar.isVisible() ) | 1085 | if ( ! bar.isVisible() ) |
1086 | return false; | 1086 | return false; |
1087 | if ( incCounter % modulo == 0 ) | 1087 | if ( incCounter % modulo == 0 ) |
1088 | bar.setProgress( incCounter ); | 1088 | bar.setProgress( incCounter ); |
1089 | ++incCounter; | 1089 | ++incCounter; |
1090 | uid = inL->uid(); | 1090 | uid = inL->uid(); |
1091 | bool skipIncidence = false; | 1091 | bool skipIncidence = false; |
1092 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1092 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1093 | skipIncidence = true; | 1093 | skipIncidence = true; |
1094 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1094 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1095 | skipIncidence = true; | 1095 | skipIncidence = true; |
1096 | if ( !skipIncidence ) { | 1096 | if ( !skipIncidence ) { |
1097 | inR = remote->incidence( uid ); | 1097 | inR = remote->incidence( uid ); |
1098 | if ( ! inR ) { | 1098 | if ( ! inR ) { |
1099 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1099 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1100 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1100 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1101 | checkExternSyncEvent(eventLSyncSharp, inL); | 1101 | checkExternSyncEvent(eventLSyncSharp, inL); |
1102 | local->deleteIncidence( inL ); | 1102 | local->deleteIncidence( inL ); |
1103 | ++deletedEventL; | 1103 | ++deletedEventL; |
1104 | } else { | 1104 | } else { |
1105 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1105 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1106 | inL->removeID(mCurrentSyncDevice ); | 1106 | inL->removeID(mCurrentSyncDevice ); |
1107 | ++addedEventR; | 1107 | ++addedEventR; |
1108 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1108 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1109 | inL->setLastModified( modifiedCalendar ); | 1109 | inL->setLastModified( modifiedCalendar ); |
1110 | inR = inL->clone(); | 1110 | inR = inL->clone(); |
1111 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1111 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1112 | remote->addIncidence( inR ); | 1112 | remote->addIncidence( inR ); |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | } else { | 1115 | } else { |
1116 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1116 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1117 | checkExternSyncEvent(eventLSyncSharp, inL); | 1117 | checkExternSyncEvent(eventLSyncSharp, inL); |
1118 | local->deleteIncidence( inL ); | 1118 | local->deleteIncidence( inL ); |
1119 | ++deletedEventL; | 1119 | ++deletedEventL; |
1120 | } else { | 1120 | } else { |
1121 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1121 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1122 | ++addedEventR; | 1122 | ++addedEventR; |
1123 | inL->setLastModified( modifiedCalendar ); | 1123 | inL->setLastModified( modifiedCalendar ); |
1124 | remote->addIncidence( inL->clone() ); | 1124 | remote->addIncidence( inL->clone() ); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | inL = el.next(); | 1130 | inL = el.next(); |
1131 | } | 1131 | } |
1132 | int delFut = 0; | 1132 | int delFut = 0; |
1133 | int remRem = 0; | ||
1133 | if ( mSyncManager->mWriteBackInFuture ) { | 1134 | if ( mSyncManager->mWriteBackInFuture ) { |
1134 | er = remote->rawIncidences(); | 1135 | er = remote->rawIncidences(); |
1136 | remRem = er.count(); | ||
1135 | inR = er.first(); | 1137 | inR = er.first(); |
1136 | QDateTime dt; | 1138 | QDateTime dt; |
1137 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1139 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1138 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1140 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1139 | while ( inR ) { | 1141 | while ( inR ) { |
1140 | if ( inR->type() == "Todo" ) { | 1142 | if ( inR->type() == "Todo" ) { |
1141 | Todo * t = (Todo*)inR; | 1143 | Todo * t = (Todo*)inR; |
1142 | if ( t->hasDueDate() ) | 1144 | if ( t->hasDueDate() ) |
1143 | dt = t->dtDue(); | 1145 | dt = t->dtDue(); |
1144 | else | 1146 | else |
1145 | dt = cur.addSecs( 62 ); | 1147 | dt = cur.addSecs( 62 ); |
1146 | } | 1148 | } |
1147 | else if (inR->type() == "Event" ) { | 1149 | else if (inR->type() == "Event" ) { |
1148 | bool ok; | 1150 | bool ok; |
1149 | dt = inR->getNextOccurence( cur, &ok ); | 1151 | dt = inR->getNextOccurence( cur, &ok ); |
1150 | if ( !ok ) | 1152 | if ( !ok ) |
1151 | dt = cur.addSecs( -62 ); | 1153 | dt = cur.addSecs( -62 ); |
1152 | } | 1154 | } |
1153 | else | 1155 | else |
1154 | dt = inR->dtStart(); | 1156 | dt = inR->dtStart(); |
1155 | if ( dt < cur || dt > end ) { | 1157 | if ( dt < cur || dt > end ) { |
1156 | remote->deleteIncidence( inR ); | 1158 | remote->deleteIncidence( inR ); |
1157 | ++delFut; | 1159 | ++delFut; |
1158 | } | 1160 | } |
1159 | inR = er.next(); | 1161 | inR = er.next(); |
1160 | } | 1162 | } |
1161 | } | 1163 | } |
1162 | bar.hide(); | 1164 | bar.hide(); |
1163 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1165 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1164 | eventLSync->setReadOnly( false ); | 1166 | eventLSync->setReadOnly( false ); |
1165 | eventLSync->setDtStart( mLastCalendarSync ); | 1167 | eventLSync->setDtStart( mLastCalendarSync ); |
1166 | eventRSync->setDtStart( mLastCalendarSync ); | 1168 | eventRSync->setDtStart( mLastCalendarSync ); |
1167 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1169 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1168 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1170 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1169 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1171 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1170 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1172 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1171 | eventLSync->setReadOnly( true ); | 1173 | eventLSync->setReadOnly( true ); |
1172 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1174 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1173 | remote->addEvent( eventRSync ); | 1175 | remote->addEvent( eventRSync ); |
1174 | QString mes; | 1176 | QString mes; |
1175 | 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 ); | 1177 | 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 ); |
1176 | QString delmess; | 1178 | QString delmess; |
1177 | if ( delFut ) { | 1179 | if ( delFut ) { |
1178 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); | 1180 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1179 | mes += delmess; | 1181 | mes += delmess; |
1180 | } | 1182 | } |
1181 | if ( mSyncManager->mShowSyncSummary ) { | 1183 | if ( mSyncManager->mShowSyncSummary ) { |
1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1184 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1183 | } | 1185 | } |
1184 | qDebug( mes ); | 1186 | qDebug( mes ); |
1185 | mCalendar->checkAlarmForIncidence( 0, true ); | 1187 | mCalendar->checkAlarmForIncidence( 0, true ); |
1186 | return syncOK; | 1188 | return syncOK; |
1187 | } | 1189 | } |
1188 | 1190 | ||
1189 | void CalendarView::setSyncDevice( QString s ) | 1191 | void CalendarView::setSyncDevice( QString s ) |
1190 | { | 1192 | { |
1191 | mCurrentSyncDevice= s; | 1193 | mCurrentSyncDevice= s; |
1192 | } | 1194 | } |
1193 | void CalendarView::setSyncName( QString s ) | 1195 | void CalendarView::setSyncName( QString s ) |
1194 | { | 1196 | { |
1195 | mCurrentSyncName= s; | 1197 | mCurrentSyncName= s; |
1196 | } | 1198 | } |
1197 | bool CalendarView::syncCalendar(QString filename, int mode) | 1199 | bool CalendarView::syncCalendar(QString filename, int mode) |
1198 | { | 1200 | { |
1199 | //qDebug("syncCalendar %s ", filename.latin1()); | 1201 | //qDebug("syncCalendar %s ", filename.latin1()); |
1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1202 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1201 | CalendarLocal* calendar = new CalendarLocal(); | 1203 | CalendarLocal* calendar = new CalendarLocal(); |
1202 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1204 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1203 | FileStorage* storage = new FileStorage( calendar ); | 1205 | FileStorage* storage = new FileStorage( calendar ); |
1204 | bool syncOK = false; | 1206 | bool syncOK = false; |
1205 | storage->setFileName( filename ); | 1207 | storage->setFileName( filename ); |
1206 | // qDebug("loading ... "); | 1208 | // qDebug("loading ... "); |
1207 | if ( storage->load() ) { | 1209 | if ( storage->load() ) { |
1208 | getEventViewerDialog()->setSyncMode( true ); | 1210 | getEventViewerDialog()->setSyncMode( true ); |
1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1211 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1210 | getEventViewerDialog()->setSyncMode( false ); | 1212 | getEventViewerDialog()->setSyncMode( false ); |
1211 | if ( syncOK ) { | 1213 | if ( syncOK ) { |
1212 | if ( mSyncManager->mWriteBackFile ) | 1214 | if ( mSyncManager->mWriteBackFile ) |
1213 | { | 1215 | { |
1214 | storage->setSaveFormat( new ICalFormat() ); | 1216 | storage->setSaveFormat( new ICalFormat() ); |
1215 | storage->save(); | 1217 | storage->save(); |
1216 | } | 1218 | } |
1217 | } | 1219 | } |
1218 | setModified( true ); | 1220 | setModified( true ); |
1219 | } | 1221 | } |
1220 | delete storage; | 1222 | delete storage; |
1221 | delete calendar; | 1223 | delete calendar; |
1222 | if ( syncOK ) | 1224 | if ( syncOK ) |
1223 | updateView(); | 1225 | updateView(); |
1224 | return syncOK; | 1226 | return syncOK; |
1225 | } | 1227 | } |
1226 | 1228 | ||