summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-27 12:27:39 (UTC)
committer zautrix <zautrix>2004-10-27 12:27:39 (UTC)
commit2f3396d84d2f3c92e1e0e420d677892c1f9c0778 (patch) (unidiff)
tree1ebab5dc6d00cb09720789897ce2c86df05cc9ab /korganizer
parentf73d249579d52d7aeaacde2dcb23abeb42f9ee95 (diff)
downloadkdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.zip
kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.gz
kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.bz2
completed KDE AB sync. but will it work ...?
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp15
-rw-r--r--korganizer/calendarview.h1
2 files changed, 6 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 326db88..6e61351 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -882,205 +882,205 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
882 return; 882 return;
883 883
884 Event* eve = lastSync.first(); 884 Event* eve = lastSync.first();
885 885
886 while ( eve ) { 886 while ( eve ) {
887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
888 if ( !id.isEmpty() ) { 888 if ( !id.isEmpty() ) {
889 QString des = eve->description(); 889 QString des = eve->description();
890 QString pref = "e"; 890 QString pref = "e";
891 if ( toDelete->type() == "Todo" ) 891 if ( toDelete->type() == "Todo" )
892 pref = "t"; 892 pref = "t";
893 des += pref+ id + ","; 893 des += pref+ id + ",";
894 eve->setReadOnly( false ); 894 eve->setReadOnly( false );
895 eve->setDescription( des ); 895 eve->setDescription( des );
896 //qDebug("setdes %s ", des.latin1()); 896 //qDebug("setdes %s ", des.latin1());
897 eve->setReadOnly( true ); 897 eve->setReadOnly( true );
898 } 898 }
899 eve = lastSync.next(); 899 eve = lastSync.next();
900 } 900 }
901 901
902} 902}
903void CalendarView::checkExternalId( Incidence * inc ) 903void CalendarView::checkExternalId( Incidence * inc )
904{ 904{
905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
906 checkExternSyncEvent( lastSync, inc ); 906 checkExternSyncEvent( lastSync, inc );
907 907
908} 908}
909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
910{ 910{
911 bool syncOK = true; 911 bool syncOK = true;
912 int addedEvent = 0; 912 int addedEvent = 0;
913 int addedEventR = 0; 913 int addedEventR = 0;
914 int deletedEventR = 0; 914 int deletedEventR = 0;
915 int deletedEventL = 0; 915 int deletedEventL = 0;
916 int changedLocal = 0; 916 int changedLocal = 0;
917 int changedRemote = 0; 917 int changedRemote = 0;
918 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
919 Event* eventR; 919 Event* eventR;
920 QString uid; 920 QString uid;
921 int take; 921 int take;
922 Event* eventL; 922 Event* eventL;
923 Event* eventRSync; 923 Event* eventRSync;
924 Event* eventLSync; 924 Event* eventLSync;
925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
927 bool fullDateRange = false; 927 bool fullDateRange = false;
928 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
929 mLastCalendarSync = QDateTime::currentDateTime(); 929 mLastCalendarSync = QDateTime::currentDateTime();
930 if ( mSyncKDE ) { 930 if ( mSyncManager->syncWithDesktop() ) {
931 remote->resetPilotStat(1); 931 remote->resetPilotStat(1);
932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
935 } else { 935 } else {
936 qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); 936 qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime ");
937 } 937 }
938 } 938 }
939 QDateTime modifiedCalendar = mLastCalendarSync;; 939 QDateTime modifiedCalendar = mLastCalendarSync;;
940 eventLSync = getLastSyncEvent(); 940 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 942 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 943 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 944 remote->deleteEvent(eventR );
945 945
946 } else { 946 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { 947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
948 eventRSync = (Event*)eventLSync->clone(); 948 eventRSync = (Event*)eventLSync->clone();
949 } else { 949 } else {
950 fullDateRange = true; 950 fullDateRange = true;
951 eventRSync = new Event(); 951 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
957 } 957 }
958 } 958 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 960 fullDateRange = true;
961 961
962 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 964
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 967 fullDateRange = true;
968 } 968 }
969 } 969 }
970 if ( mSyncKDE ) { 970 if ( mSyncManager->syncWithDesktop() ) {
971 fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); 971 fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync );
972 } 972 }
973 if ( fullDateRange ) 973 if ( fullDateRange )
974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
975 else 975 else
976 mLastCalendarSync = eventLSync->dtStart(); 976 mLastCalendarSync = eventLSync->dtStart();
977 // for resyncing if own file has changed 977 // for resyncing if own file has changed
978 if ( mCurrentSyncDevice == "deleteaftersync" ) { 978 if ( mCurrentSyncDevice == "deleteaftersync" ) {
979 mLastCalendarSync = loadedFileVersion; 979 mLastCalendarSync = loadedFileVersion;
980 //qDebug("setting mLastCalendarSync "); 980 //qDebug("setting mLastCalendarSync ");
981 } 981 }
982 //qDebug("*************************** "); 982 //qDebug("*************************** ");
983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
984 QPtrList<Incidence> er = remote->rawIncidences(); 984 QPtrList<Incidence> er = remote->rawIncidences();
985 Incidence* inR = er.first(); 985 Incidence* inR = er.first();
986 Incidence* inL; 986 Incidence* inL;
987 QProgressBar bar( er.count(),0 ); 987 QProgressBar bar( er.count(),0 );
988 bar.setCaption (i18n("Syncing - close to abort!") ); 988 bar.setCaption (i18n("Syncing - close to abort!") );
989 989
990 int w = 300; 990 int w = 300;
991 if ( QApplication::desktop()->width() < 320 ) 991 if ( QApplication::desktop()->width() < 320 )
992 w = 220; 992 w = 220;
993 int h = bar.sizeHint().height() ; 993 int h = bar.sizeHint().height() ;
994 int dw = QApplication::desktop()->width(); 994 int dw = QApplication::desktop()->width();
995 int dh = QApplication::desktop()->height(); 995 int dh = QApplication::desktop()->height();
996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
997 bar.show(); 997 bar.show();
998 int modulo = (er.count()/10)+1; 998 int modulo = (er.count()/10)+1;
999 int incCounter = 0; 999 int incCounter = 0;
1000 while ( inR ) { 1000 while ( inR ) {
1001 if ( ! bar.isVisible() ) 1001 if ( ! bar.isVisible() )
1002 return false; 1002 return false;
1003 if ( incCounter % modulo == 0 ) 1003 if ( incCounter % modulo == 0 )
1004 bar.setProgress( incCounter ); 1004 bar.setProgress( incCounter );
1005 ++incCounter; 1005 ++incCounter;
1006 uid = inR->uid(); 1006 uid = inR->uid();
1007 bool skipIncidence = false; 1007 bool skipIncidence = false;
1008 if ( uid.left(15) == QString("last-syncEvent-") ) 1008 if ( uid.left(15) == QString("last-syncEvent-") )
1009 skipIncidence = true; 1009 skipIncidence = true;
1010 QString idS; 1010 QString idS;
1011 qApp->processEvents(); 1011 qApp->processEvents();
1012 if ( !skipIncidence ) { 1012 if ( !skipIncidence ) {
1013 inL = local->incidence( uid ); 1013 inL = local->incidence( uid );
1014 if ( inL ) { // maybe conflict - same uid in both calendars 1014 if ( inL ) { // maybe conflict - same uid in both calendars
1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1016 //qDebug("take %d %s ", take, inL->summary().latin1()); 1016 //qDebug("take %d %s ", take, inL->summary().latin1());
1017 if ( take == 3 ) 1017 if ( take == 3 )
1018 return false; 1018 return false;
1019 if ( take == 1 ) {// take local 1019 if ( take == 1 ) {// take local
1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 else 1022 else
1023 idS = inR->IDStr(); 1023 idS = inR->IDStr();
1024 remote->deleteIncidence( inR ); 1024 remote->deleteIncidence( inR );
1025 inR = inL->clone(); 1025 inR = inL->clone();
1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1028 inR->setIDStr( idS ); 1028 inR->setIDStr( idS );
1029 remote->addIncidence( inR ); 1029 remote->addIncidence( inR );
1030 if ( mSyncKDE ) 1030 if ( mSyncManager->syncWithDesktop() )
1031 inR->setPilotId( 2 ); 1031 inR->setPilotId( 2 );
1032 ++changedRemote; 1032 ++changedRemote;
1033 } else { 1033 } else {
1034 idS = inL->IDStr(); 1034 idS = inL->IDStr();
1035 int pid = inL->pilotId(); 1035 int pid = inL->pilotId();
1036 local->deleteIncidence( inL ); 1036 local->deleteIncidence( inL );
1037 inL = inR->clone(); 1037 inL = inR->clone();
1038 if ( mSyncKDE ) 1038 if ( mSyncManager->syncWithDesktop() )
1039 inL->setPilotId( pid ); 1039 inL->setPilotId( pid );
1040 inL->setIDStr( idS ); 1040 inL->setIDStr( idS );
1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1044 } 1044 }
1045 local->addIncidence( inL ); 1045 local->addIncidence( inL );
1046 ++changedLocal; 1046 ++changedLocal;
1047 } 1047 }
1048 } 1048 }
1049 } else { // no conflict 1049 } else { // no conflict
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1051 QString des = eventLSync->description(); 1051 QString des = eventLSync->description();
1052 QString pref = "e"; 1052 QString pref = "e";
1053 if ( inR->type() == "Todo" ) 1053 if ( inR->type() == "Todo" )
1054 pref = "t"; 1054 pref = "t";
1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1057 //remote->deleteIncidence( inR ); 1057 //remote->deleteIncidence( inR );
1058 ++deletedEventR; 1058 ++deletedEventR;
1059 } else { 1059 } else {
1060 inR->setLastModified( modifiedCalendar ); 1060 inR->setLastModified( modifiedCalendar );
1061 inL = inR->clone(); 1061 inL = inR->clone();
1062 inL->setIDStr( ":" ); 1062 inL->setIDStr( ":" );
1063 local->addIncidence( inL ); 1063 local->addIncidence( inL );
1064 ++addedEvent; 1064 ++addedEvent;
1065 } 1065 }
1066 } else { 1066 } else {
1067 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1067 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1068 inR->setLastModified( modifiedCalendar ); 1068 inR->setLastModified( modifiedCalendar );
1069 inL = inR->clone(); 1069 inL = inR->clone();
1070 inL->setIDStr( ":" ); 1070 inL->setIDStr( ":" );
1071 local->addIncidence( inL ); 1071 local->addIncidence( inL );
1072 ++addedEvent; 1072 ++addedEvent;
1073 } else { 1073 } else {
1074 checkExternSyncEvent(eventRSyncSharp, inR); 1074 checkExternSyncEvent(eventRSyncSharp, inR);
1075 remote->deleteIncidence( inR ); 1075 remote->deleteIncidence( inR );
1076 ++deletedEventR; 1076 ++deletedEventR;
1077 } 1077 }
1078 } 1078 }
1079 } 1079 }
1080 } 1080 }
1081 inR = er.next(); 1081 inR = er.next();
1082 } 1082 }
1083 QPtrList<Incidence> el = local->rawIncidences(); 1083 QPtrList<Incidence> el = local->rawIncidences();
1084 inL = el.first(); 1084 inL = el.first();
1085 modulo = (el.count()/10)+1; 1085 modulo = (el.count()/10)+1;
1086 bar.setCaption (i18n("Add / remove events") ); 1086 bar.setCaption (i18n("Add / remove events") );
@@ -1138,97 +1138,97 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1138 } 1138 }
1139 } 1139 }
1140 } 1140 }
1141 } 1141 }
1142 inL = el.next(); 1142 inL = el.next();
1143 } 1143 }
1144 int delFut = 0; 1144 int delFut = 0;
1145 int remRem = 0; 1145 int remRem = 0;
1146 if ( mSyncManager->mWriteBackInFuture ) { 1146 if ( mSyncManager->mWriteBackInFuture ) {
1147 er = remote->rawIncidences(); 1147 er = remote->rawIncidences();
1148 remRem = er.count(); 1148 remRem = er.count();
1149 inR = er.first(); 1149 inR = er.first();
1150 QDateTime dt; 1150 QDateTime dt;
1151 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1151 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1152 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1152 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1153 while ( inR ) { 1153 while ( inR ) {
1154 if ( inR->type() == "Todo" ) { 1154 if ( inR->type() == "Todo" ) {
1155 Todo * t = (Todo*)inR; 1155 Todo * t = (Todo*)inR;
1156 if ( t->hasDueDate() ) 1156 if ( t->hasDueDate() )
1157 dt = t->dtDue(); 1157 dt = t->dtDue();
1158 else 1158 else
1159 dt = cur.addSecs( 62 ); 1159 dt = cur.addSecs( 62 );
1160 } 1160 }
1161 else if (inR->type() == "Event" ) { 1161 else if (inR->type() == "Event" ) {
1162 bool ok; 1162 bool ok;
1163 dt = inR->getNextOccurence( cur, &ok ); 1163 dt = inR->getNextOccurence( cur, &ok );
1164 if ( !ok ) 1164 if ( !ok )
1165 dt = cur.addSecs( -62 ); 1165 dt = cur.addSecs( -62 );
1166 } 1166 }
1167 else 1167 else
1168 dt = inR->dtStart(); 1168 dt = inR->dtStart();
1169 if ( dt < cur || dt > end ) { 1169 if ( dt < cur || dt > end ) {
1170 remote->deleteIncidence( inR ); 1170 remote->deleteIncidence( inR );
1171 ++delFut; 1171 ++delFut;
1172 } 1172 }
1173 inR = er.next(); 1173 inR = er.next();
1174 } 1174 }
1175 } 1175 }
1176 bar.hide(); 1176 bar.hide();
1177 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1177 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1178 eventLSync->setReadOnly( false ); 1178 eventLSync->setReadOnly( false );
1179 eventLSync->setDtStart( mLastCalendarSync ); 1179 eventLSync->setDtStart( mLastCalendarSync );
1180 eventRSync->setDtStart( mLastCalendarSync ); 1180 eventRSync->setDtStart( mLastCalendarSync );
1181 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1181 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1182 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1182 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1183 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1183 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1184 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1184 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1185 eventLSync->setReadOnly( true ); 1185 eventLSync->setReadOnly( true );
1186 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... 1186 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1187 remote->addEvent( eventRSync ); 1187 remote->addEvent( eventRSync );
1188 else 1188 else
1189 delete eventRSync; 1189 delete eventRSync;
1190 QString mes; 1190 QString mes;
1191 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1191 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1192 QString delmess; 1192 QString delmess;
1193 if ( delFut ) { 1193 if ( delFut ) {
1194 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1194 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
1195 mes += delmess; 1195 mes += delmess;
1196 } 1196 }
1197 if ( mSyncManager->mShowSyncSummary ) { 1197 if ( mSyncManager->mShowSyncSummary ) {
1198 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1198 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1199 } 1199 }
1200 qDebug( mes ); 1200 qDebug( mes );
1201 mCalendar->checkAlarmForIncidence( 0, true ); 1201 mCalendar->checkAlarmForIncidence( 0, true );
1202 return syncOK; 1202 return syncOK;
1203} 1203}
1204 1204
1205void CalendarView::setSyncDevice( QString s ) 1205void CalendarView::setSyncDevice( QString s )
1206{ 1206{
1207 mCurrentSyncDevice= s; 1207 mCurrentSyncDevice= s;
1208} 1208}
1209void CalendarView::setSyncName( QString s ) 1209void CalendarView::setSyncName( QString s )
1210{ 1210{
1211 mCurrentSyncName= s; 1211 mCurrentSyncName= s;
1212} 1212}
1213bool CalendarView::syncCalendar(QString filename, int mode) 1213bool CalendarView::syncCalendar(QString filename, int mode)
1214{ 1214{
1215 //qDebug("syncCalendar %s ", filename.latin1()); 1215 //qDebug("syncCalendar %s ", filename.latin1());
1216 mGlobalSyncMode = SYNC_MODE_NORMAL; 1216 mGlobalSyncMode = SYNC_MODE_NORMAL;
1217 CalendarLocal* calendar = new CalendarLocal(); 1217 CalendarLocal* calendar = new CalendarLocal();
1218 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1218 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1219 FileStorage* storage = new FileStorage( calendar ); 1219 FileStorage* storage = new FileStorage( calendar );
1220 bool syncOK = false; 1220 bool syncOK = false;
1221 storage->setFileName( filename ); 1221 storage->setFileName( filename );
1222 // qDebug("loading ... "); 1222 // qDebug("loading ... ");
1223 if ( storage->load() ) { 1223 if ( storage->load() ) {
1224 getEventViewerDialog()->setSyncMode( true ); 1224 getEventViewerDialog()->setSyncMode( true );
1225 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1225 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1226 getEventViewerDialog()->setSyncMode( false ); 1226 getEventViewerDialog()->setSyncMode( false );
1227 if ( syncOK ) { 1227 if ( syncOK ) {
1228 if ( mSyncManager->mWriteBackFile ) 1228 if ( mSyncManager->mWriteBackFile )
1229 { 1229 {
1230 storage->setSaveFormat( new ICalFormat() ); 1230 storage->setSaveFormat( new ICalFormat() );
1231 storage->save(); 1231 storage->save();
1232 } 1232 }
1233 } 1233 }
1234 setModified( true ); 1234 setModified( true );
@@ -3700,81 +3700,78 @@ void CalendarView::purgeCompleted()
3700{ 3700{
3701 int result = KMessageBox::warningContinueCancel(this, 3701 int result = KMessageBox::warningContinueCancel(this,
3702 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3702 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3703 3703
3704 if (result == KMessageBox::Continue) { 3704 if (result == KMessageBox::Continue) {
3705 3705
3706 QPtrList<Todo> todoCal; 3706 QPtrList<Todo> todoCal;
3707 QPtrList<Todo> rootTodos; 3707 QPtrList<Todo> rootTodos;
3708 //QPtrList<Incidence> rel; 3708 //QPtrList<Incidence> rel;
3709 Todo *aTodo;//, *rTodo; 3709 Todo *aTodo;//, *rTodo;
3710 Incidence *rIncidence; 3710 Incidence *rIncidence;
3711 bool childDelete = false; 3711 bool childDelete = false;
3712 bool deletedOne = true; 3712 bool deletedOne = true;
3713 todoCal = calendar()->todos(); 3713 todoCal = calendar()->todos();
3714 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3714 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3715 if ( !aTodo->relatedTo() ) 3715 if ( !aTodo->relatedTo() )
3716 rootTodos.append( aTodo ); 3716 rootTodos.append( aTodo );
3717 } 3717 }
3718 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3718 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3719 removeCompletedSubTodos( aTodo ); 3719 removeCompletedSubTodos( aTodo );
3720 } 3720 }
3721 3721
3722 updateView(); 3722 updateView();
3723 } 3723 }
3724} 3724}
3725 3725
3726void CalendarView::slotCalendarChanged() 3726void CalendarView::slotCalendarChanged()
3727{ 3727{
3728 ; 3728 ;
3729} 3729}
3730 3730
3731NavigatorBar *CalendarView::navigatorBar() 3731NavigatorBar *CalendarView::navigatorBar()
3732{ 3732{
3733 return mNavigatorBar; 3733 return mNavigatorBar;
3734} 3734}
3735 3735
3736 3736
3737 3737
3738void CalendarView::keyPressEvent ( QKeyEvent *e) 3738void CalendarView::keyPressEvent ( QKeyEvent *e)
3739{ 3739{
3740 //qDebug(" alendarView::keyPressEvent "); 3740 //qDebug(" alendarView::keyPressEvent ");
3741 e->ignore(); 3741 e->ignore();
3742} 3742}
3743 3743
3744 3744
3745bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3745bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3746{ 3746{
3747 // mSyncManager = manager; 3747 // mSyncManager = manager;
3748 mSyncKDE = false;
3749 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3748 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3750 qDebug("SyncKDE request detected!"); 3749 qDebug("SyncKDE request detected!");
3751 mSyncKDE = true;
3752 } 3750 }
3753 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3751 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3754 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3752 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3755 return syncCalendar( filename, mode ); 3753 return syncCalendar( filename, mode );
3756} 3754}
3757bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3755bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3758{ 3756{
3759 mSyncKDE = false;
3760 //mSyncManager = manager; 3757 //mSyncManager = manager;
3761 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3758 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3762 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3759 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3763 if ( resource == "sharp" ) 3760 if ( resource == "sharp" )
3764 syncExternal( 0 ); 3761 syncExternal( 0 );
3765 if ( resource == "phone" ) 3762 if ( resource == "phone" )
3766 syncExternal( 1 ); 3763 syncExternal( 1 );
3767 // pending setmodified 3764 // pending setmodified
3768 return true; 3765 return true;
3769} 3766}
3770void CalendarView::setSyncManager(KSyncManager* manager) 3767void CalendarView::setSyncManager(KSyncManager* manager)
3771{ 3768{
3772 mSyncManager = manager; 3769 mSyncManager = manager;
3773} 3770}
3774 3771
3775void CalendarView::removeSyncInfo( QString syncProfile) 3772void CalendarView::removeSyncInfo( QString syncProfile)
3776{ 3773{
3777 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 3774 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
3778 mCalendar->removeSyncInfo( syncProfile ); 3775 mCalendar->removeSyncInfo( syncProfile );
3779 3776
3780} 3777}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index acc20d6..437a51c 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -444,97 +444,96 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
444 void beamIncidence(Incidence *) ; 444 void beamIncidence(Incidence *) ;
445 void beamCalendar() ; 445 void beamCalendar() ;
446 void beamFilteredCalendar() ; 446 void beamFilteredCalendar() ;
447 void beamIncidenceList(QPtrList<Incidence>) ; 447 void beamIncidenceList(QPtrList<Incidence>) ;
448 void manageCategories(); 448 void manageCategories();
449 int addCategories(); 449 int addCategories();
450 void removeCategories(); 450 void removeCategories();
451 void setSyncDevice( QString ); 451 void setSyncDevice( QString );
452 void setSyncName( QString ); 452 void setSyncName( QString );
453 protected slots: 453 protected slots:
454 void timerAlarm(); 454 void timerAlarm();
455 void suspendAlarm(); 455 void suspendAlarm();
456 void beamDone( Ir *ir ); 456 void beamDone( Ir *ir );
457 /** Select a view or adapt the current view to display the specified dates. */ 457 /** Select a view or adapt the current view to display the specified dates. */
458 void showDates( const KCal::DateList & ); 458 void showDates( const KCal::DateList & );
459 void selectWeekNum ( int ); 459 void selectWeekNum ( int );
460 460
461 public: 461 public:
462 // show a standard warning 462 // show a standard warning
463 // returns KMsgBox::yesNoCancel() 463 // returns KMsgBox::yesNoCancel()
464 int msgCalModified(); 464 int msgCalModified();
465 virtual bool sync(KSyncManager* manager, QString filename, int mode); 465 virtual bool sync(KSyncManager* manager, QString filename, int mode);
466 466
467 virtual bool syncExternal(KSyncManager* manager, QString resource); 467 virtual bool syncExternal(KSyncManager* manager, QString resource);
468 virtual void removeSyncInfo( QString syncProfile); 468 virtual void removeSyncInfo( QString syncProfile);
469 void setSyncManager(KSyncManager* manager); 469 void setSyncManager(KSyncManager* manager);
470 void setLoadedFileVersion(QDateTime); 470 void setLoadedFileVersion(QDateTime);
471 bool checkFileVersion(QString fn); 471 bool checkFileVersion(QString fn);
472 bool checkFileChanged(QString fn); 472 bool checkFileChanged(QString fn);
473 Event* getLastSyncEvent(); 473 Event* getLastSyncEvent();
474 /** Adapt navigation units correpsonding to step size of navigation of the 474 /** Adapt navigation units correpsonding to step size of navigation of the
475 * current view. 475 * current view.
476 */ 476 */
477 void adaptNavigationUnits(); 477 void adaptNavigationUnits();
478 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 478 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
479 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 479 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
480 //Attendee* getYourAttendee(Event *event); 480 //Attendee* getYourAttendee(Event *event);
481 protected: 481 protected:
482 void schedule(Scheduler::Method, Incidence *incidence = 0); 482 void schedule(Scheduler::Method, Incidence *incidence = 0);
483 483
484 // returns KMsgBox::OKCandel() 484 // returns KMsgBox::OKCandel()
485 int msgItemDelete(); 485 int msgItemDelete();
486 void showEventEditor(); 486 void showEventEditor();
487 void showTodoEditor(); 487 void showTodoEditor();
488 void writeLocale(); 488 void writeLocale();
489 Todo *selectedTodo(); 489 Todo *selectedTodo();
490 490
491 private: 491 private:
492 bool mSyncKDE;
493 KSyncManager* mSyncManager; 492 KSyncManager* mSyncManager;
494 AlarmDialog * mAlarmDialog; 493 AlarmDialog * mAlarmDialog;
495 QString mAlarmNotification; 494 QString mAlarmNotification;
496 QString mSuspendAlarmNotification; 495 QString mSuspendAlarmNotification;
497 QTimer* mSuspendTimer; 496 QTimer* mSuspendTimer;
498 QTimer* mAlarmTimer; 497 QTimer* mAlarmTimer;
499 QTimer* mRecheckAlarmTimer; 498 QTimer* mRecheckAlarmTimer;
500 void computeAlarm( QString ); 499 void computeAlarm( QString );
501 void startAlarm( QString, QString ); 500 void startAlarm( QString, QString );
502 void setSyncEventsReadOnly(); 501 void setSyncEventsReadOnly();
503 502
504 QDateTime loadedFileVersion; 503 QDateTime loadedFileVersion;
505 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 504 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
506 void checkExternalId( Incidence * inc ); 505 void checkExternalId( Incidence * inc );
507 int mGlobalSyncMode; 506 int mGlobalSyncMode;
508 QString mCurrentSyncDevice; 507 QString mCurrentSyncDevice;
509 QString mCurrentSyncName; 508 QString mCurrentSyncName;
510 KOBeamPrefs* beamDialog; 509 KOBeamPrefs* beamDialog;
511 void init(); 510 void init();
512 int mDatePickerMode; 511 int mDatePickerMode;
513 bool mFlagEditDescription; 512 bool mFlagEditDescription;
514 QDateTime mLastCalendarSync; 513 QDateTime mLastCalendarSync;
515 void createPrinter(); 514 void createPrinter();
516 515
517 void calendarModified( bool, Calendar * ); 516 void calendarModified( bool, Calendar * );
518 517
519 CalPrinter *mCalPrinter; 518 CalPrinter *mCalPrinter;
520 519
521 QSplitter *mPanner; 520 QSplitter *mPanner;
522 QSplitter *mLeftSplitter; 521 QSplitter *mLeftSplitter;
523 QWidget *mLeftFrame; 522 QWidget *mLeftFrame;
524 QWidgetStack *mRightFrame; 523 QWidgetStack *mRightFrame;
525 524
526 KDatePicker* mDatePicker; 525 KDatePicker* mDatePicker;
527 QVBox* mDateFrame; 526 QVBox* mDateFrame;
528 NavigatorBar *mNavigatorBar; 527 NavigatorBar *mNavigatorBar;
529 528
530 KDateNavigator *mDateNavigator; // widget showing small month view. 529 KDateNavigator *mDateNavigator; // widget showing small month view.
531 530
532 KOFilterView *mFilterView; 531 KOFilterView *mFilterView;
533 532
534 ResourceView *mResourceView; 533 ResourceView *mResourceView;
535 534
536 // calendar object for this viewing instance 535 // calendar object for this viewing instance
537 Calendar *mCalendar; 536 Calendar *mCalendar;
538 537
539 CalendarResourceManager *mResourceManager; 538 CalendarResourceManager *mResourceManager;
540 539