summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index fab4540..5150455 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -718,25 +718,25 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
718 // int zaurusId() const; 718 // int zaurusId() const;
719 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
720 // int zaurusUid() const; 720 // int zaurusUid() const;
721 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
722 // int zaurusStat() const; 722 // int zaurusStat() const;
723 // 0 equal 723 // 0 equal
724 // 1 take local 724 // 1 take local
725 // 2 take remote 725 // 2 take remote
726 // 3 cancel 726 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
729 bool remCh, locCh; 729 bool remCh, locCh;
730 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
731 locCh = ( local->lastModified() > mLastCalendarSync ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
733 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
734 //qDebug("both not changed "); 734 //qDebug("both not changed ");
735 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
736 } else { 736 } else {
737 if ( locCh ) { 737 if ( locCh ) {
738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
739 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
740 if ( !remCh ) 740 if ( !remCh )
741 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
742 } else { 742 } else {
@@ -764,25 +764,25 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
764 if ( full ) { 764 if ( full ) {
765 bool equ = false; 765 bool equ = false;
766 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
767 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
768 } 768 }
769 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
770 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
771 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
772 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
773 if ( equ ) { 773 if ( equ ) {
774 //qDebug("equal "); 774 //qDebug("equal ");
775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
776 local->setZaurusUid( remote->zaurusUid() ); 776 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
777 } 777 }
778 if ( mode < SYNC_PREF_FORCE_LOCAL ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
779 return 0; 779 return 0;
780 780
781 }//else //debug only 781 }//else //debug only
782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
783 } 783 }
784 int result; 784 int result;
785 bool localIsNew; 785 bool localIsNew;
786 if ( full && mode < SYNC_PREF_NEWEST ) 786 if ( full && mode < SYNC_PREF_NEWEST )
787 mode = SYNC_PREF_ASK; 787 mode = SYNC_PREF_ASK;
788 788
@@ -886,31 +886,31 @@ void CalendarView::setupExternSyncProfiles()
886// we check, if the to delete event has a id for a profile 886// we check, if the to delete event has a id for a profile
887// if yes, we set this id in the profile to delete 887// if yes, we set this id in the profile to delete
888void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 888void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
889{ 889{
890 if ( ! lastSync.count() == 0 ) 890 if ( ! lastSync.count() == 0 )
891 return; 891 return;
892 if ( toDelete->type() == "Journal" ) 892 if ( toDelete->type() == "Journal" )
893 return; 893 return;
894 894
895 Event* eve = lastSync.first(); 895 Event* eve = lastSync.first();
896 896
897 while ( eve ) { 897 while ( eve ) {
898 int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 898 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
899 if ( id >= 0 ) { 899 if ( !id.isEmpty() ) {
900 QString des = eve->description(); 900 QString des = eve->description();
901 QString pref = "e"; 901 QString pref = "e";
902 if ( toDelete->type() == "Todo" ) 902 if ( toDelete->type() == "Todo" )
903 pref = "t"; 903 pref = "t";
904 des += pref+ QString::number ( id ) + ","; 904 des += pref+ id + ",";
905 eve->setReadOnly( false ); 905 eve->setReadOnly( false );
906 eve->setDescription( des ); 906 eve->setDescription( des );
907 eve->setReadOnly( true ); 907 eve->setReadOnly( true );
908 } 908 }
909 eve = lastSync.next(); 909 eve = lastSync.next();
910 } 910 }
911 911
912} 912}
913void CalendarView::checkExternalId( Incidence * inc ) 913void CalendarView::checkExternalId( Incidence * inc )
914{ 914{
915 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 915 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
916 checkExternSyncEvent( lastSync, inc ); 916 checkExternSyncEvent( lastSync, inc );
@@ -1004,45 +1004,45 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1004 qApp->processEvents(); 1004 qApp->processEvents();
1005 if ( !skipIncidence ) { 1005 if ( !skipIncidence ) {
1006 inL = local->incidence( uid ); 1006 inL = local->incidence( uid );
1007 if ( inL ) { // maybe conflict - same uid in both calendars 1007 if ( inL ) { // maybe conflict - same uid in both calendars
1008 int maxrev = inL->revision(); 1008 int maxrev = inL->revision();
1009 if ( maxrev < inR->revision() ) 1009 if ( maxrev < inR->revision() )
1010 maxrev = inR->revision(); 1010 maxrev = inR->revision();
1011 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1011 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1012 //qDebug("take %d %s ", take, inL->summary().latin1()); 1012 //qDebug("take %d %s ", take, inL->summary().latin1());
1013 if ( take == 3 ) 1013 if ( take == 3 )
1014 return false; 1014 return false;
1015 if ( take == 1 ) {// take local 1015 if ( take == 1 ) {// take local
1016 inL->setZaurusUid( inR->zaurusUid() ); 1016 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1017 remote->deleteIncidence( inR ); 1017 remote->deleteIncidence( inR );
1018 if ( inL->revision() < maxrev ) 1018 if ( inL->revision() < maxrev )
1019 inL->setRevision( maxrev ); 1019 inL->setRevision( maxrev );
1020 remote->addIncidence( inL->clone() ); 1020 remote->addIncidence( inL->clone() );
1021 ++changedRemote; 1021 ++changedRemote;
1022 } else { 1022 } else {
1023 if ( inR->revision() < maxrev ) 1023 if ( inR->revision() < maxrev )
1024 inR->setRevision( maxrev ); 1024 inR->setRevision( maxrev );
1025 local->deleteIncidence( inL ); 1025 local->deleteIncidence( inL );
1026 local->addIncidence( inR->clone() ); 1026 local->addIncidence( inR->clone() );
1027 ++changedLocal; 1027 ++changedLocal;
1028 } 1028 }
1029 } 1029 }
1030 } else { // no conflict 1030 } else { // no conflict
1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1032 QString des = eventLSync->description(); 1032 QString des = eventLSync->description();
1033 QString pref = "e"; 1033 QString pref = "e";
1034 if ( inR->type() == "Todo" ) 1034 if ( inR->type() == "Todo" )
1035 pref = "t"; 1035 pref = "t";
1036 if ( des.find(pref+QString::number( inR->getID(mCurrentSyncDevice) ) +"," ) >= 0 && mode != 5) { // delete it 1036 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1037 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1037 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1038 //remote->deleteIncidence( inR ); 1038 //remote->deleteIncidence( inR );
1039 ++deletedEventR; 1039 ++deletedEventR;
1040 } else { 1040 } else {
1041 inR->setLastModified( modifiedCalendar ); 1041 inR->setLastModified( modifiedCalendar );
1042 local->addIncidence( inR->clone() ); 1042 local->addIncidence( inR->clone() );
1043 ++addedEvent; 1043 ++addedEvent;
1044 } 1044 }
1045 } else { 1045 } else {
1046 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1046 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1047 inR->setLastModified( modifiedCalendar ); 1047 inR->setLastModified( modifiedCalendar );
1048 local->addIncidence( inR->clone() ); 1048 local->addIncidence( inR->clone() );
@@ -1074,30 +1074,30 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1074 bar.setProgress( incCounter ); 1074 bar.setProgress( incCounter );
1075 ++incCounter; 1075 ++incCounter;
1076 uid = inL->uid(); 1076 uid = inL->uid();
1077 bool skipIncidence = false; 1077 bool skipIncidence = false;
1078 if ( uid.left(15) == QString("last-syncEvent-") ) 1078 if ( uid.left(15) == QString("last-syncEvent-") )
1079 skipIncidence = true; 1079 skipIncidence = true;
1080 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1080 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1081 skipIncidence = true; 1081 skipIncidence = true;
1082 if ( !skipIncidence ) { 1082 if ( !skipIncidence ) {
1083 inR = remote->incidence( uid ); 1083 inR = remote->incidence( uid );
1084 if ( ! inR ) { 1084 if ( ! inR ) {
1085 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1085 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1086 if ( inL->getID(mCurrentSyncDevice) >= 0 && mode != 4 ) { 1086 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1087 local->deleteIncidence( inL ); 1087 local->deleteIncidence( inL );
1088 ++deletedEventL; 1088 ++deletedEventL;
1089 } else { 1089 } else {
1090 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1090 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1091 inL->setID(mCurrentSyncDevice, -1 ); 1091 inL->removeID(mCurrentSyncDevice );
1092 ++addedEventR; 1092 ++addedEventR;
1093 inL->setLastModified( modifiedCalendar ); 1093 inL->setLastModified( modifiedCalendar );
1094 remote->addIncidence( inL->clone() ); 1094 remote->addIncidence( inL->clone() );
1095 } 1095 }
1096 } 1096 }
1097 } else { 1097 } else {
1098 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1098 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1099 checkExternSyncEvent(eventLSyncSharp, inL); 1099 checkExternSyncEvent(eventLSyncSharp, inL);
1100 local->deleteIncidence( inL ); 1100 local->deleteIncidence( inL );
1101 ++deletedEventL; 1101 ++deletedEventL;
1102 } else { 1102 } else {
1103 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1103 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
@@ -1199,25 +1199,25 @@ void CalendarView::syncSharp()
1199 } 1199 }
1200 */ 1200 */
1201 // pending: clean last sync event description 1201 // pending: clean last sync event description
1202 sharpFormat.save(calendar); 1202 sharpFormat.save(calendar);
1203 iL = calendar->rawIncidences(); 1203 iL = calendar->rawIncidences();
1204 inc = iL.first(); 1204 inc = iL.first();
1205 Incidence* loc; 1205 Incidence* loc;
1206 while ( inc ) { 1206 while ( inc ) {
1207 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1207 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1208 loc = mCalendar->incidence(inc->uid() ); 1208 loc = mCalendar->incidence(inc->uid() );
1209 if ( loc ) { 1209 if ( loc ) {
1210 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1210 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1211 loc->setZaurusUid( inc->zaurusUid() ); 1211 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1212 } 1212 }
1213 } 1213 }
1214 inc = iL.next(); 1214 inc = iL.next();
1215 } 1215 }
1216 Incidence* lse = getLastSyncEvent(); 1216 Incidence* lse = getLastSyncEvent();
1217 if ( lse ) { 1217 if ( lse ) {
1218 lse->setReadOnly( false ); 1218 lse->setReadOnly( false );
1219 lse->setDescription( "" ); 1219 lse->setDescription( "" );
1220 lse->setReadOnly( true ); 1220 lse->setReadOnly( true );
1221 } 1221 }
1222 } 1222 }
1223 } 1223 }