summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-17 16:06:42 (UTC)
committer zautrix <zautrix>2004-10-17 16:06:42 (UTC)
commitd92f58ffa1937af8a4240b9d235da15f5f352769 (patch) (unidiff)
tree48768599988f33c7f20017a76d05e919fa77ac51 /korganizer
parent711c4c06a7d1a52b97fd24efa3586543f46cc6d7 (diff)
downloadkdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.zip
kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.gz
kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.bz2
KDE sync fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1f8ad5b..f727cd4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -903,64 +903,69 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
903 eve->setReadOnly( true ); 903 eve->setReadOnly( true );
904 } 904 }
905 eve = lastSync.next(); 905 eve = lastSync.next();
906 } 906 }
907 907
908} 908}
909void CalendarView::checkExternalId( Incidence * inc ) 909void CalendarView::checkExternalId( Incidence * inc )
910{ 910{
911 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 911 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
912 checkExternSyncEvent( lastSync, inc ); 912 checkExternSyncEvent( lastSync, inc );
913 913
914} 914}
915bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 915bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
916{ 916{
917 bool syncOK = true; 917 bool syncOK = true;
918 int addedEvent = 0; 918 int addedEvent = 0;
919 int addedEventR = 0; 919 int addedEventR = 0;
920 int deletedEventR = 0; 920 int deletedEventR = 0;
921 int deletedEventL = 0; 921 int deletedEventL = 0;
922 int changedLocal = 0; 922 int changedLocal = 0;
923 int changedRemote = 0; 923 int changedRemote = 0;
924 //QPtrList<Event> el = local->rawEvents(); 924 //QPtrList<Event> el = local->rawEvents();
925 Event* eventR; 925 Event* eventR;
926 QString uid; 926 QString uid;
927 int take; 927 int take;
928 Event* eventL; 928 Event* eventL;
929 Event* eventRSync; 929 Event* eventRSync;
930 Event* eventLSync; 930 Event* eventLSync;
931 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 931 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
932 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 932 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
933 bool fullDateRange = false; 933 bool fullDateRange = false;
934 local->resetTempSyncStat(); 934 local->resetTempSyncStat();
935#ifdef DESKTOP_VERSION
936 //Needed for KDE - OL sync
937 local->resetPilotStat();
938 remote->resetPilotStat();
939#endif
935 mLastCalendarSync = QDateTime::currentDateTime(); 940 mLastCalendarSync = QDateTime::currentDateTime();
936 QDateTime modifiedCalendar = mLastCalendarSync;; 941 QDateTime modifiedCalendar = mLastCalendarSync;;
937 eventLSync = getLastSyncEvent(); 942 eventLSync = getLastSyncEvent();
938 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 943 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
939 if ( eventR ) { 944 if ( eventR ) {
940 eventRSync = (Event*) eventR->clone(); 945 eventRSync = (Event*) eventR->clone();
941 remote->deleteEvent(eventR ); 946 remote->deleteEvent(eventR );
942 947
943 } else { 948 } else {
944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 949 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
945 eventRSync = (Event*)eventLSync->clone(); 950 eventRSync = (Event*)eventLSync->clone();
946 } else { 951 } else {
947 fullDateRange = true; 952 fullDateRange = true;
948 eventRSync = new Event(); 953 eventRSync = new Event();
949 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 954 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
950 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 955 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
951 eventRSync->setDtStart( mLastCalendarSync ); 956 eventRSync->setDtStart( mLastCalendarSync );
952 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 957 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
953 eventRSync->setCategories( i18n("SyncEvent") ); 958 eventRSync->setCategories( i18n("SyncEvent") );
954 } 959 }
955 } 960 }
956 if ( eventLSync->dtStart() == mLastCalendarSync ) 961 if ( eventLSync->dtStart() == mLastCalendarSync )
957 fullDateRange = true; 962 fullDateRange = true;
958 963
959 if ( ! fullDateRange ) { 964 if ( ! fullDateRange ) {
960 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 965 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
961 966
962 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 967 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
963 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 968 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
964 fullDateRange = true; 969 fullDateRange = true;
965 } 970 }
966 } 971 }
@@ -997,64 +1002,67 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
997 if ( incCounter % modulo == 0 ) 1002 if ( incCounter % modulo == 0 )
998 bar.setProgress( incCounter ); 1003 bar.setProgress( incCounter );
999 ++incCounter; 1004 ++incCounter;
1000 uid = inR->uid(); 1005 uid = inR->uid();
1001 bool skipIncidence = false; 1006 bool skipIncidence = false;
1002 if ( uid.left(15) == QString("last-syncEvent-") ) 1007 if ( uid.left(15) == QString("last-syncEvent-") )
1003 skipIncidence = true; 1008 skipIncidence = true;
1004 QString idS; 1009 QString idS;
1005 qApp->processEvents(); 1010 qApp->processEvents();
1006 if ( !skipIncidence ) { 1011 if ( !skipIncidence ) {
1007 inL = local->incidence( uid ); 1012 inL = local->incidence( uid );
1008 if ( inL ) { // maybe conflict - same uid in both calendars 1013 if ( inL ) { // maybe conflict - same uid in both calendars
1009 int maxrev = inL->revision(); 1014 int maxrev = inL->revision();
1010 if ( maxrev < inR->revision() ) 1015 if ( maxrev < inR->revision() )
1011 maxrev = inR->revision(); 1016 maxrev = inR->revision();
1012 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1017 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1013 //qDebug("take %d %s ", take, inL->summary().latin1()); 1018 //qDebug("take %d %s ", take, inL->summary().latin1());
1014 if ( take == 3 ) 1019 if ( take == 3 )
1015 return false; 1020 return false;
1016 if ( take == 1 ) {// take local 1021 if ( take == 1 ) {// take local
1017 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1022 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1018 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1023 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1019 else 1024 else
1020 idS = inR->IDStr(); 1025 idS = inR->IDStr();
1021 remote->deleteIncidence( inR ); 1026 remote->deleteIncidence( inR );
1022 if ( inL->revision() < maxrev ) 1027 if ( inL->revision() < maxrev )
1023 inL->setRevision( maxrev ); 1028 inL->setRevision( maxrev );
1024 inR = inL->clone(); 1029 inR = inL->clone();
1025 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1030 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1026 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1031 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1027 inR->setIDStr( idS ); 1032 inR->setIDStr( idS );
1028 remote->addIncidence( inR ); 1033 remote->addIncidence( inR );
1034#ifdef DESKTOP_VERSION
1035 inR->setPilotId( 1 );
1036#endif
1029 ++changedRemote; 1037 ++changedRemote;
1030 } else { 1038 } else {
1031 if ( inR->revision() < maxrev ) 1039 if ( inR->revision() < maxrev )
1032 inR->setRevision( maxrev ); 1040 inR->setRevision( maxrev );
1033 idS = inL->IDStr(); 1041 idS = inL->IDStr();
1034 local->deleteIncidence( inL ); 1042 local->deleteIncidence( inL );
1035 inL = inR->clone(); 1043 inL = inR->clone();
1036 inL->setIDStr( idS ); 1044 inL->setIDStr( idS );
1037 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1045 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1038 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1046 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1039 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1047 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1040 } 1048 }
1041 local->addIncidence( inL ); 1049 local->addIncidence( inL );
1042 ++changedLocal; 1050 ++changedLocal;
1043 } 1051 }
1044 } 1052 }
1045 } else { // no conflict 1053 } else { // no conflict
1046 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1054 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1047 QString des = eventLSync->description(); 1055 QString des = eventLSync->description();
1048 QString pref = "e"; 1056 QString pref = "e";
1049 if ( inR->type() == "Todo" ) 1057 if ( inR->type() == "Todo" )
1050 pref = "t"; 1058 pref = "t";
1051 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1059 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1052 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1060 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1053 //remote->deleteIncidence( inR ); 1061 //remote->deleteIncidence( inR );
1054 ++deletedEventR; 1062 ++deletedEventR;
1055 } else { 1063 } else {
1056 inR->setLastModified( modifiedCalendar ); 1064 inR->setLastModified( modifiedCalendar );
1057 inL = inR->clone(); 1065 inL = inR->clone();
1058 local->addIncidence( inL ); 1066 local->addIncidence( inL );
1059 ++addedEvent; 1067 ++addedEvent;
1060 } 1068 }