summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-17 16:06:42 (UTC)
committer zautrix <zautrix>2004-10-17 16:06:42 (UTC)
commitd92f58ffa1937af8a4240b9d235da15f5f352769 (patch) (unidiff)
tree48768599988f33c7f20017a76d05e919fa77ac51
parent711c4c06a7d1a52b97fd24efa3586543f46cc6d7 (diff)
downloadkdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.zip
kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.gz
kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.bz2
KDE sync fixes
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
@@ -152,64 +152,71 @@ int main( int argc, char *argv[] )
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" )
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1f8ad5b..f727cd4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -919,32 +919,37 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 );
@@ -1013,32 +1018,35 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 }
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index a3977d7..eeb5f48 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -235,32 +235,48 @@ QPtrList<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()
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index c45d81f..d5294eb 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -54,32 +54,33 @@ namespace KCal {
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;