summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index e43a507..11c68c5 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -709,366 +709,385 @@ ulong PhoneFormat::getCsumEvent( Event* event )
709 list.append( QString::number( rec->frequency()) );//12 709 list.append( QString::number( rec->frequency()) );//12
710 list.append( "0" ); 710 list.append( "0" );
711 list.append( "0" ); 711 list.append( "0" );
712 writeEndDate = true; 712 writeEndDate = true;
713 break; 713 break;
714 714
715 default: 715 default:
716 list.append( "255" ); 716 list.append( "255" );
717 list.append( QString() ); 717 list.append( QString() );
718 list.append( "0" ); 718 list.append( "0" );
719 list.append( QString() ); 719 list.append( QString() );
720 list.append( "0" ); 720 list.append( "0" );
721 list.append( "20991231T000000" ); 721 list.append( "20991231T000000" );
722 break; 722 break;
723 } 723 }
724 if ( writeEndDate ) { 724 if ( writeEndDate ) {
725 725
726 if ( rec->endDate().isValid() ) { // 15 + 16 726 if ( rec->endDate().isValid() ) { // 15 + 16
727 list.append( "1" ); 727 list.append( "1" );
728 list.append( PhoneParser::dtToString( rec->endDate()) ); 728 list.append( PhoneParser::dtToString( rec->endDate()) );
729 } else { 729 } else {
730 list.append( "0" ); 730 list.append( "0" );
731 list.append( "20991231T000000" ); 731 list.append( "20991231T000000" );
732 } 732 }
733 733
734 } 734 }
735 attList << list.join(""); 735 attList << list.join("");
736 attList << event->categoriesStr(); 736 attList << event->categoriesStr();
737 attList << event->secrecyStr(); 737 attList << event->secrecyStr();
738 return PhoneFormat::getCsum(attList ); 738 return PhoneFormat::getCsum(attList );
739} 739}
740ulong PhoneFormat::getCsum( const QStringList & attList) 740ulong PhoneFormat::getCsum( const QStringList & attList)
741{ 741{
742 int max = attList.count() -1; 742 int max = attList.count() -1;
743 ulong cSum = 0; 743 ulong cSum = 0;
744 int j,k,i; 744 int j,k,i;
745 int add; 745 int add;
746 for ( i = 1; i < max ; ++i ) { 746 for ( i = 1; i < max ; ++i ) {
747 QString s = attList[i]; 747 QString s = attList[i];
748 if ( ! s.isEmpty() ){ 748 if ( ! s.isEmpty() ){
749 j = s.length(); 749 j = s.length();
750 for ( k = 0; k < j; ++k ) { 750 for ( k = 0; k < j; ++k ) {
751 int mul = k +1; 751 int mul = k +1;
752 add = s[k].unicode (); 752 add = s[k].unicode ();
753 if ( k < 16 ) 753 if ( k < 16 )
754 mul = mul * mul; 754 mul = mul * mul;
755 add = add * mul *i*i*i; 755 add = add * mul *i*i*i;
756 cSum += add; 756 cSum += add;
757 } 757 }
758 } 758 }
759 } 759 }
760 return cSum; 760 return cSum;
761 761
762} 762}
763//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 763//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
764#include <stdlib.h> 764#include <stdlib.h>
765#define DEBUGMODE false 765#define DEBUGMODE false
766bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 766bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
767{ 767{
768 GSM_StateMachines; 768 GSM_StateMachines;
769 qDebug(" load "); 769 qDebug(" load ");
770 s.opened = false; 770 s.opened = false;
771 s.msg = NULL; 771 s.msg = NULL;
772 s.ConfigNum = 0; 772 s.ConfigNum = 0;
773 QLabel status ( i18n("Reading data. Opening device ..."), 0 );
774 int w = status.sizeHint().width()+20 ;
775 if ( w < 200 ) w = 200;
776 int h = status.sizeHint().height()+20 ;
777 int dw = QApplication::desktop()->width();
778 int dh = QApplication::desktop()->height();
779 status.setCaption(i18n("Reading Phone Data") );
780 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
781 status.show();
782 status.raise();
783 qApp->processEvents();
773#if 0 784#if 0
774 static char*cp; 785 static char*cp;
775 static INI_Section *cfg = NULL; 786 static INI_Section *cfg = NULL;
776 cfg=GSM_FindGammuRC(); 787 cfg=GSM_FindGammuRC();
777 int i; 788 int i;
778 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 789 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
779 if (cfg!=NULL) { 790 if (cfg!=NULL) {
780 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 791 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
781 if (cp) di.coding = cp; 792 if (cp) di.coding = cp;
782 793
783 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 794 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
784 if (s.Config[i].Localize) { 795 if (s.Config[i].Localize) {
785 s.msg=INI_ReadFile(s.Config[i].Localize, true); 796 s.msg=INI_ReadFile(s.Config[i].Localize, true);
786 } else { 797 } else {
787#if !defined(WIN32) && defined(LOCALE_PATH) 798#if !defined(WIN32) && defined(LOCALE_PATH)
788 locale = setlocale(LC_MESSAGES, NULL); 799 locale = setlocale(LC_MESSAGES, NULL);
789 if (locale != NULL) { 800 if (locale != NULL) {
790 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 801 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
791 LOCALE_PATH, 802 LOCALE_PATH,
792 tolower(locale[0]), 803 tolower(locale[0]),
793 tolower(locale[1])); 804 tolower(locale[1]));
794 s.msg = INI_ReadFile(locale_file, true); 805 s.msg = INI_ReadFile(locale_file, true);
795 } 806 }
796#endif 807#endif
797 } 808 }
798 } 809 }
799 810
800 /* Wanted user specific configuration? */ 811 /* Wanted user specific configuration? */
801 812
802 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 813 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
803 814
804 s.ConfigNum++; 815 s.ConfigNum++;
805 816
806 /* We want to use only one file descriptor for global and state machine debug output */ 817 /* We want to use only one file descriptor for global and state machine debug output */
807 s.Config[i].UseGlobalDebugFile = true; 818 s.Config[i].UseGlobalDebugFile = true;
808 819
809 820
810 821
811 /* We wanted to read just user specified configuration. */ 822 /* We wanted to read just user specified configuration. */
812 {break;} 823 {break;}
813 } 824 }
814 825
815#endif 826#endif
816 int error=initDevice(&s); 827 int error=initDevice(&s);
817 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 828 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
818 if ( error != ERR_NONE ) 829 if ( error != ERR_NONE )
819 return false; 830 return false;
820 GSM_Phone_Functions*Phone; 831 GSM_Phone_Functions*Phone;
821 GSM_CalendarEntrynote; 832 GSM_CalendarEntrynote;
822 bool start = true; 833 bool start = true;
823 Phone=s.Phone.Functions; 834 Phone=s.Phone.Functions;
824 bool gshutdown = false; 835 bool gshutdown = false;
825 PhoneParser handler( calendar, mProfileName ); 836 PhoneParser handler( calendar, mProfileName );
826 int ccc = 0; 837 int ccc = 0;
838 QString message = i18n("Processing event # ");
839 int procCount = 0;
827 qDebug("Debug: only 10 calender items are downloaded "); 840 qDebug("Debug: only 10 calender items are downloaded ");
828 while (!gshutdown && ccc++ < 10) { 841 while (!gshutdown && ccc++ < 10) {
829 842 status.setText ( message + QString::number ( ++procCount ) );
843 qApp->processEvents();
830 qDebug("readEvent %d ", ccc); 844 qDebug("readEvent %d ", ccc);
831 error=Phone->GetNextCalendar(&s,&note,start); 845 error=Phone->GetNextCalendar(&s,&note,start);
832 if (error == ERR_EMPTY) break; 846 if (error == ERR_EMPTY) break;
833 start = false; 847 start = false;
834 handler.readEvent( existingCal, &note ); 848 handler.readEvent( existingCal, &note );
835 } 849 }
836 850
837 start = true; 851 start = true;
838 GSM_ToDoEntry ToDo; 852 GSM_ToDoEntry ToDo;
839 ccc = 0; 853 ccc = 0;
854 message = i18n("Processing todo # ");
855 procCount = 0;
840 while (!gshutdown) { 856 while (!gshutdown) {
857 status.setText ( message + QString::number ( ++procCount ) );
858 qApp->processEvents();
841 error = Phone->GetNextToDo(&s, &ToDo, start); 859 error = Phone->GetNextToDo(&s, &ToDo, start);
842 if (error == ERR_EMPTY) break; 860 if (error == ERR_EMPTY) break;
843 start = false; 861 start = false;
844 qDebug("ReadTodo %d ", ++ccc); 862 qDebug("ReadTodo %d ", ++ccc);
845 handler.readTodo( existingCal, &ToDo, &s); 863 handler.readTodo( existingCal, &ToDo, &s);
846 864
847 } 865 }
848 866
849 error=GSM_TerminateConnection(&s); 867 error=GSM_TerminateConnection(&s);
850 868
851 return true; 869 return true;
852} 870}
853void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) 871void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note )
854{ 872{
855 873
856} 874}
857void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsm ) 875void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsm )
858{ 876{
859#if 0 877#if 0
860 QStringList list; 878 QStringList list;
861 list.append( QString::number( todo->zaurusId() ) ); 879 list.append( QString::number( todo->zaurusId() ) );
862 list.append( todo->categories().join(",") ); 880 list.append( todo->categories().join(",") );
863 881
864 if ( todo->hasStartDate() ) { 882 if ( todo->hasStartDate() ) {
865 list.append( dtToString( todo->dtStart()) ); 883 list.append( dtToString( todo->dtStart()) );
866 } else 884 } else
867 list.append( QString() ); 885 list.append( QString() );
868 886
869 if ( todo->hasDueDate() ) { 887 if ( todo->hasDueDate() ) {
870 QTime tim; 888 QTime tim;
871 if ( todo->doesFloat()) { 889 if ( todo->doesFloat()) {
872 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; 890 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
873 } else { 891 } else {
874 list.append( dtToString(todo->dtDue() ) ); 892 list.append( dtToString(todo->dtDue() ) );
875 } 893 }
876 } else 894 } else
877 list.append( QString() ); 895 list.append( QString() );
878 896
879 if ( todo->isCompleted() ) { 897 if ( todo->isCompleted() ) {
880 list.append( dtToString( todo->completed()) ); 898 list.append( dtToString( todo->completed()) );
881 list.append( "0" ); // yes 0 == completed 899 list.append( "0" ); // yes 0 == completed
882 } else { 900 } else {
883 list.append( dtToString( todo->completed()) ); 901 list.append( dtToString( todo->completed()) );
884 list.append( "1" ); 902 list.append( "1" );
885 } 903 }
886 list.append( QString::number( todo->priority() )); 904 list.append( QString::number( todo->priority() ));
887 if( ! todo->summary().isEmpty() ) 905 if( ! todo->summary().isEmpty() )
888 list.append( todo->summary() ); 906 list.append( todo->summary() );
889 else 907 else
890 list.append( "" ); 908 list.append( "" );
891 if (! todo->description().isEmpty() ) 909 if (! todo->description().isEmpty() )
892 list.append( todo->description() ); 910 list.append( todo->description() );
893 else 911 else
894 list.append( "" ); 912 list.append( "" );
895 for(QStringList::Iterator it=list.begin(); 913 for(QStringList::Iterator it=list.begin();
896 it!=list.end(); ++it){ 914 it!=list.end(); ++it){
897 QString& s = (*it); 915 QString& s = (*it);
898 s.replace(QRegExp("\""), "\"\""); 916 s.replace(QRegExp("\""), "\"\"");
899 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 917 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
900 s.prepend('\"'); 918 s.prepend('\"');
901 s.append('\"'); 919 s.append('\"');
902 } else if(s.isEmpty() && !s.isNull()){ 920 } else if(s.isEmpty() && !s.isNull()){
903 s = "\"\""; 921 s = "\"\"";
904 } 922 }
905 } 923 }
906 return list.join(","); 924 return list.join(",");
907#endif 925#endif
908} 926}
909void PhoneFormat::afterSave( Incidence* inc) 927void PhoneFormat::afterSave( Incidence* inc)
910{ 928{
911 uint csum; 929 uint csum;
912 if ( inc->type() == "Event") 930 if ( inc->type() == "Event")
913 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 931 csum = PhoneFormat::getCsumEvent( (Event*) inc );
914 else 932 else
915 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 933 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
916 inc->setCsum( mProfileName, QString::number( csum )); 934 inc->setCsum( mProfileName, QString::number( csum ));
917 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 935 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
918 936
919} 937}
920bool PhoneFormat::save( Calendar *calendar) 938bool PhoneFormat::save( Calendar *calendar)
921{ 939{
922 GSM_StateMachines; 940 GSM_StateMachines;
923 qDebug(" save "); 941 qDebug(" save ");
924 s.opened = false; 942 s.opened = false;
925 s.msg = NULL; 943 s.msg = NULL;
926 s.ConfigNum = 0; 944 s.ConfigNum = 0;
927 QLabel status ( i18n("Writing data. Opening device ..."), 0 ); 945 QLabel status ( i18n("Writing data. Opening device ..."), 0 );
928 int w = status.sizeHint().width()+20 ; 946 int w = status.sizeHint().width()+20 ;
929 if ( w < 200 ) w = 200; 947 if ( w < 200 ) w = 200;
930 int h = status.sizeHint().height()+20 ; 948 int h = status.sizeHint().height()+20 ;
931 int dw = QApplication::desktop()->width(); 949 int dw = QApplication::desktop()->width();
932 int dh = QApplication::desktop()->height(); 950 int dh = QApplication::desktop()->height();
933 status.setCaption(i18n("Writing DTM Data") ); 951 status.setCaption(i18n("Writing Phone Data") );
934 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 952 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
935 status.show(); 953 status.show();
936 status.raise(); 954 status.raise();
937 qApp->processEvents(); 955 qApp->processEvents();
938 956
939 int error=initDevice(&s); 957 int error=initDevice(&s);
940 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 958 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
941 if ( error != ERR_NONE ) 959 if ( error != ERR_NONE )
942 return false; 960 return false;
943 GSM_Phone_Functions*Phone; 961 GSM_Phone_Functions*Phone;
944 GSM_CalendarEntryNote; 962 GSM_CalendarEntryNote;
945 bool start = true; 963 bool start = true;
946 Phone=s.Phone.Functions; 964 Phone=s.Phone.Functions;
947 bool gshutdown = false; 965 bool gshutdown = false;
948 QPtrList<Event> er = calendar->rawEvents(); 966 QPtrList<Event> er = calendar->rawEvents();
949 Event* ev = er.first(); 967 Event* ev = er.first();
950 QString message = i18n("Processing event # "); 968 QString message = i18n("Processing event # ");
951 int procCount = 0; 969 int procCount = 0;
952 while ( ev ) { 970 while ( ev ) {
953 //qDebug("i %d ", ++i); 971 //qDebug("i %d ", ++i);
954 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one 972 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one
955 973
956 status.setText ( message + QString::number ( ++procCount ) ); 974 status.setText ( message + QString::number ( ++procCount ) );
957 qApp->processEvents(); 975 qApp->processEvents();
958 event2GSM( ev, &Note ); 976 event2GSM( ev, &Note );
959 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 977 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
960 error = Phone->DeleteCalendar(&s, &Note); 978 error = Phone->DeleteCalendar(&s, &Note);
961 } 979 }
962 else if ( ev->getID(mProfileName).isEmpty() ) { // add new 980 else if ( ev->getID(mProfileName).isEmpty() ) { // add new
963 // we have to do this later after deleting 981 // we have to do this later after deleting
964 982
965 } 983 }
966 else { // change existing 984 else { // change existing
967 error = Phone->SetCalendar(&s, &Note); 985 error = Phone->SetCalendar(&s, &Note);
968 } 986 }
969 } 987 }
970 ev = er.next(); 988 ev = er.next();
971 } 989 }
972 ev = er.first(); 990 ev = er.first();
973 // pending get empty slots 991 // pending get empty slots
974 while ( ev ) { 992 while ( ev ) {
975 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 993 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
976 if ( ev->getID(mProfileName).isEmpty() ) { 994 if ( ev->getID(mProfileName).isEmpty() ) {
977 status.setText ( message + QString::number ( ++procCount ) ); 995 status.setText ( message + QString::number ( ++procCount ) );
978 qApp->processEvents(); 996 qApp->processEvents();
979 //int newID ;//= pending 997 //int newID ;//= pending
980 //ev->setID(mProfileName, QString::number( newID )); 998 //ev->setID(mProfileName, QString::number( newID ));
981 event2GSM( ev, &Note ); 999 event2GSM( ev, &Note );
982 Note.Location = 0; 1000 Note.Location = 0;
983 error = Phone->AddCalendar(&s, &Note); 1001 error = Phone->AddCalendar(&s, &Note);
984 ev->setID( mProfileName, QString::number( Note.Location ) ); 1002 ev->setID( mProfileName, QString::number( Note.Location ) );
1003 qDebug("New Calendar. Location %d ",Note.Location );
985 afterSave( ev ); 1004 afterSave( ev );
986 } else { 1005 } else {
987 afterSave( ev ); // setting temp sync stat for changed items 1006 afterSave( ev ); // setting temp sync stat for changed items
988 } 1007 }
989 } 1008 }
990 ev = er.next(); 1009 ev = er.next();
991 } 1010 }
992 GSM_ToDoEntry ToDoEntry; 1011 GSM_ToDoEntry ToDoEntry;
993 QPtrList<Todo> tl = calendar->rawTodos(); 1012 QPtrList<Todo> tl = calendar->rawTodos();
994 Todo* to = tl.first(); 1013 Todo* to = tl.first();
995 1014
996 message = i18n("Processing todo # "); 1015 message = i18n("Processing todo # ");
997 procCount = 0; 1016 procCount = 0;
998 while ( to ) { 1017 while ( to ) {
999 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 1018 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1000 status.setText ( message + QString::number ( ++procCount ) ); 1019 status.setText ( message + QString::number ( ++procCount ) );
1001 qApp->processEvents(); 1020 qApp->processEvents();
1002 todo2GSM( to, &ToDoEntry ); 1021 todo2GSM( to, &ToDoEntry );
1003 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 1022 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
1004 error=Phone->DeleteToDo(&s,&ToDoEntry); 1023 error=Phone->DeleteToDo(&s,&ToDoEntry);
1005 } 1024 }
1006 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new 1025 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
1007 ; 1026 ;
1008 } 1027 }
1009 else { // change existing 1028 else { // change existing
1010 error=Phone->AddToDo(&s,&ToDoEntry); 1029 error=Phone->SetToDo(&s,&ToDoEntry);
1011 } 1030 }
1012 } 1031 }
1013 to = tl.next(); 1032 to = tl.next();
1014 } 1033 }
1015 1034
1016 // pending get empty slots 1035 // pending get empty slots
1017 to = tl.first(); 1036 to = tl.first();
1018 while ( to ) { 1037 while ( to ) {
1019 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 1038 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1020 if ( to->getID(mProfileName).isEmpty() ) { 1039 if ( to->getID(mProfileName).isEmpty() ) {
1021 status.setText ( message + QString::number ( ++procCount ) ); 1040 status.setText ( message + QString::number ( ++procCount ) );
1022 qApp->processEvents(); 1041 qApp->processEvents();
1023 //int newID ;//= pending 1042 //int newID ;//= pending
1024 //to->setID(mProfileName, QString::number( newID )); 1043 //to->setID(mProfileName, QString::number( newID ));
1025 todo2GSM( to, &ToDoEntry ); 1044 todo2GSM( to, &ToDoEntry );
1026 ToDoEntry.Location = 0; 1045 ToDoEntry.Location = 0;
1027 error=Phone->AddToDo(&s,&ToDoEntry); 1046 error=Phone->AddToDo(&s,&ToDoEntry);
1028 to->setID(mProfileName, QString::number( ToDoEntry.Location )); 1047 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1029 afterSave( to ); 1048 afterSave( to );
1030 qDebug("New Todo. Location %d ",ToDoEntry.Location ); 1049 qDebug("New Todo. Location %d ",ToDoEntry.Location );
1031 } else { 1050 } else {
1032 afterSave( to ); 1051 afterSave( to );
1033 } 1052 }
1034 } 1053 }
1035 to = tl.next(); 1054 to = tl.next();
1036 } 1055 }
1037 return true; 1056 return true;
1038} 1057}
1039QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) 1058QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ )
1040{ 1059{
1041 QString datestr; 1060 QString datestr;
1042 QString timestr; 1061 QString timestr;
1043 int offset = KGlobal::locale()->localTimeOffset( dti ); 1062 int offset = KGlobal::locale()->localTimeOffset( dti );
1044 QDateTime dt; 1063 QDateTime dt;
1045 if (useTZ) 1064 if (useTZ)
1046 dt = dti.addSecs ( -(offset*60)); 1065 dt = dti.addSecs ( -(offset*60));
1047 else 1066 else
1048 dt = dti; 1067 dt = dti;
1049 if(dt.date().isValid()){ 1068 if(dt.date().isValid()){
1050 const QDate& date = dt.date(); 1069 const QDate& date = dt.date();
1051 datestr.sprintf("%04d%02d%02d", 1070 datestr.sprintf("%04d%02d%02d",
1052 date.year(), date.month(), date.day()); 1071 date.year(), date.month(), date.day());
1053 } 1072 }
1054 if(dt.time().isValid()){ 1073 if(dt.time().isValid()){
1055 const QTime& time = dt.time(); 1074 const QTime& time = dt.time();
1056 timestr.sprintf("T%02d%02d%02d", 1075 timestr.sprintf("T%02d%02d%02d",
1057 time.hour(), time.minute(), time.second()); 1076 time.hour(), time.minute(), time.second());
1058 } 1077 }
1059 return datestr + timestr; 1078 return datestr + timestr;
1060} 1079}
1061QString PhoneFormat::getEventString( Event* event ) 1080QString PhoneFormat::getEventString( Event* event )
1062{ 1081{
1063#if 0 1082#if 0
1064 QStringList list; 1083 QStringList list;
1065 list.append( QString::number(event->zaurusId() ) ); 1084 list.append( QString::number(event->zaurusId() ) );
1066 list.append( event->categories().join(",") ); 1085 list.append( event->categories().join(",") );
1067 if ( !event->summary().isEmpty() ) 1086 if ( !event->summary().isEmpty() )
1068 list.append( event->summary() ); 1087 list.append( event->summary() );
1069 else 1088 else
1070 list.append("" ); 1089 list.append("" );
1071 if ( !event->location().isEmpty() ) 1090 if ( !event->location().isEmpty() )
1072 list.append( event->location() ); 1091 list.append( event->location() );
1073 else 1092 else
1074 list.append("" ); 1093 list.append("" );