author | zautrix <zautrix> | 2004-10-17 18:08:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-17 18:08:43 (UTC) |
commit | 6f6d1d58938539215bb4fcb5b97cf9fb089a11ef (patch) (unidiff) | |
tree | 9937fe24c3fa3f29421b39a58b393e893a11636a /kde2file/caldump | |
parent | d92f58ffa1937af8a4240b9d235da15f5f352769 (diff) | |
download | kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.zip kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.gz kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.bz2 |
more KDE sync fixes
-rw-r--r-- | kde2file/caldump/main.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp index 755e792..be1735b 100644 --- a/kde2file/caldump/main.cpp +++ b/kde2file/caldump/main.cpp | |||
@@ -46,24 +46,25 @@ | |||
46 | #include <kstandarddirs.h> | 46 | #include <kstandarddirs.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | 48 | ||
49 | #include <libkcal/calformat.h> | 49 | #include <libkcal/calformat.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcelocal.h> | 51 | #include <libkcal/resourcelocal.h> |
52 | #include <libkcal/filestorage.h> | 52 | #include <libkcal/filestorage.h> |
53 | #include <libkcal/icalformat.h> | 53 | #include <libkcal/icalformat.h> |
54 | 54 | ||
55 | #include <qdatetime.h> | 55 | #include <qdatetime.h> |
56 | #include <qfile.h> | 56 | #include <qfile.h> |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | #include <qapplication.h> | ||
58 | 59 | ||
59 | #include <stdlib.h> | 60 | #include <stdlib.h> |
60 | #include <iostream> | 61 | #include <iostream> |
61 | 62 | ||
62 | using namespace KCal; | 63 | using namespace KCal; |
63 | using namespace std; | 64 | using namespace std; |
64 | 65 | ||
65 | static const char progName[] = "kdecalendar"; | 66 | static const char progName[] = "kdecalendar"; |
66 | static const char progDisplay[] = "KDE_Calendar"; | 67 | static const char progDisplay[] = "KDE_Calendar"; |
67 | static const char progVersion[] = "33.1/3"; | 68 | static const char progVersion[] = "33.1/3"; |
68 | static const char progDesc[] = "A command line interface to KDE calendars"; | 69 | static const char progDesc[] = "A command line interface to KDE calendars"; |
69 | 70 | ||
@@ -143,78 +144,75 @@ int main( int argc, char *argv[] ) | |||
143 | 144 | ||
144 | FileStorage* storage = new FileStorage( calendarResource ); | 145 | FileStorage* storage = new FileStorage( calendarResource ); |
145 | storage->setFileName( fileName ); | 146 | storage->setFileName( fileName ); |
146 | storage->setSaveFormat( new ICalFormat() ); | 147 | storage->setSaveFormat( new ICalFormat() ); |
147 | storage->save(); | 148 | storage->save(); |
148 | delete storage; | 149 | delete storage; |
149 | qDebug("************************************* "); | 150 | qDebug("************************************* "); |
150 | qDebug("************kdecaldump*************** "); | 151 | qDebug("************kdecaldump*************** "); |
151 | qDebug("************************************* "); | 152 | qDebug("************************************* "); |
152 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); | 153 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); |
153 | 154 | ||
154 | } else { | 155 | } else { |
155 | qDebug("*************************load"); | 156 | qDebug("************load"); |
156 | localCalendar = new CalendarLocal(); | 157 | localCalendar = new CalendarLocal(); |
157 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); | 158 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); |
158 | FileStorage* storage = new FileStorage( localCalendar ); | 159 | FileStorage* storage = new FileStorage( localCalendar ); |
159 | storage->setFileName( fileName ); | 160 | storage->setFileName( fileName ); |
160 | int num = 0; | 161 | int num = 0; |
161 | int del = 0; | 162 | int del = 0; |
162 | int add = 0; | 163 | int add = 0; |
163 | if ( storage->load() ) { | 164 | if ( storage->load() ) { |
164 | qDebug("*************************loaded!"); | 165 | qDebug("***********loaded!"); |
165 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); | 166 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); |
166 | Incidence::List::ConstIterator it; | 167 | Incidence::List::ConstIterator it; |
167 | for( it = newInc.begin(); it != newInc.end(); ++it ) { | 168 | for( it = newInc.begin(); it != newInc.end(); ++it ) { |
168 | if ( (*it)->pilotId() > 0 ) { //changed | 169 | if ( (*it)->pilotId() > 1 ) { //changed |
169 | Incidence* cl = (*it)->clone(); | 170 | qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); |
170 | Incidence *incOld = calendarResource->incidence( cl->uid() ); | 171 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
171 | ResourceCalendar * res = 0; | 172 | ResourceCalendar * res = 0; |
172 | if ( incOld ) | 173 | if ( incOld ) |
173 | res = calendarResource->resource( incOld ); | 174 | res = calendarResource->resource( incOld ); |
174 | if ( res ) { | 175 | if ( res ) { |
176 | Incidence* cl = (*it)->clone(); | ||
175 | cl->setPilotId( incOld->pilotId() ); | 177 | cl->setPilotId( incOld->pilotId() ); |
176 | ++num; | 178 | ++num; |
177 | if ( incOld->type() == "Journal" ) | 179 | if ( incOld->type() == "Journal" ) |
178 | calendarResource->deleteJournal( (Journal *) incOld ); | 180 | calendarResource->deleteJournal( (Journal *) incOld ); |
179 | else if ( incOld->type() == "Todo" ) | 181 | else if ( incOld->type() == "Todo" ) |
180 | calendarResource->deleteTodo( (Todo *) incOld ); | 182 | calendarResource->deleteTodo( (Todo *) incOld ); |
181 | else if ( incOld->type() == "Event" ) | 183 | else if ( incOld->type() == "Event" ) |
182 | calendarResource->deleteEvent( (Event *) incOld ); | 184 | calendarResource->deleteEvent( (Event *) incOld ); |
183 | 185 | qDebug("*********change incidence %s ",cl->summary().latin1()); | |
184 | if ( cl->type() == "Journal" ) | 186 | if ( cl->type() == "Journal" ) |
185 | calendarResource->addJournal( (Journal *) cl, res ); | 187 | calendarResource->addJournal( (Journal *) cl, res ); |
186 | else if ( cl->type() == "Todo" ) | 188 | else if ( cl->type() == "Todo" ) |
187 | calendarResource->addTodo( (Todo *) cl, res ); | 189 | calendarResource->addTodo( (Todo *) cl, res ); |
188 | else if ( cl->type() == "Event" ) | 190 | else if ( cl->type() == "Event" ) |
189 | calendarResource->addEvent( (Event *) cl, res ); | 191 | calendarResource->addEvent( (Event *) cl, res ); |
190 | 192 | ||
191 | } else { | 193 | } else { |
192 | if ( incOld ) { | 194 | Incidence* cl = (*it)->clone(); |
193 | qDebug("ERROR: no resource found for old incidence "); | 195 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
194 | if ( incOld->type() == "Journal" ) | 196 | calendarResource->addIncidence( cl ); |
195 | calendarResource->deleteJournal( (Journal *) incOld ); | 197 | ++add; |
196 | else if ( incOld->type() == "Todo" ) | 198 | } |
197 | calendarResource->deleteTodo( (Todo *) incOld ); | 199 | } else { // maybe added |
198 | else if ( incOld->type() == "Event" ) | 200 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
199 | calendarResource->deleteEvent( (Event *) incOld ); | 201 | if ( !incOld ) { //added |
200 | 202 | Incidence* cl = (*it)->clone(); | |
201 | } | 203 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
202 | calendarResource->addIncidence( cl ); | 204 | calendarResource->addIncidence( cl ); |
203 | ++add; | 205 | ++add; |
204 | } | 206 | } |
205 | } else { // added | ||
206 | Incidence* cl = (*it)->clone(); | ||
207 | calendarResource->addIncidence( cl ); | ||
208 | ++add; | ||
209 | } | 207 | } |
210 | } | 208 | } |
211 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); | 209 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); |
212 | 210 | ||
213 | for( it = allInc.begin(); it != allInc.end(); ++it ) { | 211 | for( it = allInc.begin(); it != allInc.end(); ++it ) { |
214 | ResourceCalendar * re = calendarResource->resource( (*it) ); | 212 | ResourceCalendar * re = calendarResource->resource( (*it) ); |
215 | if ( re && !re->readOnly() ) { | 213 | if ( re && !re->readOnly() ) { |
216 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); | 214 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); |
217 | if ( !cl ) { | 215 | if ( !cl ) { |
218 | ++del; | 216 | ++del; |
219 | cl = (*it); | 217 | cl = (*it); |
220 | if ( cl->type() == "Journal" ) | 218 | if ( cl->type() == "Journal" ) |