summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -720,37 +720,39 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
// void setZaurusUid(int id);
// int zaurusUid() const;
// void setZaurusStat(int id);
// int zaurusStat() const;
// 0 equal
// 1 take local
// 2 take remote
// 3 cancel
QDateTime lastSync = mLastCalendarSync;
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
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 )
remote->setLastModified( lastSync.addDays( 1 ) );
}
}
full = true;
if ( mode < SYNC_PREF_ASK )
mode = SYNC_PREF_ASK;
} else {
if ( local->lastModified() == remote->lastModified() )
if ( local->revision() == remote->revision() )
@@ -775,24 +777,26 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
//qDebug("equal ");
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
}
if ( mode < SYNC_PREF_FORCE_LOCAL )
return 0;
}//else //debug only
//qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
}
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;
switch( mode ) {
case SYNC_PREF_LOCAL:
if ( lastSync > remote->lastModified() )
return 1;
if ( lastSync > local->lastModified() )
return 2;
return 1;
break;
case SYNC_PREF_REMOTE:
@@ -806,25 +810,25 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
if ( local->lastModified() > remote->lastModified() )
return 1;
else
return 2;
break;
case SYNC_PREF_ASK:
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
if ( lastSync > remote->lastModified() )
return 1;
if ( lastSync > local->lastModified() )
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 );
else
getEventViewerDialog()->setColorMode( 2 );
getEventViewerDialog()->setIncidence(local);
if ( localIsNew )
getEventViewerDialog()->setColorMode( 2 );
else
getEventViewerDialog()->setColorMode( 1 );
getEventViewerDialog()->addIncidence(remote);
getEventViewerDialog()->setColorMode( 0 );
//qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
@@ -933,39 +937,43 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
Event* eventR;
QString uid;
int take;
Event* eventL;
Event* eventRSync;
Event* eventLSync;
QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastCalendarSync = QDateTime::currentDateTime();
QDateTime modifiedCalendar = mLastCalendarSync;;
+ eventLSync = getLastSyncEvent();
eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
if ( eventR ) {
eventRSync = (Event*) eventR->clone();
remote->deleteEvent(eventR );
} 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;
if ( ! fullDateRange ) {
if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
// qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
//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 )
@@ -1107,25 +1115,44 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
} else {
if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
remote->addIncidence( inL->clone() );
}
}
}
}
}
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 );
eventLSync->setReadOnly( false );
eventLSync->setDtStart( mLastCalendarSync );
eventRSync->setDtStart( mLastCalendarSync );
eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
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)
remote->addEvent( eventRSync );
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 446fe2e..a9ac52f 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -190,24 +190,25 @@ class KOPrefs : public KPimPrefs
bool mShowIconNext;
bool mShowIconJournal;
bool mShowIconStretch;
bool mToolBarHor;
bool mToolBarUp;
bool mToolBarMiniIcons;
bool mAskForQuit;
bool mUsePassWd;
bool mWriteBackFile;
+ int mWriteBackInFuture;
bool mAskForPreferences;
bool mShowSyncSummary;
bool mShowSyncEvents;
bool mShowTodoInAgenda;
bool mWriteBackExistingOnly;
QString mRemoteIP;
QString mRemoteUser;
QString mRemotePassWd;
QString mRemoteFile;
QString mLocalTempFile;
QString mPhoneDevice;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d8aa43a..aa30b52 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -905,24 +905,27 @@ int MainWindow::ringSync()
KSyncProfile* temp = new KSyncProfile ();
KOPrefs::instance()->mAskForPreferences = false;
for ( i = 0; i < syncProfileNames.count(); ++i ) {
mCurrentSyncProfile = i;
temp->setName(syncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
++syncedProfiles;
// KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
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] );
mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
if ( i == 0 ) {
syncSharp();
} else {
if ( temp->getIsLocalFileSync() ) {
if ( syncWithFile( temp->getRemoteFileName( ), true ) )
KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
} else {
if ( temp->getIsPhoneSync() ) {
KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
@@ -1008,24 +1011,27 @@ void MainWindow::slotSyncMenu( int action )
mBlockSaveFlag = true;
mCurrentSyncProfile = action - 1000 ;
mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* temp = new KSyncProfile ();
temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
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 ) {
syncSharp();
} else if ( action == 1001 ) {
syncLocalFile();
} else if ( action == 1002 ) {
quickSyncLocalFile();
} else if ( action >= 1003 ) {
if ( temp->getIsLocalFileSync() ) {
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index ef69bce..6d0da5c 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -266,26 +266,24 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
if ( ! s.isEmpty() ){
j = s.length();
for ( k = 0; k < j; ++k ) {
int mul = k +1;
add = s[k].unicode ();
if ( k < 16 )
mul = mul * mul;
int ii = i+1;
add = add * mul *ii*ii*ii;
cSum += add;
}
}
- if ( i == 0 )
- qDebug("csum: i == 0 %d ", cSum);
}
QString dump = attList.join(",");
qDebug("csum: %d %s", cSum,dump.latin1());
return cSum;
}
//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
#include <stdlib.h>
#define DEBUGMODE false
bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
@@ -458,31 +456,30 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
else if (to->priority() == 4 && from->priority() == 5 )
;
else
to->setPriority(from->priority());
}
#include <qcstring.h>
void PhoneFormat::afterSave( Incidence* inc)
{
uint csum;
inc->removeID( mProfileName );
-#if 0
if ( inc->type() == "Event")
csum = PhoneFormat::getCsumEvent( (Event*) inc );
else
csum = PhoneFormat::getCsumTodo( (Todo*) inc );
inc->setCsum( mProfileName, QString::number( csum ));
-#endif
+
inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
}
bool PhoneFormat::save( Calendar *calendar)
{
QLabel status ( i18n(" Opening device ..."), 0 );
int w = status.sizeHint().width()+20 ;
if ( w < 200 ) w = 230;
int h = status.sizeHint().height()+20 ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
status.setCaption(i18n("Writing to phone...") );
@@ -505,25 +502,29 @@ bool PhoneFormat::save( Calendar *calendar)
calendar->deleteEvent( ev );
} else {
}
ev = er.next();
}
// 2 remove todos which should be deleted
QPtrList<Todo> tl = calendar->rawTodos();
Todo* to = tl.first();
while ( to ) {
if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteTodo( to );
- }
+ } else {
+ if ( to->isCompleted()) {
+ calendar->deleteTodo( to );
+ }
+ }
to = tl.next();
}
// 3 save file
VCalFormat vfsave;
vfsave.setLocalTime ( true );
if ( ! vfsave.save( calendar, fileName ) )
return false;
// 4 call kammu
QString command ="./kammu --restore " + fileName ;
int ret;
while ( (ret = system ( command.latin1())) != 0 ) {
qDebug("Error S::command returned %d. asking users", ret);
@@ -554,25 +555,25 @@ bool PhoneFormat::save( Calendar *calendar)
ev = er.first();
message = i18n(" Comparing event # ");
QPtrList<Event> er1 = calendarTemp->rawEvents();
Event* ev1;
int procCount = 0;
while ( ev ) {
//qDebug("event new ID %s",ev->summary().latin1());
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
uint csum;
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();
while ( ev1 ) {
if ( ev1->getCsum( mProfileName ) == cSum ) {
er1.remove( ev1 );
afterSave( ev );
ev->setID(mProfileName, ev1->getID(mProfileName) );
//qDebug("Event found on phone for %s ", ev->summary().latin1());
break;
}
ev1 = er1.next();
@@ -590,25 +591,25 @@ bool PhoneFormat::save( Calendar *calendar)
to = tl.first();
procCount = 0;
QPtrList<Todo> tl1 = calendarTemp->rawTodos();
Todo* to1 ;
message = i18n(" Comparing todo # ");
while ( to ) {
qDebug("todo2 %d ", procCount);
status.setText ( message + QString::number ( ++procCount ) );
qApp->processEvents();
uint csum;
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();
while ( to1 ) {
if ( to1->getCsum( mProfileName ) == cSum ) {
tl1.remove( to1 );
afterSave( to );
to->setID(mProfileName, to1->getID(mProfileName) );
break;
}
to1 = tl1.next();
}
if ( ! to1 ) {