summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-07 21:04:24 (UTC)
committer zautrix <zautrix>2004-08-07 21:04:24 (UTC)
commita9c3191a42084b6631dededef1709fa67eb2c048 (patch) (unidiff)
tree9950e3c8fc54c2994a4a50417008921bfdc58889
parent809e502f4b6e84524c10fa963e2d17564e6b1af9 (diff)
downloadkdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.zip
kdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.tar.gz
kdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.tar.bz2
more phone sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp9
-rw-r--r--libkcal/phoneformat.cpp273
-rw-r--r--libkcal/phoneformat.h3
3 files changed, 222 insertions, 63 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b307649..d6ead37 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -671,1045 +671,1050 @@ QDate CalendarView::endDate()
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
677void CalendarView::createPrinter() 677void 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
687void CalendarView::confSync() 687void 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
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int 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 locCh = ( local->lastModified() > mLastCalendarSync ); 732 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 735 //qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 736 lastSync = local->lastModified().addDays(1);
737 } else { 737 } else {
738 if ( locCh ) { 738 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 740 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 741 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 742 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 743 } else {
744 //qDebug(" not loc changed "); 744 //qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 745 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 746 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 747 remote->setLastModified( lastSync.addDays( 1 ) );
748 748
749 } 749 }
750 } 750 }
751 full = true; 751 full = true;
752 if ( mode < SYNC_PREF_ASK ) 752 if ( mode < SYNC_PREF_ASK )
753 mode = SYNC_PREF_ASK; 753 mode = SYNC_PREF_ASK;
754 } else { 754 } else {
755 if ( local->lastModified() == remote->lastModified() ) 755 if ( local->lastModified() == remote->lastModified() )
756 if ( local->revision() == remote->revision() ) 756 if ( local->revision() == remote->revision() )
757 return 0; 757 return 0;
758 758
759 } 759 }
760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
761 761
762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
764 //full = true; //debug only 764 //full = true; //debug only
765 if ( full ) { 765 if ( full ) {
766 bool equ = false; 766 bool equ = false;
767 if ( local->type() == "Event" ) { 767 if ( local->type() == "Event" ) {
768 equ = (*((Event*) local) == *((Event*) remote)); 768 equ = (*((Event*) local) == *((Event*) remote));
769 } 769 }
770 else if ( local->type() =="Todo" ) 770 else if ( local->type() =="Todo" )
771 equ = (*((Todo*) local) == (*(Todo*) remote)); 771 equ = (*((Todo*) local) == (*(Todo*) remote));
772 else if ( local->type() =="Journal" ) 772 else if ( local->type() =="Journal" )
773 equ = (*((Journal*) local) == *((Journal*) remote)); 773 equ = (*((Journal*) local) == *((Journal*) remote));
774 if ( equ ) { 774 if ( equ ) {
775 //qDebug("equal "); 775 //qDebug("equal ");
776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
778 } 778 }
779 if ( mode < SYNC_PREF_FORCE_LOCAL ) 779 if ( mode < SYNC_PREF_FORCE_LOCAL )
780 return 0; 780 return 0;
781 781
782 }//else //debug only 782 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 784 }
785 int result; 785 int result;
786 bool localIsNew; 786 bool localIsNew;
787 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
789 789
790 switch( mode ) { 790 switch( mode ) {
791 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 792 if ( lastSync > remote->lastModified() )
793 return 1; 793 return 1;
794 if ( lastSync > local->lastModified() ) 794 if ( lastSync > local->lastModified() )
795 return 2; 795 return 2;
796 return 1; 796 return 1;
797 break; 797 break;
798 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
799 if ( lastSync > remote->lastModified() ) 799 if ( lastSync > remote->lastModified() )
800 return 1; 800 return 1;
801 if ( lastSync > local->lastModified() ) 801 if ( lastSync > local->lastModified() )
802 return 2; 802 return 2;
803 return 2; 803 return 2;
804 break; 804 break;
805 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
806 if ( local->lastModified() > remote->lastModified() ) 806 if ( local->lastModified() > remote->lastModified() )
807 return 1; 807 return 1;
808 else 808 else
809 return 2; 809 return 2;
810 break; 810 break;
811 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 813 if ( lastSync > remote->lastModified() )
814 return 1; 814 return 1;
815 if ( lastSync > local->lastModified() ) 815 if ( lastSync > local->lastModified() )
816 return 2; 816 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 818 localIsNew = local->lastModified() > remote->lastModified();
819 if ( localIsNew ) 819 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
821 else 821 else
822 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 824 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
826 else 826 else
827 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 834 return result;
835 835
836 break; 836 break;
837 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 838 return 1;
839 break; 839 break;
840 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 841 return 2;
842 break; 842 break;
843 843
844 default: 844 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 846 break;
847 } 847 }
848 return 0; 848 return 0;
849} 849}
850Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
851{ 851{
852 Event* lse; 852 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
855 if (!lse) { 855 if (!lse) {
856 lse = new Event(); 856 lse = new Event();
857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
858 QString sum = ""; 858 QString sum = "";
859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
860 sum = "E: "; 860 sum = "E: ";
861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
862 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
864 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
865 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
866 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
867 } 867 }
868 868
869 return lse; 869 return lse;
870 870
871} 871}
872// probaly useless 872// probaly useless
873void CalendarView::setupExternSyncProfiles() 873void CalendarView::setupExternSyncProfiles()
874{ 874{
875 Event* lse; 875 Event* lse;
876 mExternLastSyncEvent.clear(); 876 mExternLastSyncEvent.clear();
877 int i; 877 int i;
878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
880 if ( lse ) 880 if ( lse )
881 mExternLastSyncEvent.append( lse ); 881 mExternLastSyncEvent.append( lse );
882 else 882 else
883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
884 } 884 }
885 885
886} 886}
887// we check, if the to delete event has a id for a profile 887// we check, if the to delete event has a id for a profile
888// if yes, we set this id in the profile to delete 888// if yes, we set this id in the profile to delete
889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
890{ 890{
891 if ( lastSync.count() == 0 ) { 891 if ( lastSync.count() == 0 ) {
892 //qDebug(" lastSync.count() == 0"); 892 //qDebug(" lastSync.count() == 0");
893 return; 893 return;
894 } 894 }
895 if ( toDelete->type() == "Journal" ) 895 if ( toDelete->type() == "Journal" )
896 return; 896 return;
897 897
898 Event* eve = lastSync.first(); 898 Event* eve = lastSync.first();
899 899
900 while ( eve ) { 900 while ( eve ) {
901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
902 if ( !id.isEmpty() ) { 902 if ( !id.isEmpty() ) {
903 QString des = eve->description(); 903 QString des = eve->description();
904 QString pref = "e"; 904 QString pref = "e";
905 if ( toDelete->type() == "Todo" ) 905 if ( toDelete->type() == "Todo" )
906 pref = "t"; 906 pref = "t";
907 des += pref+ id + ","; 907 des += pref+ id + ",";
908 eve->setReadOnly( false ); 908 eve->setReadOnly( false );
909 eve->setDescription( des ); 909 eve->setDescription( des );
910 //qDebug("setdes %s ", des.latin1()); 910 //qDebug("setdes %s ", des.latin1());
911 eve->setReadOnly( true ); 911 eve->setReadOnly( true );
912 } 912 }
913 eve = lastSync.next(); 913 eve = lastSync.next();
914 } 914 }
915 915
916} 916}
917void CalendarView::checkExternalId( Incidence * inc ) 917void CalendarView::checkExternalId( Incidence * inc )
918{ 918{
919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
920 checkExternSyncEvent( lastSync, inc ); 920 checkExternSyncEvent( lastSync, inc );
921 921
922} 922}
923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
924{ 924{
925 bool syncOK = true; 925 bool syncOK = true;
926 int addedEvent = 0; 926 int addedEvent = 0;
927 int addedEventR = 0; 927 int addedEventR = 0;
928 int deletedEventR = 0; 928 int deletedEventR = 0;
929 int deletedEventL = 0; 929 int deletedEventL = 0;
930 int changedLocal = 0; 930 int changedLocal = 0;
931 int changedRemote = 0; 931 int changedRemote = 0;
932 //QPtrList<Event> el = local->rawEvents(); 932 //QPtrList<Event> el = local->rawEvents();
933 Event* eventR; 933 Event* eventR;
934 QString uid; 934 QString uid;
935 int take; 935 int take;
936 Event* eventL; 936 Event* eventL;
937 Event* eventRSync; 937 Event* eventRSync;
938 Event* eventLSync; 938 Event* eventLSync;
939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
941 bool fullDateRange = false; 941 bool fullDateRange = false;
942 mLastCalendarSync = QDateTime::currentDateTime(); 942 mLastCalendarSync = QDateTime::currentDateTime();
943 QDateTime modifiedCalendar = mLastCalendarSync;; 943 QDateTime modifiedCalendar = mLastCalendarSync;;
944 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 944 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
945 if ( eventR ) { 945 if ( eventR ) {
946 eventRSync = (Event*) eventR->clone(); 946 eventRSync = (Event*) eventR->clone();
947 remote->deleteEvent(eventR ); 947 remote->deleteEvent(eventR );
948 948
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 eventLSync = getLastSyncEvent(); 958 eventLSync = getLastSyncEvent();
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 ( fullDateRange ) 970 if ( fullDateRange )
971 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 971 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
972 else 972 else
973 mLastCalendarSync = eventLSync->dtStart(); 973 mLastCalendarSync = eventLSync->dtStart();
974 // for resyncing if own file has changed 974 // for resyncing if own file has changed
975 if ( mCurrentSyncDevice == "deleteaftersync" ) { 975 if ( mCurrentSyncDevice == "deleteaftersync" ) {
976 mLastCalendarSync = loadedFileVersion; 976 mLastCalendarSync = loadedFileVersion;
977 qDebug("setting mLastCalendarSync "); 977 qDebug("setting mLastCalendarSync ");
978 } 978 }
979 //qDebug("*************************** "); 979 //qDebug("*************************** ");
980 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 980 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
981 QPtrList<Incidence> er = remote->rawIncidences(); 981 QPtrList<Incidence> er = remote->rawIncidences();
982 Incidence* inR = er.first(); 982 Incidence* inR = er.first();
983 Incidence* inL; 983 Incidence* inL;
984 QProgressBar bar( er.count(),0 ); 984 QProgressBar bar( er.count(),0 );
985 bar.setCaption (i18n("Syncing - close to abort!") ); 985 bar.setCaption (i18n("Syncing - close to abort!") );
986 986
987 int w = 300; 987 int w = 300;
988 if ( QApplication::desktop()->width() < 320 ) 988 if ( QApplication::desktop()->width() < 320 )
989 w = 220; 989 w = 220;
990 int h = bar.sizeHint().height() ; 990 int h = bar.sizeHint().height() ;
991 int dw = QApplication::desktop()->width(); 991 int dw = QApplication::desktop()->width();
992 int dh = QApplication::desktop()->height(); 992 int dh = QApplication::desktop()->height();
993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
994 bar.show(); 994 bar.show();
995 int modulo = (er.count()/10)+1; 995 int modulo = (er.count()/10)+1;
996 int incCounter = 0; 996 int incCounter = 0;
997 while ( inR ) { 997 while ( inR ) {
998 if ( ! bar.isVisible() ) 998 if ( ! bar.isVisible() )
999 return false; 999 return false;
1000 if ( incCounter % modulo == 0 ) 1000 if ( incCounter % modulo == 0 )
1001 bar.setProgress( incCounter ); 1001 bar.setProgress( incCounter );
1002 ++incCounter; 1002 ++incCounter;
1003 uid = inR->uid(); 1003 uid = inR->uid();
1004 bool skipIncidence = false; 1004 bool skipIncidence = false;
1005 if ( uid.left(15) == QString("last-syncEvent-") ) 1005 if ( uid.left(15) == QString("last-syncEvent-") )
1006 skipIncidence = true; 1006 skipIncidence = true;
1007 1007
1008 qApp->processEvents(); 1008 qApp->processEvents();
1009 if ( !skipIncidence ) { 1009 if ( !skipIncidence ) {
1010 inL = local->incidence( uid ); 1010 inL = local->incidence( uid );
1011 if ( inL ) { // maybe conflict - same uid in both calendars 1011 if ( inL ) { // maybe conflict - same uid in both calendars
1012 int maxrev = inL->revision(); 1012 int maxrev = inL->revision();
1013 if ( maxrev < inR->revision() ) 1013 if ( maxrev < inR->revision() )
1014 maxrev = inR->revision(); 1014 maxrev = inR->revision();
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 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1020 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1021 remote->deleteIncidence( inR ); 1021 remote->deleteIncidence( inR );
1022 if ( inL->revision() < maxrev ) 1022 if ( inL->revision() < maxrev )
1023 inL->setRevision( maxrev ); 1023 inL->setRevision( maxrev );
1024 remote->addIncidence( inL->clone() ); 1024 remote->addIncidence( inL->clone() );
1025 ++changedRemote; 1025 ++changedRemote;
1026 } else { 1026 } else {
1027 if ( inR->revision() < maxrev ) 1027 if ( inR->revision() < maxrev )
1028 inR->setRevision( maxrev ); 1028 inR->setRevision( maxrev );
1029 local->deleteIncidence( inL ); 1029 local->deleteIncidence( inL );
1030 local->addIncidence( inR->clone() ); 1030 local->addIncidence( inR->clone() );
1031 ++changedLocal; 1031 ++changedLocal;
1032 } 1032 }
1033 } 1033 }
1034 } else { // no conflict 1034 } else { // no conflict
1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1036 QString des = eventLSync->description(); 1036 QString des = eventLSync->description();
1037 QString pref = "e"; 1037 QString pref = "e";
1038 if ( inR->type() == "Todo" ) 1038 if ( inR->type() == "Todo" )
1039 pref = "t"; 1039 pref = "t";
1040 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1040 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1041 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1042 //remote->deleteIncidence( inR ); 1042 //remote->deleteIncidence( inR );
1043 ++deletedEventR; 1043 ++deletedEventR;
1044 } else { 1044 } else {
1045 inR->setLastModified( modifiedCalendar ); 1045 inR->setLastModified( modifiedCalendar );
1046 local->addIncidence( inR->clone() ); 1046 local->addIncidence( inR->clone() );
1047 ++addedEvent; 1047 ++addedEvent;
1048 } 1048 }
1049 } else { 1049 } else {
1050 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1050 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1051 inR->setLastModified( modifiedCalendar ); 1051 inR->setLastModified( modifiedCalendar );
1052 local->addIncidence( inR->clone() ); 1052 local->addIncidence( inR->clone() );
1053 ++addedEvent; 1053 ++addedEvent;
1054 } else { 1054 } else {
1055 checkExternSyncEvent(eventRSyncSharp, inR); 1055 checkExternSyncEvent(eventRSyncSharp, inR);
1056 remote->deleteIncidence( inR ); 1056 remote->deleteIncidence( inR );
1057 ++deletedEventR; 1057 ++deletedEventR;
1058 } 1058 }
1059 } 1059 }
1060 } 1060 }
1061 } 1061 }
1062 inR = er.next(); 1062 inR = er.next();
1063 } 1063 }
1064 QPtrList<Incidence> el = local->rawIncidences(); 1064 QPtrList<Incidence> el = local->rawIncidences();
1065 inL = el.first(); 1065 inL = el.first();
1066 modulo = (el.count()/10)+1; 1066 modulo = (el.count()/10)+1;
1067 bar.setCaption (i18n("Add / remove events") ); 1067 bar.setCaption (i18n("Add / remove events") );
1068 bar.setTotalSteps ( el.count() ) ; 1068 bar.setTotalSteps ( el.count() ) ;
1069 bar.show(); 1069 bar.show();
1070 incCounter = 0; 1070 incCounter = 0;
1071 1071
1072 while ( inL ) { 1072 while ( inL ) {
1073 1073
1074 qApp->processEvents(); 1074 qApp->processEvents();
1075 if ( ! bar.isVisible() ) 1075 if ( ! bar.isVisible() )
1076 return false; 1076 return false;
1077 if ( incCounter % modulo == 0 ) 1077 if ( incCounter % modulo == 0 )
1078 bar.setProgress( incCounter ); 1078 bar.setProgress( incCounter );
1079 ++incCounter; 1079 ++incCounter;
1080 uid = inL->uid(); 1080 uid = inL->uid();
1081 bool skipIncidence = false; 1081 bool skipIncidence = false;
1082 if ( uid.left(15) == QString("last-syncEvent-") ) 1082 if ( uid.left(15) == QString("last-syncEvent-") )
1083 skipIncidence = true; 1083 skipIncidence = true;
1084 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1084 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1085 skipIncidence = true; 1085 skipIncidence = true;
1086 if ( !skipIncidence ) { 1086 if ( !skipIncidence ) {
1087 inR = remote->incidence( uid ); 1087 inR = remote->incidence( uid );
1088 if ( ! inR ) { 1088 if ( ! inR ) {
1089 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1089 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1090 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1090 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1091 local->deleteIncidence( inL ); 1091 local->deleteIncidence( inL );
1092 ++deletedEventL; 1092 ++deletedEventL;
1093 } else { 1093 } else {
1094 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1094 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1095 inL->removeID(mCurrentSyncDevice ); 1095 inL->removeID(mCurrentSyncDevice );
1096 ++addedEventR; 1096 ++addedEventR;
1097 inL->setLastModified( modifiedCalendar ); 1097 inL->setLastModified( modifiedCalendar );
1098 remote->addIncidence( inL->clone() ); 1098 remote->addIncidence( inL->clone() );
1099 } 1099 }
1100 } 1100 }
1101 } else { 1101 } else {
1102 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1102 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1103 checkExternSyncEvent(eventLSyncSharp, inL); 1103 checkExternSyncEvent(eventLSyncSharp, inL);
1104 local->deleteIncidence( inL ); 1104 local->deleteIncidence( inL );
1105 ++deletedEventL; 1105 ++deletedEventL;
1106 } else { 1106 } else {
1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1108 ++addedEventR; 1108 ++addedEventR;
1109 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1110 remote->addIncidence( inL->clone() ); 1110 remote->addIncidence( inL->clone() );
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 } 1115 }
1116 inL = el.next(); 1116 inL = el.next();
1117 } 1117 }
1118 1118
1119 bar.hide(); 1119 bar.hide();
1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1121 eventLSync->setReadOnly( false ); 1121 eventLSync->setReadOnly( false );
1122 eventLSync->setDtStart( mLastCalendarSync ); 1122 eventLSync->setDtStart( mLastCalendarSync );
1123 eventRSync->setDtStart( mLastCalendarSync ); 1123 eventRSync->setDtStart( mLastCalendarSync );
1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1128 eventLSync->setReadOnly( true ); 1128 eventLSync->setReadOnly( true );
1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1130 remote->addEvent( eventRSync ); 1130 remote->addEvent( eventRSync );
1131 QString mes; 1131 QString mes;
1132 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 ); 1132 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 );
1133 if ( KOPrefs::instance()->mShowSyncSummary ) { 1133 if ( KOPrefs::instance()->mShowSyncSummary ) {
1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1135 } 1135 }
1136 qDebug( mes ); 1136 qDebug( mes );
1137 mCalendar->checkAlarmForIncidence( 0, true ); 1137 mCalendar->checkAlarmForIncidence( 0, true );
1138 return syncOK; 1138 return syncOK;
1139} 1139}
1140 1140
1141void CalendarView::setSyncDevice( QString s ) 1141void CalendarView::setSyncDevice( QString s )
1142{ 1142{
1143 mCurrentSyncDevice= s; 1143 mCurrentSyncDevice= s;
1144} 1144}
1145void CalendarView::setSyncName( QString s ) 1145void CalendarView::setSyncName( QString s )
1146{ 1146{
1147 mCurrentSyncName= s; 1147 mCurrentSyncName= s;
1148} 1148}
1149bool CalendarView::syncCalendar(QString filename, int mode) 1149bool CalendarView::syncCalendar(QString filename, int mode)
1150{ 1150{
1151 mGlobalSyncMode = SYNC_MODE_NORMAL; 1151 mGlobalSyncMode = SYNC_MODE_NORMAL;
1152 CalendarLocal* calendar = new CalendarLocal(); 1152 CalendarLocal* calendar = new CalendarLocal();
1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1154 FileStorage* storage = new FileStorage( calendar ); 1154 FileStorage* storage = new FileStorage( calendar );
1155 bool syncOK = false; 1155 bool syncOK = false;
1156 storage->setFileName( filename ); 1156 storage->setFileName( filename );
1157 // qDebug("loading ... "); 1157 // qDebug("loading ... ");
1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1159 getEventViewerDialog()->setSyncMode( true ); 1159 getEventViewerDialog()->setSyncMode( true );
1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1161 getEventViewerDialog()->setSyncMode( false ); 1161 getEventViewerDialog()->setSyncMode( false );
1162 if ( syncOK ) { 1162 if ( syncOK ) {
1163 if ( KOPrefs::instance()->mWriteBackFile ) 1163 if ( KOPrefs::instance()->mWriteBackFile )
1164 { 1164 {
1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1166 storage->save(); 1166 storage->save();
1167 } 1167 }
1168 } 1168 }
1169 setModified( true ); 1169 setModified( true );
1170 } 1170 }
1171 delete storage; 1171 delete storage;
1172 delete calendar; 1172 delete calendar;
1173 if ( syncOK ) 1173 if ( syncOK )
1174 updateView(); 1174 updateView();
1175 return syncOK; 1175 return syncOK;
1176} 1176}
1177void CalendarView::syncPhone() 1177void CalendarView::syncPhone()
1178{ 1178{
1179 syncExternal( 1 ); 1179 syncExternal( 1 );
1180} 1180}
1181void CalendarView::syncExternal( int mode ) 1181void CalendarView::syncExternal( int mode )
1182{ 1182{
1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1184 //mCurrentSyncDevice = "sharp-DTM"; 1184 //mCurrentSyncDevice = "sharp-DTM";
1185 if ( KOPrefs::instance()->mAskForPreferences ) 1185 if ( KOPrefs::instance()->mAskForPreferences )
1186 edit_sync_options(); 1186 edit_sync_options();
1187 qApp->processEvents(); 1187 qApp->processEvents();
1188 CalendarLocal* calendar = new CalendarLocal(); 1188 CalendarLocal* calendar = new CalendarLocal();
1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1190 bool syncOK = false; 1190 bool syncOK = false;
1191 bool loadSuccess = false; 1191 bool loadSuccess = false;
1192 PhoneFormat* phoneFormat = 0; 1192 PhoneFormat* phoneFormat = 0;
1193#ifndef DESKTOP_VERSION 1193#ifndef DESKTOP_VERSION
1194 SharpFormat* sharpFormat = 0; 1194 SharpFormat* sharpFormat = 0;
1195 if ( mode == 0 ) { // sharp 1195 if ( mode == 0 ) { // sharp
1196 sharpFormat = new SharpFormat () ; 1196 sharpFormat = new SharpFormat () ;
1197 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1197 loadSuccess = sharpFormat->load( calendar, mCalendar );
1198 1198
1199 } else 1199 } else
1200#endif 1200#endif
1201 if ( mode == 1 ) { // phone 1201 if ( mode == 1 ) { // phone
1202 phoneFormat = new PhoneFormat (); 1202 phoneFormat = new PhoneFormat ();
1203 loadSuccess = phoneFormat->load( calendar, mCalendar ); 1203 loadSuccess = phoneFormat->load( calendar,
1204 mCalendar,
1205 mCurrentSyncDevice,
1206 KOPrefs::instance()->mPhoneDevice,
1207 KOPrefs::instance()->mPhoneConnection,
1208 KOPrefs::instance()->mPhoneModel);
1204 1209
1205 } else 1210 } else
1206 return; 1211 return;
1207 if ( loadSuccess ) { 1212 if ( loadSuccess ) {
1208 getEventViewerDialog()->setSyncMode( true ); 1213 getEventViewerDialog()->setSyncMode( true );
1209 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1214 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1210 getEventViewerDialog()->setSyncMode( false ); 1215 getEventViewerDialog()->setSyncMode( false );
1211 qApp->processEvents(); 1216 qApp->processEvents();
1212 if ( syncOK ) { 1217 if ( syncOK ) {
1213 if ( KOPrefs::instance()->mWriteBackFile ) 1218 if ( KOPrefs::instance()->mWriteBackFile )
1214 { 1219 {
1215 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1220 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1216 Incidence* inc = iL.first(); 1221 Incidence* inc = iL.first();
1217 /* obsolete 1222 /* obsolete
1218 while ( inc ) { 1223 while ( inc ) {
1219 inc->setZaurusStat( inc->revision () ); 1224 inc->setZaurusStat( inc->revision () );
1220 inc = iL.next(); 1225 inc = iL.next();
1221 } 1226 }
1222 */ 1227 */
1223#ifndef DESKTOP_VERSION 1228#ifndef DESKTOP_VERSION
1224 if ( sharpFormat ) 1229 if ( sharpFormat )
1225 sharpFormat->save(calendar); 1230 sharpFormat->save(calendar);
1226#endif 1231#endif
1227 if ( phoneFormat ) 1232 if ( phoneFormat )
1228 phoneFormat->save(calendar); 1233 phoneFormat->save(calendar);
1229 iL = calendar->rawIncidences(); 1234 iL = calendar->rawIncidences();
1230 inc = iL.first(); 1235 inc = iL.first();
1231 Incidence* loc; 1236 Incidence* loc;
1232 while ( inc ) { 1237 while ( inc ) {
1233 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1238 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1234 loc = mCalendar->incidence(inc->uid() ); 1239 loc = mCalendar->incidence(inc->uid() );
1235 if ( loc ) { 1240 if ( loc ) {
1236 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1241 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1237 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1242 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1238 } 1243 }
1239 } 1244 }
1240 inc = iL.next(); 1245 inc = iL.next();
1241 } 1246 }
1242 Incidence* lse = getLastSyncEvent(); 1247 Incidence* lse = getLastSyncEvent();
1243 if ( lse ) { 1248 if ( lse ) {
1244 lse->setReadOnly( false ); 1249 lse->setReadOnly( false );
1245 lse->setDescription( "" ); 1250 lse->setDescription( "" );
1246 lse->setReadOnly( true ); 1251 lse->setReadOnly( true );
1247 } 1252 }
1248 } 1253 }
1249 } 1254 }
1250 setModified( true ); 1255 setModified( true );
1251 } else { 1256 } else {
1252 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1257 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1253 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1258 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1254 question, i18n("Ok")) ; 1259 question, i18n("Ok")) ;
1255 1260
1256 } 1261 }
1257 delete calendar; 1262 delete calendar;
1258 updateView(); 1263 updateView();
1259 return ;//syncOK; 1264 return ;//syncOK;
1260 1265
1261} 1266}
1262void CalendarView::syncSharp() 1267void CalendarView::syncSharp()
1263{ 1268{
1264 syncExternal( 0 ); 1269 syncExternal( 0 );
1265 1270
1266} 1271}
1267 1272
1268 1273
1269#include <kabc/stdaddressbook.h> 1274#include <kabc/stdaddressbook.h>
1270bool CalendarView::importBday() 1275bool CalendarView::importBday()
1271{ 1276{
1272 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1277 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1273 KABC::AddressBook::Iterator it; 1278 KABC::AddressBook::Iterator it;
1274 int count = 0; 1279 int count = 0;
1275 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1280 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1276 ++count; 1281 ++count;
1277 } 1282 }
1278 QProgressBar bar(count,0 ); 1283 QProgressBar bar(count,0 );
1279 int w = 300; 1284 int w = 300;
1280 if ( QApplication::desktop()->width() < 320 ) 1285 if ( QApplication::desktop()->width() < 320 )
1281 w = 220; 1286 w = 220;
1282 int h = bar.sizeHint().height() ; 1287 int h = bar.sizeHint().height() ;
1283 int dw = QApplication::desktop()->width(); 1288 int dw = QApplication::desktop()->width();
1284 int dh = QApplication::desktop()->height(); 1289 int dh = QApplication::desktop()->height();
1285 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1290 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1286 bar.show(); 1291 bar.show();
1287 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1292 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1288 qApp->processEvents(); 1293 qApp->processEvents();
1289 count = 0; 1294 count = 0;
1290 int addCount = 0; 1295 int addCount = 0;
1291 KCal::Attendee* a = 0; 1296 KCal::Attendee* a = 0;
1292 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1297 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1293 if ( ! bar.isVisible() ) 1298 if ( ! bar.isVisible() )
1294 return false; 1299 return false;
1295 bar.setProgress( count++ ); 1300 bar.setProgress( count++ );
1296 qApp->processEvents(); 1301 qApp->processEvents();
1297 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1302 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1298 if ( (*it).birthday().date().isValid() ){ 1303 if ( (*it).birthday().date().isValid() ){
1299 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1304 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1300 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1305 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1301 ++addCount; 1306 ++addCount;
1302 } 1307 }
1303 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1308 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1304 if ( anni.isValid() ){ 1309 if ( anni.isValid() ){
1305 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1310 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1306 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1311 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1307 ++addCount; 1312 ++addCount;
1308 } 1313 }
1309 } 1314 }
1310 updateView(); 1315 updateView();
1311 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1316 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1312 return true; 1317 return true;
1313} 1318}
1314 1319
1315bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1320bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1316{ 1321{
1317 //qDebug("addAnni "); 1322 //qDebug("addAnni ");
1318 Event * ev = new Event(); 1323 Event * ev = new Event();
1319 if ( a ) { 1324 if ( a ) {
1320 ev->addAttendee( a ); 1325 ev->addAttendee( a );
1321 } 1326 }
1322 QString kind; 1327 QString kind;
1323 if ( birthday ) 1328 if ( birthday )
1324 kind = i18n( "Birthday" ); 1329 kind = i18n( "Birthday" );
1325 else 1330 else
1326 kind = i18n( "Anniversary" ); 1331 kind = i18n( "Anniversary" );
1327 ev->setSummary( name + " - " + kind ); 1332 ev->setSummary( name + " - " + kind );
1328 ev->setOrganizer( "nobody@nowhere" ); 1333 ev->setOrganizer( "nobody@nowhere" );
1329 ev->setCategories( kind ); 1334 ev->setCategories( kind );
1330 ev->setDtStart( QDateTime(date) ); 1335 ev->setDtStart( QDateTime(date) );
1331 ev->setDtEnd( QDateTime(date) ); 1336 ev->setDtEnd( QDateTime(date) );
1332 ev->setFloats( true ); 1337 ev->setFloats( true );
1333 Recurrence * rec = ev->recurrence(); 1338 Recurrence * rec = ev->recurrence();
1334 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1339 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1335 rec->addYearlyNum( date.month() ); 1340 rec->addYearlyNum( date.month() );
1336 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1341 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1337 delete ev; 1342 delete ev;
1338 return false; 1343 return false;
1339 } 1344 }
1340 return true; 1345 return true;
1341 1346
1342} 1347}
1343bool CalendarView::importQtopia( const QString &categories, 1348bool CalendarView::importQtopia( const QString &categories,
1344 const QString &datebook, 1349 const QString &datebook,
1345 const QString &todolist ) 1350 const QString &todolist )
1346{ 1351{
1347 1352
1348 QtopiaFormat qtopiaFormat; 1353 QtopiaFormat qtopiaFormat;
1349 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1354 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1350 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1355 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1351 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1356 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1352 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1357 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1353 1358
1354 updateView(); 1359 updateView();
1355 return true; 1360 return true;
1356 1361
1357#if 0 1362#if 0
1358 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1363 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1359 mCurrentSyncDevice = "qtopia-XML"; 1364 mCurrentSyncDevice = "qtopia-XML";
1360 if ( KOPrefs::instance()->mAskForPreferences ) 1365 if ( KOPrefs::instance()->mAskForPreferences )
1361 edit_sync_options(); 1366 edit_sync_options();
1362 qApp->processEvents(); 1367 qApp->processEvents();
1363 CalendarLocal* calendar = new CalendarLocal(); 1368 CalendarLocal* calendar = new CalendarLocal();
1364 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1369 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1365 bool syncOK = false; 1370 bool syncOK = false;
1366 QtopiaFormat qtopiaFormat; 1371 QtopiaFormat qtopiaFormat;
1367 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1372 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1368 bool loadOk = true; 1373 bool loadOk = true;
1369 if ( !categories.isEmpty() ) 1374 if ( !categories.isEmpty() )
1370 loadOk = qtopiaFormat.load( calendar, categories ); 1375 loadOk = qtopiaFormat.load( calendar, categories );
1371 if ( loadOk && !datebook.isEmpty() ) 1376 if ( loadOk && !datebook.isEmpty() )
1372 loadOk = qtopiaFormat.load( calendar, datebook ); 1377 loadOk = qtopiaFormat.load( calendar, datebook );
1373 if ( loadOk && !todolist.isEmpty() ) 1378 if ( loadOk && !todolist.isEmpty() )
1374 loadOk = qtopiaFormat.load( calendar, todolist ); 1379 loadOk = qtopiaFormat.load( calendar, todolist );
1375 1380
1376 if ( loadOk ) { 1381 if ( loadOk ) {
1377 getEventViewerDialog()->setSyncMode( true ); 1382 getEventViewerDialog()->setSyncMode( true );
1378 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1383 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1379 getEventViewerDialog()->setSyncMode( false ); 1384 getEventViewerDialog()->setSyncMode( false );
1380 qApp->processEvents(); 1385 qApp->processEvents();
1381 if ( syncOK ) { 1386 if ( syncOK ) {
1382 if ( KOPrefs::instance()->mWriteBackFile ) 1387 if ( KOPrefs::instance()->mWriteBackFile )
1383 { 1388 {
1384 // write back XML file 1389 // write back XML file
1385 1390
1386 } 1391 }
1387 setModified( true ); 1392 setModified( true );
1388 } 1393 }
1389 } else { 1394 } else {
1390 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1395 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1391 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1396 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1392 question, i18n("Ok")) ; 1397 question, i18n("Ok")) ;
1393 } 1398 }
1394 delete calendar; 1399 delete calendar;
1395 updateView(); 1400 updateView();
1396 return syncOK; 1401 return syncOK;
1397 1402
1398 1403
1399#endif 1404#endif
1400 1405
1401} 1406}
1402 1407
1403void CalendarView::setSyncEventsReadOnly() 1408void CalendarView::setSyncEventsReadOnly()
1404{ 1409{
1405 Event * ev; 1410 Event * ev;
1406 QPtrList<Event> eL = mCalendar->rawEvents(); 1411 QPtrList<Event> eL = mCalendar->rawEvents();
1407 ev = eL.first(); 1412 ev = eL.first();
1408 while ( ev ) { 1413 while ( ev ) {
1409 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1414 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1410 ev->setReadOnly( true ); 1415 ev->setReadOnly( true );
1411 ev = eL.next(); 1416 ev = eL.next();
1412 } 1417 }
1413} 1418}
1414bool CalendarView::openCalendar(QString filename, bool merge) 1419bool CalendarView::openCalendar(QString filename, bool merge)
1415{ 1420{
1416 1421
1417 if (filename.isEmpty()) { 1422 if (filename.isEmpty()) {
1418 return false; 1423 return false;
1419 } 1424 }
1420 1425
1421 if (!QFile::exists(filename)) { 1426 if (!QFile::exists(filename)) {
1422 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1427 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1423 return false; 1428 return false;
1424 } 1429 }
1425 1430
1426 globalFlagBlockAgenda = 1; 1431 globalFlagBlockAgenda = 1;
1427 if (!merge) mCalendar->close(); 1432 if (!merge) mCalendar->close();
1428 1433
1429 mStorage->setFileName( filename ); 1434 mStorage->setFileName( filename );
1430 1435
1431 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1436 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1432 if ( merge ) ;//setModified( true ); 1437 if ( merge ) ;//setModified( true );
1433 else { 1438 else {
1434 //setModified( true ); 1439 //setModified( true );
1435 mViewManager->setDocumentId( filename ); 1440 mViewManager->setDocumentId( filename );
1436 mDialogManager->setDocumentId( filename ); 1441 mDialogManager->setDocumentId( filename );
1437 mTodoList->setDocumentId( filename ); 1442 mTodoList->setDocumentId( filename );
1438 } 1443 }
1439 globalFlagBlockAgenda = 2; 1444 globalFlagBlockAgenda = 2;
1440 // if ( getLastSyncEvent() ) 1445 // if ( getLastSyncEvent() )
1441 // getLastSyncEvent()->setReadOnly( true ); 1446 // getLastSyncEvent()->setReadOnly( true );
1442 mCalendar->reInitAlarmSettings(); 1447 mCalendar->reInitAlarmSettings();
1443 setSyncEventsReadOnly(); 1448 setSyncEventsReadOnly();
1444 updateUnmanagedViews(); 1449 updateUnmanagedViews();
1445 updateView(); 1450 updateView();
1446 if ( filename != MainWindow::defaultFileName() ) 1451 if ( filename != MainWindow::defaultFileName() )
1447 saveCalendar( MainWindow::defaultFileName() ); 1452 saveCalendar( MainWindow::defaultFileName() );
1448 loadedFileVersion = QDateTime::currentDateTime(); 1453 loadedFileVersion = QDateTime::currentDateTime();
1449 return true; 1454 return true;
1450 } else { 1455 } else {
1451 // while failing to load, the calendar object could 1456 // while failing to load, the calendar object could
1452 // have become partially populated. Clear it out. 1457 // have become partially populated. Clear it out.
1453 if ( !merge ) mCalendar->close(); 1458 if ( !merge ) mCalendar->close();
1454 1459
1455 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1460 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1456 1461
1457 globalFlagBlockAgenda = 2; 1462 globalFlagBlockAgenda = 2;
1458 updateView(); 1463 updateView();
1459 } 1464 }
1460 return false; 1465 return false;
1461} 1466}
1462void CalendarView::setLoadedFileVersion(QDateTime dt) 1467void CalendarView::setLoadedFileVersion(QDateTime dt)
1463{ 1468{
1464 loadedFileVersion = dt; 1469 loadedFileVersion = dt;
1465} 1470}
1466bool CalendarView::checkFileChanged(QString fn) 1471bool CalendarView::checkFileChanged(QString fn)
1467{ 1472{
1468 QFileInfo finf ( fn ); 1473 QFileInfo finf ( fn );
1469 if ( !finf.exists() ) 1474 if ( !finf.exists() )
1470 return true; 1475 return true;
1471 QDateTime dt = finf.lastModified (); 1476 QDateTime dt = finf.lastModified ();
1472 if ( dt <= loadedFileVersion ) 1477 if ( dt <= loadedFileVersion )
1473 return false; 1478 return false;
1474 return true; 1479 return true;
1475 1480
1476} 1481}
1477bool CalendarView::checkFileVersion(QString fn) 1482bool CalendarView::checkFileVersion(QString fn)
1478{ 1483{
1479 QFileInfo finf ( fn ); 1484 QFileInfo finf ( fn );
1480 if ( !finf.exists() ) 1485 if ( !finf.exists() )
1481 return true; 1486 return true;
1482 QDateTime dt = finf.lastModified (); 1487 QDateTime dt = finf.lastModified ();
1483 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1488 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1484 //qDebug("file on disk version %s",dt.toString().latin1()); 1489 //qDebug("file on disk version %s",dt.toString().latin1());
1485 if ( dt <= loadedFileVersion ) 1490 if ( dt <= loadedFileVersion )
1486 return true; 1491 return true;
1487 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1492 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1488 i18n("KO/Pi Warning"),i18n("Overwrite"), 1493 i18n("KO/Pi Warning"),i18n("Overwrite"),
1489 i18n("Sync+save")); 1494 i18n("Sync+save"));
1490 1495
1491 if ( km == KMessageBox::Cancel ) 1496 if ( km == KMessageBox::Cancel )
1492 return false; 1497 return false;
1493 if ( km == KMessageBox::Yes ) 1498 if ( km == KMessageBox::Yes )
1494 return true; 1499 return true;
1495 1500
1496 setSyncDevice("deleteaftersync" ); 1501 setSyncDevice("deleteaftersync" );
1497 KOPrefs::instance()->mAskForPreferences = true; 1502 KOPrefs::instance()->mAskForPreferences = true;
1498 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1503 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1499 KOPrefs::instance()->mWriteBackFile = false; 1504 KOPrefs::instance()->mWriteBackFile = false;
1500 KOPrefs::instance()->mWriteBackExistingOnly = false; 1505 KOPrefs::instance()->mWriteBackExistingOnly = false;
1501 KOPrefs::instance()->mShowSyncSummary = false; 1506 KOPrefs::instance()->mShowSyncSummary = false;
1502 syncCalendar( fn, 3 ); 1507 syncCalendar( fn, 3 );
1503 Event * e = getLastSyncEvent(); 1508 Event * e = getLastSyncEvent();
1504 mCalendar->deleteEvent ( e ); 1509 mCalendar->deleteEvent ( e );
1505 updateView(); 1510 updateView();
1506 return true; 1511 return true;
1507} 1512}
1508 1513
1509bool CalendarView::saveCalendar( QString filename ) 1514bool CalendarView::saveCalendar( QString filename )
1510{ 1515{
1511 1516
1512 // Store back all unsaved data into calendar object 1517 // Store back all unsaved data into calendar object
1513 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1518 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1514 if ( mViewManager->currentView() ) 1519 if ( mViewManager->currentView() )
1515 mViewManager->currentView()->flushView(); 1520 mViewManager->currentView()->flushView();
1516 1521
1517 //mStorage->setFileName( filename ); 1522 //mStorage->setFileName( filename );
1518 1523
1519 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1524 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1520 mStorage->setFileName( filename ); 1525 mStorage->setFileName( filename );
1521 bool success; 1526 bool success;
1522 success = mStorage->save(); 1527 success = mStorage->save();
1523 if ( !success ) { 1528 if ( !success ) {
1524 return false; 1529 return false;
1525 } 1530 }
1526 1531
1527 return true; 1532 return true;
1528} 1533}
1529 1534
1530void CalendarView::closeCalendar() 1535void CalendarView::closeCalendar()
1531{ 1536{
1532 1537
1533 // child windows no longer valid 1538 // child windows no longer valid
1534 emit closingDown(); 1539 emit closingDown();
1535 1540
1536 mCalendar->close(); 1541 mCalendar->close();
1537 setModified(false); 1542 setModified(false);
1538 updateView(); 1543 updateView();
1539} 1544}
1540 1545
1541void CalendarView::archiveCalendar() 1546void CalendarView::archiveCalendar()
1542{ 1547{
1543 mDialogManager->showArchiveDialog(); 1548 mDialogManager->showArchiveDialog();
1544} 1549}
1545 1550
1546 1551
1547void CalendarView::readSettings() 1552void CalendarView::readSettings()
1548{ 1553{
1549 1554
1550 1555
1551 // mViewManager->showAgendaView(); 1556 // mViewManager->showAgendaView();
1552 QString str; 1557 QString str;
1553 //qDebug("CalendarView::readSettings() "); 1558 //qDebug("CalendarView::readSettings() ");
1554 // read settings from the KConfig, supplying reasonable 1559 // read settings from the KConfig, supplying reasonable
1555 // defaults where none are to be found 1560 // defaults where none are to be found
1556 KConfig *config = KOGlobals::config(); 1561 KConfig *config = KOGlobals::config();
1557#ifndef KORG_NOSPLITTER 1562#ifndef KORG_NOSPLITTER
1558 config->setGroup("KOrganizer Geometry"); 1563 config->setGroup("KOrganizer Geometry");
1559 1564
1560 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1565 QValueList<int> sizes = config->readIntListEntry("Separator1");
1561 if (sizes.count() != 2) { 1566 if (sizes.count() != 2) {
1562 sizes << mDateNavigator->minimumSizeHint().width(); 1567 sizes << mDateNavigator->minimumSizeHint().width();
1563 sizes << 300; 1568 sizes << 300;
1564 } 1569 }
1565 mPanner->setSizes(sizes); 1570 mPanner->setSizes(sizes);
1566 1571
1567 sizes = config->readIntListEntry("Separator2"); 1572 sizes = config->readIntListEntry("Separator2");
1568 if ( ( mResourceView && sizes.count() == 4 ) || 1573 if ( ( mResourceView && sizes.count() == 4 ) ||
1569 ( !mResourceView && sizes.count() == 3 ) ) { 1574 ( !mResourceView && sizes.count() == 3 ) ) {
1570 mLeftSplitter->setSizes(sizes); 1575 mLeftSplitter->setSizes(sizes);
1571 } 1576 }
1572#endif 1577#endif
1573 globalFlagBlockAgenda = 1; 1578 globalFlagBlockAgenda = 1;
1574 mViewManager->showAgendaView(); 1579 mViewManager->showAgendaView();
1575 //mViewManager->readSettings( config ); 1580 //mViewManager->readSettings( config );
1576 mTodoList->restoreLayout(config,QString("Todo Layout")); 1581 mTodoList->restoreLayout(config,QString("Todo Layout"));
1577 readFilterSettings(config); 1582 readFilterSettings(config);
1578 config->setGroup( "Views" ); 1583 config->setGroup( "Views" );
1579 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1584 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1580 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1585 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1581 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1586 else if ( dateCount == 7 ) mNavigator->selectWeek();
1582 else mNavigator->selectDates( dateCount ); 1587 else mNavigator->selectDates( dateCount );
1583 // mViewManager->readSettings( config ); 1588 // mViewManager->readSettings( config );
1584 updateConfig(); 1589 updateConfig();
1585 globalFlagBlockAgenda = 2; 1590 globalFlagBlockAgenda = 2;
1586 mViewManager->readSettings( config ); 1591 mViewManager->readSettings( config );
1587#ifdef DESKTOP_VERSION 1592#ifdef DESKTOP_VERSION
1588 config->setGroup("WidgetLayout"); 1593 config->setGroup("WidgetLayout");
1589 QStringList list; 1594 QStringList list;
1590 list = config->readListEntry("MainLayout"); 1595 list = config->readListEntry("MainLayout");
1591 int x,y,w,h; 1596 int x,y,w,h;
1592 if ( ! list.isEmpty() ) { 1597 if ( ! list.isEmpty() ) {
1593 x = list[0].toInt(); 1598 x = list[0].toInt();
1594 y = list[1].toInt(); 1599 y = list[1].toInt();
1595 w = list[2].toInt(); 1600 w = list[2].toInt();
1596 h = list[3].toInt(); 1601 h = list[3].toInt();
1597 topLevelWidget()->setGeometry(x,y,w,h); 1602 topLevelWidget()->setGeometry(x,y,w,h);
1598 1603
1599 } else { 1604 } else {
1600 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1605 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1601 } 1606 }
1602 list = config->readListEntry("EditEventLayout"); 1607 list = config->readListEntry("EditEventLayout");
1603 if ( ! list.isEmpty() ) { 1608 if ( ! list.isEmpty() ) {
1604 x = list[0].toInt(); 1609 x = list[0].toInt();
1605 y = list[1].toInt(); 1610 y = list[1].toInt();
1606 w = list[2].toInt(); 1611 w = list[2].toInt();
1607 h = list[3].toInt(); 1612 h = list[3].toInt();
1608 mEventEditor->setGeometry(x,y,w,h); 1613 mEventEditor->setGeometry(x,y,w,h);
1609 1614
1610 } 1615 }
1611 list = config->readListEntry("EditTodoLayout"); 1616 list = config->readListEntry("EditTodoLayout");
1612 if ( ! list.isEmpty() ) { 1617 if ( ! list.isEmpty() ) {
1613 x = list[0].toInt(); 1618 x = list[0].toInt();
1614 y = list[1].toInt(); 1619 y = list[1].toInt();
1615 w = list[2].toInt(); 1620 w = list[2].toInt();
1616 h = list[3].toInt(); 1621 h = list[3].toInt();
1617 mTodoEditor->setGeometry(x,y,w,h); 1622 mTodoEditor->setGeometry(x,y,w,h);
1618 1623
1619 } 1624 }
1620 list = config->readListEntry("ViewerLayout"); 1625 list = config->readListEntry("ViewerLayout");
1621 if ( ! list.isEmpty() ) { 1626 if ( ! list.isEmpty() ) {
1622 x = list[0].toInt(); 1627 x = list[0].toInt();
1623 y = list[1].toInt(); 1628 y = list[1].toInt();
1624 w = list[2].toInt(); 1629 w = list[2].toInt();
1625 h = list[3].toInt(); 1630 h = list[3].toInt();
1626 getEventViewerDialog()->setGeometry(x,y,w,h); 1631 getEventViewerDialog()->setGeometry(x,y,w,h);
1627 } 1632 }
1628#endif 1633#endif
1629 1634
1630} 1635}
1631 1636
1632 1637
1633void CalendarView::writeSettings() 1638void CalendarView::writeSettings()
1634{ 1639{
1635 // kdDebug() << "CalendarView::writeSettings" << endl; 1640 // kdDebug() << "CalendarView::writeSettings" << endl;
1636 1641
1637 KConfig *config = KOGlobals::config(); 1642 KConfig *config = KOGlobals::config();
1638 1643
1639#ifndef KORG_NOSPLITTER 1644#ifndef KORG_NOSPLITTER
1640 config->setGroup("KOrganizer Geometry"); 1645 config->setGroup("KOrganizer Geometry");
1641 1646
1642 QValueList<int> list = mPanner->sizes(); 1647 QValueList<int> list = mPanner->sizes();
1643 config->writeEntry("Separator1",list); 1648 config->writeEntry("Separator1",list);
1644 1649
1645 list = mLeftSplitter->sizes(); 1650 list = mLeftSplitter->sizes();
1646 config->writeEntry("Separator2",list); 1651 config->writeEntry("Separator2",list);
1647#endif 1652#endif
1648 1653
1649 mViewManager->writeSettings( config ); 1654 mViewManager->writeSettings( config );
1650 mTodoList->saveLayout(config,QString("Todo Layout")); 1655 mTodoList->saveLayout(config,QString("Todo Layout"));
1651 mDialogManager->writeSettings( config ); 1656 mDialogManager->writeSettings( config );
1652 //KOPrefs::instance()->usrWriteConfig(); 1657 //KOPrefs::instance()->usrWriteConfig();
1653 KOPrefs::instance()->writeConfig(); 1658 KOPrefs::instance()->writeConfig();
1654 1659
1655 writeFilterSettings(config); 1660 writeFilterSettings(config);
1656 1661
1657 config->setGroup( "Views" ); 1662 config->setGroup( "Views" );
1658 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1663 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1659 1664
1660#ifdef DESKTOP_VERSION 1665#ifdef DESKTOP_VERSION
1661 config->setGroup("WidgetLayout"); 1666 config->setGroup("WidgetLayout");
1662 QStringList list ;//= config->readListEntry("MainLayout"); 1667 QStringList list ;//= config->readListEntry("MainLayout");
1663 int x,y,w,h; 1668 int x,y,w,h;
1664 QWidget* wid; 1669 QWidget* wid;
1665 wid = topLevelWidget(); 1670 wid = topLevelWidget();
1666 x = wid->geometry().x(); 1671 x = wid->geometry().x();
1667 y = wid->geometry().y(); 1672 y = wid->geometry().y();
1668 w = wid->width(); 1673 w = wid->width();
1669 h = wid->height(); 1674 h = wid->height();
1670 list.clear(); 1675 list.clear();
1671 list << QString::number( x ); 1676 list << QString::number( x );
1672 list << QString::number( y ); 1677 list << QString::number( y );
1673 list << QString::number( w ); 1678 list << QString::number( w );
1674 list << QString::number( h ); 1679 list << QString::number( h );
1675 config->writeEntry("MainLayout",list ); 1680 config->writeEntry("MainLayout",list );
1676 1681
1677 wid = mEventEditor; 1682 wid = mEventEditor;
1678 x = wid->geometry().x(); 1683 x = wid->geometry().x();
1679 y = wid->geometry().y(); 1684 y = wid->geometry().y();
1680 w = wid->width(); 1685 w = wid->width();
1681 h = wid->height(); 1686 h = wid->height();
1682 list.clear(); 1687 list.clear();
1683 list << QString::number( x ); 1688 list << QString::number( x );
1684 list << QString::number( y ); 1689 list << QString::number( y );
1685 list << QString::number( w ); 1690 list << QString::number( w );
1686 list << QString::number( h ); 1691 list << QString::number( h );
1687 config->writeEntry("EditEventLayout",list ); 1692 config->writeEntry("EditEventLayout",list );
1688 1693
1689 wid = mTodoEditor; 1694 wid = mTodoEditor;
1690 x = wid->geometry().x(); 1695 x = wid->geometry().x();
1691 y = wid->geometry().y(); 1696 y = wid->geometry().y();
1692 w = wid->width(); 1697 w = wid->width();
1693 h = wid->height(); 1698 h = wid->height();
1694 list.clear(); 1699 list.clear();
1695 list << QString::number( x ); 1700 list << QString::number( x );
1696 list << QString::number( y ); 1701 list << QString::number( y );
1697 list << QString::number( w ); 1702 list << QString::number( w );
1698 list << QString::number( h ); 1703 list << QString::number( h );
1699 config->writeEntry("EditTodoLayout",list ); 1704 config->writeEntry("EditTodoLayout",list );
1700 wid = getEventViewerDialog(); 1705 wid = getEventViewerDialog();
1701 x = wid->geometry().x(); 1706 x = wid->geometry().x();
1702 y = wid->geometry().y(); 1707 y = wid->geometry().y();
1703 w = wid->width(); 1708 w = wid->width();
1704 h = wid->height(); 1709 h = wid->height();
1705 list.clear(); 1710 list.clear();
1706 list << QString::number( x ); 1711 list << QString::number( x );
1707 list << QString::number( y ); 1712 list << QString::number( y );
1708 list << QString::number( w ); 1713 list << QString::number( w );
1709 list << QString::number( h ); 1714 list << QString::number( h );
1710 config->writeEntry("ViewerLayout",list ); 1715 config->writeEntry("ViewerLayout",list );
1711 wid = mDialogManager->getSearchDialog(); 1716 wid = mDialogManager->getSearchDialog();
1712 if ( wid ) { 1717 if ( wid ) {
1713 x = wid->geometry().x(); 1718 x = wid->geometry().x();
1714 y = wid->geometry().y(); 1719 y = wid->geometry().y();
1715 w = wid->width(); 1720 w = wid->width();
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index fa18683..fd6b6af 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,1364 +1,1517 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
43 43
44#include "phoneformat.h" 44#include "phoneformat.h"
45#include "syncdefines.h"
45 46
46using namespace KCal; 47using namespace KCal;
47 48
48//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
49// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
50 51
51//ARSD silentalarm = 0 52//ARSD silentalarm = 0
52// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
53// 12 RFRQ 54// 12 RFRQ
54// 13 RPOS pos = 4. monday in month 55// 13 RPOS pos = 4. monday in month
55// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
56// 15 REND 0 = no end/ 1 = end 57// 15 REND 0 = no end/ 1 = end
57// 16 REDT rec end dt 58// 16 REDT rec end dt
58//ALSD 59//ALSD
59//ALED 60//ALED
60//MDAY 61//MDAY
61 62
62class PhoneParser : public QObject 63class PhoneParser : public QObject
63{ 64{
64 public: 65 public:
65 PhoneParser( Calendar *calendar ) : mCalendar( calendar ) { 66 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) {
66 oldCategories = 0; 67 oldCategories = 0;
67 } 68 }
68 69
69 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 70 bool startElement( Calendar *existingCalendar, GSM_CalendarEntry*Note, QString qName )
70 { 71 {
72 QStringList attList;
73 /*
74// pending csum
71 int i = 1; 75 int i = 1;
72 bool skip = true; 76 bool skip = true;
73 int max = attList.count() -2; 77 int max = attList.count() -2;
74 while ( i < max ) { 78 while ( i < max ) {
75 if ( !attList[i].isEmpty() ) { 79 if ( !attList[i].isEmpty() ) {
76 skip = false; 80 skip = false;
77 break; 81 break;
78 } 82 }
79 ++i ; 83 ++i ;
80 } 84 }
81 if ( skip ) 85 if ( skip )
82 return false; 86 return false;
83 ulong cSum = PhoneFormat::getCsum(attList ); 87 ulong cSum = PhoneFormat::getCsum(attList );
84 88 */
85 if ( qName == "Event" ) { 89 if ( qName == "Event" ) {
90 int id = Note->Location;
86 Event *event; 91 Event *event;
87 event = existingCalendar->event( attList[0] ); 92 event = existingCalendar->event( mProfileName ,QString::number( id ) );
88 if ( event ) 93 if ( event )
89 event = (Event*)event->clone(); 94 event = (Event*)event->clone();
90 else 95 else
91 event = new Event; 96 event = new Event;
92 // event->setZaurusId( attList[0].toInt() ); 97 event->setID( mProfileName, attList[0] );
93 //event->setZaurusUid( cSum ); 98 // pending event->setCsum( "Sharp_DTM", QString::number( cSum ));
94 //event->setZaurusStat( -2 ); 99 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
100
101
102 int i = 0;
103 bool repeating = false;
104 int repeat_dayofweek = -1;
105 int repeat_day = -1;
106 int repeat_weekofmonth = -1;
107 int repeat_month = -1;
108 int repeat_frequency = -1;
109 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
110 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
111 GSM_DateTime* dtp;
112 bool alarm = false;
113 QDateTime alarmDt;
114 repeat_startdate.Day= 0;
115 repeat_stopdate.Day = 0;
116 for (i=0;i<Note->EntriesNum;i++) {
117
118 qDebug(" for ");
119 switch (Note->Entries[i].EntryType) {
120 case CAL_START_DATETIME:
121 dtp = &Note->Entries[i].Date ;
122 if ( dtp->Hour > 24 ) {
123 event->setFloats( true );
124 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
125 } else {
126 event->setDtStart (fromGSM ( dtp ));
95 127
96 event->setSummary( attList[2] ); 128 }
97 event->setLocation( attList[3] ); 129 break;
98 event->setDescription( attList[4] ); 130 case CAL_END_DATETIME:
99 if ( attList[7] == "1" ) { 131 dtp = &Note->Entries[i].Date ;
100 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); 132 if ( dtp->Hour > 24 ) {
101 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); 133 event->setFloats( true );
102 event->setFloats( true ); 134 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
103 } else { 135 } else {
104 event->setFloats( false ); 136 event->setDtEnd (fromGSM ( dtp ));
105 event->setDtStart( fromString( attList[5] ) ); 137 }
106 event->setDtEnd( fromString( attList[6] )); 138 break;
139 case CAL_ALARM_DATETIME:
140 dtp = &Note->Entries[i].Date ;
141 alarm = true;
142 alarmDt = fromGSM ( dtp );
143 break;
144 case CAL_SILENT_ALARM_DATETIME:
145 dtp = &Note->Entries[i].Date ;
146 alarm = true;
147 alarmDt = fromGSM ( dtp );
148 break;
149 case CAL_RECURRANCE:
150 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
151 break;
152 case CAL_TEXT:
153 event->setSummary( QString ( (const char*) Note->Entries[i].Text ));
154 break;
155 case CAL_LOCATION:
156 event->setLocation(QString ((const char*) Note->Entries[i].Text ));
157 break;
158 case CAL_PHONE:
159 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
160 break;
161 case CAL_PRIVATE:
162 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
163 break;
164 case CAL_CONTACTID:
165#if 0
166 entry.Location = Note->Entries[i].Number;
167 entry.MemoryType = MEM_ME;
168 error=Phone->GetMemory(&s, &entry);
169 if (error == ERR_NONE) {
170 name = GSM_PhonebookGetEntryName(&entry);
171 if (name != NULL) {
172 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
173 } else {
174 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
175 }
176 } else {
177 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
178 }
179#endif
180 break;
181 case CAL_REPEAT_DAYOFWEEK:
182 repeat_dayofweek = Note->Entries[i].Number;
183 repeating = true;
184 break;
185 case CAL_REPEAT_DAY:
186 repeat_day = Note->Entries[i].Number;
187 repeating = true;
188 break;
189 case CAL_REPEAT_WEEKOFMONTH:
190 repeat_weekofmonth = Note->Entries[i].Number;
191 repeating = true;
192 break;
193 case CAL_REPEAT_MONTH:
194 repeat_month = Note->Entries[i].Number;
195 repeating = true;
196 break;
197 case CAL_REPEAT_FREQUENCY:
198 repeat_frequency = Note->Entries[i].Number;
199 repeating = true;
200 break;
201 case CAL_REPEAT_STARTDATE:
202 repeat_startdate = Note->Entries[i].Date;
203 repeating = true;
204 break;
205 case CAL_REPEAT_STOPDATE:
206 repeat_stopdate = Note->Entries[i].Date;
207 repeating = true;
208 break;
209 }
107 } 210 }
211#if 0
212 event->setDescription( attList[4] );
213 bool repeating = false;
214 int repeat_dayofweek = -1;
215 int repeat_day = -1;
216 int repeat_weekofmonth = -1;
217 int repeat_month = -1;
218 int repeat_frequency = -1;
219 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
220 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
221
222#endif
108 223
109 QString rtype = attList[11]; 224 QString rtype = attList[11];
110 if ( rtype != "255" ) { 225 if ( repeating ) {
226 int rtype = 0;
111 // qDebug("recurs "); 227 // qDebug("recurs ");
112 QDate startDate = event->dtStart().date(); 228 QDate startDate, endDate;
113 229 if ( repeat_startdate.Day > 0 )
114 QString freqStr = attList[12]; 230 startDate = datefromGSM ( &repeat_startdate );
115 int freq = freqStr.toInt(); 231 else
116 232 startDate = event->dtStart().date();
117 QString hasEndDateStr = attList[15] ; 233 int freq = repeat_frequency;
118 bool hasEndDate = hasEndDateStr == "1"; 234 bool hasEndDate = false;
119 235 if ( repeat_stopdate.Day > 0 ) {
120 QString endDateStr = attList[16]; 236 endDate = datefromGSM ( &repeat_stopdate );
121 QDate endDate = fromString( endDateStr ).date(); 237 hasEndDate = true;
122 238 }
123 QString weekDaysStr = attList[14]; 239
124 uint weekDaysNum = weekDaysStr.toInt(); 240 uint weekDaysNum = repeat_dayofweek ;
125 241
126 QBitArray weekDays( 7 ); 242 QBitArray weekDays( 7 );
127 int i; 243 int i;
128 int bb = 1; 244 int bb = 1;
129 for( i = 1; i <= 7; ++i ) { 245 for( i = 1; i <= 7; ++i ) {
130 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 246 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
131 bb = 2 << (i-1); 247 bb = 2 << (i-1);
132 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 248 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
133 } 249 }
134 // qDebug("next "); 250 // qDebug("next ");
135 QString posStr = attList[13]; 251 int pos = 0;
136 int pos = posStr.toInt();
137 Recurrence *r = event->recurrence(); 252 Recurrence *r = event->recurrence();
253 /*
254 0 daily;
255 1 weekly;x
256 2 monthpos;x
257 3 monthlyday;
258 4 rYearlyMont
259 */
260 int dayOfWeek = startDate.dayOfWeek();
261 if ( repeat_weekofmonth >= 0 ) {
262 rtype = 2;
263 pos = repeat_weekofmonth;
264 if ( repeat_dayofweek >= 0 )
265 dayOfWeek = repeat_dayofweek;
266 } else if ( repeat_dayofweek >= 0 ) {
267 rtype = 1;
268 } if ( repeat_dayofweek >= 0 ) {
269 rtype = 1;
270 }
138 271
139 if ( rtype == "0" ) { 272 if ( rtype == 0 ) {
140 if ( hasEndDate ) r->setDaily( freq, endDate ); 273 if ( hasEndDate ) r->setDaily( freq, endDate );
141 else r->setDaily( freq, -1 ); 274 else r->setDaily( freq, -1 );
142 } else if ( rtype == "1" ) { 275 } else if ( rtype == 1 ) {
143 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 276 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
144 else r->setWeekly( freq, weekDays, -1 ); 277 else r->setWeekly( freq, weekDays, -1 );
145 } else if ( rtype == "3" ) { 278 } else if ( rtype == 3 ) {
146 if ( hasEndDate ) 279 if ( hasEndDate )
147 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 280 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
148 else 281 else
149 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 282 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
150 r->addMonthlyDay( startDate.day() ); 283 r->addMonthlyDay( startDate.day() );
151 } else if ( rtype == "2" ) { 284 } else if ( rtype == 2 ) {
152 if ( hasEndDate ) 285 if ( hasEndDate )
153 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 286 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
154 else 287 else
155 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 288 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
156 QBitArray days( 7 ); 289 QBitArray days( 7 );
157 days.fill( false ); 290 days.fill( false );
158 days.setBit( startDate.dayOfWeek() - 1 ); 291 days.setBit( dayOfWeek - 1 );
159 r->addMonthlyPos( pos, days ); 292 r->addMonthlyPos( pos, days );
160 } else if ( rtype == "4" ) { 293 } else if ( rtype == 4 ) {
161 if ( hasEndDate ) 294 if ( hasEndDate )
162 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 295 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
163 else 296 else
164 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 297 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
165 r->addYearlyNum( startDate.month() ); 298 r->addYearlyNum( startDate.month() );
166 } 299 }
300 } else {
301 event->recurrence()->unsetRecurs();
167 } 302 }
168 303
169 QString categoryList = attList[1] ; 304 QString categoryList = attList[1] ;
170 event->setCategories( lookupCategories( categoryList ) ); 305 event->setCategories( lookupCategories( categoryList ) );
171 306
172 // strange 0 semms to mean: alarm enabled 307 // strange 0 semms to mean: alarm enabled
173 if ( attList[8] == "0" ) { 308 if ( alarm ) {
174 Alarm *alarm; 309 Alarm *alarm;
175 if ( event->alarms().count() > 0 ) 310 if ( event->alarms().count() > 0 )
176 alarm = event->alarms().first(); 311 alarm = event->alarms().first();
177 else { 312 else {
178 alarm = new Alarm( event ); 313 alarm = new Alarm( event );
179 event->addAlarm( alarm ); 314 event->addAlarm( alarm );
180 } 315 }
181 alarm->setType( Alarm::Audio ); 316 alarm->setType( Alarm::Audio );
182 alarm->setEnabled( true ); 317 alarm->setEnabled( true );
183 int alarmOffset = attList[9].toInt(); 318 int alarmOffset = alarmDt.secsTo( event->dtStart() );
184 alarm->setStartOffset( alarmOffset * -60 ); 319 alarm->setStartOffset( alarmOffset );
185 } 320 }
186
187 mCalendar->addEvent( event); 321 mCalendar->addEvent( event);
188 } else if ( qName == "Todo" ) { 322 } else if ( qName == "Todo" ) {
323#if 0
189 Todo *todo; 324 Todo *todo;
190 325
191 todo = existingCalendar->todo( attList[0] ); 326 todo = existingCalendar->todo( attList[0] );
192 if (todo ) 327 if (todo )
193 todo = (Todo*)todo->clone(); 328 todo = (Todo*)todo->clone();
194 else 329 else
195 todo = new Todo; 330 todo = new Todo;
196 331
197//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 332//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
198// 0 1 2 3 4 5 6 7 8 333// 0 1 2 3 4 5 6 7 8
199//1,,,,,1,4,Loch zumachen,"" 334//1,,,,,1,4,Loch zumachen,""
200//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 335//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
201//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 336//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
202 337
203 //todo->setZaurusId( attList[0] ); 338 //todo->setZaurusId( attList[0] );
204 //todo->setZaurusUid( cSum ); 339 //todo->setZaurusUid( cSum );
205 //todo->setZaurusStat( -2 ); 340 //todo->setZaurusStat( -2 );
206 341
207 todo->setSummary( attList[7] ); 342 todo->setSummary( attList[7] );
208 todo->setDescription( attList[8]); 343 todo->setDescription( attList[8]);
209 344
210 int priority = attList[6].toInt(); 345 int priority = attList[6].toInt();
211 if ( priority == 0 ) priority = 3; 346 if ( priority == 0 ) priority = 3;
212 todo->setPriority( priority ); 347 todo->setPriority( priority );
213 348
214 QString categoryList = attList[1]; 349 QString categoryList = attList[1];
215 todo->setCategories( lookupCategories( categoryList ) ); 350 todo->setCategories( lookupCategories( categoryList ) );
216 351
217 352
218 353
219 QString hasDateStr = attList[3]; // due 354 QString hasDateStr = attList[3]; // due
220 if ( !hasDateStr.isEmpty() ) { 355 if ( !hasDateStr.isEmpty() ) {
221 if ( hasDateStr.right(6) == "000000" ) { 356 if ( hasDateStr.right(6) == "000000" ) {
222 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 357 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
223 todo->setFloats( true ); 358 todo->setFloats( true );
224 } 359 }
225 else { 360 else {
226 todo->setDtDue( fromString( hasDateStr ) ); 361 todo->setDtDue( fromString( hasDateStr ) );
227 todo->setFloats( false ); 362 todo->setFloats( false );
228 } 363 }
229 364
230 todo->setHasDueDate( true ); 365 todo->setHasDueDate( true );
231 } 366 }
232 hasDateStr = attList[2];//start 367 hasDateStr = attList[2];//start
233 if ( !hasDateStr.isEmpty() ) { 368 if ( !hasDateStr.isEmpty() ) {
234 369
235 todo->setDtStart( fromString( hasDateStr ) ); 370 todo->setDtStart( fromString( hasDateStr ) );
236 todo->setHasStartDate( true); 371 todo->setHasStartDate( true);
237 } else 372 } else
238 todo->setHasStartDate( false ); 373 todo->setHasStartDate( false );
239 hasDateStr = attList[4];//completed 374 hasDateStr = attList[4];//completed
240 if ( !hasDateStr.isEmpty() ) { 375 if ( !hasDateStr.isEmpty() ) {
241 todo->setCompleted(fromString( hasDateStr ) ); 376 todo->setCompleted(fromString( hasDateStr ) );
242 } 377 }
243 QString completedStr = attList[5]; 378 QString completedStr = attList[5];
244 if ( completedStr == "0" ) 379 if ( completedStr == "0" )
245 todo->setCompleted( true ); 380 todo->setCompleted( true );
246 else 381 else
247 todo->setCompleted( false ); 382 todo->setCompleted( false );
248 mCalendar->addTodo( todo ); 383 mCalendar->addTodo( todo );
384#endif
249 385
250 } else if ( qName == "Category" ) { 386 } else if ( qName == "Category" ) {
251 /* 387 /*
252 QString id = attributes.value( "id" ); 388 QString id = attributes.value( "id" );
253 QString name = attributes.value( "name" ); 389 QString name = attributes.value( "name" );
254 setCategory( id, name ); 390 setCategory( id, name );
255 */ 391 */
256 } 392 }
257 //qDebug("end "); 393 //qDebug("end ");
258 return true; 394 return true;
259 } 395 }
260 396
261 397
262 void setCategoriesList ( QStringList * c ) 398 void setCategoriesList ( QStringList * c )
263 { 399 {
264 oldCategories = c; 400 oldCategories = c;
265 } 401 }
266 402
267 QDateTime fromString ( QString s, bool useTz = true ) { 403 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) {
268 QDateTime dt; 404 QDateTime dt;
269 int y,m,t,h,min,sec; 405 int y,m,t,h,min,sec;
270 y = s.mid(0,4).toInt(); 406 y = dtp->Year;
271 m = s.mid(4,2).toInt(); 407 m = dtp->Month;
272 t = s.mid(6,2).toInt(); 408 t = dtp->Day;
273 h = s.mid(9,2).toInt(); 409 h = dtp->Hour;
274 min = s.mid(11,2).toInt(); 410 min = dtp->Minute;
275 sec = s.mid(13,2).toInt(); 411 sec = dtp->Second;
276 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 412 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
413 // dtp->Timezone: offset in hours
277 int offset = KGlobal::locale()->localTimeOffset( dt ); 414 int offset = KGlobal::locale()->localTimeOffset( dt );
278 if ( useTz ) 415 if ( useTz )
279 dt = dt.addSecs ( offset*60); 416 dt = dt.addSecs ( offset*60);
280 return dt; 417 return dt;
281 418
282 } 419 }
420 QDate datefromGSM ( GSM_DateTime*dtp ) {
421 return QDate ( dtp->Year, dtp->Month, dtp->Day );
422 }
283 protected: 423 protected:
284 QDateTime toDateTime( const QString &value ) 424 QDateTime toDateTime( const QString &value )
285 { 425 {
286 QDateTime dt; 426 QDateTime dt;
287 dt.setTime_t( value.toUInt() ); 427 dt.setTime_t( value.toUInt() );
288 428
289 return dt; 429 return dt;
290 } 430 }
291 431
292 QStringList lookupCategories( const QString &categoryList ) 432 QStringList lookupCategories( const QString &categoryList )
293 { 433 {
294 QStringList categoryIds = QStringList::split( ";", categoryList ); 434 QStringList categoryIds = QStringList::split( ";", categoryList );
295 QStringList categories; 435 QStringList categories;
296 QStringList::ConstIterator it; 436 QStringList::ConstIterator it;
297 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 437 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
298 QString cate = category( *it ); 438 QString cate = category( *it );
299 if ( oldCategories ) { 439 if ( oldCategories ) {
300 if ( ! oldCategories->contains( cate ) ) 440 if ( ! oldCategories->contains( cate ) )
301 oldCategories->append( cate ); 441 oldCategories->append( cate );
302 } 442 }
303 categories.append(cate ); 443 categories.append(cate );
304 } 444 }
305 return categories; 445 return categories;
306 } 446 }
307 447
308 private: 448 private:
449 QString mProfileName ;
309 Calendar *mCalendar; 450 Calendar *mCalendar;
310 QStringList * oldCategories; 451 QStringList * oldCategories;
311 static QString category( const QString &id ) 452 static QString category( const QString &id )
312 { 453 {
313 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 454 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
314 if ( it == mCategoriesMap.end() ) return id; 455 if ( it == mCategoriesMap.end() ) return id;
315 else return *it; 456 else return *it;
316 } 457 }
317 458
318 static void setCategory( const QString &id, const QString &name ) 459 static void setCategory( const QString &id, const QString &name )
319 { 460 {
320 mCategoriesMap.insert( id, name ); 461 mCategoriesMap.insert( id, name );
321 } 462 }
322 463
323 static QMap<QString,QString> mCategoriesMap; 464 static QMap<QString,QString> mCategoriesMap;
324}; 465};
325 466
326QMap<QString,QString> PhoneParser::mCategoriesMap; 467QMap<QString,QString> PhoneParser::mCategoriesMap;
327 468
328PhoneFormat::PhoneFormat() 469PhoneFormat::PhoneFormat()
329{ 470{
330 mCategories = 0; 471 mCategories = 0;
331} 472}
332 473
333PhoneFormat::~PhoneFormat() 474PhoneFormat::~PhoneFormat()
334{ 475{
335} 476}
336ulong PhoneFormat::getCsum( const QStringList & attList) 477ulong PhoneFormat::getCsum( const QStringList & attList)
337{ 478{
338 int max = attList.count() -1; 479 int max = attList.count() -1;
339 ulong cSum = 0; 480 ulong cSum = 0;
340 int j,k,i; 481 int j,k,i;
341 int add; 482 int add;
342 for ( i = 1; i < max ; ++i ) { 483 for ( i = 1; i < max ; ++i ) {
343 QString s = attList[i]; 484 QString s = attList[i];
344 if ( ! s.isEmpty() ){ 485 if ( ! s.isEmpty() ){
345 j = s.length(); 486 j = s.length();
346 for ( k = 0; k < j; ++k ) { 487 for ( k = 0; k < j; ++k ) {
347 int mul = k +1; 488 int mul = k +1;
348 add = s[k].unicode (); 489 add = s[k].unicode ();
349 if ( k < 16 ) 490 if ( k < 16 )
350 mul = mul * mul; 491 mul = mul * mul;
351 add = add * mul *i*i*i; 492 add = add * mul *i*i*i;
352 cSum += add; 493 cSum += add;
353 } 494 }
354 } 495 }
355 } 496 }
356 return cSum; 497 return cSum;
357 498
358} 499}
359//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 500//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
360#include <stdlib.h> 501#include <stdlib.h>
361#define DEBUGMODE false 502#define DEBUGMODE false
362bool PhoneFormat::load( Calendar *calendar, Calendar *existngCal ) 503bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profileName, QString device,QString connection, QString model )
363{ 504{
364 505 mProfileName = profileName;
365 GSM_StateMachines; 506 GSM_StateMachines;
366 qDebug(" load "); 507 qDebug(" load ");
367 s.opened = false; 508 s.opened = false;
368 s.msg = NULL; 509 s.msg = NULL;
369 s.ConfigNum = 0; 510 s.ConfigNum = 0;
370 static char*cp; 511 static char*cp;
371 static INI_Section *cfg = NULL; 512 static INI_Section *cfg = NULL;
372 cfg=GSM_FindGammuRC(); 513 cfg=GSM_FindGammuRC();
373 int i; 514 int i;
374 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 515 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
375 if (cfg!=NULL) { 516 if (cfg!=NULL) {
376 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 517 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
377 if (cp) di.coding = cp; 518 if (cp) di.coding = cp;
378 519
379 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 520 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
380 if (s.Config[i].Localize) { 521 if (s.Config[i].Localize) {
381 s.msg=INI_ReadFile(s.Config[i].Localize, true); 522 s.msg=INI_ReadFile(s.Config[i].Localize, true);
382 } else { 523 } else {
383#if !defined(WIN32) && defined(LOCALE_PATH) 524#if !defined(WIN32) && defined(LOCALE_PATH)
384 locale = setlocale(LC_MESSAGES, NULL); 525 locale = setlocale(LC_MESSAGES, NULL);
385 if (locale != NULL) { 526 if (locale != NULL) {
386 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 527 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
387 LOCALE_PATH, 528 LOCALE_PATH,
388 tolower(locale[0]), 529 tolower(locale[0]),
389 tolower(locale[1])); 530 tolower(locale[1]));
390 s.msg = INI_ReadFile(locale_file, true); 531 s.msg = INI_ReadFile(locale_file, true);
391 } 532 }
392#endif 533#endif
393 } 534 }
394 } 535 }
395 536
396 /* Wanted user specific configuration? */ 537 /* Wanted user specific configuration? */
397 538
398 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 539 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
399 540
400 s.ConfigNum++; 541 s.ConfigNum++;
401 542
402 /* We want to use only one file descriptor for global and state machine debug output */ 543 /* We want to use only one file descriptor for global and state machine debug output */
403 s.Config[i].UseGlobalDebugFile = true; 544 s.Config[i].UseGlobalDebugFile = true;
404 545
405 546
406 547
407 /* We wanted to read just user specified configuration. */ 548 /* We wanted to read just user specified configuration. */
408 {break;} 549 {break;}
409 } 550 }
410 551
411 552
412 553
413 554
414 int error=GSM_InitConnection(&s,3); 555 int error=GSM_InitConnection(&s,3);
415 556
416 557
417 qDebug(" init %d %d", error, ERR_NONE); 558 qDebug(" init %d %d", error, ERR_NONE);
418 if ( error != ERR_NONE ) 559 if ( error != ERR_NONE )
419 return false; 560 return false;
420 fromString2Cal( calendar, existngCal, &s, "Event" ); 561 // fromString2Cal( calendar, existngCal, &s, "Event" );
421 562 GSM_Phone_Functions*Phone;
422 563 GSM_CalendarEntrynote;
564 bool refresh= true;
565 Phone=s.Phone.Functions;
566 bool gshutdown = false;
567 PhoneParser handler( calendar, profileName );
568 //handler.setCategoriesList( mCategories );
569 int ccc = 0;
570 while (!gshutdown && ccc++ < 10 ) {
571
572 qDebug("count %d ", ccc);
573 error=Phone->GetNextCalendar(&s,&note,refresh);
574 if (error == ERR_EMPTY) break;
575 handler.startElement( existingCal, &note, "Event" );
576 }
423 error=GSM_TerminateConnection(&s); 577 error=GSM_TerminateConnection(&s);
424
425
426#if 0 578#if 0
427 579
428 bool debug = DEBUGMODE; 580 bool debug = DEBUGMODE;
429 //debug = true; 581 //debug = true;
430 QString text; 582 QString text;
431 QString codec = "utf8"; 583 QString codec = "utf8";
432 QLabel status ( i18n("Reading events ..."), 0 ); 584 QLabel status ( i18n("Reading events ..."), 0 );
433 585
434 int w = status.sizeHint().width()+20 ; 586 int w = status.sizeHint().width()+20 ;
435 if ( w < 200 ) w = 200; 587 if ( w < 200 ) w = 200;
436 int h = status.sizeHint().height()+20 ; 588 int h = status.sizeHint().height()+20 ;
437 int dw = QApplication::desktop()->width(); 589 int dw = QApplication::desktop()->width();
438 int dh = QApplication::desktop()->height(); 590 int dh = QApplication::desktop()->height();
439 status.setCaption(i18n("Reading DTM Data") ); 591 status.setCaption(i18n("Reading DTM Data") );
440 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 592 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
441 status.show(); 593 status.show();
442 status.raise(); 594 status.raise();
443 qApp->processEvents(); 595 qApp->processEvents();
444 QString fileName; 596 QString fileName;
445 if ( ! debug ) { 597 if ( ! debug ) {
446 fileName = "/tmp/kopitempout"; 598 fileName = "/tmp/kopitempout";
447 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 599 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
448 system ( command.latin1() ); 600 system ( command.latin1() );
449 } else { 601 } else {
450 fileName = "/tmp/events.txt"; 602 fileName = "/tmp/events.txt";
451 603
452 } 604 }
453 QFile file( fileName ); 605 QFile file( fileName );
454 if (!file.open( IO_ReadOnly ) ) { 606 if (!file.open( IO_ReadOnly ) ) {
455 return false; 607 return false;
456 608
457 } 609 }
458 QTextStream ts( &file ); 610 QTextStream ts( &file );
459 ts.setCodec( QTextCodec::codecForName("utf8") ); 611 ts.setCodec( QTextCodec::codecForName("utf8") );
460 text = ts.read(); 612 text = ts.read();
461 file.close(); 613 file.close();
462 status.setText( i18n("Processing events ...") ); 614 status.setText( i18n("Processing events ...") );
463 status.raise(); 615 status.raise();
464 qApp->processEvents(); 616 qApp->processEvents();
465 fromString2Cal( calendar, existngCal, text, "Event" ); 617 fromString2Cal( calendar, existngCal, text, "Event" );
466 status.setText( i18n("Reading todos ...") ); 618 status.setText( i18n("Reading todos ...") );
467 qApp->processEvents(); 619 qApp->processEvents();
468 if ( ! debug ) { 620 if ( ! debug ) {
469 fileName = "/tmp/kopitempout"; 621 fileName = "/tmp/kopitempout";
470 QString command = "db2file todo -r -c " + codec+ " > " + fileName; 622 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
471 system ( command.latin1() ); 623 system ( command.latin1() );
472 } else { 624 } else {
473 fileName = "/tmp/todo.txt"; 625 fileName = "/tmp/todo.txt";
474 } 626 }
475 file.setName( fileName ); 627 file.setName( fileName );
476 if (!file.open( IO_ReadOnly ) ) { 628 if (!file.open( IO_ReadOnly ) ) {
477 return false; 629 return false;
478 630
479 } 631 }
480 ts.setDevice( &file ); 632 ts.setDevice( &file );
481 text = ts.read(); 633 text = ts.read();
482 file.close(); 634 file.close();
483 635
484 status.setText( i18n("Processing todos ...") ); 636 status.setText( i18n("Processing todos ...") );
485 status.raise(); 637 status.raise();
486 qApp->processEvents(); 638 qApp->processEvents();
487 fromString2Cal( calendar, existngCal, text, "Todo" ); 639 fromString2Cal( calendar, existngCal, text, "Todo" );
488#endif 640#endif
489 return true; 641 return true;
490} 642}
491int PhoneFormat::getNumFromRecord( QString answer, Incidence* inc ) 643int PhoneFormat::getNumFromRecord( QString answer, Incidence* inc )
492{ 644{
493 int retval = -1; 645 int retval = -1;
494 QStringList templist; 646 QStringList templist;
495 QString tempString; 647 QString tempString;
496 int start = 0; 648 int start = 0;
497 int len = answer.length(); 649 int len = answer.length();
498 int end = answer.find ("\n",start)+1; 650 int end = answer.find ("\n",start)+1;
499 bool ok = true; 651 bool ok = true;
500 start = end; 652 start = end;
501 int ccc = 0; 653 int ccc = 0;
502 while ( start > 0 ) { 654 while ( start > 0 ) {
503 templist.clear(); 655 templist.clear();
504 ok = true; 656 ok = true;
505 int loopCount = 0; 657 int loopCount = 0;
506 while ( ok ) { 658 while ( ok ) {
507 ++loopCount; 659 ++loopCount;
508 if ( loopCount > 25 ) { 660 if ( loopCount > 25 ) {
509 qDebug("KO: Error in while loop"); 661 qDebug("KO: Error in while loop");
510 ok = false; 662 ok = false;
511 start = 0; 663 start = 0;
512 break; 664 break;
513 } 665 }
514 if ( ok ) 666 if ( ok )
515 tempString = getPart( answer, ok, start ); 667 tempString = getPart( answer, ok, start );
516 if ( start >= len || start == 0 ) { 668 if ( start >= len || start == 0 ) {
517 start = 0; 669 start = 0;
518 ok = false; 670 ok = false;
519 } 671 }
520 if ( tempString.right(1) =="\n" ) 672 if ( tempString.right(1) =="\n" )
521 tempString = tempString.left( tempString.length()-1); 673 tempString = tempString.left( tempString.length()-1);
522 674
523 templist.append( tempString ); 675 templist.append( tempString );
524 } 676 }
525 ++ccc; 677 ++ccc;
526 if ( ccc == 2 && loopCount < 25 ) { 678 if ( ccc == 2 && loopCount < 25 ) {
527 start = 0; 679 start = 0;
528 bool ok; 680 bool ok;
529 int newnum = templist[0].toInt( &ok ); 681 int newnum = templist[0].toInt( &ok );
530 if ( ok && newnum > 0) { 682 if ( ok && newnum > 0) {
531 retval = newnum; 683 retval = newnum;
532 //inc->setZaurusId( newnum ); 684 //inc->setZaurusId( newnum );
533 //inc->setZaurusUid( getCsum( templist ) ); 685 //inc->setZaurusUid( getCsum( templist ) );
534 //inc->setZaurusStat( -4 ); 686 //inc->setZaurusStat( -4 );
535 } 687 }
536 } 688 }
537 } 689 }
538 //qDebug("getNumFromRecord returning : %d ", retval); 690 //qDebug("getNumFromRecord returning : %d ", retval);
539 return retval; 691 return retval;
540} 692}
541bool PhoneFormat::save( Calendar *calendar) 693bool PhoneFormat::save( Calendar *calendar)
542{ 694{
543 695
544 QLabel status ( i18n("Processing/adding events ..."), 0 ); 696 QLabel status ( i18n("Processing/adding events ..."), 0 );
545 int w = status.sizeHint().width()+20 ; 697 int w = status.sizeHint().width()+20 ;
546 if ( w < 200 ) w = 200; 698 if ( w < 200 ) w = 200;
547 int h = status.sizeHint().height()+20 ; 699 int h = status.sizeHint().height()+20 ;
548 int dw = QApplication::desktop()->width(); 700 int dw = QApplication::desktop()->width();
549 int dh = QApplication::desktop()->height(); 701 int dh = QApplication::desktop()->height();
550 status.setCaption(i18n("Writing DTM Data") ); 702 status.setCaption(i18n("Writing DTM Data") );
551 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 703 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
552 status.show(); 704 status.show();
553 status.raise(); 705 status.raise();
554 qApp->processEvents(); 706 qApp->processEvents();
555 bool debug = DEBUGMODE; 707 bool debug = DEBUGMODE;
556 QString codec = "utf8"; 708 QString codec = "utf8";
557 QString answer; 709 QString answer;
558 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 710 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
559 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 711 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
560 QString command; 712 QString command;
561 QPtrList<Event> er = calendar->rawEvents(); 713 QPtrList<Event> er = calendar->rawEvents();
562 Event* ev = er.first(); 714 Event* ev = er.first();
563 QString fileName = "/tmp/kopitempout"; 715 QString fileName = "/tmp/kopitempout";
564 int i = 0; 716 int i = 0;
565 QString changeString = ePrefix; 717 QString changeString = ePrefix;
566 QString deleteString = ePrefix; 718 QString deleteString = ePrefix;
567 bool deleteEnt = false; 719 bool deleteEnt = false;
568 bool changeEnt = false; 720 bool changeEnt = false;
569 QString message = i18n("Processing event # "); 721 QString message = i18n("Processing event # ");
570 int procCount = 0; 722 int procCount = 0;
571 while ( ev ) { 723 while ( ev ) {
572 //qDebug("i %d ", ++i); 724 //qDebug("i %d ", ++i);
573 if ( true /*ev->zaurusStat() != -2*/ ) { 725 if ( true /*ev->zaurusStat() != -2*/ ) {
574 status.setText ( message + QString::number ( ++procCount ) ); 726 status.setText ( message + QString::number ( ++procCount ) );
575 qApp->processEvents(); 727 qApp->processEvents();
576 QString eString = getEventString( ev ); 728 QString eString = getEventString( ev );
577 if (/* ev->zaurusStat() == -3 */ true) { // delete 729 if (/* ev->zaurusStat() == -3 */ true) { // delete
578 // deleting empty strings does not work. 730 // deleting empty strings does not work.
579 // we write first and x and then delete the record with the x 731 // we write first and x and then delete the record with the x
580 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 732 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
581 changeString += eString + "\n"; 733 changeString += eString + "\n";
582 deleteString += eString + "\n"; 734 deleteString += eString + "\n";
583 deleteEnt = true; 735 deleteEnt = true;
584 changeEnt = true; 736 changeEnt = true;
585 } 737 }
586 else if ( /*ev->zaurusId() == -1*/true ) { // add new 738 else if ( /*ev->zaurusId() == -1*/true ) { // add new
587 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 739 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
588 system ( command.utf8() ); 740 system ( command.utf8() );
589 QFile file( fileName ); 741 QFile file( fileName );
590 if (!file.open( IO_ReadOnly ) ) { 742 if (!file.open( IO_ReadOnly ) ) {
591 return false; 743 return false;
592 744
593 } 745 }
594 QTextStream ts( &file ); 746 QTextStream ts( &file );
595 ts.setCodec( QTextCodec::codecForName("utf8") ); 747 ts.setCodec( QTextCodec::codecForName("utf8") );
596 answer = ts.read(); 748 answer = ts.read();
597 file.close(); 749 file.close();
598 //qDebug("answer \n%s ", answer.latin1()); 750 //qDebug("answer \n%s ", answer.latin1());
599 getNumFromRecord( answer, ev ) ; 751 getNumFromRecord( answer, ev ) ;
600 752
601 } 753 }
602 else { // change existing 754 else { // change existing
603 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 755 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
604 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 756 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
605 changeString += eString + "\n"; 757 changeString += eString + "\n";
606 changeEnt = true; 758 changeEnt = true;
607 759
608 } 760 }
609 } 761 }
610 ev = er.next(); 762 ev = er.next();
611 } 763 }
612 status.setText ( i18n("Changing events ...") ); 764 status.setText ( i18n("Changing events ...") );
613 qApp->processEvents(); 765 qApp->processEvents();
614 //qDebug("changing... "); 766 //qDebug("changing... ");
615 if ( changeEnt ) { 767 if ( changeEnt ) {
616 QFile file( fileName ); 768 QFile file( fileName );
617 if (!file.open( IO_WriteOnly ) ) { 769 if (!file.open( IO_WriteOnly ) ) {
618 return false; 770 return false;
619 771
620 } 772 }
621 QTextStream ts( &file ); 773 QTextStream ts( &file );
622 ts.setCodec( QTextCodec::codecForName("utf8") ); 774 ts.setCodec( QTextCodec::codecForName("utf8") );
623 ts << changeString ; 775 ts << changeString ;
624 file.close(); 776 file.close();
625 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 777 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
626 system ( command.latin1() ); 778 system ( command.latin1() );
627 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 779 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
628 780
629 } 781 }
630 status.setText ( i18n("Deleting events ...") ); 782 status.setText ( i18n("Deleting events ...") );
631 qApp->processEvents(); 783 qApp->processEvents();
632 //qDebug("deleting... "); 784 //qDebug("deleting... ");
633 if ( deleteEnt ) { 785 if ( deleteEnt ) {
634 QFile file( fileName ); 786 QFile file( fileName );
635 if (!file.open( IO_WriteOnly ) ) { 787 if (!file.open( IO_WriteOnly ) ) {
636 return false; 788 return false;
637 789
638 } 790 }
639 QTextStream ts( &file ); 791 QTextStream ts( &file );
640 ts.setCodec( QTextCodec::codecForName("utf8") ); 792 ts.setCodec( QTextCodec::codecForName("utf8") );
641 ts << deleteString; 793 ts << deleteString;
642 file.close(); 794 file.close();
643 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 795 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
644 system ( command.latin1() ); 796 system ( command.latin1() );
645 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 797 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
646 } 798 }
647 799
648 800
649 changeString = tPrefix; 801 changeString = tPrefix;
650 deleteString = tPrefix; 802 deleteString = tPrefix;
651 status.setText ( i18n("Processing todos ...") ); 803 status.setText ( i18n("Processing todos ...") );
652 qApp->processEvents(); 804 qApp->processEvents();
653 QPtrList<Todo> tl = calendar->rawTodos(); 805 QPtrList<Todo> tl = calendar->rawTodos();
654 Todo* to = tl.first(); 806 Todo* to = tl.first();
655 i = 0; 807 i = 0;
656 message = i18n("Processing todo # "); 808 message = i18n("Processing todo # ");
657 procCount = 0; 809 procCount = 0;
658 while ( to ) { 810 while ( to ) {
659 if ( true /*to->zaurusStat() != -2 */) { 811 if ( true /*to->zaurusStat() != -2 */) {
660 status.setText ( message + QString::number ( ++procCount ) ); 812 status.setText ( message + QString::number ( ++procCount ) );
661 qApp->processEvents(); 813 qApp->processEvents();
662 QString eString = getTodoString( to ); 814 QString eString = getTodoString( to );
663 if ( /*to->zaurusStat() == -3*/true ) { // delete 815 if ( /*to->zaurusStat() == -3*/true ) { // delete
664 // deleting empty strings does not work. 816 // deleting empty strings does not work.
665 // we write first and x and then delete the record with the x 817 // we write first and x and then delete the record with the x
666 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 818 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
667 changeString += eString + "\n"; 819 changeString += eString + "\n";
668 deleteString += eString + "\n"; 820 deleteString += eString + "\n";
669 deleteEnt = true; 821 deleteEnt = true;
670 changeEnt = true; 822 changeEnt = true;
671 } 823 }
672 else if ( true /*to->zaurusId() == -1*/ ) { // add new 824 else if ( true /*to->zaurusId() == -1*/ ) { // add new
673 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 825 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
674 system ( command.utf8() ); 826 system ( command.utf8() );
675 QFile file( fileName ); 827 QFile file( fileName );
676 if (!file.open( IO_ReadOnly ) ) { 828 if (!file.open( IO_ReadOnly ) ) {
677 return false; 829 return false;
678 830
679 } 831 }
680 QTextStream ts( &file ); 832 QTextStream ts( &file );
681 ts.setCodec( QTextCodec::codecForName("utf8") ); 833 ts.setCodec( QTextCodec::codecForName("utf8") );
682 answer = ts.read(); 834 answer = ts.read();
683 file.close(); 835 file.close();
684 //qDebug("answer \n%s ", answer.latin1()); 836 //qDebug("answer \n%s ", answer.latin1());
685 getNumFromRecord( answer, to ) ; 837 getNumFromRecord( answer, to ) ;
686 838
687 } 839 }
688 else { // change existing 840 else { // change existing
689 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 841 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
690 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 842 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
691 changeString += eString + "\n"; 843 changeString += eString + "\n";
692 changeEnt = true; 844 changeEnt = true;
693 845
694 } 846 }
695 } 847 }
696 848
697 to = tl.next(); 849 to = tl.next();
698 } 850 }
699 status.setText ( i18n("Changing todos ...") ); 851 status.setText ( i18n("Changing todos ...") );
700 qApp->processEvents(); 852 qApp->processEvents();
701 //qDebug("changing... "); 853 //qDebug("changing... ");
702 if ( changeEnt ) { 854 if ( changeEnt ) {
703 QFile file( fileName ); 855 QFile file( fileName );
704 if (!file.open( IO_WriteOnly ) ) { 856 if (!file.open( IO_WriteOnly ) ) {
705 return false; 857 return false;
706 858
707 } 859 }
708 QTextStream ts( &file ); 860 QTextStream ts( &file );
709 ts.setCodec( QTextCodec::codecForName("utf8") ); 861 ts.setCodec( QTextCodec::codecForName("utf8") );
710 ts << changeString ; 862 ts << changeString ;
711 file.close(); 863 file.close();
712 command = "db2file todo -w -g -c " + codec+ " < "+ fileName; 864 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
713 system ( command.latin1() ); 865 system ( command.latin1() );
714 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 866 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
715 867
716 } 868 }
717 status.setText ( i18n("Deleting todos ...") ); 869 status.setText ( i18n("Deleting todos ...") );
718 qApp->processEvents(); 870 qApp->processEvents();
719 //qDebug("deleting... "); 871 //qDebug("deleting... ");
720 if ( deleteEnt ) { 872 if ( deleteEnt ) {
721 QFile file( fileName ); 873 QFile file( fileName );
722 if (!file.open( IO_WriteOnly ) ) { 874 if (!file.open( IO_WriteOnly ) ) {
723 return false; 875 return false;
724 876
725 } 877 }
726 QTextStream ts( &file ); 878 QTextStream ts( &file );
727 ts.setCodec( QTextCodec::codecForName("utf8") ); 879 ts.setCodec( QTextCodec::codecForName("utf8") );
728 ts << deleteString; 880 ts << deleteString;
729 file.close(); 881 file.close();
730 command = "db2file todo -d -c " + codec+ " < "+ fileName; 882 command = "db2file todo -d -c " + codec+ " < "+ fileName;
731 system ( command.latin1() ); 883 system ( command.latin1() );
732 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 884 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
733 } 885 }
734 886
735 return true; 887 return true;
736} 888}
737QString PhoneFormat::dtToString( const QDateTime& dti, bool useTZ ) 889QString PhoneFormat::dtToString( const QDateTime& dti, bool useTZ )
738{ 890{
739 QString datestr; 891 QString datestr;
740 QString timestr; 892 QString timestr;
741 int offset = KGlobal::locale()->localTimeOffset( dti ); 893 int offset = KGlobal::locale()->localTimeOffset( dti );
742 QDateTime dt; 894 QDateTime dt;
743 if (useTZ) 895 if (useTZ)
744 dt = dti.addSecs ( -(offset*60)); 896 dt = dti.addSecs ( -(offset*60));
745 else 897 else
746 dt = dti; 898 dt = dti;
747 if(dt.date().isValid()){ 899 if(dt.date().isValid()){
748 const QDate& date = dt.date(); 900 const QDate& date = dt.date();
749 datestr.sprintf("%04d%02d%02d", 901 datestr.sprintf("%04d%02d%02d",
750 date.year(), date.month(), date.day()); 902 date.year(), date.month(), date.day());
751 } 903 }
752 if(dt.time().isValid()){ 904 if(dt.time().isValid()){
753 const QTime& time = dt.time(); 905 const QTime& time = dt.time();
754 timestr.sprintf("T%02d%02d%02d", 906 timestr.sprintf("T%02d%02d%02d",
755 time.hour(), time.minute(), time.second()); 907 time.hour(), time.minute(), time.second());
756 } 908 }
757 return datestr + timestr; 909 return datestr + timestr;
758} 910}
759QString PhoneFormat::getEventString( Event* event ) 911QString PhoneFormat::getEventString( Event* event )
760{ 912{
761#if 0 913#if 0
762 QStringList list; 914 QStringList list;
763 list.append( QString::number(event->zaurusId() ) ); 915 list.append( QString::number(event->zaurusId() ) );
764 list.append( event->categories().join(",") ); 916 list.append( event->categories().join(",") );
765 if ( !event->summary().isEmpty() ) 917 if ( !event->summary().isEmpty() )
766 list.append( event->summary() ); 918 list.append( event->summary() );
767 else 919 else
768 list.append("" ); 920 list.append("" );
769 if ( !event->location().isEmpty() ) 921 if ( !event->location().isEmpty() )
770 list.append( event->location() ); 922 list.append( event->location() );
771 else 923 else
772 list.append("" ); 924 list.append("" );
773 if ( !event->description().isEmpty() ) 925 if ( !event->description().isEmpty() )
774 list.append( event->description() ); 926 list.append( event->description() );
775 else 927 else
776 list.append( "" ); 928 list.append( "" );
777 if ( event->doesFloat () ) { 929 if ( event->doesFloat () ) {
778 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); 930 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
779 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 931 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
780 list.append( "1" ); 932 list.append( "1" );
781 933
782 } 934 }
783 else { 935 else {
784 list.append( dtToString( event->dtStart()) ); 936 list.append( dtToString( event->dtStart()) );
785 list.append( dtToString( event->dtEnd()) ); //6 937 list.append( dtToString( event->dtEnd()) ); //6
786 list.append( "0" ); 938 list.append( "0" );
787 } 939 }
788 bool noAlarm = true; 940 bool noAlarm = true;
789 if ( event->alarms().count() > 0 ) { 941 if ( event->alarms().count() > 0 ) {
790 Alarm * al = event->alarms().first(); 942 Alarm * al = event->alarms().first();
791 if ( al->enabled() ) { 943 if ( al->enabled() ) {
792 noAlarm = false; 944 noAlarm = false;
793 list.append( "0" ); // yes, 0 == alarm 945 list.append( "0" ); // yes, 0 == alarm
794 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); 946 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
795 if ( al->type() == Alarm::Audio ) 947 if ( al->type() == Alarm::Audio )
796 list.append( "1" ); // type audio 948 list.append( "1" ); // type audio
797 else 949 else
798 list.append( "0" ); // type silent 950 list.append( "0" ); // type silent
799 } 951 }
800 } 952 }
801 if ( noAlarm ) { 953 if ( noAlarm ) {
802 list.append( "1" ); // yes, 1 == no alarm 954 list.append( "1" ); // yes, 1 == no alarm
803 list.append( "0" ); // no alarm offset 955 list.append( "0" ); // no alarm offset
804 list.append( "1" ); // type 956 list.append( "1" ); // type
805 } 957 }
806 // next is: 11 958 // next is: 11
807 // next is: 11-16 are recurrence 959 // next is: 11-16 are recurrence
808 Recurrence* rec = event->recurrence(); 960 Recurrence* rec = event->recurrence();
809 961
810 bool writeEndDate = false; 962 bool writeEndDate = false;
811 switch ( rec->doesRecur() ) 963 switch ( rec->doesRecur() )
812 { 964 {
813 case Recurrence::rDaily: // 0 965 case Recurrence::rDaily: // 0
814 list.append( "0" ); 966 list.append( "0" );
815 list.append( QString::number( rec->frequency() ));//12 967 list.append( QString::number( rec->frequency() ));//12
816 list.append( "0" ); 968 list.append( "0" );
817 list.append( "0" ); 969 list.append( "0" );
818 writeEndDate = true; 970 writeEndDate = true;
819 break; 971 break;
820 case Recurrence::rWeekly:// 1 972 case Recurrence::rWeekly:// 1
821 list.append( "1" ); 973 list.append( "1" );
822 list.append( QString::number( rec->frequency()) );//12 974 list.append( QString::number( rec->frequency()) );//12
823 list.append( "0" ); 975 list.append( "0" );
824 { 976 {
825 int days = 0; 977 int days = 0;
826 QBitArray weekDays = rec->days(); 978 QBitArray weekDays = rec->days();
827 int i; 979 int i;
828 for( i = 1; i <= 7; ++i ) { 980 for( i = 1; i <= 7; ++i ) {
829 if ( weekDays[i-1] ) { 981 if ( weekDays[i-1] ) {
830 days += 1 << (i-1); 982 days += 1 << (i-1);
831 } 983 }
832 } 984 }
833 list.append( QString::number( days ) ); 985 list.append( QString::number( days ) );
834 } 986 }
835 //pending weekdays 987 //pending weekdays
836 writeEndDate = true; 988 writeEndDate = true;
837 989
838 break; 990 break;
839 case Recurrence::rMonthlyPos:// 2 991 case Recurrence::rMonthlyPos:// 2
840 list.append( "2" ); 992 list.append( "2" );
841 list.append( QString::number( rec->frequency()) );//12 993 list.append( QString::number( rec->frequency()) );//12
842 994
843 writeEndDate = true; 995 writeEndDate = true;
844 { 996 {
845 int count = 1; 997 int count = 1;
846 QPtrList<Recurrence::rMonthPos> rmp; 998 QPtrList<Recurrence::rMonthPos> rmp;
847 rmp = rec->monthPositions(); 999 rmp = rec->monthPositions();
848 if ( rmp.first()->negative ) 1000 if ( rmp.first()->negative )
849 count = 5 - rmp.first()->rPos - 1; 1001 count = 5 - rmp.first()->rPos - 1;
850 else 1002 else
851 count = rmp.first()->rPos - 1; 1003 count = rmp.first()->rPos - 1;
852 list.append( QString::number( count ) ); 1004 list.append( QString::number( count ) );
853 1005
854 } 1006 }
855 1007
856 list.append( "0" ); 1008 list.append( "0" );
857 break; 1009 break;
858 case Recurrence::rMonthlyDay:// 3 1010 case Recurrence::rMonthlyDay:// 3
859 list.append( "3" ); 1011 list.append( "3" );
860 list.append( QString::number( rec->frequency()) );//12 1012 list.append( QString::number( rec->frequency()) );//12
861 list.append( "0" ); 1013 list.append( "0" );
862 list.append( "0" ); 1014 list.append( "0" );
863 writeEndDate = true; 1015 writeEndDate = true;
864 break; 1016 break;
865 case Recurrence::rYearlyMonth://4 1017 case Recurrence::rYearlyMonth://4
866 list.append( "4" ); 1018 list.append( "4" );
867 list.append( QString::number( rec->frequency()) );//12 1019 list.append( QString::number( rec->frequency()) );//12
868 list.append( "0" ); 1020 list.append( "0" );
869 list.append( "0" ); 1021 list.append( "0" );
870 writeEndDate = true; 1022 writeEndDate = true;
871 break; 1023 break;
872 1024
873 default: 1025 default:
874 list.append( "255" ); 1026 list.append( "255" );
875 list.append( QString() ); 1027 list.append( QString() );
876 list.append( "0" ); 1028 list.append( "0" );
877 list.append( QString() ); 1029 list.append( QString() );
878 list.append( "0" ); 1030 list.append( "0" );
879 list.append( "20991231T000000" ); 1031 list.append( "20991231T000000" );
880 break; 1032 break;
881 } 1033 }
882 if ( writeEndDate ) { 1034 if ( writeEndDate ) {
883 1035
884 if ( rec->endDate().isValid() ) { // 15 + 16 1036 if ( rec->endDate().isValid() ) { // 15 + 16
885 list.append( "1" ); 1037 list.append( "1" );
886 list.append( dtToString( rec->endDate()) ); 1038 list.append( dtToString( rec->endDate()) );
887 } else { 1039 } else {
888 list.append( "0" ); 1040 list.append( "0" );
889 list.append( "20991231T000000" ); 1041 list.append( "20991231T000000" );
890 } 1042 }
891 1043
892 } 1044 }
893 if ( event->doesFloat () ) { 1045 if ( event->doesFloat () ) {
894 list.append( dtToString( event->dtStart(), false ).left( 8 )); 1046 list.append( dtToString( event->dtStart(), false ).left( 8 ));
895 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 1047 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
896 1048
897 } 1049 }
898 else { 1050 else {
899 list.append( QString() ); 1051 list.append( QString() );
900 list.append( QString() ); 1052 list.append( QString() );
901 1053
902 } 1054 }
903 if (event->dtStart().date() == event->dtEnd().date() ) 1055 if (event->dtStart().date() == event->dtEnd().date() )
904 list.append( "0" ); 1056 list.append( "0" );
905 else 1057 else
906 list.append( "1" ); 1058 list.append( "1" );
907 1059
908 1060
909 for(QStringList::Iterator it=list.begin(); 1061 for(QStringList::Iterator it=list.begin();
910 it!=list.end(); ++it){ 1062 it!=list.end(); ++it){
911 QString& s = (*it); 1063 QString& s = (*it);
912 s.replace(QRegExp("\""), "\"\""); 1064 s.replace(QRegExp("\""), "\"\"");
913 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 1065 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
914 s.prepend('\"'); 1066 s.prepend('\"');
915 s.append('\"'); 1067 s.append('\"');
916 } else if(s.isEmpty() && !s.isNull()){ 1068 } else if(s.isEmpty() && !s.isNull()){
917 s = "\"\""; 1069 s = "\"\"";
918 } 1070 }
919 } 1071 }
920 return list.join(","); 1072 return list.join(",");
921#endif 1073#endif
922 return QString(); 1074 return QString();
923 1075
924} 1076}
925QString PhoneFormat::getTodoString( Todo* todo ) 1077QString PhoneFormat::getTodoString( Todo* todo )
926{ 1078{
927#if 0 1079#if 0
928 QStringList list; 1080 QStringList list;
929 list.append( QString::number( todo->zaurusId() ) ); 1081 list.append( QString::number( todo->zaurusId() ) );
930 list.append( todo->categories().join(",") ); 1082 list.append( todo->categories().join(",") );
931 1083
932 if ( todo->hasStartDate() ) { 1084 if ( todo->hasStartDate() ) {
933 list.append( dtToString( todo->dtStart()) ); 1085 list.append( dtToString( todo->dtStart()) );
934 } else 1086 } else
935 list.append( QString() ); 1087 list.append( QString() );
936 1088
937 if ( todo->hasDueDate() ) { 1089 if ( todo->hasDueDate() ) {
938 QTime tim; 1090 QTime tim;
939 if ( todo->doesFloat()) { 1091 if ( todo->doesFloat()) {
940 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; 1092 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
941 } else { 1093 } else {
942 list.append( dtToString(todo->dtDue() ) ); 1094 list.append( dtToString(todo->dtDue() ) );
943 } 1095 }
944 } else 1096 } else
945 list.append( QString() ); 1097 list.append( QString() );
946 1098
947 if ( todo->isCompleted() ) { 1099 if ( todo->isCompleted() ) {
948 list.append( dtToString( todo->completed()) ); 1100 list.append( dtToString( todo->completed()) );
949 list.append( "0" ); // yes 0 == completed 1101 list.append( "0" ); // yes 0 == completed
950 } else { 1102 } else {
951 list.append( dtToString( todo->completed()) ); 1103 list.append( dtToString( todo->completed()) );
952 list.append( "1" ); 1104 list.append( "1" );
953 } 1105 }
954 list.append( QString::number( todo->priority() )); 1106 list.append( QString::number( todo->priority() ));
955 if( ! todo->summary().isEmpty() ) 1107 if( ! todo->summary().isEmpty() )
956 list.append( todo->summary() ); 1108 list.append( todo->summary() );
957 else 1109 else
958 list.append( "" ); 1110 list.append( "" );
959 if (! todo->description().isEmpty() ) 1111 if (! todo->description().isEmpty() )
960 list.append( todo->description() ); 1112 list.append( todo->description() );
961 else 1113 else
962 list.append( "" ); 1114 list.append( "" );
963 for(QStringList::Iterator it=list.begin(); 1115 for(QStringList::Iterator it=list.begin();
964 it!=list.end(); ++it){ 1116 it!=list.end(); ++it){
965 QString& s = (*it); 1117 QString& s = (*it);
966 s.replace(QRegExp("\""), "\"\""); 1118 s.replace(QRegExp("\""), "\"\"");
967 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 1119 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
968 s.prepend('\"'); 1120 s.prepend('\"');
969 s.append('\"'); 1121 s.append('\"');
970 } else if(s.isEmpty() && !s.isNull()){ 1122 } else if(s.isEmpty() && !s.isNull()){
971 s = "\"\""; 1123 s = "\"\"";
972 } 1124 }
973 } 1125 }
974 return list.join(","); 1126 return list.join(",");
975#endif 1127#endif
976 return QString(); 1128 return QString();
977} 1129}
978QString PhoneFormat::getPart( const QString & text, bool &ok, int &start ) 1130QString PhoneFormat::getPart( const QString & text, bool &ok, int &start )
979{ 1131{
980 //qDebug("start %d ", start); 1132 //qDebug("start %d ", start);
981 1133
982 QString retval =""; 1134 QString retval ="";
983 if ( text.at(start) == '"' ) { 1135 if ( text.at(start) == '"' ) {
984 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { 1136 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) {
985 start = start +2; 1137 start = start +2;
986 if ( text.mid( start,1) == "," ) { 1138 if ( text.mid( start,1) == "," ) {
987 start += 1; 1139 start += 1;
988 } 1140 }
989 retval = ""; 1141 retval = "";
990 if ( text.mid( start,1) == "\n" ) { 1142 if ( text.mid( start,1) == "\n" ) {
991 start += 1; 1143 start += 1;
992 ok = false; 1144 ok = false;
993 } 1145 }
994 return retval; 1146 return retval;
995 } 1147 }
996 int hk = start+1; 1148 int hk = start+1;
997 hk = text.find ('"',hk); 1149 hk = text.find ('"',hk);
998 while ( text.at(hk+1) == '"' ) 1150 while ( text.at(hk+1) == '"' )
999 hk = text.find ('"',hk+2); 1151 hk = text.find ('"',hk+2);
1000 retval = text.mid( start+1, hk-start-1); 1152 retval = text.mid( start+1, hk-start-1);
1001 start = hk+1; 1153 start = hk+1;
1002 retval.replace( QRegExp("\"\""), "\""); 1154 retval.replace( QRegExp("\"\""), "\"");
1003 if ( text.mid( start,1) == "," ) { 1155 if ( text.mid( start,1) == "," ) {
1004 start += 1; 1156 start += 1;
1005 } 1157 }
1006 if ( text.mid( start,1) == "\n" ) { 1158 if ( text.mid( start,1) == "\n" ) {
1007 start += 1; 1159 start += 1;
1008 ok = false; 1160 ok = false;
1009 } 1161 }
1010 //qDebug("retval***%s*** ",retval.latin1() ); 1162 //qDebug("retval***%s*** ",retval.latin1() );
1011 return retval; 1163 return retval;
1012 1164
1013 } else { 1165 } else {
1014 int nl = text.find ("\n",start); 1166 int nl = text.find ("\n",start);
1015 int kom = text.find (',',start); 1167 int kom = text.find (',',start);
1016 if ( kom < nl ) { 1168 if ( kom < nl ) {
1017 // qDebug("kom < nl %d ", kom); 1169 // qDebug("kom < nl %d ", kom);
1018 retval = text.mid(start, kom-start); 1170 retval = text.mid(start, kom-start);
1019 start = kom+1; 1171 start = kom+1;
1020 return retval; 1172 return retval;
1021 } else { 1173 } else {
1022 if ( nl == kom ) { 1174 if ( nl == kom ) {
1023 // qDebug(" nl == kom "); 1175 // qDebug(" nl == kom ");
1024 start = 0; 1176 start = 0;
1025 ok = false; 1177 ok = false;
1026 return "0"; 1178 return "0";
1027 } 1179 }
1028 // qDebug(" nl < kom ", nl); 1180 // qDebug(" nl < kom ", nl);
1029 retval = text.mid( start, nl-start); 1181 retval = text.mid( start, nl-start);
1030 ok = false; 1182 ok = false;
1031 start = nl+1; 1183 start = nl+1;
1032 return retval; 1184 return retval;
1033 } 1185 }
1034 } 1186 }
1035} 1187}
1036bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 1188bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
1037{ 1189{
1038 return false; 1190 return false;
1039} 1191}
1040 bool PhoneFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type) 1192 bool PhoneFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type)
1041{ 1193{
1194#if 0
1042 GSM_Phone_Functions*Phone; 1195 GSM_Phone_Functions*Phone;
1043 1196
1044 GSM_CalendarEntrynote; 1197 GSM_CalendarEntrynote;
1045 GSM_CalendarEntry*Note; 1198 GSM_CalendarEntry*Note;
1046 bool refresh= true; 1199 bool refresh= true;
1047 1200
1048 Phone=s->Phone.Functions; 1201 Phone=s->Phone.Functions;
1049 bool gshutdown = false; 1202 bool gshutdown = false;
1050 PhoneParser handler( calendar ); 1203 PhoneParser handler( calendar );
1051 //handler.setCategoriesList( mCategories ); 1204 //handler.setCategoriesList( mCategories );
1052 QStringList templist; 1205 QStringList templist;
1053 QString tempString; 1206 QString tempString;
1054 int start = 0; 1207 int start = 0;
1055 int error; 1208 int error;
1056 int ccc = 0; 1209 int ccc = 0;
1057 while (!gshutdown && ccc++ < 10 ) { 1210 while (!gshutdown && ccc++ < 10 ) {
1058 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY; 1211 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY;
1059 templist.clear(); 1212 templist.clear();
1060 qDebug("count %d ", ccc); 1213 qDebug("count %d ", ccc);
1061 error=Phone->GetNextCalendar(s,&note,refresh); 1214 error=Phone->GetNextCalendar(s,&note,refresh);
1062 if (error == ERR_EMPTY) break; 1215 if (error == ERR_EMPTY) break;
1063 1216
1064 Note = &note; 1217 Note = &note;
1065//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 1218//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1066// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1219// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1067 1220
1068//ARSD silentalarm = 0 1221//ARSD silentalarm = 0
1069// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 1222// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
1070// 12 RFRQ 1223// 12 RFRQ
1071// 13 RPOS pos = 4. monday in month 1224// 13 RPOS pos = 4. monday in month
1072// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 1225// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
1073// 15 REND 0 = no end/ 1 = end 1226// 15 REND 0 = no end/ 1 = end
1074// 16 REDT rec end dt 1227// 16 REDT rec end dt
1075//ALSD 1228//ALSD
1076//ALED 1229//ALED
1077//MDAY 1230//MDAY
1078 1231
1079 CARDID = QString::number( Note->Location ); // 0 1232 CARDID = QString::number( Note->Location ); // 0
1080 1233
1081 1234
1082 int i_age = 0,i; 1235 int i_age = 0,i;
1083 GSM_DateTime Alarm,DateTime; 1236 GSM_DateTime Alarm,DateTime;
1084 GSM_DateTime* dtp; 1237 GSM_DateTime* dtp;
1085 GSM_MemoryEntry entry; 1238 GSM_MemoryEntry entry;
1086 unsigned char *name; 1239 unsigned char *name;
1087 1240
1088 bool repeating = false; 1241 bool repeating = false;
1089 int repeat_dayofweek = -1; 1242 int repeat_dayofweek = -1;
1090 int repeat_day = -1; 1243 int repeat_day = -1;
1091 int repeat_weekofmonth = -1; 1244 int repeat_weekofmonth = -1;
1092 int repeat_month = -1; 1245 int repeat_month = -1;
1093 int repeat_frequency = -1; 1246 int repeat_frequency = -1;
1094 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 1247 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
1095 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 1248 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
1096 1249
1097 Alarm.Year = 0; 1250 Alarm.Year = 0;
1098 1251
1099 repeating = false; 1252 repeating = false;
1100 repeat_dayofweek = -1; 1253 repeat_dayofweek = -1;
1101 repeat_day = -1; 1254 repeat_day = -1;
1102 repeat_weekofmonth = -1; 1255 repeat_weekofmonth = -1;
1103 repeat_month = -1; 1256 repeat_month = -1;
1104 repeat_frequency = -1; 1257 repeat_frequency = -1;
1105 repeat_startdate.Day= 0; 1258 repeat_startdate.Day= 0;
1106 repeat_stopdate.Day = 0; 1259 repeat_stopdate.Day = 0;
1107 1260
1108 1261
1109 switch (Note->Type) { 1262 switch (Note->Type) {
1110 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; 1263 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
1111 case GSM_CAL_CALL : CATEGORY = QString("Call"); break; 1264 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
1112 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; 1265 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
1113 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; 1266 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
1114 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; 1267 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
1115 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; 1268 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
1116 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; 1269 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
1117 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; 1270 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
1118 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; 1271 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
1119 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; 1272 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
1120 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; 1273 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
1121 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; 1274 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
1122 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; 1275 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
1123 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; 1276 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
1124 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; 1277 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
1125 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; 1278 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
1126 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; 1279 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
1127 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; 1280 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
1128 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; 1281 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
1129 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; 1282 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
1130 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; 1283 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
1131 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; 1284 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
1132 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; 1285 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
1133 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; 1286 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
1134 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; 1287 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
1135 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; 1288 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
1136 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; 1289 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
1137 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; 1290 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
1138 default : CATEGORY = QString(""); 1291 default : CATEGORY = QString("");
1139 } 1292 }
1140//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 1293//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1141// 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19? 1294// 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19?
1142 1295
1143 MEM1 = ""; 1296 MEM1 = "";
1144 1297
1145#if 0 1298#if 0
1146 1299
1147 if ( attList[7] == "1" ) { 1300 if ( attList[7] == "1" ) {
1148 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); 1301 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
1149 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); 1302 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 )));
1150 event->setFloats( true ); 1303 event->setFloats( true );
1151 } else { 1304 } else {
1152 event->setFloats( false ); 1305 event->setFloats( false );
1153 event->setDtStart( fromString( attList[5] ) ); 1306 event->setDtStart( fromString( attList[5] ) );
1154 event->setDtEnd( fromString( attList[6] )); 1307 event->setDtEnd( fromString( attList[6] ));
1155 } 1308 }
1156 1309
1157 1310
1158 1311
1159typedef struct { 1312typedef struct {
1160 /** 1313 /**
1161 * The difference between local time and GMT in hours 1314 * The difference between local time and GMT in hours
1162 */ 1315 */
1163 int Timezone; 1316 int Timezone;
1164 1317
1165 unsigned int Second; 1318 unsigned int Second;
1166 unsigned int Minute; 1319 unsigned int Minute;
1167 unsigned int Hour; 1320 unsigned int Hour;
1168 1321
1169 unsigned int Day; 1322 unsigned int Day;
1170 /** 1323 /**
1171 * January = 1, February = 2, etc. 1324 * January = 1, February = 2, etc.
1172 */ 1325 */
1173 unsigned int Month; 1326 unsigned int Month;
1174 /** 1327 /**
1175 * Complete year number. Not 03, but 2003 1328 * Complete year number. Not 03, but 2003
1176 */ 1329 */
1177 unsigned int Year; 1330 unsigned int Year;
1178} GSM_DateTime; 1331} GSM_DateTime;
1179 1332
1180 if(dt.date().isValid()){ 1333 if(dt.date().isValid()){
1181 const QDate& date = dt.date(); 1334 const QDate& date = dt.date();
1182 datestr.sprintf("%04d%02d%02d", 1335 datestr.sprintf("%04d%02d%02d",
1183 date.year(), date.month(), date.day()); 1336 date.year(), date.month(), date.day());
1184 } 1337 }
1185 if(dt.time().isValid()){ 1338 if(dt.time().isValid()){
1186 const QTime& time = dt.time(); 1339 const QTime& time = dt.time();
1187 timestr.sprintf("T%02d%02d%02d", 1340 timestr.sprintf("T%02d%02d%02d",
1188 time.hour(), time.minute(), time.second()); 1341 time.hour(), time.minute(), time.second());
1189 } 1342 }
1190 return datestr + timestr; 1343 return datestr + timestr;
1191 1344
1192 1345
1193 1346
1194 1347
1195#endif 1348#endif
1196 1349
1197 1350
1198 ADAY = "0"; 1351 ADAY = "0";
1199 ARON = "1"; // 1 == disabled 1352 ARON = "1"; // 1 == disabled
1200 ARMN = "0"; //alarm offset in minutes 1353 ARMN = "0"; //alarm offset in minutes
1201 1354
1202 for (i=0;i<Note->EntriesNum;i++) { 1355 for (i=0;i<Note->EntriesNum;i++) {
1203 1356
1204 qDebug(" for "); 1357 qDebug(" for ");
1205 switch (Note->Entries[i].EntryType) { 1358 switch (Note->Entries[i].EntryType) {
1206 case CAL_START_DATETIME: 1359 case CAL_START_DATETIME:
1207 dtp = &Note->Entries[i].Date ; 1360 dtp = &Note->Entries[i].Date ;
1208 1361
1209 qDebug("hour: %d ", dtp->Hour); 1362 qDebug("hour: %d ", dtp->Hour);
1210 if ( dtp->Hour == -1 ) { 1363 if ( dtp->Hour == -1 ) {
1211 ADAY = "1"; 1364 ADAY = "1";
1212 ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); 1365 ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1213 TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); 1366 TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1214 } else { 1367 } else {
1215 TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1368 TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1216 1369
1217 } 1370 }
1218 ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1371 ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
1219 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1372 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1220 break; 1373 break;
1221 case CAL_END_DATETIME: 1374 case CAL_END_DATETIME:
1222 dtp = &Note->Entries[i].Date ; 1375 dtp = &Note->Entries[i].Date ;
1223 qDebug("hour2: %d ", dtp->Hour); 1376 qDebug("hour2: %d ", dtp->Hour);
1224 if ( dtp->Hour == -1 ) { 1377 if ( dtp->Hour == -1 ) {
1225 ADAY = "1"; 1378 ADAY = "1";
1226 ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); 1379 ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1227 TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); 1380 TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1228 } else { 1381 } else {
1229 TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1382 TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1230 1383
1231 } 1384 }
1232 //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1385 //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
1233 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1386 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1234 break; 1387 break;
1235 case CAL_ALARM_DATETIME: 1388 case CAL_ALARM_DATETIME:
1236 ARON = "0"; 1389 ARON = "0";
1237 dtp = &Note->Entries[i].Date ; 1390 dtp = &Note->Entries[i].Date ;
1238 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1391 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1239 //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1392 //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1240 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1393 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1241 break; 1394 break;
1242 case CAL_SILENT_ALARM_DATETIME: 1395 case CAL_SILENT_ALARM_DATETIME:
1243 ARON = "0"; 1396 ARON = "0";
1244 dtp = &Note->Entries[i].Date ; 1397 dtp = &Note->Entries[i].Date ;
1245 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); 1398 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1246 //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1399 //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1247 //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1400 //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1248 break; 1401 break;
1249 case CAL_RECURRANCE: 1402 case CAL_RECURRANCE:
1250 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); 1403 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
1251 break; 1404 break;
1252 case CAL_TEXT: 1405 case CAL_TEXT:
1253 DSRP = QString ( (const char*) Note->Entries[i].Text ); 1406 DSRP = QString ( (const char*) Note->Entries[i].Text );
1254 break; 1407 break;
1255 case CAL_LOCATION: 1408 case CAL_LOCATION:
1256 PLCE = QString ((const char*) Note->Entries[i].Text ); 1409 PLCE = QString ((const char*) Note->Entries[i].Text );
1257 break; 1410 break;
1258 case CAL_PHONE: 1411 case CAL_PHONE:
1259 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1412 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1260 break; 1413 break;
1261 case CAL_PRIVATE: 1414 case CAL_PRIVATE:
1262 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); 1415 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
1263 break; 1416 break;
1264 case CAL_CONTACTID: 1417 case CAL_CONTACTID:
1265#if 0 1418#if 0
1266 entry.Location = Note->Entries[i].Number; 1419 entry.Location = Note->Entries[i].Number;
1267 entry.MemoryType = MEM_ME; 1420 entry.MemoryType = MEM_ME;
1268 error=Phone->GetMemory(&s, &entry); 1421 error=Phone->GetMemory(&s, &entry);
1269 if (error == ERR_NONE) { 1422 if (error == ERR_NONE) {
1270 name = GSM_PhonebookGetEntryName(&entry); 1423 name = GSM_PhonebookGetEntryName(&entry);
1271 if (name != NULL) { 1424 if (name != NULL) {
1272 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 1425 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
1273 } else { 1426 } else {
1274 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1427 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1275 } 1428 }
1276 } else { 1429 } else {
1277 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1430 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1278 } 1431 }
1279#endif 1432#endif
1280 break; 1433 break;
1281 case CAL_REPEAT_DAYOFWEEK: 1434 case CAL_REPEAT_DAYOFWEEK:
1282 repeat_dayofweek = Note->Entries[i].Number; 1435 repeat_dayofweek = Note->Entries[i].Number;
1283 repeating = true; 1436 repeating = true;
1284 break; 1437 break;
1285 case CAL_REPEAT_DAY: 1438 case CAL_REPEAT_DAY:
1286 repeat_day = Note->Entries[i].Number; 1439 repeat_day = Note->Entries[i].Number;
1287 repeating = true; 1440 repeating = true;
1288 break; 1441 break;
1289 case CAL_REPEAT_WEEKOFMONTH: 1442 case CAL_REPEAT_WEEKOFMONTH:
1290 repeat_weekofmonth = Note->Entries[i].Number; 1443 repeat_weekofmonth = Note->Entries[i].Number;
1291 repeating = true; 1444 repeating = true;
1292 break; 1445 break;
1293 case CAL_REPEAT_MONTH: 1446 case CAL_REPEAT_MONTH:
1294 repeat_month = Note->Entries[i].Number; 1447 repeat_month = Note->Entries[i].Number;
1295 repeating = true; 1448 repeating = true;
1296 break; 1449 break;
1297 case CAL_REPEAT_FREQUENCY: 1450 case CAL_REPEAT_FREQUENCY:
1298 repeat_frequency = Note->Entries[i].Number; 1451 repeat_frequency = Note->Entries[i].Number;
1299 repeating = true; 1452 repeating = true;
1300 break; 1453 break;
1301 case CAL_REPEAT_STARTDATE: 1454 case CAL_REPEAT_STARTDATE:
1302 repeat_startdate = Note->Entries[i].Date; 1455 repeat_startdate = Note->Entries[i].Date;
1303 repeating = true; 1456 repeating = true;
1304 break; 1457 break;
1305 case CAL_REPEAT_STOPDATE: 1458 case CAL_REPEAT_STOPDATE:
1306 repeat_stopdate = Note->Entries[i].Date; 1459 repeat_stopdate = Note->Entries[i].Date;
1307 repeating = true; 1460 repeating = true;
1308 break; 1461 break;
1309 } 1462 }
1310 } 1463 }
1311 1464
1312 1465
1313 1466
1314 if ( ARON == "0" ) { 1467 if ( ARON == "0" ) {
1315 QDateTime start,alarm; 1468 QDateTime start,alarm;
1316 start = handler.fromString( TIM1 ); 1469 start = handler.fromString( TIM1 );
1317 alarm = handler.fromString( ARMN ); 1470 alarm = handler.fromString( ARMN );
1318 int min = alarm.secsTo ( start )/60; 1471 int min = alarm.secsTo ( start )/60;
1319 ARMN = QString::number ( min ); 1472 ARMN = QString::number ( min );
1320 } 1473 }
1321 1474
1322 templist.clear(); 1475 templist.clear();
1323 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY; 1476 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY;
1324 handler.startElement( existingCalendar, templist, type ); 1477 handler.startElement( existingCalendar, templist, type );
1325 } 1478 }
1326 1479
1327 1480
1328 1481#endif
1329#if 0 1482#if 0
1330 // qDebug("test %s ", text.latin1()); 1483 // qDebug("test %s ", text.latin1());
1331 QStringList templist; 1484 QStringList templist;
1332 QString tempString; 1485 QString tempString;
1333 int start = 0; 1486 int start = 0;
1334 int len = text.length(); 1487 int len = text.length();
1335 int end = text.find ("\n",start)+1; 1488 int end = text.find ("\n",start)+1;
1336 bool ok = true; 1489 bool ok = true;
1337 start = end; 1490 start = end;
1338 PhoneParser handler( calendar ); 1491 PhoneParser handler( calendar );
1339 handler.setCategoriesList( mCategories ); 1492 handler.setCategoriesList( mCategories );
1340 while ( start > 0 ) { 1493 while ( start > 0 ) {
1341 templist.clear(); 1494 templist.clear();
1342 ok = true; 1495 ok = true;
1343 while ( ok ) { 1496 while ( ok ) {
1344 tempString = getPart( text, ok, start ); 1497 tempString = getPart( text, ok, start );
1345 if ( start >= len || start == 0 ) { 1498 if ( start >= len || start == 0 ) {
1346 start = 0; 1499 start = 0;
1347 ok = false; 1500 ok = false;
1348 } 1501 }
1349 if ( tempString.right(1) =="\n" ) 1502 if ( tempString.right(1) =="\n" )
1350 tempString = tempString.left( tempString.length()-1); 1503 tempString = tempString.left( tempString.length()-1);
1351 //if ( ok ) 1504 //if ( ok )
1352 templist.append( tempString ); 1505 templist.append( tempString );
1353 //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); 1506 //qDebug("%d ---%s---", templist.count(),tempString.latin1() );
1354 } 1507 }
1355 handler.startElement( existingCalendar, templist, type ); 1508 handler.startElement( existingCalendar, templist, type );
1356 } 1509 }
1357#endif 1510#endif
1358 return false; 1511 return false;
1359} 1512}
1360 1513
1361QString PhoneFormat::toString( Calendar * ) 1514QString PhoneFormat::toString( Calendar * )
1362{ 1515{
1363 return QString::null; 1516 return QString::null;
1364} 1517}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 4ddf6f0..4da38c8 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,65 +1,66 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27 27
28#include "calformat.h" 28#include "calformat.h"
29extern "C" { 29extern "C" {
30#include "../gammu/emb/common/gammu.h" 30#include "../gammu/emb/common/gammu.h"
31} 31}
32 32
33namespace KCal { 33namespace KCal {
34 34
35/** 35/**
36 This class implements the calendar format used by Phone. 36 This class implements the calendar format used by Phone.
37*/ 37*/
38 38
39class PhoneFormat : public QObject { 39class PhoneFormat : public QObject {
40 public: 40 public:
41 /** Create new iCalendar format. */ 41 /** Create new iCalendar format. */
42 PhoneFormat(); 42 PhoneFormat();
43 virtual ~PhoneFormat(); 43 virtual ~PhoneFormat();
44 44
45 bool load( Calendar * ,Calendar *); 45 bool load( Calendar * ,Calendar *, QString profileName, QString device,QString connection, QString model );
46 bool save( Calendar * ); 46 bool save( Calendar * );
47 void setCategoriesList ( QStringList * cat ){ mCategories = cat; } 47 void setCategoriesList ( QStringList * cat ){ mCategories = cat; }
48 bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & ); 48 bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & );
49 bool fromString( Calendar *, const QString & ); 49 bool fromString( Calendar *, const QString & );
50 QString toString( Calendar * ); 50 QString toString( Calendar * );
51 static ulong getCsum( const QStringList & ); 51 static ulong getCsum( const QStringList & );
52 52
53 private: 53 private:
54 QString getEventString( Event* ); 54 QString getEventString( Event* );
55 QString getTodoString( Todo* ); 55 QString getTodoString( Todo* );
56 QString dtToString( const QDateTime& dt, bool useTZ = true ); 56 QString dtToString( const QDateTime& dt, bool useTZ = true );
57 57
58 QStringList *mCategories; 58 QStringList *mCategories;
59 int getNumFromRecord( QString answer,Incidence* inc ) ; 59 int getNumFromRecord( QString answer,Incidence* inc ) ;
60 QString getPart( const QString & text, bool &ok, int &start ); 60 QString getPart( const QString & text, bool &ok, int &start );
61 QString mProfileName;
61}; 62};
62 63
63} 64}
64 65
65#endif 66#endif