author | zautrix <zautrix> | 2004-10-17 14:32:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-17 14:32:16 (UTC) |
commit | 780a12295cbbcf4eff4f9570322c1cac517414ad (patch) (side-by-side diff) | |
tree | 4c68b7e6ee854f9d4f0e7e3032f7c70cc45668be /kde2file/caldump/main.cpp | |
parent | f909868a098a22c17906f3d2ab05d5fac0332e85 (diff) | |
download | kdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.zip kdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.tar.gz kdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.tar.bz2 |
many kde sync fixes
-rw-r--r-- | kde2file/caldump/main.cpp | 97 |
1 files changed, 67 insertions, 30 deletions
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp index 76bfad3..8d81307 100644 --- a/kde2file/caldump/main.cpp +++ b/kde2file/caldump/main.cpp @@ -56,2 +56,3 @@ #include <qfile.h> +#include <qdir.h> @@ -107,6 +108,9 @@ int main( int argc, char *argv[] ) } + QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; CalendarResources *calendarResource = 0; CalendarLocal *localCalendar = 0; - - calendarResource = new CalendarResources( "" ); + KConfig c( locate( "config", "korganizerrc" ) ); + c.setGroup( "Time & Date" ); + QString tz = c.readEntry( "TimeZoneId" ); + calendarResource = new CalendarResources( tz ); calendarResource->readConfig(); @@ -114,3 +118,3 @@ int main( int argc, char *argv[] ) qDebug("************************************* "); - qDebug("************************************* "); + qDebug("**************kdecaldump************* "); qDebug("************************************* "); @@ -140,3 +144,3 @@ int main( int argc, char *argv[] ) FileStorage* storage = new FileStorage( calendarResource ); - storage->setFileName( "/tmp/kdedumpall.ics" ); + storage->setFileName( fileName ); storage->setSaveFormat( new ICalFormat() ); @@ -145,5 +149,5 @@ int main( int argc, char *argv[] ) qDebug("************************************* "); + qDebug("************kdecaldump*************** "); qDebug("************************************* "); - qDebug("************************************* "); - qDebug("%d calendar entries dumped to file /tmp/kdedumpall.ics", num); + qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); @@ -153,33 +157,66 @@ int main( int argc, char *argv[] ) FileStorage* storage = new FileStorage( localCalendar ); - storage->setFileName( "/tmp/kdedumpall.ics" ); + storage->setFileName( fileName ); int num = 0; int del = 0; + int add = 0; if ( storage->load() ) { - KCal::Incidence::List allInc = calendarResource->rawIncidences(); KCal::Incidence::List newInc = localCalendar->rawIncidences(); Incidence::List::ConstIterator it; - for( it = allInc.begin(); it != allInc.end(); ++it ) { - ResourceCalendar * re = calendarResource->resource( (*it) ); - if ( re && !re->readOnly() ) { - Incidence* cl = localCalendar->incidence( (*it)->uid() ); - if ( cl ) { - QDateTime lm = cl->lastModified(); - cl->setResources( (*it)->resources() ); - cl->setLastModified(lm); - } - ++del; - cl = (*it); + for( it = newInc.begin(); it != newInc.end(); ++it ) { + Incidence* cl = (*it)->clone(); + Incidence *incOld = calendarResource->incidence( cl->uid() ); + ResourceCalendar * res = 0; + if ( incOld ) + res = calendarResource->resource( incOld ); + if ( res ) { + ++num; + if ( incOld->type() == "Journal" ) + calendarResource->deleteJournal( (Journal *) incOld ); + else if ( incOld->type() == "Todo" ) + calendarResource->deleteTodo( (Todo *) incOld ); + else if ( incOld->type() == "Event" ) + calendarResource->deleteEvent( (Event *) incOld ); + if ( cl->type() == "Journal" ) - calendarResource->deleteJournal( (Journal *) cl ); + calendarResource->addJournal( (Journal *) cl, res ); else if ( cl->type() == "Todo" ) - calendarResource->deleteTodo( (Todo *) cl ); + calendarResource->addTodo( (Todo *) cl, res ); else if ( cl->type() == "Event" ) - calendarResource->deleteEvent( (Event *) cl ); + calendarResource->addEvent( (Event *) cl, res ); + + } else { + if ( incOld ) { + qDebug("ERROR: no resource found for old incidence "); + if ( incOld->type() == "Journal" ) + calendarResource->deleteJournal( (Journal *) incOld ); + else if ( incOld->type() == "Todo" ) + calendarResource->deleteTodo( (Todo *) incOld ); + else if ( incOld->type() == "Event" ) + calendarResource->deleteEvent( (Event *) incOld ); + + } + calendarResource->addIncidence( cl ); + ++add; + } + KCal::Incidence::List allInc = calendarResource->rawIncidences(); + + for( it = allInc.begin(); it != allInc.end(); ++it ) { + ResourceCalendar * re = calendarResource->resource( (*it) ); + if ( re && !re->readOnly() ) { + Incidence* cl = localCalendar->incidence( (*it)->uid() ); + if ( !cl ) { + ++del; + cl = (*it); + if ( cl->type() == "Journal" ) + calendarResource->deleteJournal( (Journal *) cl ); + else if ( cl->type() == "Todo" ) + calendarResource->deleteTodo( (Todo *) cl ); + else if ( cl->type() == "Event" ) + calendarResource->deleteEvent( (Event *) cl ); + //QDateTime lm = cl->lastModified(); + //cl->setResources( (*it)->resources() ); + //cl->setLastModified(lm); + } + } } - } - for( it = newInc.begin(); it != newInc.end(); ++it ) { - Incidence* cl = (*it)->clone(); - ++num; - calendarResource->addIncidence( cl ); - //cl->setLastModified( (*it)->lastModified() ); } @@ -187,5 +224,5 @@ int main( int argc, char *argv[] ) qDebug("************************************* "); + qDebug("************kdecaldump*************** "); qDebug("************************************* "); - qDebug("************************************* "); - qDebug("%d calendar entries deleted/ %d added from file /tmp/kdedumpall.ics", del, num); + qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); |