-rw-r--r-- | kde2file/caldump/main.cpp | 38 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 29 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 8 | ||||
-rw-r--r-- | libkcal/calendar.h | 2 |
5 files changed, 42 insertions, 36 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 @@ -54,8 +54,9 @@ #include <qdatetime.h> #include <qfile.h> #include <qdir.h> +#include <qapplication.h> #include <stdlib.h> #include <iostream> @@ -151,62 +152,59 @@ int main( int argc, char *argv[] ) qDebug("************************************* "); qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); } else { - qDebug("*************************load"); + qDebug("************load"); localCalendar = new CalendarLocal(); localCalendar->setTimeZoneId( calendarResource->timeZoneId()); FileStorage* storage = new FileStorage( localCalendar ); storage->setFileName( fileName ); int num = 0; int del = 0; int add = 0; if ( storage->load() ) { - qDebug("*************************loaded!"); + qDebug("***********loaded!"); KCal::Incidence::List newInc = localCalendar->rawIncidences(); Incidence::List::ConstIterator it; for( it = newInc.begin(); it != newInc.end(); ++it ) { - if ( (*it)->pilotId() > 0 ) { //changed - Incidence* cl = (*it)->clone(); - Incidence *incOld = calendarResource->incidence( cl->uid() ); + if ( (*it)->pilotId() > 1 ) { //changed + qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); + Incidence *incOld = calendarResource->incidence( (*it)->uid() ); ResourceCalendar * res = 0; if ( incOld ) res = calendarResource->resource( incOld ); if ( res ) { + Incidence* cl = (*it)->clone(); cl->setPilotId( incOld->pilotId() ); ++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 ); - + qDebug("*********change incidence %s ",cl->summary().latin1()); if ( cl->type() == "Journal" ) calendarResource->addJournal( (Journal *) cl, res ); else if ( cl->type() == "Todo" ) calendarResource->addTodo( (Todo *) cl, res ); else if ( cl->type() == "Event" ) 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 ); - - } + Incidence* cl = (*it)->clone(); + qDebug("*********add incidence %s ",cl->summary().latin1()); + calendarResource->addIncidence( cl ); + ++add; + } + } else { // maybe added + Incidence *incOld = calendarResource->incidence( (*it)->uid() ); + if ( !incOld ) { //added + Incidence* cl = (*it)->clone(); + qDebug("*********add incidence %s ",cl->summary().latin1()); calendarResource->addIncidence( cl ); ++add; } - } else { // added - Incidence* cl = (*it)->clone(); - calendarResource->addIncidence( cl ); - ++add; } } KCal::Incidence::List allInc = calendarResource->rawIncidences(); diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index f727cd4..ff1db2c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -756,9 +756,9 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { if ( localMod == remoteMod ) - if ( local->revision() == remote->revision() ) + // if ( local->revision() == remote->revision() ) return 0; } // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); @@ -931,13 +931,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); bool fullDateRange = false; local->resetTempSyncStat(); -#ifdef DESKTOP_VERSION - //Needed for KDE - OL sync - local->resetPilotStat(); - remote->resetPilotStat(); -#endif + if ( mSyncKDE ) + remote->resetPilotStat(1); mLastCalendarSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastCalendarSync;; eventLSync = getLastSyncEvent(); eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); @@ -968,9 +965,9 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); fullDateRange = true; } } - if ( fullDateRange ) + if ( fullDateRange && !mSyncKDE ) mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); else mLastCalendarSync = eventLSync->dtStart(); // for resyncing if own file has changed @@ -1030,18 +1027,20 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) inR->setIDStr( idS ); remote->addIncidence( inR ); -#ifdef DESKTOP_VERSION - inR->setPilotId( 1 ); -#endif + if ( mSyncKDE ) + inR->setPilotId( 2 ); ++changedRemote; } else { if ( inR->revision() < maxrev ) inR->setRevision( maxrev ); idS = inL->IDStr(); + int pid = inL->pilotId(); local->deleteIncidence( inL ); inL = inR->clone(); + if ( mSyncKDE ) + inL->setPilotId( pid ); inL->setIDStr( idS ); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); @@ -1180,10 +1179,12 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); eventLSync->setReadOnly( true ); - if ( mGlobalSyncMode == SYNC_MODE_NORMAL) + if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... remote->addEvent( eventRSync ); + else + delete eventRSync; QString mes; mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); QString delmess; if ( delFut ) { @@ -3733,14 +3734,20 @@ void CalendarView::keyPressEvent ( QKeyEvent *e) bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) { // mSyncManager = manager; + mSyncKDE = false; + if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { + qDebug("SyncKDE request detected!"); + mSyncKDE = true; + } mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); mCurrentSyncName = mSyncManager->getCurrentSyncName(); return syncCalendar( filename, mode ); } bool CalendarView::syncExternal(KSyncManager* manager, QString resource) { + mSyncKDE = false; //mSyncManager = manager; mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); mCurrentSyncName = mSyncManager->getCurrentSyncName(); if ( resource == "sharp" ) diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 9f56cc8..1cd896d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -486,8 +486,9 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void writeLocale(); Todo *selectedTodo(); private: + bool mSyncKDE; KSyncManager* mSyncManager; AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index eeb5f48..52daaaa 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -248,22 +248,22 @@ QPtrList<Incidence> Calendar::incidences() return incidences; } -void Calendar::resetPilotStat() +void Calendar::resetPilotStat(int id ) { QPtrList<Incidence> incidences; Incidence *i; QPtrList<Event> e = rawEvents(); - for( i = e.first(); i; i = e.next() ) i->setPilotId( 0 ); + for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); QPtrList<Todo> t = rawTodos(); - for( i = t.first(); i; i = t.next() ) i->setPilotId( 0 ); + for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); QPtrList<Journal> j = journals(); - for( i = j.first(); i; i = j.next() ) i->setPilotId( 0 ); + for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); } void Calendar::resetTempSyncStat() { QPtrList<Incidence> incidences; diff --git a/libkcal/calendar.h b/libkcal/calendar.h index d5294eb..b801186 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -66,9 +66,9 @@ public: Calendar(const QString &timeZoneId); virtual ~Calendar(); void deleteIncidence(Incidence *in); void resetTempSyncStat(); - void resetPilotStat(); + void resetPilotStat(int id); /** Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; |