summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-12 17:18:27 (UTC)
committer zautrix <zautrix>2004-09-12 17:18:27 (UTC)
commitbc4153a99e205f43d0144e2e910730dd1a14d402 (patch) (side-by-side diff)
tree16aeb28cd765539bac6e85e714478f31a7b93bac
parenta222c2f7369eeefd19454c973c0cc48300f72bec (diff)
downloadkdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.zip
kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.gz
kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.bz2
added missing sync featute
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp53
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/mainwindow.cpp6
-rw-r--r--libkcal/phoneformat.cpp15
4 files changed, 55 insertions, 20 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index db07713..cfd9290 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -730,17 +730,19 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
bool remCh, locCh;
remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
+ if ( remCh )
+ qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
locCh = ( local->lastModified() > mLastCalendarSync );
//qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
if ( !remCh && ! locCh ) {
- //qDebug("both not changed ");
+ qDebug("both not changed ");
lastSync = local->lastModified().addDays(1);
} else {
if ( locCh ) {
- //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
+ qDebug("loc changed %d", local->revision() );
lastSync = local->lastModified().addDays( -1 );
if ( !remCh )
remote->setLastModified( lastSync.addDays( -1 ) );
} else {
- //qDebug(" not loc changed ");
+ qDebug(" not loc changed ");
lastSync = local->lastModified().addDays( 1 );
if ( remCh )
@@ -785,4 +787,6 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
int result;
bool localIsNew;
+ qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
+
if ( full && mode < SYNC_PREF_NEWEST )
mode = SYNC_PREF_ASK;
@@ -816,5 +820,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
return 2;
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
- localIsNew = local->lastModified() > remote->lastModified();
+ localIsNew = local->lastModified() >= remote->lastModified();
if ( localIsNew )
getEventViewerDialog()->setColorMode( 1 );
@@ -943,4 +947,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
mLastCalendarSync = QDateTime::currentDateTime();
QDateTime modifiedCalendar = mLastCalendarSync;;
+ eventLSync = getLastSyncEvent();
eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
if ( eventR ) {
@@ -949,13 +954,16 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
} else {
- fullDateRange = true;
- eventRSync = new Event();
- eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
- eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
- eventRSync->setDtStart( mLastCalendarSync );
- eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
- eventRSync->setCategories( i18n("SyncEvent") );
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
+ eventRSync = (Event*)eventLSync->clone();
+ } else {
+ fullDateRange = true;
+ eventRSync = new Event();
+ eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
+ eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
+ eventRSync->setDtStart( mLastCalendarSync );
+ eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
+ eventRSync->setCategories( i18n("SyncEvent") );
+ }
}
- eventLSync = getLastSyncEvent();
if ( eventLSync->dtStart() == mLastCalendarSync )
fullDateRange = true;
@@ -1117,5 +1125,24 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
inL = el.next();
}
-
+ if ( KOPrefs::instance()->mWriteBackInFuture ) {
+ er = remote->rawIncidences();
+ inR = er.first();
+ QDateTime dt;
+ QDateTime cur = QDateTime::currentDateTime();
+ QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 );
+ while ( inR ) {
+ if ( inR->type() == "Todo" ) {
+ Todo * t = (Todo*)inR;
+ if ( t->hasDueDate() )
+ dt = t->dtDue();
+ else
+ dt = cur.addSecs( 62 );
+ }
+ else dt = inR->dtStart();
+ if ( dt < cur || dt > end )
+ remote->deleteIncidence( inR );
+ inR = er.next();
+ }
+ }
bar.hide();
mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 446fe2e..a9ac52f 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -200,4 +200,5 @@ class KOPrefs : public KPimPrefs
bool mUsePassWd;
bool mWriteBackFile;
+ int mWriteBackInFuture;
bool mAskForPreferences;
bool mShowSyncSummary;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d8aa43a..aa30b52 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -915,4 +915,7 @@ int MainWindow::ringSync()
KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
+ KOPrefs::instance()->mWriteBackInFuture = 0;
+ if ( temp->getWriteBackFuture() )
+ KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
KOPrefs::instance()->mShowSyncSummary = false;
mView->setSyncDevice(syncProfileNames[i] );
@@ -1018,4 +1021,7 @@ void MainWindow::slotSyncMenu( int action )
KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
+ KOPrefs::instance()->mWriteBackInFuture = 0;
+ if ( temp->getWriteBackFuture() )
+ KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
if ( action == 1000 ) {
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index ef69bce..6d0da5c 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -276,6 +276,4 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
}
}
- if ( i == 0 )
- qDebug("csum: i == 0 %d ", cSum);
}
@@ -468,5 +466,4 @@ void PhoneFormat::afterSave( Incidence* inc)
uint csum;
inc->removeID( mProfileName );
-#if 0
if ( inc->type() == "Event")
csum = PhoneFormat::getCsumEvent( (Event*) inc );
@@ -474,5 +471,5 @@ void PhoneFormat::afterSave( Incidence* inc)
csum = PhoneFormat::getCsumTodo( (Todo*) inc );
inc->setCsum( mProfileName, QString::number( csum ));
-#endif
+
inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
@@ -515,5 +512,9 @@ bool PhoneFormat::save( Calendar *calendar)
if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteTodo( to );
- }
+ } else {
+ if ( to->isCompleted()) {
+ calendar->deleteTodo( to );
+ }
+ }
to = tl.next();
}
@@ -564,5 +565,5 @@ bool PhoneFormat::save( Calendar *calendar)
csum = PhoneFormat::getCsumEvent( ev );
QString cSum = QString::number( csum );
- ev->setCsum( mProfileName, cSum );
+ //ev->setCsum( mProfileName, cSum );
//qDebug("Event cSum %s ", cSum.latin1());
ev1 = er1.first();
@@ -600,5 +601,5 @@ bool PhoneFormat::save( Calendar *calendar)
csum = PhoneFormat::getCsumTodo( to );
QString cSum = QString::number( csum );
- to->setCsum( mProfileName, cSum );
+ //to->setCsum( mProfileName, cSum );
qDebug("Todo cSum %s ", cSum.latin1());
Todo* to1 = tl1.first();