summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-12 17:18:27 (UTC)
committer zautrix <zautrix>2004-09-12 17:18:27 (UTC)
commitbc4153a99e205f43d0144e2e910730dd1a14d402 (patch) (unidiff)
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
@@ -726,25 +726,27 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
726 // 2 take remote 726 // 2 take remote
727 // 3 cancel 727 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 730 bool remCh, locCh;
731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
732 if ( remCh )
733 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
732 locCh = ( local->lastModified() > mLastCalendarSync ); 734 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 735 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 736 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 737 qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 738 lastSync = local->lastModified().addDays(1);
737 } else { 739 } else {
738 if ( locCh ) { 740 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 741 qDebug("loc changed %d", local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 742 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 743 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 744 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 745 } else {
744 //qDebug(" not loc changed "); 746 qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 747 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 748 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 749 remote->setLastModified( lastSync.addDays( 1 ) );
748 750
749 } 751 }
750 } 752 }
@@ -781,12 +783,14 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
781 783
782 }//else //debug only 784 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 785 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 786 }
785 int result; 787 int result;
786 bool localIsNew; 788 bool localIsNew;
789 qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
790
787 if ( full && mode < SYNC_PREF_NEWEST ) 791 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 792 mode = SYNC_PREF_ASK;
789 793
790 switch( mode ) { 794 switch( mode ) {
791 case SYNC_PREF_LOCAL: 795 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 796 if ( lastSync > remote->lastModified() )
@@ -812,13 +816,13 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 817 if ( lastSync > remote->lastModified() )
814 return 1; 818 return 1;
815 if ( lastSync > local->lastModified() ) 819 if ( lastSync > local->lastModified() )
816 return 2; 820 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 822 localIsNew = local->lastModified() >= remote->lastModified();
819 if ( localIsNew ) 823 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 824 getEventViewerDialog()->setColorMode( 1 );
821 else 825 else
822 getEventViewerDialog()->setColorMode( 2 ); 826 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 827 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 828 if ( localIsNew )
@@ -939,27 +943,31 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 943 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 944 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
941 bool fullDateRange = false; 945 bool fullDateRange = false;
942 local->resetTempSyncStat(); 946 local->resetTempSyncStat();
943 mLastCalendarSync = QDateTime::currentDateTime(); 947 mLastCalendarSync = QDateTime::currentDateTime();
944 QDateTime modifiedCalendar = mLastCalendarSync;; 948 QDateTime modifiedCalendar = mLastCalendarSync;;
949 eventLSync = getLastSyncEvent();
945 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
946 if ( eventR ) { 951 if ( eventR ) {
947 eventRSync = (Event*) eventR->clone(); 952 eventRSync = (Event*) eventR->clone();
948 remote->deleteEvent(eventR ); 953 remote->deleteEvent(eventR );
949 954
950 } else { 955 } else {
951 fullDateRange = true; 956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
952 eventRSync = new Event(); 957 eventRSync = (Event*)eventLSync->clone();
953 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 958 } else {
954 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 959 fullDateRange = true;
955 eventRSync->setDtStart( mLastCalendarSync ); 960 eventRSync = new Event();
956 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
957 eventRSync->setCategories( i18n("SyncEvent") ); 962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
963 eventRSync->setDtStart( mLastCalendarSync );
964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
965 eventRSync->setCategories( i18n("SyncEvent") );
966 }
958 } 967 }
959 eventLSync = getLastSyncEvent();
960 if ( eventLSync->dtStart() == mLastCalendarSync ) 968 if ( eventLSync->dtStart() == mLastCalendarSync )
961 fullDateRange = true; 969 fullDateRange = true;
962 970
963 if ( ! fullDateRange ) { 971 if ( ! fullDateRange ) {
964 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
965 973
@@ -1113,13 +1121,32 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1113 } 1121 }
1114 } 1122 }
1115 } 1123 }
1116 } 1124 }
1117 inL = el.next(); 1125 inL = el.next();
1118 } 1126 }
1119 1127 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1128 er = remote->rawIncidences();
1129 inR = er.first();
1130 QDateTime dt;
1131 QDateTime cur = QDateTime::currentDateTime();
1132 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 );
1133 while ( inR ) {
1134 if ( inR->type() == "Todo" ) {
1135 Todo * t = (Todo*)inR;
1136 if ( t->hasDueDate() )
1137 dt = t->dtDue();
1138 else
1139 dt = cur.addSecs( 62 );
1140 }
1141 else dt = inR->dtStart();
1142 if ( dt < cur || dt > end )
1143 remote->deleteIncidence( inR );
1144 inR = er.next();
1145 }
1146 }
1120 bar.hide(); 1147 bar.hide();
1121 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1148 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1122 eventLSync->setReadOnly( false ); 1149 eventLSync->setReadOnly( false );
1123 eventLSync->setDtStart( mLastCalendarSync ); 1150 eventLSync->setDtStart( mLastCalendarSync );
1124 eventRSync->setDtStart( mLastCalendarSync ); 1151 eventRSync->setDtStart( mLastCalendarSync );
1125 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1152 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 446fe2e..a9ac52f 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -196,12 +196,13 @@ class KOPrefs : public KPimPrefs
196 bool mToolBarUp; 196 bool mToolBarUp;
197 bool mToolBarMiniIcons; 197 bool mToolBarMiniIcons;
198 198
199 bool mAskForQuit; 199 bool mAskForQuit;
200 bool mUsePassWd; 200 bool mUsePassWd;
201 bool mWriteBackFile; 201 bool mWriteBackFile;
202 int mWriteBackInFuture;
202 bool mAskForPreferences; 203 bool mAskForPreferences;
203 bool mShowSyncSummary; 204 bool mShowSyncSummary;
204 bool mShowSyncEvents; 205 bool mShowSyncEvents;
205 bool mShowTodoInAgenda; 206 bool mShowTodoInAgenda;
206 bool mWriteBackExistingOnly; 207 bool mWriteBackExistingOnly;
207 208
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d8aa43a..aa30b52 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -911,12 +911,15 @@ int MainWindow::ringSync()
911 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 911 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
912 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 912 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
913 ++syncedProfiles; 913 ++syncedProfiles;
914 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 914 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
915 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 915 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
916 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 916 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
917 KOPrefs::instance()->mWriteBackInFuture = 0;
918 if ( temp->getWriteBackFuture() )
919 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
917 KOPrefs::instance()->mShowSyncSummary = false; 920 KOPrefs::instance()->mShowSyncSummary = false;
918 mView->setSyncDevice(syncProfileNames[i] ); 921 mView->setSyncDevice(syncProfileNames[i] );
919 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 922 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
920 if ( i == 0 ) { 923 if ( i == 0 ) {
921 syncSharp(); 924 syncSharp();
922 } else { 925 } else {
@@ -1014,12 +1017,15 @@ void MainWindow::slotSyncMenu( int action )
1014 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1017 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1015 temp->readConfig(&config); 1018 temp->readConfig(&config);
1016 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1019 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1017 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1020 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1018 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1021 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1019 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1022 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1023 KOPrefs::instance()->mWriteBackInFuture = 0;
1024 if ( temp->getWriteBackFuture() )
1025 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1020 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1026 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1021 if ( action == 1000 ) { 1027 if ( action == 1000 ) {
1022 syncSharp(); 1028 syncSharp();
1023 1029
1024 } else if ( action == 1001 ) { 1030 } else if ( action == 1001 ) {
1025 syncLocalFile(); 1031 syncLocalFile();
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index ef69bce..6d0da5c 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -272,14 +272,12 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
272 mul = mul * mul; 272 mul = mul * mul;
273 int ii = i+1; 273 int ii = i+1;
274 add = add * mul *ii*ii*ii; 274 add = add * mul *ii*ii*ii;
275 cSum += add; 275 cSum += add;
276 } 276 }
277 } 277 }
278 if ( i == 0 )
279 qDebug("csum: i == 0 %d ", cSum);
280 278
281 } 279 }
282 QString dump = attList.join(","); 280 QString dump = attList.join(",");
283 qDebug("csum: %d %s", cSum,dump.latin1()); 281 qDebug("csum: %d %s", cSum,dump.latin1());
284 282
285 return cSum; 283 return cSum;
@@ -464,19 +462,18 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
464#include <qcstring.h> 462#include <qcstring.h>
465 463
466void PhoneFormat::afterSave( Incidence* inc) 464void PhoneFormat::afterSave( Incidence* inc)
467{ 465{
468 uint csum; 466 uint csum;
469 inc->removeID( mProfileName ); 467 inc->removeID( mProfileName );
470#if 0
471 if ( inc->type() == "Event") 468 if ( inc->type() == "Event")
472 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 469 csum = PhoneFormat::getCsumEvent( (Event*) inc );
473 else 470 else
474 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 471 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
475 inc->setCsum( mProfileName, QString::number( csum )); 472 inc->setCsum( mProfileName, QString::number( csum ));
476#endif 473
477 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 474 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
478 475
479} 476}
480bool PhoneFormat::save( Calendar *calendar) 477bool PhoneFormat::save( Calendar *calendar)
481{ 478{
482 QLabel status ( i18n(" Opening device ..."), 0 ); 479 QLabel status ( i18n(" Opening device ..."), 0 );
@@ -511,13 +508,17 @@ bool PhoneFormat::save( Calendar *calendar)
511 // 2 remove todos which should be deleted 508 // 2 remove todos which should be deleted
512 QPtrList<Todo> tl = calendar->rawTodos(); 509 QPtrList<Todo> tl = calendar->rawTodos();
513 Todo* to = tl.first(); 510 Todo* to = tl.first();
514 while ( to ) { 511 while ( to ) {
515 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 512 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
516 calendar->deleteTodo( to ); 513 calendar->deleteTodo( to );
517 } 514 } else {
515 if ( to->isCompleted()) {
516 calendar->deleteTodo( to );
517 }
518 }
518 to = tl.next(); 519 to = tl.next();
519 } 520 }
520 // 3 save file 521 // 3 save file
521 VCalFormat vfsave; 522 VCalFormat vfsave;
522 vfsave.setLocalTime ( true ); 523 vfsave.setLocalTime ( true );
523 if ( ! vfsave.save( calendar, fileName ) ) 524 if ( ! vfsave.save( calendar, fileName ) )
@@ -560,13 +561,13 @@ bool PhoneFormat::save( Calendar *calendar)
560 //qDebug("event new ID %s",ev->summary().latin1()); 561 //qDebug("event new ID %s",ev->summary().latin1());
561 status.setText ( message + QString::number ( ++procCount ) ); 562 status.setText ( message + QString::number ( ++procCount ) );
562 qApp->processEvents(); 563 qApp->processEvents();
563 uint csum; 564 uint csum;
564 csum = PhoneFormat::getCsumEvent( ev ); 565 csum = PhoneFormat::getCsumEvent( ev );
565 QString cSum = QString::number( csum ); 566 QString cSum = QString::number( csum );
566 ev->setCsum( mProfileName, cSum ); 567 //ev->setCsum( mProfileName, cSum );
567 //qDebug("Event cSum %s ", cSum.latin1()); 568 //qDebug("Event cSum %s ", cSum.latin1());
568 ev1 = er1.first(); 569 ev1 = er1.first();
569 while ( ev1 ) { 570 while ( ev1 ) {
570 if ( ev1->getCsum( mProfileName ) == cSum ) { 571 if ( ev1->getCsum( mProfileName ) == cSum ) {
571 er1.remove( ev1 ); 572 er1.remove( ev1 );
572 afterSave( ev ); 573 afterSave( ev );
@@ -596,13 +597,13 @@ bool PhoneFormat::save( Calendar *calendar)
596 qDebug("todo2 %d ", procCount); 597 qDebug("todo2 %d ", procCount);
597 status.setText ( message + QString::number ( ++procCount ) ); 598 status.setText ( message + QString::number ( ++procCount ) );
598 qApp->processEvents(); 599 qApp->processEvents();
599 uint csum; 600 uint csum;
600 csum = PhoneFormat::getCsumTodo( to ); 601 csum = PhoneFormat::getCsumTodo( to );
601 QString cSum = QString::number( csum ); 602 QString cSum = QString::number( csum );
602 to->setCsum( mProfileName, cSum ); 603 //to->setCsum( mProfileName, cSum );
603 qDebug("Todo cSum %s ", cSum.latin1()); 604 qDebug("Todo cSum %s ", cSum.latin1());
604 Todo* to1 = tl1.first(); 605 Todo* to1 = tl1.first();
605 while ( to1 ) { 606 while ( to1 ) {
606 if ( to1->getCsum( mProfileName ) == cSum ) { 607 if ( to1->getCsum( mProfileName ) == cSum ) {
607 tl1.remove( to1 ); 608 tl1.remove( to1 );
608 afterSave( to ); 609 afterSave( to );