-rw-r--r-- | korganizer/calendarview.cpp | 9 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 18 |
2 files changed, 21 insertions, 6 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 5a6d615..369c7a0 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -708,58 +708,57 @@ void CalendarView::confSync() | |||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
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 ) | 732 | //if ( remCh ) |
733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | ||
736 | if ( !remCh && ! locCh ) { | 735 | if ( !remCh && ! locCh ) { |
737 | //qDebug("both not changed "); | 736 | //qDebug("both not changed "); |
738 | lastSync = local->lastModified().addDays(1); | 737 | lastSync = local->lastModified().addDays(1); |
739 | } else { | 738 | } else { |
740 | if ( locCh ) { | 739 | if ( locCh ) { |
741 | // qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 740 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); |
742 | lastSync = local->lastModified().addDays( -1 ); | 741 | lastSync = local->lastModified().addDays( -1 ); |
743 | if ( !remCh ) | 742 | if ( !remCh ) |
744 | remote->setLastModified( lastSync.addDays( -1 ) ); | 743 | remote->setLastModified( lastSync.addDays( -1 ) ); |
745 | } else { | 744 | } else { |
746 | //qDebug(" not loc changed "); | 745 | //qDebug(" not loc changed "); |
747 | lastSync = local->lastModified().addDays( 1 ); | 746 | lastSync = local->lastModified().addDays( 1 ); |
748 | if ( remCh ) | 747 | if ( remCh ) |
749 | remote->setLastModified( lastSync.addDays( 1 ) ); | 748 | remote->setLastModified( lastSync.addDays( 1 ) ); |
750 | 749 | ||
751 | } | 750 | } |
752 | } | 751 | } |
753 | full = true; | 752 | full = true; |
754 | if ( mode < SYNC_PREF_ASK ) | 753 | if ( mode < SYNC_PREF_ASK ) |
755 | mode = SYNC_PREF_ASK; | 754 | mode = SYNC_PREF_ASK; |
756 | } else { | 755 | } else { |
757 | if ( local->lastModified() == remote->lastModified() ) | 756 | if ( local->lastModified() == remote->lastModified() ) |
758 | if ( local->revision() == remote->revision() ) | 757 | if ( local->revision() == remote->revision() ) |
759 | return 0; | 758 | return 0; |
760 | 759 | ||
761 | } | 760 | } |
762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 761 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
763 | 762 | ||
764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 763 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 764 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
@@ -1094,49 +1093,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1094 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1095 | if ( ! bar.isVisible() ) | 1094 | if ( ! bar.isVisible() ) |
1096 | return false; | 1095 | return false; |
1097 | if ( incCounter % modulo == 0 ) | 1096 | if ( incCounter % modulo == 0 ) |
1098 | bar.setProgress( incCounter ); | 1097 | bar.setProgress( incCounter ); |
1099 | ++incCounter; | 1098 | ++incCounter; |
1100 | uid = inL->uid(); | 1099 | uid = inL->uid(); |
1101 | bool skipIncidence = false; | 1100 | bool skipIncidence = false; |
1102 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1101 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1103 | skipIncidence = true; | 1102 | skipIncidence = true; |
1104 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1105 | skipIncidence = true; | 1104 | skipIncidence = true; |
1106 | if ( !skipIncidence ) { | 1105 | if ( !skipIncidence ) { |
1107 | inR = remote->incidence( uid ); | 1106 | inR = remote->incidence( uid ); |
1108 | if ( ! inR ) { | 1107 | if ( ! inR ) { |
1109 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1110 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1111 | checkExternSyncEvent(eventLSyncSharp, inL); | 1110 | checkExternSyncEvent(eventLSyncSharp, inL); |
1112 | local->deleteIncidence( inL ); | 1111 | local->deleteIncidence( inL ); |
1113 | ++deletedEventL; | 1112 | ++deletedEventL; |
1114 | } else { | 1113 | } else { |
1115 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1114 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1116 | inL->removeID(mCurrentSyncDevice ); | 1115 | inL->removeID(mCurrentSyncDevice ); |
1117 | ++addedEventR; | 1116 | ++addedEventR; |
1118 | qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1119 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1120 | inR = inL->clone(); | 1119 | inR = inL->clone(); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1120 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1121 | remote->addIncidence( inR ); |
1123 | } | 1122 | } |
1124 | } | 1123 | } |
1125 | } else { | 1124 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1125 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1126 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1127 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1128 | ++deletedEventL; |
1130 | } else { | 1129 | } else { |
1131 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1130 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1131 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1132 | inL->setLastModified( modifiedCalendar ); |
1134 | remote->addIncidence( inL->clone() ); | 1133 | remote->addIncidence( inL->clone() ); |
1135 | } | 1134 | } |
1136 | } | 1135 | } |
1137 | } | 1136 | } |
1138 | } | 1137 | } |
1139 | } | 1138 | } |
1140 | inL = el.next(); | 1139 | inL = el.next(); |
1141 | } | 1140 | } |
1142 | int delFut = 0; | 1141 | int delFut = 0; |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index a53b3f8..e7fc670 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -460,48 +460,51 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | |||
460 | break; | 460 | break; |
461 | } | 461 | } |
462 | if ( ok ) | 462 | if ( ok ) |
463 | tempString = getPart( answer, ok, start ); | 463 | tempString = getPart( answer, ok, start ); |
464 | if ( start >= len || start == 0 ) { | 464 | if ( start >= len || start == 0 ) { |
465 | start = 0; | 465 | start = 0; |
466 | ok = false; | 466 | ok = false; |
467 | } | 467 | } |
468 | if ( tempString.right(1) =="\n" ) | 468 | if ( tempString.right(1) =="\n" ) |
469 | tempString = tempString.left( tempString.length()-1); | 469 | tempString = tempString.left( tempString.length()-1); |
470 | 470 | ||
471 | templist.append( tempString ); | 471 | templist.append( tempString ); |
472 | } | 472 | } |
473 | ++ccc; | 473 | ++ccc; |
474 | if ( ccc == 2 && loopCount < 25 ) { | 474 | if ( ccc == 2 && loopCount < 25 ) { |
475 | start = 0; | 475 | start = 0; |
476 | bool ok; | 476 | bool ok; |
477 | int newnum = templist[0].toInt( &ok ); | 477 | int newnum = templist[0].toInt( &ok ); |
478 | if ( ok && newnum > 0) { | 478 | if ( ok && newnum > 0) { |
479 | retval = newnum; | 479 | retval = newnum; |
480 | inc->setID( "Sharp_DTM",templist[0] ); | 480 | inc->setID( "Sharp_DTM",templist[0] ); |
481 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); | 481 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); |
482 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 482 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
483 | } | 483 | } |
484 | if ( ok && newnum == -1 ) { | ||
485 | qDebug("Error writing back %s ", inc->summary().latin1()); | ||
486 | } | ||
484 | } | 487 | } |
485 | } | 488 | } |
486 | //qDebug("getNumFromRecord returning : %d ", retval); | 489 | //qDebug("getNumFromRecord returning : %d ", retval); |
487 | return retval; | 490 | return retval; |
488 | } | 491 | } |
489 | bool SharpFormat::save( Calendar *calendar) | 492 | bool SharpFormat::save( Calendar *calendar) |
490 | { | 493 | { |
491 | 494 | ||
492 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 495 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
493 | int w = status.sizeHint().width()+20 ; | 496 | int w = status.sizeHint().width()+20 ; |
494 | if ( w < 200 ) w = 200; | 497 | if ( w < 200 ) w = 200; |
495 | int h = status.sizeHint().height()+20 ; | 498 | int h = status.sizeHint().height()+20 ; |
496 | int dw = QApplication::desktop()->width(); | 499 | int dw = QApplication::desktop()->width(); |
497 | int dh = QApplication::desktop()->height(); | 500 | int dh = QApplication::desktop()->height(); |
498 | status.setCaption(i18n("Writing DTM Data") ); | 501 | status.setCaption(i18n("Writing DTM Data") ); |
499 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 502 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
500 | status.show(); | 503 | status.show(); |
501 | status.raise(); | 504 | status.raise(); |
502 | qApp->processEvents(); | 505 | qApp->processEvents(); |
503 | bool debug = DEBUGMODE; | 506 | bool debug = DEBUGMODE; |
504 | QString codec = "utf8"; | 507 | QString codec = "utf8"; |
505 | QString answer; | 508 | QString answer; |
506 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 509 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
507 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 510 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
@@ -511,49 +514,62 @@ bool SharpFormat::save( Calendar *calendar) | |||
511 | QString fileName = "/tmp/kopitempout"; | 514 | QString fileName = "/tmp/kopitempout"; |
512 | int i = 0; | 515 | int i = 0; |
513 | QString changeString = ePrefix; | 516 | QString changeString = ePrefix; |
514 | QString deleteString = ePrefix; | 517 | QString deleteString = ePrefix; |
515 | bool deleteEnt = false; | 518 | bool deleteEnt = false; |
516 | bool changeEnt = false; | 519 | bool changeEnt = false; |
517 | QString message = i18n("Processing event # "); | 520 | QString message = i18n("Processing event # "); |
518 | int procCount = 0; | 521 | int procCount = 0; |
519 | while ( ev ) { | 522 | while ( ev ) { |
520 | //qDebug("i %d ", ++i); | 523 | //qDebug("i %d ", ++i); |
521 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 524 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
522 | status.setText ( message + QString::number ( ++procCount ) ); | 525 | status.setText ( message + QString::number ( ++procCount ) ); |
523 | qApp->processEvents(); | 526 | qApp->processEvents(); |
524 | QString eString = getEventString( ev ); | 527 | QString eString = getEventString( ev ); |
525 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 528 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
526 | // deleting empty strings does not work. | 529 | // deleting empty strings does not work. |
527 | // we write first and x and then delete the record with the x | 530 | // we write first and x and then delete the record with the x |
528 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 531 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
529 | changeString += eString + "\n"; | 532 | changeString += eString + "\n"; |
530 | deleteString += eString + "\n"; | 533 | deleteString += eString + "\n"; |
531 | deleteEnt = true; | 534 | deleteEnt = true; |
532 | changeEnt = true; | 535 | changeEnt = true; |
533 | } | 536 | } |
534 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new | 537 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new |
535 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 538 | QString fileNameIn = "/tmp/kopitempin"; |
539 | QFile fileIn( fileNameIn ); | ||
540 | if (!fileIn.open( IO_WriteOnly ) ) { | ||
541 | return false; | ||
542 | } | ||
543 | QTextStream tsIn( &fileIn ); | ||
544 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | ||
545 | tsIn << ePrefix << eString ; | ||
546 | fileIn.close(); | ||
547 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | ||
548 | command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; | ||
549 | qDebug("command ++++++++ "); | ||
550 | qDebug("%s ",command.latin1()); | ||
551 | qDebug("command -------- "); | ||
536 | system ( command.utf8() ); | 552 | system ( command.utf8() ); |
537 | QFile file( fileName ); | 553 | QFile file( fileName ); |
538 | if (!file.open( IO_ReadOnly ) ) { | 554 | if (!file.open( IO_ReadOnly ) ) { |
539 | return false; | 555 | return false; |
540 | 556 | ||
541 | } | 557 | } |
542 | QTextStream ts( &file ); | 558 | QTextStream ts( &file ); |
543 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 559 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
544 | answer = ts.read(); | 560 | answer = ts.read(); |
545 | file.close(); | 561 | file.close(); |
546 | //qDebug("answer \n%s ", answer.latin1()); | 562 | //qDebug("answer \n%s ", answer.latin1()); |
547 | getNumFromRecord( answer, ev ) ; | 563 | getNumFromRecord( answer, ev ) ; |
548 | 564 | ||
549 | } | 565 | } |
550 | else { // change existing | 566 | else { // change existing |
551 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | 567 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); |
552 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 568 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
553 | changeString += eString + "\n"; | 569 | changeString += eString + "\n"; |
554 | changeEnt = true; | 570 | changeEnt = true; |
555 | 571 | ||
556 | } | 572 | } |
557 | } | 573 | } |
558 | ev = er.next(); | 574 | ev = er.next(); |
559 | } | 575 | } |