summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-17 18:08:43 (UTC)
committer zautrix <zautrix>2004-10-17 18:08:43 (UTC)
commit6f6d1d58938539215bb4fcb5b97cf9fb089a11ef (patch) (side-by-side diff)
tree9937fe24c3fa3f29421b39a58b393e893a11636a
parentd92f58ffa1937af8a4240b9d235da15f5f352769 (diff)
downloadkdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.zip
kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.gz
kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.bz2
more KDE sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kde2file/caldump/main.cpp38
-rw-r--r--korganizer/calendarview.cpp29
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--libkcal/calendar.cpp8
-rw-r--r--libkcal/calendar.h2
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
@@ -55,6 +55,7 @@
#include <qdatetime.h>
#include <qfile.h>
#include <qdir.h>
+#include <qapplication.h>
#include <stdlib.h>
#include <iostream>
@@ -152,7 +153,7 @@ int main( int argc, char *argv[] )
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 );
@@ -161,17 +162,18 @@ int main( int argc, char *argv[] )
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" )
@@ -180,7 +182,7 @@ int main( int argc, char *argv[] )
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" )
@@ -189,23 +191,19 @@ int main( int argc, char *argv[] )
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
@@ -757,7 +757,7 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
mode = SYNC_PREF_ASK;
} else {
if ( localMod == remoteMod )
- if ( local->revision() == remote->revision() )
+ // if ( local->revision() == remote->revision() )
return 0;
}
@@ -932,11 +932,8 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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();
@@ -969,7 +966,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
fullDateRange = true;
}
}
- if ( fullDateRange )
+ if ( fullDateRange && !mSyncKDE )
mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastCalendarSync = eventLSync->dtStart();
@@ -1031,16 +1028,18 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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) );
@@ -1181,8 +1180,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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;
@@ -3734,12 +3735,18 @@ 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();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 9f56cc8..1cd896d 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -487,6 +487,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
Todo *selectedTodo();
private:
+ bool mSyncKDE;
KSyncManager* mSyncManager;
AlarmDialog * mAlarmDialog;
QString mAlarmNotification;
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index eeb5f48..52daaaa 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -249,20 +249,20 @@ 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()
{
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index d5294eb..b801186 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -67,7 +67,7 @@ public:
virtual ~Calendar();
void deleteIncidence(Incidence *in);
void resetTempSyncStat();
- void resetPilotStat();
+ void resetPilotStat(int id);
/**
Clears out the current calendar, freeing all used memory etc.
*/