author | zautrix <zautrix> | 2004-09-14 02:04:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-14 02:04:12 (UTC) |
commit | 5060b0737c0c279859cac3bcfb73d2ac21c6a79e (patch) (unidiff) | |
tree | 8de6965559cb5bd6eba1eea5c635315d0945cfd1 | |
parent | 739fec31c8cea89dd40ff1ce7dd7b84b05e4e973 (diff) | |
download | kdepimpi-5060b0737c0c279859cac3bcfb73d2ac21c6a79e.zip kdepimpi-5060b0737c0c279859cac3bcfb73d2ac21c6a79e.tar.gz kdepimpi-5060b0737c0c279859cac3bcfb73d2ac21c6a79e.tar.bz2 |
debug off
-rw-r--r-- | korganizer/calendarview.cpp | 6 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ce41fbd..5a6d615 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -481,522 +481,522 @@ void CalendarView::timerAlarm() | |||
481 | computeAlarm(mAlarmNotification ); | 481 | computeAlarm(mAlarmNotification ); |
482 | } | 482 | } |
483 | 483 | ||
484 | void CalendarView::suspendAlarm() | 484 | void CalendarView::suspendAlarm() |
485 | { | 485 | { |
486 | //qDebug(" CalendarView::suspendAlarm() "); | 486 | //qDebug(" CalendarView::suspendAlarm() "); |
487 | computeAlarm(mSuspendAlarmNotification ); | 487 | computeAlarm(mSuspendAlarmNotification ); |
488 | 488 | ||
489 | } | 489 | } |
490 | 490 | ||
491 | void CalendarView::startAlarm( QString mess , QString filename) | 491 | void CalendarView::startAlarm( QString mess , QString filename) |
492 | { | 492 | { |
493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
495 | 495 | ||
496 | } | 496 | } |
497 | 497 | ||
498 | void CalendarView::checkNextTimerAlarm() | 498 | void CalendarView::checkNextTimerAlarm() |
499 | { | 499 | { |
500 | mCalendar->checkAlarmForIncidence( 0, true ); | 500 | mCalendar->checkAlarmForIncidence( 0, true ); |
501 | } | 501 | } |
502 | 502 | ||
503 | void CalendarView::computeAlarm( QString msg ) | 503 | void CalendarView::computeAlarm( QString msg ) |
504 | { | 504 | { |
505 | 505 | ||
506 | QString mess = msg; | 506 | QString mess = msg; |
507 | QString mAlarmMessage = mess.mid( 9 ); | 507 | QString mAlarmMessage = mess.mid( 9 ); |
508 | QString filename = MainWindow::resourcePath(); | 508 | QString filename = MainWindow::resourcePath(); |
509 | filename += "koalarm.wav"; | 509 | filename += "koalarm.wav"; |
510 | QString tempfilename; | 510 | QString tempfilename; |
511 | if ( mess.left( 13 ) == "suspend_alarm") { | 511 | if ( mess.left( 13 ) == "suspend_alarm") { |
512 | bool error = false; | 512 | bool error = false; |
513 | int len = mess.mid( 13 ).find("+++"); | 513 | int len = mess.mid( 13 ).find("+++"); |
514 | if ( len < 2 ) | 514 | if ( len < 2 ) |
515 | error = true; | 515 | error = true; |
516 | else { | 516 | else { |
517 | tempfilename = mess.mid( 13, len ); | 517 | tempfilename = mess.mid( 13, len ); |
518 | if ( !QFile::exists( tempfilename ) ) | 518 | if ( !QFile::exists( tempfilename ) ) |
519 | error = true; | 519 | error = true; |
520 | } | 520 | } |
521 | if ( ! error ) { | 521 | if ( ! error ) { |
522 | filename = tempfilename; | 522 | filename = tempfilename; |
523 | } | 523 | } |
524 | mAlarmMessage = mess.mid( 13+len+3 ); | 524 | mAlarmMessage = mess.mid( 13+len+3 ); |
525 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 525 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
526 | startAlarm( mAlarmMessage, filename); | 526 | startAlarm( mAlarmMessage, filename); |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | if ( mess.left( 11 ) == "timer_alarm") { | 529 | if ( mess.left( 11 ) == "timer_alarm") { |
530 | //mTimerTime = 0; | 530 | //mTimerTime = 0; |
531 | startAlarm( mess.mid( 11 ), filename ); | 531 | startAlarm( mess.mid( 11 ), filename ); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | if ( mess.left( 10 ) == "proc_alarm") { | 534 | if ( mess.left( 10 ) == "proc_alarm") { |
535 | bool error = false; | 535 | bool error = false; |
536 | int len = mess.mid( 10 ).find("+++"); | 536 | int len = mess.mid( 10 ).find("+++"); |
537 | if ( len < 2 ) | 537 | if ( len < 2 ) |
538 | error = true; | 538 | error = true; |
539 | else { | 539 | else { |
540 | tempfilename = mess.mid( 10, len ); | 540 | tempfilename = mess.mid( 10, len ); |
541 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
542 | error = true; | 542 | error = true; |
543 | } | 543 | } |
544 | if ( error ) { | 544 | if ( error ) { |
545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
546 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 546 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
547 | } else { | 547 | } else { |
548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
549 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 549 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
550 | #ifndef _WIN32_ | 550 | #ifndef _WIN32_ |
551 | if ( vfork () == 0 ) { | 551 | if ( vfork () == 0 ) { |
552 | execl ( tempfilename.latin1(), 0 ); | 552 | execl ( tempfilename.latin1(), 0 ); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | #else | 555 | #else |
556 | QProcess* p = new QProcess(); | 556 | QProcess* p = new QProcess(); |
557 | p->addArgument( tempfilename.latin1() ); | 557 | p->addArgument( tempfilename.latin1() ); |
558 | p->start(); | 558 | p->start(); |
559 | return; | 559 | return; |
560 | #endif | 560 | #endif |
561 | 561 | ||
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | 564 | ||
565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
566 | } | 566 | } |
567 | if ( mess.left( 11 ) == "audio_alarm") { | 567 | if ( mess.left( 11 ) == "audio_alarm") { |
568 | bool error = false; | 568 | bool error = false; |
569 | int len = mess.mid( 11 ).find("+++"); | 569 | int len = mess.mid( 11 ).find("+++"); |
570 | if ( len < 2 ) | 570 | if ( len < 2 ) |
571 | error = true; | 571 | error = true; |
572 | else { | 572 | else { |
573 | tempfilename = mess.mid( 11, len ); | 573 | tempfilename = mess.mid( 11, len ); |
574 | if ( !QFile::exists( tempfilename ) ) | 574 | if ( !QFile::exists( tempfilename ) ) |
575 | error = true; | 575 | error = true; |
576 | } | 576 | } |
577 | if ( ! error ) { | 577 | if ( ! error ) { |
578 | filename = tempfilename; | 578 | filename = tempfilename; |
579 | } | 579 | } |
580 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 580 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
581 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 581 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 9 ) == "cal_alarm") { | 583 | if ( mess.left( 9 ) == "cal_alarm") { |
584 | mAlarmMessage = mess.mid( 9 ) ; | 584 | mAlarmMessage = mess.mid( 9 ) ; |
585 | } | 585 | } |
586 | 586 | ||
587 | startAlarm( mAlarmMessage, filename ); | 587 | startAlarm( mAlarmMessage, filename ); |
588 | 588 | ||
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
593 | { | 593 | { |
594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
595 | 595 | ||
596 | mSuspendAlarmNotification = noti; | 596 | mSuspendAlarmNotification = noti; |
597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
599 | mSuspendTimer->start( ms , true ); | 599 | mSuspendTimer->start( ms , true ); |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
604 | { | 604 | { |
605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
607 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
609 | #endif | 609 | #endif |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | int maxSec; | 612 | int maxSec; |
613 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
614 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
615 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
617 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
618 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
620 | return; | 620 | return; |
621 | } else { | 621 | } else { |
622 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
623 | } | 623 | } |
624 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
625 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
626 | 626 | ||
627 | } | 627 | } |
628 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
629 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
630 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
631 | { | 631 | { |
632 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
633 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
634 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
635 | } | 635 | } |
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
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() ); | 735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
736 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
737 | qDebug("both not changed "); | 737 | //qDebug("both not changed "); |
738 | lastSync = local->lastModified().addDays(1); | 738 | lastSync = local->lastModified().addDays(1); |
739 | } else { | 739 | } else { |
740 | if ( locCh ) { | 740 | if ( locCh ) { |
741 | qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 741 | // qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); |
742 | lastSync = local->lastModified().addDays( -1 ); | 742 | lastSync = local->lastModified().addDays( -1 ); |
743 | if ( !remCh ) | 743 | if ( !remCh ) |
744 | remote->setLastModified( lastSync.addDays( -1 ) ); | 744 | remote->setLastModified( lastSync.addDays( -1 ) ); |
745 | } else { | 745 | } else { |
746 | qDebug(" not loc changed "); | 746 | //qDebug(" not loc changed "); |
747 | lastSync = local->lastModified().addDays( 1 ); | 747 | lastSync = local->lastModified().addDays( 1 ); |
748 | if ( remCh ) | 748 | if ( remCh ) |
749 | remote->setLastModified( lastSync.addDays( 1 ) ); | 749 | remote->setLastModified( lastSync.addDays( 1 ) ); |
750 | 750 | ||
751 | } | 751 | } |
752 | } | 752 | } |
753 | full = true; | 753 | full = true; |
754 | if ( mode < SYNC_PREF_ASK ) | 754 | if ( mode < SYNC_PREF_ASK ) |
755 | mode = SYNC_PREF_ASK; | 755 | mode = SYNC_PREF_ASK; |
756 | } else { | 756 | } else { |
757 | if ( local->lastModified() == remote->lastModified() ) | 757 | if ( local->lastModified() == remote->lastModified() ) |
758 | if ( local->revision() == remote->revision() ) | 758 | if ( local->revision() == remote->revision() ) |
759 | return 0; | 759 | return 0; |
760 | 760 | ||
761 | } | 761 | } |
762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
763 | 763 | ||
764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 764 | //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() ); | 765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
766 | //full = true; //debug only | 766 | //full = true; //debug only |
767 | if ( full ) { | 767 | if ( full ) { |
768 | bool equ = false; | 768 | bool equ = false; |
769 | if ( local->type() == "Event" ) { | 769 | if ( local->type() == "Event" ) { |
770 | equ = (*((Event*) local) == *((Event*) remote)); | 770 | equ = (*((Event*) local) == *((Event*) remote)); |
771 | } | 771 | } |
772 | else if ( local->type() =="Todo" ) | 772 | else if ( local->type() =="Todo" ) |
773 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 773 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
774 | else if ( local->type() =="Journal" ) | 774 | else if ( local->type() =="Journal" ) |
775 | equ = (*((Journal*) local) == *((Journal*) remote)); | 775 | equ = (*((Journal*) local) == *((Journal*) remote)); |
776 | if ( equ ) { | 776 | if ( equ ) { |
777 | //qDebug("equal "); | 777 | //qDebug("equal "); |
778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
780 | } | 780 | } |
781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
782 | return 0; | 782 | return 0; |
783 | 783 | ||
784 | }//else //debug only | 784 | }//else //debug only |
785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
786 | } | 786 | } |
787 | int result; | 787 | int result; |
788 | bool localIsNew; | 788 | bool localIsNew; |
789 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 789 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
790 | 790 | ||
791 | if ( full && mode < SYNC_PREF_NEWEST ) | 791 | if ( full && mode < SYNC_PREF_NEWEST ) |
792 | mode = SYNC_PREF_ASK; | 792 | mode = SYNC_PREF_ASK; |
793 | 793 | ||
794 | switch( mode ) { | 794 | switch( mode ) { |
795 | case SYNC_PREF_LOCAL: | 795 | case SYNC_PREF_LOCAL: |
796 | if ( lastSync > remote->lastModified() ) | 796 | if ( lastSync > remote->lastModified() ) |
797 | return 1; | 797 | return 1; |
798 | if ( lastSync > local->lastModified() ) | 798 | if ( lastSync > local->lastModified() ) |
799 | return 2; | 799 | return 2; |
800 | return 1; | 800 | return 1; |
801 | break; | 801 | break; |
802 | case SYNC_PREF_REMOTE: | 802 | case SYNC_PREF_REMOTE: |
803 | if ( lastSync > remote->lastModified() ) | 803 | if ( lastSync > remote->lastModified() ) |
804 | return 1; | 804 | return 1; |
805 | if ( lastSync > local->lastModified() ) | 805 | if ( lastSync > local->lastModified() ) |
806 | return 2; | 806 | return 2; |
807 | return 2; | 807 | return 2; |
808 | break; | 808 | break; |
809 | case SYNC_PREF_NEWEST: | 809 | case SYNC_PREF_NEWEST: |
810 | if ( local->lastModified() > remote->lastModified() ) | 810 | if ( local->lastModified() > remote->lastModified() ) |
811 | return 1; | 811 | return 1; |
812 | else | 812 | else |
813 | return 2; | 813 | return 2; |
814 | break; | 814 | break; |
815 | case SYNC_PREF_ASK: | 815 | case SYNC_PREF_ASK: |
816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
817 | if ( lastSync > remote->lastModified() ) | 817 | if ( lastSync > remote->lastModified() ) |
818 | return 1; | 818 | return 1; |
819 | if ( lastSync > local->lastModified() ) | 819 | if ( lastSync > local->lastModified() ) |
820 | return 2; | 820 | return 2; |
821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
822 | localIsNew = local->lastModified() >= remote->lastModified(); | 822 | localIsNew = local->lastModified() >= remote->lastModified(); |
823 | if ( localIsNew ) | 823 | if ( localIsNew ) |
824 | getEventViewerDialog()->setColorMode( 1 ); | 824 | getEventViewerDialog()->setColorMode( 1 ); |
825 | else | 825 | else |
826 | getEventViewerDialog()->setColorMode( 2 ); | 826 | getEventViewerDialog()->setColorMode( 2 ); |
827 | getEventViewerDialog()->setIncidence(local); | 827 | getEventViewerDialog()->setIncidence(local); |
828 | if ( localIsNew ) | 828 | if ( localIsNew ) |
829 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
830 | else | 830 | else |
831 | getEventViewerDialog()->setColorMode( 1 ); | 831 | getEventViewerDialog()->setColorMode( 1 ); |
832 | getEventViewerDialog()->addIncidence(remote); | 832 | getEventViewerDialog()->addIncidence(remote); |
833 | getEventViewerDialog()->setColorMode( 0 ); | 833 | getEventViewerDialog()->setColorMode( 0 ); |
834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
836 | getEventViewerDialog()->showMe(); | 836 | getEventViewerDialog()->showMe(); |
837 | result = getEventViewerDialog()->executeS( localIsNew ); | 837 | result = getEventViewerDialog()->executeS( localIsNew ); |
838 | return result; | 838 | return result; |
839 | 839 | ||
840 | break; | 840 | break; |
841 | case SYNC_PREF_FORCE_LOCAL: | 841 | case SYNC_PREF_FORCE_LOCAL: |
842 | return 1; | 842 | return 1; |
843 | break; | 843 | break; |
844 | case SYNC_PREF_FORCE_REMOTE: | 844 | case SYNC_PREF_FORCE_REMOTE: |
845 | return 2; | 845 | return 2; |
846 | break; | 846 | break; |
847 | 847 | ||
848 | default: | 848 | default: |
849 | // SYNC_PREF_TAKE_BOTH not implemented | 849 | // SYNC_PREF_TAKE_BOTH not implemented |
850 | break; | 850 | break; |
851 | } | 851 | } |
852 | return 0; | 852 | return 0; |
853 | } | 853 | } |
854 | Event* CalendarView::getLastSyncEvent() | 854 | Event* CalendarView::getLastSyncEvent() |
855 | { | 855 | { |
856 | Event* lse; | 856 | Event* lse; |
857 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 857 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
858 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 858 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
859 | if (!lse) { | 859 | if (!lse) { |
860 | lse = new Event(); | 860 | lse = new Event(); |
861 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 861 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
862 | QString sum = ""; | 862 | QString sum = ""; |
863 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 863 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
864 | sum = "E: "; | 864 | sum = "E: "; |
865 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 865 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
866 | lse->setDtStart( mLastCalendarSync ); | 866 | lse->setDtStart( mLastCalendarSync ); |
867 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 867 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
868 | lse->setCategories( i18n("SyncEvent") ); | 868 | lse->setCategories( i18n("SyncEvent") ); |
869 | lse->setReadOnly( true ); | 869 | lse->setReadOnly( true ); |
870 | mCalendar->addEvent( lse ); | 870 | mCalendar->addEvent( lse ); |
871 | } | 871 | } |
872 | 872 | ||
873 | return lse; | 873 | return lse; |
874 | 874 | ||
875 | } | 875 | } |
876 | // probaly useless | 876 | // probaly useless |
877 | void CalendarView::setupExternSyncProfiles() | 877 | void CalendarView::setupExternSyncProfiles() |
878 | { | 878 | { |
879 | Event* lse; | 879 | Event* lse; |
880 | mExternLastSyncEvent.clear(); | 880 | mExternLastSyncEvent.clear(); |
881 | int i; | 881 | int i; |
882 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 882 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
883 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 883 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
884 | if ( lse ) | 884 | if ( lse ) |
885 | mExternLastSyncEvent.append( lse ); | 885 | mExternLastSyncEvent.append( lse ); |
886 | else | 886 | else |
887 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 887 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
888 | } | 888 | } |
889 | 889 | ||
890 | } | 890 | } |
891 | // we check, if the to delete event has a id for a profile | 891 | // we check, if the to delete event has a id for a profile |
892 | // if yes, we set this id in the profile to delete | 892 | // if yes, we set this id in the profile to delete |
893 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 893 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
894 | { | 894 | { |
895 | if ( lastSync.count() == 0 ) { | 895 | if ( lastSync.count() == 0 ) { |
896 | //qDebug(" lastSync.count() == 0"); | 896 | //qDebug(" lastSync.count() == 0"); |
897 | return; | 897 | return; |
898 | } | 898 | } |
899 | if ( toDelete->type() == "Journal" ) | 899 | if ( toDelete->type() == "Journal" ) |
900 | return; | 900 | return; |
901 | 901 | ||
902 | Event* eve = lastSync.first(); | 902 | Event* eve = lastSync.first(); |
903 | 903 | ||
904 | while ( eve ) { | 904 | while ( eve ) { |
905 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 905 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
906 | if ( !id.isEmpty() ) { | 906 | if ( !id.isEmpty() ) { |
907 | QString des = eve->description(); | 907 | QString des = eve->description(); |
908 | QString pref = "e"; | 908 | QString pref = "e"; |
909 | if ( toDelete->type() == "Todo" ) | 909 | if ( toDelete->type() == "Todo" ) |
910 | pref = "t"; | 910 | pref = "t"; |
911 | des += pref+ id + ","; | 911 | des += pref+ id + ","; |
912 | eve->setReadOnly( false ); | 912 | eve->setReadOnly( false ); |
913 | eve->setDescription( des ); | 913 | eve->setDescription( des ); |
914 | //qDebug("setdes %s ", des.latin1()); | 914 | //qDebug("setdes %s ", des.latin1()); |
915 | eve->setReadOnly( true ); | 915 | eve->setReadOnly( true ); |
916 | } | 916 | } |
917 | eve = lastSync.next(); | 917 | eve = lastSync.next(); |
918 | } | 918 | } |
919 | 919 | ||
920 | } | 920 | } |
921 | void CalendarView::checkExternalId( Incidence * inc ) | 921 | void CalendarView::checkExternalId( Incidence * inc ) |
922 | { | 922 | { |
923 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 923 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
924 | checkExternSyncEvent( lastSync, inc ); | 924 | checkExternSyncEvent( lastSync, inc ); |
925 | 925 | ||
926 | } | 926 | } |
927 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 927 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
928 | { | 928 | { |
929 | bool syncOK = true; | 929 | bool syncOK = true; |
930 | int addedEvent = 0; | 930 | int addedEvent = 0; |
931 | int addedEventR = 0; | 931 | int addedEventR = 0; |
932 | int deletedEventR = 0; | 932 | int deletedEventR = 0; |
933 | int deletedEventL = 0; | 933 | int deletedEventL = 0; |
934 | int changedLocal = 0; | 934 | int changedLocal = 0; |
935 | int changedRemote = 0; | 935 | int changedRemote = 0; |
936 | //QPtrList<Event> el = local->rawEvents(); | 936 | //QPtrList<Event> el = local->rawEvents(); |
937 | Event* eventR; | 937 | Event* eventR; |
938 | QString uid; | 938 | QString uid; |
939 | int take; | 939 | int take; |
940 | Event* eventL; | 940 | Event* eventL; |
941 | Event* eventRSync; | 941 | Event* eventRSync; |
942 | Event* eventLSync; | 942 | Event* eventLSync; |
943 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 943 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
944 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
945 | bool fullDateRange = false; | 945 | bool fullDateRange = false; |
946 | local->resetTempSyncStat(); | 946 | local->resetTempSyncStat(); |
947 | mLastCalendarSync = QDateTime::currentDateTime(); | 947 | mLastCalendarSync = QDateTime::currentDateTime(); |
948 | QDateTime modifiedCalendar = mLastCalendarSync;; | 948 | QDateTime modifiedCalendar = mLastCalendarSync;; |
949 | eventLSync = getLastSyncEvent(); | 949 | eventLSync = getLastSyncEvent(); |
950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
951 | if ( eventR ) { | 951 | if ( eventR ) { |
952 | eventRSync = (Event*) eventR->clone(); | 952 | eventRSync = (Event*) eventR->clone(); |
953 | remote->deleteEvent(eventR ); | 953 | remote->deleteEvent(eventR ); |
954 | 954 | ||
955 | } else { | 955 | } else { |
956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
957 | eventRSync = (Event*)eventLSync->clone(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
958 | } else { | 958 | } else { |
959 | fullDateRange = true; | 959 | fullDateRange = true; |
960 | eventRSync = new Event(); | 960 | eventRSync = new Event(); |
961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | 963 | eventRSync->setDtStart( mLastCalendarSync ); |
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
965 | eventRSync->setCategories( i18n("SyncEvent") ); | 965 | eventRSync->setCategories( i18n("SyncEvent") ); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
969 | fullDateRange = true; | 969 | fullDateRange = true; |
970 | 970 | ||
971 | if ( ! fullDateRange ) { | 971 | if ( ! fullDateRange ) { |
972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
973 | 973 | ||
974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
976 | fullDateRange = true; | 976 | fullDateRange = true; |
977 | } | 977 | } |
978 | } | 978 | } |
979 | if ( fullDateRange ) | 979 | if ( fullDateRange ) |
980 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 980 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
981 | else | 981 | else |
982 | mLastCalendarSync = eventLSync->dtStart(); | 982 | mLastCalendarSync = eventLSync->dtStart(); |
983 | // for resyncing if own file has changed | 983 | // for resyncing if own file has changed |
984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
985 | mLastCalendarSync = loadedFileVersion; | 985 | mLastCalendarSync = loadedFileVersion; |
986 | qDebug("setting mLastCalendarSync "); | 986 | qDebug("setting mLastCalendarSync "); |
987 | } | 987 | } |
988 | //qDebug("*************************** "); | 988 | //qDebug("*************************** "); |
989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
990 | QPtrList<Incidence> er = remote->rawIncidences(); | 990 | QPtrList<Incidence> er = remote->rawIncidences(); |
991 | Incidence* inR = er.first(); | 991 | Incidence* inR = er.first(); |
992 | Incidence* inL; | 992 | Incidence* inL; |
993 | QProgressBar bar( er.count(),0 ); | 993 | QProgressBar bar( er.count(),0 ); |
994 | bar.setCaption (i18n("Syncing - close to abort!") ); | 994 | bar.setCaption (i18n("Syncing - close to abort!") ); |
995 | 995 | ||
996 | int w = 300; | 996 | int w = 300; |
997 | if ( QApplication::desktop()->width() < 320 ) | 997 | if ( QApplication::desktop()->width() < 320 ) |
998 | w = 220; | 998 | w = 220; |
999 | int h = bar.sizeHint().height() ; | 999 | int h = bar.sizeHint().height() ; |
1000 | int dw = QApplication::desktop()->width(); | 1000 | int dw = QApplication::desktop()->width(); |
1001 | int dh = QApplication::desktop()->height(); | 1001 | int dh = QApplication::desktop()->height(); |
1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index 89eb72f..a53b3f8 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -116,514 +116,514 @@ class SharpParser : public QObject | |||
116 | int freq = freqStr.toInt(); | 116 | int freq = freqStr.toInt(); |
117 | 117 | ||
118 | QString hasEndDateStr = attList[15] ; | 118 | QString hasEndDateStr = attList[15] ; |
119 | bool hasEndDate = hasEndDateStr == "1"; | 119 | bool hasEndDate = hasEndDateStr == "1"; |
120 | 120 | ||
121 | QString endDateStr = attList[16]; | 121 | QString endDateStr = attList[16]; |
122 | QDate endDate = fromString( endDateStr ).date(); | 122 | QDate endDate = fromString( endDateStr ).date(); |
123 | 123 | ||
124 | QString weekDaysStr = attList[14]; | 124 | QString weekDaysStr = attList[14]; |
125 | uint weekDaysNum = weekDaysStr.toInt(); | 125 | uint weekDaysNum = weekDaysStr.toInt(); |
126 | 126 | ||
127 | QBitArray weekDays( 7 ); | 127 | QBitArray weekDays( 7 ); |
128 | int i; | 128 | int i; |
129 | int bb = 1; | 129 | int bb = 1; |
130 | for( i = 1; i <= 7; ++i ) { | 130 | for( i = 1; i <= 7; ++i ) { |
131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
132 | bb = 2 << (i-1); | 132 | bb = 2 << (i-1); |
133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
134 | } | 134 | } |
135 | // qDebug("next "); | 135 | // qDebug("next "); |
136 | QString posStr = attList[13]; | 136 | QString posStr = attList[13]; |
137 | int pos = posStr.toInt(); | 137 | int pos = posStr.toInt(); |
138 | Recurrence *r = event->recurrence(); | 138 | Recurrence *r = event->recurrence(); |
139 | 139 | ||
140 | if ( rtype == "0" ) { | 140 | if ( rtype == "0" ) { |
141 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 141 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
142 | else r->setDaily( freq, -1 ); | 142 | else r->setDaily( freq, -1 ); |
143 | } else if ( rtype == "1" ) { | 143 | } else if ( rtype == "1" ) { |
144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
145 | else r->setWeekly( freq, weekDays, -1 ); | 145 | else r->setWeekly( freq, weekDays, -1 ); |
146 | } else if ( rtype == "3" ) { | 146 | } else if ( rtype == "3" ) { |
147 | if ( hasEndDate ) | 147 | if ( hasEndDate ) |
148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
149 | else | 149 | else |
150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
151 | r->addMonthlyDay( startDate.day() ); | 151 | r->addMonthlyDay( startDate.day() ); |
152 | } else if ( rtype == "2" ) { | 152 | } else if ( rtype == "2" ) { |
153 | if ( hasEndDate ) | 153 | if ( hasEndDate ) |
154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
155 | else | 155 | else |
156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
157 | QBitArray days( 7 ); | 157 | QBitArray days( 7 ); |
158 | days.fill( false ); | 158 | days.fill( false ); |
159 | days.setBit( startDate.dayOfWeek() - 1 ); | 159 | days.setBit( startDate.dayOfWeek() - 1 ); |
160 | r->addMonthlyPos( pos, days ); | 160 | r->addMonthlyPos( pos, days ); |
161 | } else if ( rtype == "4" ) { | 161 | } else if ( rtype == "4" ) { |
162 | if ( hasEndDate ) | 162 | if ( hasEndDate ) |
163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
164 | else | 164 | else |
165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
166 | r->addYearlyNum( startDate.month() ); | 166 | r->addYearlyNum( startDate.month() ); |
167 | } | 167 | } |
168 | } else { | 168 | } else { |
169 | event->recurrence()->unsetRecurs(); | 169 | event->recurrence()->unsetRecurs(); |
170 | } | 170 | } |
171 | 171 | ||
172 | QString categoryList = attList[1] ; | 172 | QString categoryList = attList[1] ; |
173 | event->setCategories( lookupCategories( categoryList ) ); | 173 | event->setCategories( lookupCategories( categoryList ) ); |
174 | 174 | ||
175 | // strange 0 semms to mean: alarm enabled | 175 | // strange 0 semms to mean: alarm enabled |
176 | if ( attList[8] == "0" ) { | 176 | if ( attList[8] == "0" ) { |
177 | Alarm *alarm; | 177 | Alarm *alarm; |
178 | if ( event->alarms().count() > 0 ) | 178 | if ( event->alarms().count() > 0 ) |
179 | alarm = event->alarms().first(); | 179 | alarm = event->alarms().first(); |
180 | else { | 180 | else { |
181 | alarm = new Alarm( event ); | 181 | alarm = new Alarm( event ); |
182 | event->addAlarm( alarm ); | 182 | event->addAlarm( alarm ); |
183 | alarm->setType( Alarm::Audio ); | 183 | alarm->setType( Alarm::Audio ); |
184 | } | 184 | } |
185 | //alarm->setType( Alarm::Audio ); | 185 | //alarm->setType( Alarm::Audio ); |
186 | alarm->setEnabled( true ); | 186 | alarm->setEnabled( true ); |
187 | int alarmOffset = attList[9].toInt(); | 187 | int alarmOffset = attList[9].toInt(); |
188 | alarm->setStartOffset( alarmOffset * -60 ); | 188 | alarm->setStartOffset( alarmOffset * -60 ); |
189 | } else { | 189 | } else { |
190 | Alarm *alarm; | 190 | Alarm *alarm; |
191 | if ( event->alarms().count() > 0 ) { | 191 | if ( event->alarms().count() > 0 ) { |
192 | alarm = event->alarms().first(); | 192 | alarm = event->alarms().first(); |
193 | alarm->setType( Alarm::Audio ); | 193 | alarm->setType( Alarm::Audio ); |
194 | alarm->setStartOffset( -60*15 ); | 194 | alarm->setStartOffset( -60*15 ); |
195 | alarm->setEnabled( false ); | 195 | alarm->setEnabled( false ); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | mCalendar->addEvent( event); | 199 | mCalendar->addEvent( event); |
200 | } else if ( qName == "Todo" ) { | 200 | } else if ( qName == "Todo" ) { |
201 | Todo *todo; | 201 | Todo *todo; |
202 | 202 | ||
203 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); | 203 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); |
204 | if (todo ) | 204 | if (todo ) |
205 | todo = (Todo*)todo->clone(); | 205 | todo = (Todo*)todo->clone(); |
206 | else | 206 | else |
207 | todo = new Todo; | 207 | todo = new Todo; |
208 | 208 | ||
209 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 209 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
210 | // 0 1 2 3 4 5 6 7 8 | 210 | // 0 1 2 3 4 5 6 7 8 |
211 | //1,,,,,1,4,Loch zumachen,"" | 211 | //1,,,,,1,4,Loch zumachen,"" |
212 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 212 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
213 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 213 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
214 | 214 | ||
215 | todo->setID( "Sharp_DTM", attList[0]); | 215 | todo->setID( "Sharp_DTM", attList[0]); |
216 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); | 216 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); |
217 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 217 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
218 | 218 | ||
219 | todo->setSummary( attList[7] ); | 219 | todo->setSummary( attList[7] ); |
220 | todo->setDescription( attList[8]); | 220 | todo->setDescription( attList[8]); |
221 | 221 | ||
222 | int priority = attList[6].toInt(); | 222 | int priority = attList[6].toInt(); |
223 | if ( priority == 0 ) priority = 3; | 223 | if ( priority == 0 ) priority = 3; |
224 | todo->setPriority( priority ); | 224 | todo->setPriority( priority ); |
225 | 225 | ||
226 | QString categoryList = attList[1]; | 226 | QString categoryList = attList[1]; |
227 | todo->setCategories( lookupCategories( categoryList ) ); | 227 | todo->setCategories( lookupCategories( categoryList ) ); |
228 | 228 | ||
229 | 229 | ||
230 | 230 | ||
231 | QString hasDateStr = attList[3]; // due | 231 | QString hasDateStr = attList[3]; // due |
232 | if ( !hasDateStr.isEmpty() ) { | 232 | if ( !hasDateStr.isEmpty() ) { |
233 | if ( hasDateStr.right(6) == "000000" ) { | 233 | if ( hasDateStr.right(6) == "000000" ) { |
234 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 234 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
235 | todo->setFloats( true ); | 235 | todo->setFloats( true ); |
236 | } | 236 | } |
237 | else { | 237 | else { |
238 | todo->setDtDue( fromString( hasDateStr ) ); | 238 | todo->setDtDue( fromString( hasDateStr ) ); |
239 | todo->setFloats( false ); | 239 | todo->setFloats( false ); |
240 | } | 240 | } |
241 | 241 | ||
242 | todo->setHasDueDate( true ); | 242 | todo->setHasDueDate( true ); |
243 | } | 243 | } |
244 | hasDateStr = attList[2];//start | 244 | hasDateStr = attList[2];//start |
245 | if ( !hasDateStr.isEmpty() ) { | 245 | if ( !hasDateStr.isEmpty() ) { |
246 | 246 | ||
247 | todo->setDtStart( fromString( hasDateStr ) ); | 247 | todo->setDtStart( fromString( hasDateStr ) ); |
248 | todo->setHasStartDate( true); | 248 | todo->setHasStartDate( true); |
249 | } else | 249 | } else |
250 | todo->setHasStartDate( false ); | 250 | todo->setHasStartDate( false ); |
251 | hasDateStr = attList[4];//completed | 251 | hasDateStr = attList[4];//completed |
252 | if ( !hasDateStr.isEmpty() ) { | 252 | if ( !hasDateStr.isEmpty() ) { |
253 | todo->setCompleted(fromString( hasDateStr ) ); | 253 | todo->setCompleted(fromString( hasDateStr ) ); |
254 | } | 254 | } |
255 | QString completedStr = attList[5]; | 255 | QString completedStr = attList[5]; |
256 | if ( completedStr == "0" ) | 256 | if ( completedStr == "0" ) |
257 | todo->setCompleted( true ); | 257 | todo->setCompleted( true ); |
258 | else | 258 | else |
259 | todo->setCompleted( false ); | 259 | todo->setCompleted( false ); |
260 | mCalendar->addTodo( todo ); | 260 | mCalendar->addTodo( todo ); |
261 | 261 | ||
262 | } else if ( qName == "Category" ) { | 262 | } else if ( qName == "Category" ) { |
263 | /* | 263 | /* |
264 | QString id = attributes.value( "id" ); | 264 | QString id = attributes.value( "id" ); |
265 | QString name = attributes.value( "name" ); | 265 | QString name = attributes.value( "name" ); |
266 | setCategory( id, name ); | 266 | setCategory( id, name ); |
267 | */ | 267 | */ |
268 | } | 268 | } |
269 | //qDebug("end "); | 269 | //qDebug("end "); |
270 | return true; | 270 | return true; |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | void setCategoriesList ( QStringList * c ) | 274 | void setCategoriesList ( QStringList * c ) |
275 | { | 275 | { |
276 | oldCategories = c; | 276 | oldCategories = c; |
277 | } | 277 | } |
278 | 278 | ||
279 | QDateTime fromString ( QString s, bool useTz = true ) { | 279 | QDateTime fromString ( QString s, bool useTz = true ) { |
280 | QDateTime dt; | 280 | QDateTime dt; |
281 | int y,m,t,h,min,sec; | 281 | int y,m,t,h,min,sec; |
282 | y = s.mid(0,4).toInt(); | 282 | y = s.mid(0,4).toInt(); |
283 | m = s.mid(4,2).toInt(); | 283 | m = s.mid(4,2).toInt(); |
284 | t = s.mid(6,2).toInt(); | 284 | t = s.mid(6,2).toInt(); |
285 | h = s.mid(9,2).toInt(); | 285 | h = s.mid(9,2).toInt(); |
286 | min = s.mid(11,2).toInt(); | 286 | min = s.mid(11,2).toInt(); |
287 | sec = s.mid(13,2).toInt(); | 287 | sec = s.mid(13,2).toInt(); |
288 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 288 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
289 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 289 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
290 | if ( useTz ) | 290 | if ( useTz ) |
291 | dt = dt.addSecs ( offset*60); | 291 | dt = dt.addSecs ( offset*60); |
292 | return dt; | 292 | return dt; |
293 | 293 | ||
294 | } | 294 | } |
295 | protected: | 295 | protected: |
296 | QDateTime toDateTime( const QString &value ) | 296 | QDateTime toDateTime( const QString &value ) |
297 | { | 297 | { |
298 | QDateTime dt; | 298 | QDateTime dt; |
299 | dt.setTime_t( value.toUInt() ); | 299 | dt.setTime_t( value.toUInt() ); |
300 | 300 | ||
301 | return dt; | 301 | return dt; |
302 | } | 302 | } |
303 | 303 | ||
304 | QStringList lookupCategories( const QString &categoryList ) | 304 | QStringList lookupCategories( const QString &categoryList ) |
305 | { | 305 | { |
306 | QStringList categoryIds = QStringList::split( ";", categoryList ); | 306 | QStringList categoryIds = QStringList::split( ";", categoryList ); |
307 | QStringList categories; | 307 | QStringList categories; |
308 | QStringList::ConstIterator it; | 308 | QStringList::ConstIterator it; |
309 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { | 309 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { |
310 | QString cate = category( *it ); | 310 | QString cate = category( *it ); |
311 | if ( oldCategories ) { | 311 | if ( oldCategories ) { |
312 | if ( ! oldCategories->contains( cate ) ) | 312 | if ( ! oldCategories->contains( cate ) ) |
313 | oldCategories->append( cate ); | 313 | oldCategories->append( cate ); |
314 | } | 314 | } |
315 | categories.append(cate ); | 315 | categories.append(cate ); |
316 | } | 316 | } |
317 | return categories; | 317 | return categories; |
318 | } | 318 | } |
319 | 319 | ||
320 | private: | 320 | private: |
321 | Calendar *mCalendar; | 321 | Calendar *mCalendar; |
322 | QStringList * oldCategories; | 322 | QStringList * oldCategories; |
323 | static QString category( const QString &id ) | 323 | static QString category( const QString &id ) |
324 | { | 324 | { |
325 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); | 325 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); |
326 | if ( it == mCategoriesMap.end() ) return id; | 326 | if ( it == mCategoriesMap.end() ) return id; |
327 | else return *it; | 327 | else return *it; |
328 | } | 328 | } |
329 | 329 | ||
330 | static void setCategory( const QString &id, const QString &name ) | 330 | static void setCategory( const QString &id, const QString &name ) |
331 | { | 331 | { |
332 | mCategoriesMap.insert( id, name ); | 332 | mCategoriesMap.insert( id, name ); |
333 | } | 333 | } |
334 | 334 | ||
335 | static QMap<QString,QString> mCategoriesMap; | 335 | static QMap<QString,QString> mCategoriesMap; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | QMap<QString,QString> SharpParser::mCategoriesMap; | 338 | QMap<QString,QString> SharpParser::mCategoriesMap; |
339 | 339 | ||
340 | SharpFormat::SharpFormat() | 340 | SharpFormat::SharpFormat() |
341 | { | 341 | { |
342 | mCategories = 0; | 342 | mCategories = 0; |
343 | } | 343 | } |
344 | 344 | ||
345 | SharpFormat::~SharpFormat() | 345 | SharpFormat::~SharpFormat() |
346 | { | 346 | { |
347 | } | 347 | } |
348 | ulong SharpFormat::getCsum( const QStringList & attList) | 348 | ulong SharpFormat::getCsum( const QStringList & attList) |
349 | { | 349 | { |
350 | int max = attList.count() -1; | 350 | int max = attList.count() -1; |
351 | ulong cSum = 0; | 351 | ulong cSum = 0; |
352 | int j,k,i; | 352 | int j,k,i; |
353 | int add; | 353 | int add; |
354 | for ( i = 1; i < max ; ++i ) { | 354 | for ( i = 1; i < max ; ++i ) { |
355 | QString s = attList[i]; | 355 | QString s = attList[i]; |
356 | if ( ! s.isEmpty() ){ | 356 | if ( ! s.isEmpty() ){ |
357 | j = s.length(); | 357 | j = s.length(); |
358 | for ( k = 0; k < j; ++k ) { | 358 | for ( k = 0; k < j; ++k ) { |
359 | int mul = k +1; | 359 | int mul = k +1; |
360 | add = s[k].unicode (); | 360 | add = s[k].unicode (); |
361 | if ( k < 16 ) | 361 | if ( k < 16 ) |
362 | mul = mul * mul; | 362 | mul = mul * mul; |
363 | add = add * mul *i*i*i; | 363 | add = add * mul *i*i*i; |
364 | cSum += add; | 364 | cSum += add; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | } | 367 | } |
368 | return cSum; | 368 | return cSum; |
369 | 369 | ||
370 | } | 370 | } |
371 | #include <stdlib.h> | 371 | #include <stdlib.h> |
372 | //#define DEBUGMODE false | 372 | #define DEBUGMODE false |
373 | #define DEBUGMODE true | 373 | //#define DEBUGMODE true |
374 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | 374 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) |
375 | { | 375 | { |
376 | 376 | ||
377 | 377 | ||
378 | bool debug = DEBUGMODE; | 378 | bool debug = DEBUGMODE; |
379 | QString text; | 379 | QString text; |
380 | QString codec = "utf8"; | 380 | QString codec = "utf8"; |
381 | QLabel status ( i18n("Reading events ..."), 0 ); | 381 | QLabel status ( i18n("Reading events ..."), 0 ); |
382 | 382 | ||
383 | int w = status.sizeHint().width()+20 ; | 383 | int w = status.sizeHint().width()+20 ; |
384 | if ( w < 200 ) w = 200; | 384 | if ( w < 200 ) w = 200; |
385 | int h = status.sizeHint().height()+20 ; | 385 | int h = status.sizeHint().height()+20 ; |
386 | int dw = QApplication::desktop()->width(); | 386 | int dw = QApplication::desktop()->width(); |
387 | int dh = QApplication::desktop()->height(); | 387 | int dh = QApplication::desktop()->height(); |
388 | status.setCaption(i18n("Reading DTM Data") ); | 388 | status.setCaption(i18n("Reading DTM Data") ); |
389 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 389 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
390 | status.show(); | 390 | status.show(); |
391 | status.raise(); | 391 | status.raise(); |
392 | qApp->processEvents(); | 392 | qApp->processEvents(); |
393 | QString fileName; | 393 | QString fileName; |
394 | if ( ! debug ) { | 394 | if ( ! debug ) { |
395 | fileName = "/tmp/kopitempout"; | 395 | fileName = "/tmp/kopitempout"; |
396 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 396 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
397 | system ( command.latin1() ); | 397 | system ( command.latin1() ); |
398 | } else { | 398 | } else { |
399 | fileName = "/tmp/events.txt"; | 399 | fileName = "/tmp/events.txt"; |
400 | 400 | ||
401 | } | 401 | } |
402 | QFile file( fileName ); | 402 | QFile file( fileName ); |
403 | if (!file.open( IO_ReadOnly ) ) { | 403 | if (!file.open( IO_ReadOnly ) ) { |
404 | return false; | 404 | return false; |
405 | 405 | ||
406 | } | 406 | } |
407 | QTextStream ts( &file ); | 407 | QTextStream ts( &file ); |
408 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 408 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
409 | text = ts.read(); | 409 | text = ts.read(); |
410 | file.close(); | 410 | file.close(); |
411 | status.setText( i18n("Processing events ...") ); | 411 | status.setText( i18n("Processing events ...") ); |
412 | status.raise(); | 412 | status.raise(); |
413 | qApp->processEvents(); | 413 | qApp->processEvents(); |
414 | fromString2Cal( calendar, existngCal, text, "Event" ); | 414 | fromString2Cal( calendar, existngCal, text, "Event" ); |
415 | status.setText( i18n("Reading todos ...") ); | 415 | status.setText( i18n("Reading todos ...") ); |
416 | qApp->processEvents(); | 416 | qApp->processEvents(); |
417 | if ( ! debug ) { | 417 | if ( ! debug ) { |
418 | fileName = "/tmp/kopitempout"; | 418 | fileName = "/tmp/kopitempout"; |
419 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 419 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
420 | system ( command.latin1() ); | 420 | system ( command.latin1() ); |
421 | } else { | 421 | } else { |
422 | fileName = "/tmp/todo.txt"; | 422 | fileName = "/tmp/todo.txt"; |
423 | } | 423 | } |
424 | file.setName( fileName ); | 424 | file.setName( fileName ); |
425 | if (!file.open( IO_ReadOnly ) ) { | 425 | if (!file.open( IO_ReadOnly ) ) { |
426 | return false; | 426 | return false; |
427 | 427 | ||
428 | } | 428 | } |
429 | ts.setDevice( &file ); | 429 | ts.setDevice( &file ); |
430 | text = ts.read(); | 430 | text = ts.read(); |
431 | file.close(); | 431 | file.close(); |
432 | 432 | ||
433 | status.setText( i18n("Processing todos ...") ); | 433 | status.setText( i18n("Processing todos ...") ); |
434 | status.raise(); | 434 | status.raise(); |
435 | qApp->processEvents(); | 435 | qApp->processEvents(); |
436 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 436 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
437 | return true; | 437 | return true; |
438 | } | 438 | } |
439 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 439 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
440 | { | 440 | { |
441 | int retval = -1; | 441 | int retval = -1; |
442 | QStringList templist; | 442 | QStringList templist; |
443 | QString tempString; | 443 | QString tempString; |
444 | int start = 0; | 444 | int start = 0; |
445 | int len = answer.length(); | 445 | int len = answer.length(); |
446 | int end = answer.find ("\n",start)+1; | 446 | int end = answer.find ("\n",start)+1; |
447 | bool ok = true; | 447 | bool ok = true; |
448 | start = end; | 448 | start = end; |
449 | int ccc = 0; | 449 | int ccc = 0; |
450 | while ( start > 0 ) { | 450 | while ( start > 0 ) { |
451 | templist.clear(); | 451 | templist.clear(); |
452 | ok = true; | 452 | ok = true; |
453 | int loopCount = 0; | 453 | int loopCount = 0; |
454 | while ( ok ) { | 454 | while ( ok ) { |
455 | ++loopCount; | 455 | ++loopCount; |
456 | if ( loopCount > 25 ) { | 456 | if ( loopCount > 25 ) { |
457 | qDebug("KO: Error in while loop"); | 457 | qDebug("KO: Error in while loop"); |
458 | ok = false; | 458 | ok = false; |
459 | start = 0; | 459 | start = 0; |
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 | } | 484 | } |
485 | } | 485 | } |
486 | //qDebug("getNumFromRecord returning : %d ", retval); | 486 | //qDebug("getNumFromRecord returning : %d ", retval); |
487 | return retval; | 487 | return retval; |
488 | } | 488 | } |
489 | bool SharpFormat::save( Calendar *calendar) | 489 | bool SharpFormat::save( Calendar *calendar) |
490 | { | 490 | { |
491 | 491 | ||
492 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 492 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
493 | int w = status.sizeHint().width()+20 ; | 493 | int w = status.sizeHint().width()+20 ; |
494 | if ( w < 200 ) w = 200; | 494 | if ( w < 200 ) w = 200; |
495 | int h = status.sizeHint().height()+20 ; | 495 | int h = status.sizeHint().height()+20 ; |
496 | int dw = QApplication::desktop()->width(); | 496 | int dw = QApplication::desktop()->width(); |
497 | int dh = QApplication::desktop()->height(); | 497 | int dh = QApplication::desktop()->height(); |
498 | status.setCaption(i18n("Writing DTM Data") ); | 498 | status.setCaption(i18n("Writing DTM Data") ); |
499 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 499 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
500 | status.show(); | 500 | status.show(); |
501 | status.raise(); | 501 | status.raise(); |
502 | qApp->processEvents(); | 502 | qApp->processEvents(); |
503 | bool debug = DEBUGMODE; | 503 | bool debug = DEBUGMODE; |
504 | QString codec = "utf8"; | 504 | QString codec = "utf8"; |
505 | QString answer; | 505 | 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"; | 506 | 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"; | 507 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
508 | QString command; | 508 | QString command; |
509 | QPtrList<Event> er = calendar->rawEvents(); | 509 | QPtrList<Event> er = calendar->rawEvents(); |
510 | Event* ev = er.first(); | 510 | Event* ev = er.first(); |
511 | QString fileName = "/tmp/kopitempout"; | 511 | QString fileName = "/tmp/kopitempout"; |
512 | int i = 0; | 512 | int i = 0; |
513 | QString changeString = ePrefix; | 513 | QString changeString = ePrefix; |
514 | QString deleteString = ePrefix; | 514 | QString deleteString = ePrefix; |
515 | bool deleteEnt = false; | 515 | bool deleteEnt = false; |
516 | bool changeEnt = false; | 516 | bool changeEnt = false; |
517 | QString message = i18n("Processing event # "); | 517 | QString message = i18n("Processing event # "); |
518 | int procCount = 0; | 518 | int procCount = 0; |
519 | while ( ev ) { | 519 | while ( ev ) { |
520 | //qDebug("i %d ", ++i); | 520 | //qDebug("i %d ", ++i); |
521 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 521 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
522 | status.setText ( message + QString::number ( ++procCount ) ); | 522 | status.setText ( message + QString::number ( ++procCount ) ); |
523 | qApp->processEvents(); | 523 | qApp->processEvents(); |
524 | QString eString = getEventString( ev ); | 524 | QString eString = getEventString( ev ); |
525 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 525 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
526 | // deleting empty strings does not work. | 526 | // deleting empty strings does not work. |
527 | // we write first and x and then delete the record with the x | 527 | // we write first and x and then delete the record with the x |
528 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 528 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
529 | changeString += eString + "\n"; | 529 | changeString += eString + "\n"; |
530 | deleteString += eString + "\n"; | 530 | deleteString += eString + "\n"; |
531 | deleteEnt = true; | 531 | deleteEnt = true; |
532 | changeEnt = true; | 532 | changeEnt = true; |
533 | } | 533 | } |
534 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new | 534 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new |
535 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 535 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
536 | system ( command.utf8() ); | 536 | system ( command.utf8() ); |
537 | QFile file( fileName ); | 537 | QFile file( fileName ); |
538 | if (!file.open( IO_ReadOnly ) ) { | 538 | if (!file.open( IO_ReadOnly ) ) { |
539 | return false; | 539 | return false; |
540 | 540 | ||
541 | } | 541 | } |
542 | QTextStream ts( &file ); | 542 | QTextStream ts( &file ); |
543 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 543 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
544 | answer = ts.read(); | 544 | answer = ts.read(); |
545 | file.close(); | 545 | file.close(); |
546 | //qDebug("answer \n%s ", answer.latin1()); | 546 | //qDebug("answer \n%s ", answer.latin1()); |
547 | getNumFromRecord( answer, ev ) ; | 547 | getNumFromRecord( answer, ev ) ; |
548 | 548 | ||
549 | } | 549 | } |
550 | else { // change existing | 550 | else { // change existing |
551 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | 551 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); |
552 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 552 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
553 | changeString += eString + "\n"; | 553 | changeString += eString + "\n"; |
554 | changeEnt = true; | 554 | changeEnt = true; |
555 | 555 | ||
556 | } | 556 | } |
557 | } | 557 | } |
558 | ev = er.next(); | 558 | ev = er.next(); |
559 | } | 559 | } |
560 | status.setText ( i18n("Changing events ...") ); | 560 | status.setText ( i18n("Changing events ...") ); |
561 | qApp->processEvents(); | 561 | qApp->processEvents(); |
562 | //qDebug("changing... "); | 562 | //qDebug("changing... "); |
563 | if ( changeEnt ) { | 563 | if ( changeEnt ) { |
564 | QFile file( fileName ); | 564 | QFile file( fileName ); |
565 | if (!file.open( IO_WriteOnly ) ) { | 565 | if (!file.open( IO_WriteOnly ) ) { |
566 | return false; | 566 | return false; |
567 | 567 | ||
568 | } | 568 | } |
569 | QTextStream ts( &file ); | 569 | QTextStream ts( &file ); |
570 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 570 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
571 | ts << changeString ; | 571 | ts << changeString ; |
572 | file.close(); | 572 | file.close(); |
573 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; | 573 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; |
574 | system ( command.latin1() ); | 574 | system ( command.latin1() ); |
575 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 575 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
576 | 576 | ||
577 | } | 577 | } |
578 | status.setText ( i18n("Deleting events ...") ); | 578 | status.setText ( i18n("Deleting events ...") ); |
579 | qApp->processEvents(); | 579 | qApp->processEvents(); |
580 | //qDebug("deleting... "); | 580 | //qDebug("deleting... "); |
581 | if ( deleteEnt ) { | 581 | if ( deleteEnt ) { |
582 | QFile file( fileName ); | 582 | QFile file( fileName ); |
583 | if (!file.open( IO_WriteOnly ) ) { | 583 | if (!file.open( IO_WriteOnly ) ) { |
584 | return false; | 584 | return false; |
585 | 585 | ||
586 | } | 586 | } |
587 | QTextStream ts( &file ); | 587 | QTextStream ts( &file ); |
588 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 588 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
589 | ts << deleteString; | 589 | ts << deleteString; |
590 | file.close(); | 590 | file.close(); |
591 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; | 591 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; |
592 | system ( command.latin1() ); | 592 | system ( command.latin1() ); |
593 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 593 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | changeString = tPrefix; | 597 | changeString = tPrefix; |
598 | deleteString = tPrefix; | 598 | deleteString = tPrefix; |
599 | status.setText ( i18n("Processing todos ...") ); | 599 | status.setText ( i18n("Processing todos ...") ); |
600 | qApp->processEvents(); | 600 | qApp->processEvents(); |
601 | QPtrList<Todo> tl = calendar->rawTodos(); | 601 | QPtrList<Todo> tl = calendar->rawTodos(); |
602 | Todo* to = tl.first(); | 602 | Todo* to = tl.first(); |
603 | i = 0; | 603 | i = 0; |
604 | message = i18n("Processing todo # "); | 604 | message = i18n("Processing todo # "); |
605 | procCount = 0; | 605 | procCount = 0; |
606 | while ( to ) { | 606 | while ( to ) { |
607 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 607 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
608 | status.setText ( message + QString::number ( ++procCount ) ); | 608 | status.setText ( message + QString::number ( ++procCount ) ); |
609 | qApp->processEvents(); | 609 | qApp->processEvents(); |
610 | QString eString = getTodoString( to ); | 610 | QString eString = getTodoString( to ); |
611 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 611 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
612 | // deleting empty strings does not work. | 612 | // deleting empty strings does not work. |
613 | // we write first and x and then delete the record with the x | 613 | // we write first and x and then delete the record with the x |
614 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 614 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
615 | changeString += eString + "\n"; | 615 | changeString += eString + "\n"; |
616 | deleteString += eString + "\n"; | 616 | deleteString += eString + "\n"; |
617 | deleteEnt = true; | 617 | deleteEnt = true; |
618 | changeEnt = true; | 618 | changeEnt = true; |
619 | } | 619 | } |
620 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new | 620 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new |
621 | command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; | 621 | command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; |
622 | system ( command.utf8() ); | 622 | system ( command.utf8() ); |
623 | QFile file( fileName ); | 623 | QFile file( fileName ); |
624 | if (!file.open( IO_ReadOnly ) ) { | 624 | if (!file.open( IO_ReadOnly ) ) { |
625 | return false; | 625 | return false; |
626 | 626 | ||
627 | } | 627 | } |
628 | QTextStream ts( &file ); | 628 | QTextStream ts( &file ); |
629 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 629 | ts.setCodec( QTextCodec::codecForName("utf8") ); |