-rw-r--r-- | korganizer/calendarview.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ff1db2c..290c0b9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -705,30 +705,24 @@ void CalendarView::createPrinter() | |||
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | //void setZaurusId(int id); | ||
718 | // int zaurusId() const; | ||
719 | // void setZaurusUid(int id); | ||
720 | // int zaurusUid() const; | ||
721 | // void setZaurusStat(int id); | ||
722 | // int zaurusStat() const; | ||
723 | // 0 equal | 717 | // 0 equal |
724 | // 1 take local | 718 | // 1 take local |
725 | // 2 take remote | 719 | // 2 take remote |
726 | // 3 cancel | 720 | // 3 cancel |
727 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
728 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
729 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
731 | bool remCh, locCh; | 725 | bool remCh, locCh; |
732 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
733 | //if ( remCh ) | 727 | //if ( remCh ) |
734 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
@@ -934,25 +928,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
934 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
935 | if ( mSyncKDE ) | 929 | if ( mSyncKDE ) |
936 | remote->resetPilotStat(1); | 930 | remote->resetPilotStat(1); |
937 | mLastCalendarSync = QDateTime::currentDateTime(); | 931 | mLastCalendarSync = QDateTime::currentDateTime(); |
938 | QDateTime modifiedCalendar = mLastCalendarSync;; | 932 | QDateTime modifiedCalendar = mLastCalendarSync;; |
939 | eventLSync = getLastSyncEvent(); | 933 | eventLSync = getLastSyncEvent(); |
940 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
941 | if ( eventR ) { | 935 | if ( eventR ) { |
942 | eventRSync = (Event*) eventR->clone(); | 936 | eventRSync = (Event*) eventR->clone(); |
943 | remote->deleteEvent(eventR ); | 937 | remote->deleteEvent(eventR ); |
944 | 938 | ||
945 | } else { | 939 | } else { |
946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { |
947 | eventRSync = (Event*)eventLSync->clone(); | 941 | eventRSync = (Event*)eventLSync->clone(); |
948 | } else { | 942 | } else { |
949 | fullDateRange = true; | 943 | fullDateRange = true; |
950 | eventRSync = new Event(); | 944 | eventRSync = new Event(); |
951 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
952 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
953 | eventRSync->setDtStart( mLastCalendarSync ); | 947 | eventRSync->setDtStart( mLastCalendarSync ); |
954 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
955 | eventRSync->setCategories( i18n("SyncEvent") ); | 949 | eventRSync->setCategories( i18n("SyncEvent") ); |
956 | } | 950 | } |
957 | } | 951 | } |
958 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 952 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
@@ -964,28 +958,28 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
964 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
965 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
966 | fullDateRange = true; | 960 | fullDateRange = true; |
967 | } | 961 | } |
968 | } | 962 | } |
969 | if ( fullDateRange && !mSyncKDE ) | 963 | if ( fullDateRange && !mSyncKDE ) |
970 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 964 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
971 | else | 965 | else |
972 | mLastCalendarSync = eventLSync->dtStart(); | 966 | mLastCalendarSync = eventLSync->dtStart(); |
973 | // for resyncing if own file has changed | 967 | // for resyncing if own file has changed |
974 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 968 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
975 | mLastCalendarSync = loadedFileVersion; | 969 | mLastCalendarSync = loadedFileVersion; |
976 | qDebug("setting mLastCalendarSync "); | 970 | //qDebug("setting mLastCalendarSync "); |
977 | } | 971 | } |
978 | //qDebug("*************************** "); | 972 | //qDebug("*************************** "); |
979 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 973 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
980 | QPtrList<Incidence> er = remote->rawIncidences(); | 974 | QPtrList<Incidence> er = remote->rawIncidences(); |
981 | Incidence* inR = er.first(); | 975 | Incidence* inR = er.first(); |
982 | Incidence* inL; | 976 | Incidence* inL; |
983 | QProgressBar bar( er.count(),0 ); | 977 | QProgressBar bar( er.count(),0 ); |
984 | bar.setCaption (i18n("Syncing - close to abort!") ); | 978 | bar.setCaption (i18n("Syncing - close to abort!") ); |
985 | 979 | ||
986 | int w = 300; | 980 | int w = 300; |
987 | if ( QApplication::desktop()->width() < 320 ) | 981 | if ( QApplication::desktop()->width() < 320 ) |
988 | w = 220; | 982 | w = 220; |
989 | int h = bar.sizeHint().height() ; | 983 | int h = bar.sizeHint().height() ; |
990 | int dw = QApplication::desktop()->width(); | 984 | int dw = QApplication::desktop()->width(); |
991 | int dh = QApplication::desktop()->height(); | 985 | int dh = QApplication::desktop()->height(); |
@@ -999,50 +993,43 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
999 | if ( incCounter % modulo == 0 ) | 993 | if ( incCounter % modulo == 0 ) |
1000 | bar.setProgress( incCounter ); | 994 | bar.setProgress( incCounter ); |
1001 | ++incCounter; | 995 | ++incCounter; |
1002 | uid = inR->uid(); | 996 | uid = inR->uid(); |
1003 | bool skipIncidence = false; | 997 | bool skipIncidence = false; |
1004 | if ( uid.left(15) == QString("last-syncEvent-") ) | 998 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1005 | skipIncidence = true; | 999 | skipIncidence = true; |
1006 | QString idS; | 1000 | QString idS; |
1007 | qApp->processEvents(); | 1001 | qApp->processEvents(); |
1008 | if ( !skipIncidence ) { | 1002 | if ( !skipIncidence ) { |
1009 | inL = local->incidence( uid ); | 1003 | inL = local->incidence( uid ); |
1010 | if ( inL ) { // maybe conflict - same uid in both calendars | 1004 | if ( inL ) { // maybe conflict - same uid in both calendars |
1011 | int maxrev = inL->revision(); | ||
1012 | if ( maxrev < inR->revision() ) | ||
1013 | maxrev = inR->revision(); | ||
1014 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1005 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1015 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1006 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1016 | if ( take == 3 ) | 1007 | if ( take == 3 ) |
1017 | return false; | 1008 | return false; |
1018 | if ( take == 1 ) {// take local | 1009 | if ( take == 1 ) {// take local |
1019 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1010 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1020 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1011 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1021 | else | 1012 | else |
1022 | idS = inR->IDStr(); | 1013 | idS = inR->IDStr(); |
1023 | remote->deleteIncidence( inR ); | 1014 | remote->deleteIncidence( inR ); |
1024 | if ( inL->revision() < maxrev ) | ||
1025 | inL->setRevision( maxrev ); | ||
1026 | inR = inL->clone(); | 1015 | inR = inL->clone(); |
1027 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1016 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1028 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1017 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1029 | inR->setIDStr( idS ); | 1018 | inR->setIDStr( idS ); |
1030 | remote->addIncidence( inR ); | 1019 | remote->addIncidence( inR ); |
1031 | if ( mSyncKDE ) | 1020 | if ( mSyncKDE ) |
1032 | inR->setPilotId( 2 ); | 1021 | inR->setPilotId( 2 ); |
1033 | ++changedRemote; | 1022 | ++changedRemote; |
1034 | } else { | 1023 | } else { |
1035 | if ( inR->revision() < maxrev ) | ||
1036 | inR->setRevision( maxrev ); | ||
1037 | idS = inL->IDStr(); | 1024 | idS = inL->IDStr(); |
1038 | int pid = inL->pilotId(); | 1025 | int pid = inL->pilotId(); |
1039 | local->deleteIncidence( inL ); | 1026 | local->deleteIncidence( inL ); |
1040 | inL = inR->clone(); | 1027 | inL = inR->clone(); |
1041 | if ( mSyncKDE ) | 1028 | if ( mSyncKDE ) |
1042 | inL->setPilotId( pid ); | 1029 | inL->setPilotId( pid ); |
1043 | inL->setIDStr( idS ); | 1030 | inL->setIDStr( idS ); |
1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1045 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1046 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1033 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1047 | } | 1034 | } |
1048 | local->addIncidence( inL ); | 1035 | local->addIncidence( inL ); |