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