summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kde2file/caldump/main.cpp55
-rw-r--r--korganizer/calendarview.cpp8
-rw-r--r--libkcal/calendar.cpp16
-rw-r--r--libkcal/calendar.h1
4 files changed, 56 insertions, 24 deletions
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp
index 03571b9..755e792 100644
--- a/kde2file/caldump/main.cpp
+++ b/kde2file/caldump/main.cpp
@@ -120,128 +120,135 @@ int main( int argc, char *argv[] )
120 qDebug("************************************* "); 120 qDebug("************************************* ");
121 qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); 121 qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1());
122 122
123 if ( !read ) { 123 if ( !read ) {
124 localCalendar = new CalendarLocal(); 124 localCalendar = new CalendarLocal();
125 localCalendar->setTimeZoneId( calendarResource->timeZoneId()); 125 localCalendar->setTimeZoneId( calendarResource->timeZoneId());
126 KCal::Incidence::List allInc = calendarResource->rawIncidences(); 126 KCal::Incidence::List allInc = calendarResource->rawIncidences();
127 Incidence::List::ConstIterator it; 127 Incidence::List::ConstIterator it;
128 int num = 0; 128 int num = 0;
129 for( it = allInc.begin(); it != allInc.end(); ++it ) { 129 for( it = allInc.begin(); it != allInc.end(); ++it ) {
130 ResourceCalendar * re = calendarResource->resource( (*it) ); 130 ResourceCalendar * re = calendarResource->resource( (*it) );
131 if ( re && !re->readOnly() ) { 131 if ( re && !re->readOnly() ) {
132 ++num; 132 ++num;
133 Incidence* cl = (*it)->clone(); 133 Incidence* cl = (*it)->clone();
134 cl->setLastModified( (*it)->lastModified() ); 134 cl->setLastModified( (*it)->lastModified() );
135 if ( cl->type() == "Journal" ) 135 if ( cl->type() == "Journal" )
136 localCalendar->addJournal( (Journal *) cl ); 136 localCalendar->addJournal( (Journal *) cl );
137 else if ( cl->type() == "Todo" ) 137 else if ( cl->type() == "Todo" )
138 localCalendar->addTodo( (Todo *) cl ); 138 localCalendar->addTodo( (Todo *) cl );
139 else if ( cl->type() == "Event" ) 139 else if ( cl->type() == "Event" )
140 localCalendar->addEvent( (Event *) cl ); 140 localCalendar->addEvent( (Event *) cl );
141 } 141 }
142 } 142 }
143 143
144 FileStorage* storage = new FileStorage( calendarResource ); 144 FileStorage* storage = new FileStorage( calendarResource );
145 storage->setFileName( fileName ); 145 storage->setFileName( fileName );
146 storage->setSaveFormat( new ICalFormat() ); 146 storage->setSaveFormat( new ICalFormat() );
147 storage->save(); 147 storage->save();
148 delete storage; 148 delete storage;
149 qDebug("************************************* "); 149 qDebug("************************************* ");
150 qDebug("************kdecaldump*************** "); 150 qDebug("************kdecaldump*************** ");
151 qDebug("************************************* "); 151 qDebug("************************************* ");
152 qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); 152 qDebug("%d calendar entries dumped to file %s", num, fileName.latin1());
153 153
154 } else { 154 } else {
155 qDebug("*************************load"); 155 qDebug("*************************load");
156 localCalendar = new CalendarLocal(); 156 localCalendar = new CalendarLocal();
157 localCalendar->setTimeZoneId( calendarResource->timeZoneId()); 157 localCalendar->setTimeZoneId( calendarResource->timeZoneId());
158 FileStorage* storage = new FileStorage( localCalendar ); 158 FileStorage* storage = new FileStorage( localCalendar );
159 storage->setFileName( fileName ); 159 storage->setFileName( fileName );
160 int num = 0; 160 int num = 0;
161 int del = 0; 161 int del = 0;
162 int add = 0; 162 int add = 0;
163 if ( storage->load() ) { 163 if ( storage->load() ) {
164 qDebug("*************************loaded!"); 164 qDebug("*************************loaded!");
165 KCal::Incidence::List newInc = localCalendar->rawIncidences(); 165 KCal::Incidence::List newInc = localCalendar->rawIncidences();
166 Incidence::List::ConstIterator it; 166 Incidence::List::ConstIterator it;
167 for( it = newInc.begin(); it != newInc.end(); ++it ) { 167 for( it = newInc.begin(); it != newInc.end(); ++it ) {
168 Incidence* cl = (*it)->clone(); 168 if ( (*it)->pilotId() > 0 ) { //changed
169 Incidence *incOld = calendarResource->incidence( cl->uid() ); 169 Incidence* cl = (*it)->clone();
170 ResourceCalendar * res = 0; 170 Incidence *incOld = calendarResource->incidence( cl->uid() );
171 if ( incOld ) 171 ResourceCalendar * res = 0;
172 res = calendarResource->resource( incOld ); 172 if ( incOld )
173 if ( res ) { 173 res = calendarResource->resource( incOld );
174 ++num; 174 if ( res ) {
175 if ( incOld->type() == "Journal" ) 175 cl->setPilotId( incOld->pilotId() );
176 calendarResource->deleteJournal( (Journal *) incOld ); 176 ++num;
177 else if ( incOld->type() == "Todo" )
178 calendarResource->deleteTodo( (Todo *) incOld );
179 else if ( incOld->type() == "Event" )
180 calendarResource->deleteEvent( (Event *) incOld );
181
182 if ( cl->type() == "Journal" )
183 calendarResource->addJournal( (Journal *) cl, res );
184 else if ( cl->type() == "Todo" )
185 calendarResource->addTodo( (Todo *) cl, res );
186 else if ( cl->type() == "Event" )
187 calendarResource->addEvent( (Event *) cl, res );
188
189 } else {
190 if ( incOld ) {
191 qDebug("ERROR: no resource found for old incidence ");
192 if ( incOld->type() == "Journal" ) 177 if ( incOld->type() == "Journal" )
193 calendarResource->deleteJournal( (Journal *) incOld ); 178 calendarResource->deleteJournal( (Journal *) incOld );
194 else if ( incOld->type() == "Todo" ) 179 else if ( incOld->type() == "Todo" )
195 calendarResource->deleteTodo( (Todo *) incOld ); 180 calendarResource->deleteTodo( (Todo *) incOld );
196 else if ( incOld->type() == "Event" ) 181 else if ( incOld->type() == "Event" )
197 calendarResource->deleteEvent( (Event *) incOld ); 182 calendarResource->deleteEvent( (Event *) incOld );
183
184 if ( cl->type() == "Journal" )
185 calendarResource->addJournal( (Journal *) cl, res );
186 else if ( cl->type() == "Todo" )
187 calendarResource->addTodo( (Todo *) cl, res );
188 else if ( cl->type() == "Event" )
189 calendarResource->addEvent( (Event *) cl, res );
190
191 } else {
192 if ( incOld ) {
193 qDebug("ERROR: no resource found for old incidence ");
194 if ( incOld->type() == "Journal" )
195 calendarResource->deleteJournal( (Journal *) incOld );
196 else if ( incOld->type() == "Todo" )
197 calendarResource->deleteTodo( (Todo *) incOld );
198 else if ( incOld->type() == "Event" )
199 calendarResource->deleteEvent( (Event *) incOld );
198 200
201 }
202 calendarResource->addIncidence( cl );
203 ++add;
199 } 204 }
205 } else { // added
206 Incidence* cl = (*it)->clone();
200 calendarResource->addIncidence( cl ); 207 calendarResource->addIncidence( cl );
201 ++add; 208 ++add;
202 } 209 }
203 } 210 }
204 KCal::Incidence::List allInc = calendarResource->rawIncidences(); 211 KCal::Incidence::List allInc = calendarResource->rawIncidences();
205 212
206 for( it = allInc.begin(); it != allInc.end(); ++it ) { 213 for( it = allInc.begin(); it != allInc.end(); ++it ) {
207 ResourceCalendar * re = calendarResource->resource( (*it) ); 214 ResourceCalendar * re = calendarResource->resource( (*it) );
208 if ( re && !re->readOnly() ) { 215 if ( re && !re->readOnly() ) {
209 Incidence* cl = localCalendar->incidence( (*it)->uid() ); 216 Incidence* cl = localCalendar->incidence( (*it)->uid() );
210 if ( !cl ) { 217 if ( !cl ) {
211 ++del; 218 ++del;
212 cl = (*it); 219 cl = (*it);
213 if ( cl->type() == "Journal" ) 220 if ( cl->type() == "Journal" )
214 calendarResource->deleteJournal( (Journal *) cl ); 221 calendarResource->deleteJournal( (Journal *) cl );
215 else if ( cl->type() == "Todo" ) 222 else if ( cl->type() == "Todo" )
216 calendarResource->deleteTodo( (Todo *) cl ); 223 calendarResource->deleteTodo( (Todo *) cl );
217 else if ( cl->type() == "Event" ) 224 else if ( cl->type() == "Event" )
218 calendarResource->deleteEvent( (Event *) cl ); 225 calendarResource->deleteEvent( (Event *) cl );
219 //QDateTime lm = cl->lastModified(); 226 //QDateTime lm = cl->lastModified();
220 //cl->setResources( (*it)->resources() ); 227 //cl->setResources( (*it)->resources() );
221 //cl->setLastModified(lm); 228 //cl->setLastModified(lm);
222 } 229 }
223 } 230 }
224 } 231 }
225 232
226 calendarResource->save(); 233 calendarResource->save();
227 qDebug("************************************* "); 234 qDebug("************************************* ");
228 qDebug("************kdecaldump*************** "); 235 qDebug("************kdecaldump*************** ");
229 qDebug("************************************* "); 236 qDebug("************************************* ");
230 qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); 237 qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1());
231 238
232 } else 239 } else
233 qDebug("ERROR loading file %s",fileName.latin1() ); 240 qDebug("ERROR loading file %s",fileName.latin1() );
234 241
235 } 242 }
236 243
237 if ( localCalendar ) { 244 if ( localCalendar ) {
238 localCalendar->close(); 245 localCalendar->close();
239 delete localCalendar; 246 delete localCalendar;
240 } 247 }
241 if ( calendarResource ) { 248 if ( calendarResource ) {
242 calendarResource->close(); 249 calendarResource->close();
243 delete calendarResource; 250 delete calendarResource;
244 } 251 }
245 252
246 qDebug("ente "); 253 qDebug("ente ");
247 return 0; 254 return 0;
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1f8ad5b..f727cd4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -887,190 +887,198 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
887 if ( toDelete->type() == "Journal" ) 887 if ( toDelete->type() == "Journal" )
888 return; 888 return;
889 889
890 Event* eve = lastSync.first(); 890 Event* eve = lastSync.first();
891 891
892 while ( eve ) { 892 while ( eve ) {
893 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 893 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
894 if ( !id.isEmpty() ) { 894 if ( !id.isEmpty() ) {
895 QString des = eve->description(); 895 QString des = eve->description();
896 QString pref = "e"; 896 QString pref = "e";
897 if ( toDelete->type() == "Todo" ) 897 if ( toDelete->type() == "Todo" )
898 pref = "t"; 898 pref = "t";
899 des += pref+ id + ","; 899 des += pref+ id + ",";
900 eve->setReadOnly( false ); 900 eve->setReadOnly( false );
901 eve->setDescription( des ); 901 eve->setDescription( des );
902 //qDebug("setdes %s ", des.latin1()); 902 //qDebug("setdes %s ", des.latin1());
903 eve->setReadOnly( true ); 903 eve->setReadOnly( true );
904 } 904 }
905 eve = lastSync.next(); 905 eve = lastSync.next();
906 } 906 }
907 907
908} 908}
909void CalendarView::checkExternalId( Incidence * inc ) 909void CalendarView::checkExternalId( Incidence * inc )
910{ 910{
911 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 911 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
912 checkExternSyncEvent( lastSync, inc ); 912 checkExternSyncEvent( lastSync, inc );
913 913
914} 914}
915bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 915bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
916{ 916{
917 bool syncOK = true; 917 bool syncOK = true;
918 int addedEvent = 0; 918 int addedEvent = 0;
919 int addedEventR = 0; 919 int addedEventR = 0;
920 int deletedEventR = 0; 920 int deletedEventR = 0;
921 int deletedEventL = 0; 921 int deletedEventL = 0;
922 int changedLocal = 0; 922 int changedLocal = 0;
923 int changedRemote = 0; 923 int changedRemote = 0;
924 //QPtrList<Event> el = local->rawEvents(); 924 //QPtrList<Event> el = local->rawEvents();
925 Event* eventR; 925 Event* eventR;
926 QString uid; 926 QString uid;
927 int take; 927 int take;
928 Event* eventL; 928 Event* eventL;
929 Event* eventRSync; 929 Event* eventRSync;
930 Event* eventLSync; 930 Event* eventLSync;
931 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 931 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
932 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 932 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
933 bool fullDateRange = false; 933 bool fullDateRange = false;
934 local->resetTempSyncStat(); 934 local->resetTempSyncStat();
935#ifdef DESKTOP_VERSION
936 //Needed for KDE - OL sync
937 local->resetPilotStat();
938 remote->resetPilotStat();
939#endif
935 mLastCalendarSync = QDateTime::currentDateTime(); 940 mLastCalendarSync = QDateTime::currentDateTime();
936 QDateTime modifiedCalendar = mLastCalendarSync;; 941 QDateTime modifiedCalendar = mLastCalendarSync;;
937 eventLSync = getLastSyncEvent(); 942 eventLSync = getLastSyncEvent();
938 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 943 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
939 if ( eventR ) { 944 if ( eventR ) {
940 eventRSync = (Event*) eventR->clone(); 945 eventRSync = (Event*) eventR->clone();
941 remote->deleteEvent(eventR ); 946 remote->deleteEvent(eventR );
942 947
943 } else { 948 } else {
944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 949 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
945 eventRSync = (Event*)eventLSync->clone(); 950 eventRSync = (Event*)eventLSync->clone();
946 } else { 951 } else {
947 fullDateRange = true; 952 fullDateRange = true;
948 eventRSync = new Event(); 953 eventRSync = new Event();
949 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 954 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
950 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 955 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
951 eventRSync->setDtStart( mLastCalendarSync ); 956 eventRSync->setDtStart( mLastCalendarSync );
952 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 957 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
953 eventRSync->setCategories( i18n("SyncEvent") ); 958 eventRSync->setCategories( i18n("SyncEvent") );
954 } 959 }
955 } 960 }
956 if ( eventLSync->dtStart() == mLastCalendarSync ) 961 if ( eventLSync->dtStart() == mLastCalendarSync )
957 fullDateRange = true; 962 fullDateRange = true;
958 963
959 if ( ! fullDateRange ) { 964 if ( ! fullDateRange ) {
960 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 965 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
961 966
962 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 967 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
963 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 968 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
964 fullDateRange = true; 969 fullDateRange = true;
965 } 970 }
966 } 971 }
967 if ( fullDateRange ) 972 if ( fullDateRange )
968 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 973 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
969 else 974 else
970 mLastCalendarSync = eventLSync->dtStart(); 975 mLastCalendarSync = eventLSync->dtStart();
971 // for resyncing if own file has changed 976 // for resyncing if own file has changed
972 if ( mCurrentSyncDevice == "deleteaftersync" ) { 977 if ( mCurrentSyncDevice == "deleteaftersync" ) {
973 mLastCalendarSync = loadedFileVersion; 978 mLastCalendarSync = loadedFileVersion;
974 qDebug("setting mLastCalendarSync "); 979 qDebug("setting mLastCalendarSync ");
975 } 980 }
976 //qDebug("*************************** "); 981 //qDebug("*************************** ");
977 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 982 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
978 QPtrList<Incidence> er = remote->rawIncidences(); 983 QPtrList<Incidence> er = remote->rawIncidences();
979 Incidence* inR = er.first(); 984 Incidence* inR = er.first();
980 Incidence* inL; 985 Incidence* inL;
981 QProgressBar bar( er.count(),0 ); 986 QProgressBar bar( er.count(),0 );
982 bar.setCaption (i18n("Syncing - close to abort!") ); 987 bar.setCaption (i18n("Syncing - close to abort!") );
983 988
984 int w = 300; 989 int w = 300;
985 if ( QApplication::desktop()->width() < 320 ) 990 if ( QApplication::desktop()->width() < 320 )
986 w = 220; 991 w = 220;
987 int h = bar.sizeHint().height() ; 992 int h = bar.sizeHint().height() ;
988 int dw = QApplication::desktop()->width(); 993 int dw = QApplication::desktop()->width();
989 int dh = QApplication::desktop()->height(); 994 int dh = QApplication::desktop()->height();
990 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 995 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
991 bar.show(); 996 bar.show();
992 int modulo = (er.count()/10)+1; 997 int modulo = (er.count()/10)+1;
993 int incCounter = 0; 998 int incCounter = 0;
994 while ( inR ) { 999 while ( inR ) {
995 if ( ! bar.isVisible() ) 1000 if ( ! bar.isVisible() )
996 return false; 1001 return false;
997 if ( incCounter % modulo == 0 ) 1002 if ( incCounter % modulo == 0 )
998 bar.setProgress( incCounter ); 1003 bar.setProgress( incCounter );
999 ++incCounter; 1004 ++incCounter;
1000 uid = inR->uid(); 1005 uid = inR->uid();
1001 bool skipIncidence = false; 1006 bool skipIncidence = false;
1002 if ( uid.left(15) == QString("last-syncEvent-") ) 1007 if ( uid.left(15) == QString("last-syncEvent-") )
1003 skipIncidence = true; 1008 skipIncidence = true;
1004 QString idS; 1009 QString idS;
1005 qApp->processEvents(); 1010 qApp->processEvents();
1006 if ( !skipIncidence ) { 1011 if ( !skipIncidence ) {
1007 inL = local->incidence( uid ); 1012 inL = local->incidence( uid );
1008 if ( inL ) { // maybe conflict - same uid in both calendars 1013 if ( inL ) { // maybe conflict - same uid in both calendars
1009 int maxrev = inL->revision(); 1014 int maxrev = inL->revision();
1010 if ( maxrev < inR->revision() ) 1015 if ( maxrev < inR->revision() )
1011 maxrev = inR->revision(); 1016 maxrev = inR->revision();
1012 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1017 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1013 //qDebug("take %d %s ", take, inL->summary().latin1()); 1018 //qDebug("take %d %s ", take, inL->summary().latin1());
1014 if ( take == 3 ) 1019 if ( take == 3 )
1015 return false; 1020 return false;
1016 if ( take == 1 ) {// take local 1021 if ( take == 1 ) {// take local
1017 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1022 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1018 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1023 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1019 else 1024 else
1020 idS = inR->IDStr(); 1025 idS = inR->IDStr();
1021 remote->deleteIncidence( inR ); 1026 remote->deleteIncidence( inR );
1022 if ( inL->revision() < maxrev ) 1027 if ( inL->revision() < maxrev )
1023 inL->setRevision( maxrev ); 1028 inL->setRevision( maxrev );
1024 inR = inL->clone(); 1029 inR = inL->clone();
1025 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1030 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1026 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1031 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1027 inR->setIDStr( idS ); 1032 inR->setIDStr( idS );
1028 remote->addIncidence( inR ); 1033 remote->addIncidence( inR );
1034#ifdef DESKTOP_VERSION
1035 inR->setPilotId( 1 );
1036#endif
1029 ++changedRemote; 1037 ++changedRemote;
1030 } else { 1038 } else {
1031 if ( inR->revision() < maxrev ) 1039 if ( inR->revision() < maxrev )
1032 inR->setRevision( maxrev ); 1040 inR->setRevision( maxrev );
1033 idS = inL->IDStr(); 1041 idS = inL->IDStr();
1034 local->deleteIncidence( inL ); 1042 local->deleteIncidence( inL );
1035 inL = inR->clone(); 1043 inL = inR->clone();
1036 inL->setIDStr( idS ); 1044 inL->setIDStr( idS );
1037 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1045 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1038 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1046 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1039 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1047 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1040 } 1048 }
1041 local->addIncidence( inL ); 1049 local->addIncidence( inL );
1042 ++changedLocal; 1050 ++changedLocal;
1043 } 1051 }
1044 } 1052 }
1045 } else { // no conflict 1053 } else { // no conflict
1046 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1054 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1047 QString des = eventLSync->description(); 1055 QString des = eventLSync->description();
1048 QString pref = "e"; 1056 QString pref = "e";
1049 if ( inR->type() == "Todo" ) 1057 if ( inR->type() == "Todo" )
1050 pref = "t"; 1058 pref = "t";
1051 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1059 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1052 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1060 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1053 //remote->deleteIncidence( inR ); 1061 //remote->deleteIncidence( inR );
1054 ++deletedEventR; 1062 ++deletedEventR;
1055 } else { 1063 } else {
1056 inR->setLastModified( modifiedCalendar ); 1064 inR->setLastModified( modifiedCalendar );
1057 inL = inR->clone(); 1065 inL = inR->clone();
1058 local->addIncidence( inL ); 1066 local->addIncidence( inL );
1059 ++addedEvent; 1067 ++addedEvent;
1060 } 1068 }
1061 } else { 1069 } else {
1062 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1070 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1063 inR->setLastModified( modifiedCalendar ); 1071 inR->setLastModified( modifiedCalendar );
1064 local->addIncidence( inR->clone() ); 1072 local->addIncidence( inR->clone() );
1065 ++addedEvent; 1073 ++addedEvent;
1066 } else { 1074 } else {
1067 checkExternSyncEvent(eventRSyncSharp, inR); 1075 checkExternSyncEvent(eventRSyncSharp, inR);
1068 remote->deleteIncidence( inR ); 1076 remote->deleteIncidence( inR );
1069 ++deletedEventR; 1077 ++deletedEventR;
1070 } 1078 }
1071 } 1079 }
1072 } 1080 }
1073 } 1081 }
1074 inR = er.next(); 1082 inR = er.next();
1075 } 1083 }
1076 QPtrList<Incidence> el = local->rawIncidences(); 1084 QPtrList<Incidence> el = local->rawIncidences();
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index a3977d7..eeb5f48 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -203,96 +203,112 @@ void Calendar::setLocalTime()
203 203
204 setModified( true ); 204 setModified( true );
205} 205}
206 206
207bool Calendar::isLocalTime() const 207bool Calendar::isLocalTime() const
208{ 208{
209 return mLocalTime; 209 return mLocalTime;
210} 210}
211 211
212const QString &Calendar::getEmail() 212const QString &Calendar::getEmail()
213{ 213{
214 return mOwnerEmail; 214 return mOwnerEmail;
215} 215}
216 216
217void Calendar::setEmail(const QString &e) 217void Calendar::setEmail(const QString &e)
218{ 218{
219 mOwnerEmail = e; 219 mOwnerEmail = e;
220 220
221 setModified( true ); 221 setModified( true );
222} 222}
223 223
224void Calendar::setFilter(CalFilter *filter) 224void Calendar::setFilter(CalFilter *filter)
225{ 225{
226 mFilter = filter; 226 mFilter = filter;
227} 227}
228 228
229CalFilter *Calendar::filter() 229CalFilter *Calendar::filter()
230{ 230{
231 return mFilter; 231 return mFilter;
232} 232}
233 233
234QPtrList<Incidence> Calendar::incidences() 234QPtrList<Incidence> Calendar::incidences()
235{ 235{
236 QPtrList<Incidence> incidences; 236 QPtrList<Incidence> incidences;
237 237
238 Incidence *i; 238 Incidence *i;
239 239
240 QPtrList<Event> e = events(); 240 QPtrList<Event> e = events();
241 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 241 for( i = e.first(); i; i = e.next() ) incidences.append( i );
242 242
243 QPtrList<Todo> t = todos(); 243 QPtrList<Todo> t = todos();
244 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 244 for( i = t.first(); i; i = t.next() ) incidences.append( i );
245 245
246 QPtrList<Journal> j = journals(); 246 QPtrList<Journal> j = journals();
247 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 247 for( i = j.first(); i; i = j.next() ) incidences.append( i );
248 248
249 return incidences; 249 return incidences;
250} 250}
251
252void Calendar::resetPilotStat()
253{
254 QPtrList<Incidence> incidences;
255
256 Incidence *i;
257
258 QPtrList<Event> e = rawEvents();
259 for( i = e.first(); i; i = e.next() ) i->setPilotId( 0 );
260
261 QPtrList<Todo> t = rawTodos();
262 for( i = t.first(); i; i = t.next() ) i->setPilotId( 0 );
263
264 QPtrList<Journal> j = journals();
265 for( i = j.first(); i; i = j.next() ) i->setPilotId( 0 );
266}
251void Calendar::resetTempSyncStat() 267void Calendar::resetTempSyncStat()
252{ 268{
253 QPtrList<Incidence> incidences; 269 QPtrList<Incidence> incidences;
254 270
255 Incidence *i; 271 Incidence *i;
256 272
257 QPtrList<Event> e = rawEvents(); 273 QPtrList<Event> e = rawEvents();
258 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 274 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
259 275
260 QPtrList<Todo> t = rawTodos(); 276 QPtrList<Todo> t = rawTodos();
261 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 277 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
262 278
263 QPtrList<Journal> j = journals(); 279 QPtrList<Journal> j = journals();
264 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 280 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
265} 281}
266QPtrList<Incidence> Calendar::rawIncidences() 282QPtrList<Incidence> Calendar::rawIncidences()
267{ 283{
268 QPtrList<Incidence> incidences; 284 QPtrList<Incidence> incidences;
269 285
270 Incidence *i; 286 Incidence *i;
271 287
272 QPtrList<Event> e = rawEvents(); 288 QPtrList<Event> e = rawEvents();
273 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 289 for( i = e.first(); i; i = e.next() ) incidences.append( i );
274 290
275 QPtrList<Todo> t = rawTodos(); 291 QPtrList<Todo> t = rawTodos();
276 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 292 for( i = t.first(); i; i = t.next() ) incidences.append( i );
277 293
278 QPtrList<Journal> j = journals(); 294 QPtrList<Journal> j = journals();
279 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 295 for( i = j.first(); i; i = j.next() ) incidences.append( i );
280 296
281 return incidences; 297 return incidences;
282} 298}
283 299
284QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 300QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
285{ 301{
286 QPtrList<Event> el = rawEventsForDate(date,sorted); 302 QPtrList<Event> el = rawEventsForDate(date,sorted);
287 mFilter->apply(&el); 303 mFilter->apply(&el);
288 return el; 304 return el;
289} 305}
290 306
291QPtrList<Event> Calendar::events( const QDateTime &qdt ) 307QPtrList<Event> Calendar::events( const QDateTime &qdt )
292{ 308{
293 QPtrList<Event> el = rawEventsForDate(qdt); 309 QPtrList<Event> el = rawEventsForDate(qdt);
294 mFilter->apply(&el); 310 mFilter->apply(&el);
295 return el; 311 return el;
296} 312}
297 313
298QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 314QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index c45d81f..d5294eb 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -22,96 +22,97 @@
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 void deleteIncidence(Incidence *in); 68 void deleteIncidence(Incidence *in);
69 void resetTempSyncStat(); 69 void resetTempSyncStat();
70 void resetPilotStat();
70 /** 71 /**
71 Clears out the current calendar, freeing all used memory etc. 72 Clears out the current calendar, freeing all used memory etc.
72 */ 73 */
73 virtual void close() = 0; 74 virtual void close() = 0;
74 75
75 /** 76 /**
76 Sync changes in memory to persistant storage. 77 Sync changes in memory to persistant storage.
77 */ 78 */
78 virtual void save() = 0; 79 virtual void save() = 0;
79 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 80 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
80 virtual bool isSaving() { return false; } 81 virtual bool isSaving() { return false; }
81 82
82 /** 83 /**
83 Return the owner of the calendar's full name. 84 Return the owner of the calendar's full name.
84 */ 85 */
85 const QString &getOwner() const; 86 const QString &getOwner() const;
86 /** 87 /**
87 Set the owner of the calendar. Should be owner's full name. 88 Set the owner of the calendar. Should be owner's full name.
88 */ 89 */
89 void setOwner( const QString &os ); 90 void setOwner( const QString &os );
90 /** 91 /**
91 Return the email address of the calendar owner. 92 Return the email address of the calendar owner.
92 */ 93 */
93 const QString &getEmail(); 94 const QString &getEmail();
94 /** 95 /**
95 Set the email address of the calendar owner. 96 Set the email address of the calendar owner.
96 */ 97 */
97 void setEmail( const QString & ); 98 void setEmail( const QString & );
98 99
99 /** 100 /**
100 Set time zone from a timezone string (e.g. -2:00) 101 Set time zone from a timezone string (e.g. -2:00)
101 */ 102 */
102 void setTimeZone( const QString &tz ); 103 void setTimeZone( const QString &tz );
103 /** 104 /**
104 Set time zone from a minutes value (e.g. -60) 105 Set time zone from a minutes value (e.g. -60)
105 */ 106 */
106 void setTimeZone( int tz ); 107 void setTimeZone( int tz );
107 /** 108 /**
108 Return time zone as offest in minutes. 109 Return time zone as offest in minutes.
109 */ 110 */
110 int getTimeZone() const; 111 int getTimeZone() const;
111 /** 112 /**
112 Compute an ISO 8601 format string from the time zone. 113 Compute an ISO 8601 format string from the time zone.
113 */ 114 */
114 QString getTimeZoneStr() const; 115 QString getTimeZoneStr() const;
115 /** 116 /**
116 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 117 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
117 values). 118 values).