-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | kde2file/caldump/main.cpp | 97 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 7 |
3 files changed, 73 insertions, 33 deletions
@@ -1,5 +1,5 @@ ############################################################################# # Makefile for building: kdepim-desktop -# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Oct 16 22:32:03 2004 +# Generated by qmake (1.07a) (Qt 3.3.3) on: Sun Oct 17 11:53:22 2004 # Project: kdepim-desktop.pro # Template: subdirs 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 @@ -55,4 +55,5 @@ #include <qdatetime.h> #include <qfile.h> +#include <qdir.h> #include <stdlib.h> @@ -106,12 +107,15 @@ int main( int argc, char *argv[] ) qDebug("read "); } + 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(); calendarResource->load(); qDebug("************************************* "); - qDebug("************************************* "); + qDebug("**************kdecaldump************* "); qDebug("************************************* "); qDebug("Using timezone id: %s", calendarResource->timeZoneId().latin1()); @@ -139,12 +143,12 @@ int main( int argc, char *argv[] ) FileStorage* storage = new FileStorage( calendarResource ); - storage->setFileName( "/tmp/kdedumpall.ics" ); + storage->setFileName( fileName ); storage->setSaveFormat( new ICalFormat() ); storage->save(); delete storage; 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()); } else { @@ -152,41 +156,74 @@ int main( int argc, char *argv[] ) localCalendar->setTimeZoneId( calendarResource->timeZoneId()); 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() ); } calendarResource->save(); 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()); } else diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index c6e06f8..8851097 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -782,7 +782,10 @@ void KSyncManager::syncKDE() case (KOPI): { - QString command ="./kdecaldump"; + QString command = qApp->applicationDirPath () + "/kdecaldump"; + if ( ! QFile::exists ( command ) ) + command = "kdecaldump"; + QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; system ( command.latin1()); - if ( syncWithFile( "/tmp/kdedumpall.ics",true ) ) { + if ( syncWithFile( fileName,true ) ) { if ( mWriteBackFile ) { command += " --read"; |