-rw-r--r-- | libkcal/calendar.cpp | 15 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 3 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 227 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 4 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 7 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 4 |
7 files changed, 221 insertions, 40 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 32aac7a..a3977d7 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -31,4 +31,5 @@ | |||
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | ||
33 | 34 | ||
34 | using namespace KCal; | 35 | using namespace KCal; |
@@ -248,5 +249,19 @@ QPtrList<Incidence> Calendar::incidences() | |||
248 | return incidences; | 249 | return incidences; |
249 | } | 250 | } |
251 | void Calendar::resetTempSyncStat() | ||
252 | { | ||
253 | QPtrList<Incidence> incidences; | ||
254 | |||
255 | Incidence *i; | ||
256 | |||
257 | QPtrList<Event> e = rawEvents(); | ||
258 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | ||
250 | 259 | ||
260 | QPtrList<Todo> t = rawTodos(); | ||
261 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | ||
262 | |||
263 | QPtrList<Journal> j = journals(); | ||
264 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | ||
265 | } | ||
251 | QPtrList<Incidence> Calendar::rawIncidences() | 266 | QPtrList<Incidence> Calendar::rawIncidences() |
252 | { | 267 | { |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 4a3223c..06a911c 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -67,4 +67,5 @@ public: | |||
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | void deleteIncidence(Incidence *in); | 68 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | ||
69 | /** | 70 | /** |
70 | Clears out the current calendar, freeing all used memory etc. | 71 | Clears out the current calendar, freeing all used memory etc. |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 15c4fa8..64a343c 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -25,4 +25,5 @@ | |||
25 | 25 | ||
26 | #include "calformat.h" | 26 | #include "calformat.h" |
27 | #include "syncdefines.h" | ||
27 | 28 | ||
28 | #include "incidencebase.h" | 29 | #include "incidencebase.h" |
@@ -41,5 +42,5 @@ IncidenceBase::IncidenceBase() : | |||
41 | mPilotId = 0; | 42 | mPilotId = 0; |
42 | mExternalId = ":"; | 43 | mExternalId = ":"; |
43 | mTempSyncStat = 0; | 44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
44 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
45 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index e6d4879..6bbc0a3 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -67,7 +67,7 @@ public: | |||
67 | int priority; | 67 | int priority; |
68 | switch (ToDo->Priority) { | 68 | switch (ToDo->Priority) { |
69 | case GSM_Priority_Low : priority = 1; break; | 69 | case GSM_Priority_Low : priority = 5; break; |
70 | case GSM_Priority_Medium : priority = 3; break; | 70 | case GSM_Priority_Medium : priority = 3; break; |
71 | case GSM_Priority_High : priority = 5; break; | 71 | case GSM_Priority_High : priority = 1; break; |
72 | default :priority = 3 ;break; | 72 | default :priority = 3 ;break; |
73 | } | 73 | } |
@@ -231,4 +231,5 @@ public: | |||
231 | 231 | ||
232 | } | 232 | } |
233 | //Note->Entries[i].Date.Hour = 5; | ||
233 | break; | 234 | break; |
234 | case CAL_END_DATETIME: | 235 | case CAL_END_DATETIME: |
@@ -771,11 +772,11 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
771 | s.msg = NULL; | 772 | s.msg = NULL; |
772 | s.ConfigNum = 0; | 773 | s.ConfigNum = 0; |
773 | QLabel status ( i18n("Reading data. Opening device ..."), 0 ); | 774 | QLabel status ( i18n("Opening device ..."), 0 ); |
774 | int w = status.sizeHint().width()+20 ; | 775 | int w = status.sizeHint().width()+20 ; |
775 | if ( w < 200 ) w = 200; | 776 | if ( w < 200 ) w = 230; |
776 | int h = status.sizeHint().height()+20 ; | 777 | int h = status.sizeHint().height()+20 ; |
777 | int dw = QApplication::desktop()->width(); | 778 | int dw = QApplication::desktop()->width(); |
778 | int dh = QApplication::desktop()->height(); | 779 | int dh = QApplication::desktop()->height(); |
779 | status.setCaption(i18n("Reading Phone Data") ); | 780 | status.setCaption(i18n("Reading phone...") ); |
780 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 781 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
781 | status.show(); | 782 | status.show(); |
@@ -836,5 +837,5 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
836 | PhoneParser handler( calendar, mProfileName ); | 837 | PhoneParser handler( calendar, mProfileName ); |
837 | int ccc = 0; | 838 | int ccc = 0; |
838 | QString message = i18n("Processing event # "); | 839 | QString message = i18n(" Reading event # "); |
839 | int procCount = 0; | 840 | int procCount = 0; |
840 | qDebug("Debug: only 10 calender items are downloaded "); | 841 | qDebug("Debug: only 10 calender items are downloaded "); |
@@ -847,4 +848,8 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
847 | start = false; | 848 | start = false; |
848 | handler.readEvent( existingCal, ¬e ); | 849 | handler.readEvent( existingCal, ¬e ); |
850 | qDebug("Org loc %d ",note.Location); | ||
851 | //note.Location = 0; | ||
852 | error=Phone->SetCalendar(&s,¬e); | ||
853 | qDebug("new loc %d ",note.Location); | ||
849 | } | 854 | } |
850 | 855 | ||
@@ -852,7 +857,7 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
852 | GSM_ToDoEntry ToDo; | 857 | GSM_ToDoEntry ToDo; |
853 | ccc = 0; | 858 | ccc = 0; |
854 | message = i18n("Processing todo # "); | 859 | message = i18n(" Reading todo # "); |
855 | procCount = 0; | 860 | procCount = 0; |
856 | while (!gshutdown) { | 861 | while (!gshutdown && ccc++ < 10) { |
857 | status.setText ( message + QString::number ( ++procCount ) ); | 862 | status.setText ( message + QString::number ( ++procCount ) ); |
858 | qApp->processEvents(); | 863 | qApp->processEvents(); |
@@ -860,5 +865,5 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
860 | if (error == ERR_EMPTY) break; | 865 | if (error == ERR_EMPTY) break; |
861 | start = false; | 866 | start = false; |
862 | qDebug("ReadTodo %d ", ++ccc); | 867 | qDebug("ReadTodo %d ", ccc); |
863 | handler.readTodo( existingCal, &ToDo, &s); | 868 | handler.readTodo( existingCal, &ToDo, &s); |
864 | 869 | ||
@@ -869,17 +874,40 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
869 | return true; | 874 | return true; |
870 | } | 875 | } |
871 | void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) | 876 | #include <qcstring.h> |
877 | void PhoneFormat::event2GSM( Calendar *cal,Event* ev, GSM_CalendarEntry*Note ) | ||
872 | { | 878 | { |
873 | QString eText = vfconverter.eventToString( ev ); | 879 | QString eText = vfconverter.eventToString( ev, cal ); |
874 | int pos = 0; | 880 | int pos = 0; |
875 | GSM_ToDoEntry dummy; | 881 | GSM_ToDoEntry dummy; |
876 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*)eText.latin1(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); | 882 | qDebug( "Convert event"); |
883 | QByteArray ba; | ||
884 | QDataStream s ( ba, IO_WriteOnly ); | ||
885 | s << eText.utf8(); | ||
886 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); | ||
887 | qDebug( "Convert event done"); | ||
888 | Note->Location = 0; | ||
889 | QString loc = ev->getID(mProfileName); | ||
890 | if ( !loc.isEmpty() ){ | ||
891 | Note->Location = loc.toInt(); | ||
892 | } | ||
893 | |||
877 | } | 894 | } |
878 | void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsmTodo ) | 895 | void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo ) |
879 | { | 896 | { |
880 | QString tText = vfconverter.todoToString( todo ); | 897 | qDebug( "Convert todo1"); |
898 | QString tText = vfconverter.todoToString( todo, cal ); | ||
881 | int pos = 0; | 899 | int pos = 0; |
882 | GSM_CalendarEntry dummy; | 900 | GSM_CalendarEntry dummy; |
883 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*)tText.latin1(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); | 901 | QByteArray ba; |
902 | QDataStream s ( ba, IO_WriteOnly ); | ||
903 | s << tText.utf8(); | ||
904 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); | ||
905 | qDebug( "Convert todo done "); | ||
906 | gsmTodo->Location = 0; | ||
907 | QString loc = todo->getID(mProfileName); | ||
908 | if ( !loc.isEmpty() ){ | ||
909 | gsmTodo->Location = loc.toInt(); | ||
910 | } | ||
911 | |||
884 | } | 912 | } |
885 | void PhoneFormat::afterSave( Incidence* inc) | 913 | void PhoneFormat::afterSave( Incidence* inc) |
@@ -896,4 +924,5 @@ void PhoneFormat::afterSave( Incidence* inc) | |||
896 | bool PhoneFormat::save( Calendar *calendar) | 924 | bool PhoneFormat::save( Calendar *calendar) |
897 | { | 925 | { |
926 | return true; | ||
898 | GSM_StateMachines; | 927 | GSM_StateMachines; |
899 | qDebug(" save "); | 928 | qDebug(" save "); |
@@ -901,11 +930,11 @@ bool PhoneFormat::save( Calendar *calendar) | |||
901 | s.msg = NULL; | 930 | s.msg = NULL; |
902 | s.ConfigNum = 0; | 931 | s.ConfigNum = 0; |
903 | QLabel status ( i18n("Writing data. Opening device ..."), 0 ); | 932 | QLabel status ( i18n(" Opening device ..."), 0 ); |
904 | int w = status.sizeHint().width()+20 ; | 933 | int w = status.sizeHint().width()+20 ; |
905 | if ( w < 200 ) w = 200; | 934 | if ( w < 200 ) w = 230; |
906 | int h = status.sizeHint().height()+20 ; | 935 | int h = status.sizeHint().height()+20 ; |
907 | int dw = QApplication::desktop()->width(); | 936 | int dw = QApplication::desktop()->width(); |
908 | int dh = QApplication::desktop()->height(); | 937 | int dh = QApplication::desktop()->height(); |
909 | status.setCaption(i18n("Writing Phone Data") ); | 938 | status.setCaption(i18n("Writing to phone...") ); |
910 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 939 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
911 | status.show(); | 940 | status.show(); |
@@ -924,15 +953,21 @@ bool PhoneFormat::save( Calendar *calendar) | |||
924 | QPtrList<Event> er = calendar->rawEvents(); | 953 | QPtrList<Event> er = calendar->rawEvents(); |
925 | Event* ev = er.first(); | 954 | Event* ev = er.first(); |
926 | QString message = i18n("Processing event # "); | 955 | QString message = i18n(" Processing event # "); |
927 | int procCount = 0; | 956 | int procCount = 0; |
928 | while ( ev ) { | 957 | bool planB = true;// false; |
929 | //qDebug("i %d ", ++i); | 958 | while ( ev && ! planB) { |
930 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one | 959 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one |
931 | 960 | ||
932 | status.setText ( message + QString::number ( ++procCount ) ); | 961 | status.setText ( message + QString::number ( ++procCount ) ); |
933 | qApp->processEvents(); | 962 | qApp->processEvents(); |
934 | event2GSM( ev, &Note ); | 963 | qDebug("event1 %d ", procCount); |
964 | event2GSM( calendar, ev, &Note ); | ||
935 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 965 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
936 | error = Phone->DeleteCalendar(&s, &Note); | 966 | error = Phone->DeleteCalendar(&s, &Note); |
967 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
968 | planB = true; | ||
969 | qDebug(" e delete planB %d ", error); | ||
970 | break; | ||
971 | } | ||
937 | } | 972 | } |
938 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new | 973 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new |
@@ -942,4 +977,10 @@ bool PhoneFormat::save( Calendar *calendar) | |||
942 | else { // change existing | 977 | else { // change existing |
943 | error = Phone->SetCalendar(&s, &Note); | 978 | error = Phone->SetCalendar(&s, &Note); |
979 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
980 | planB = true; | ||
981 | qDebug(" e change planB %d ", error); | ||
982 | break; | ||
983 | } | ||
984 | qDebug("Change Calendar. Location %d status: %d",Note.Location, error ); | ||
944 | } | 985 | } |
945 | } | 986 | } |
@@ -948,6 +989,8 @@ bool PhoneFormat::save( Calendar *calendar) | |||
948 | ev = er.first(); | 989 | ev = er.first(); |
949 | // pending get empty slots | 990 | // pending get empty slots |
950 | while ( ev ) { | 991 | int loc = 0; |
992 | while ( ev && ! planB) { | ||
951 | 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) { |
994 | qDebug("event2 %d ", procCount); | ||
952 | if ( ev->getID(mProfileName).isEmpty() ) { | 995 | if ( ev->getID(mProfileName).isEmpty() ) { |
953 | status.setText ( message + QString::number ( ++procCount ) ); | 996 | status.setText ( message + QString::number ( ++procCount ) ); |
@@ -955,9 +998,15 @@ bool PhoneFormat::save( Calendar *calendar) | |||
955 | //int newID ;//= pending | 998 | //int newID ;//= pending |
956 | //ev->setID(mProfileName, QString::number( newID )); | 999 | //ev->setID(mProfileName, QString::number( newID )); |
957 | event2GSM( ev, &Note ); | 1000 | event2GSM( calendar, ev, &Note ); |
958 | Note.Location = 0; | 1001 | ++loc; |
1002 | Note.Location = loc; | ||
959 | error = Phone->AddCalendar(&s, &Note); | 1003 | error = Phone->AddCalendar(&s, &Note); |
1004 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1005 | planB = true; | ||
1006 | qDebug(" e add planB %d ", error); | ||
1007 | break; | ||
1008 | } | ||
960 | ev->setID( mProfileName, QString::number( Note.Location ) ); | 1009 | ev->setID( mProfileName, QString::number( Note.Location ) ); |
961 | qDebug("New Calendar. Location %d ",Note.Location ); | 1010 | qDebug("New Calendar. Location %d stat %d %d",Note.Location ,error, ERR_UNKNOWN); |
962 | afterSave( ev ); | 1011 | afterSave( ev ); |
963 | } else { | 1012 | } else { |
@@ -967,23 +1016,90 @@ bool PhoneFormat::save( Calendar *calendar) | |||
967 | ev = er.next(); | 1016 | ev = er.next(); |
968 | } | 1017 | } |
1018 | |||
1019 | |||
1020 | if ( planB ) { | ||
1021 | qDebug("delete all calendar..."); | ||
1022 | status.setText ( i18n("Deleting all calendar...")); | ||
1023 | qApp->processEvents(); | ||
1024 | error=Phone->DeleteAllCalendar(&s); | ||
1025 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1026 | message = i18n(" Deleting event # "); | ||
1027 | procCount = 0; | ||
1028 | while (1) { | ||
1029 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1030 | qApp->processEvents(); | ||
1031 | qDebug("deleting event ... %d", procCount); | ||
1032 | error = Phone->GetNextCalendar(&s,&Note,true); | ||
1033 | if (error != ERR_NONE) break; | ||
1034 | error = Phone->DeleteCalendar(&s,&Note); | ||
1035 | } | ||
1036 | qDebug("deleting calendar ... finished"); | ||
1037 | } else { | ||
1038 | status.setText ( i18n("All calendar deleted!")); | ||
1039 | qDebug("all cal deleted"); | ||
1040 | } | ||
1041 | bool planC = false; | ||
1042 | ev = er.first(); | ||
1043 | procCount = 0; | ||
1044 | message = i18n(" Writing event # "); | ||
1045 | while ( ev && ! planC) { | ||
1046 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1047 | qApp->processEvents(); | ||
1048 | event2GSM( calendar, ev, &Note ); | ||
1049 | Note.Location = procCount; | ||
1050 | error=Phone->AddCalendar(&s,&Note); | ||
1051 | if (error != ERR_NONE ) { | ||
1052 | // we have currently no planC :-( | ||
1053 | // planC = true; | ||
1054 | //qDebug("add planC %d ", error); | ||
1055 | //break; | ||
1056 | // we remove the ID such that this todo is not deleted after next sync | ||
1057 | ev->removeID(mProfileName); | ||
1058 | ev->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
1059 | qDebug("error :cal adding loc %d planB stat %d ", Note.Location ,error); | ||
1060 | } else { | ||
1061 | qDebug("cal adding loc %d planB stat %d ", Note.Location ,error); | ||
1062 | ev->setID(mProfileName, QString::number( Note.Location )); | ||
1063 | afterSave( ev ); | ||
1064 | } | ||
1065 | ev = er.next(); | ||
1066 | } | ||
1067 | if ( planC ) { | ||
1068 | qDebug("writing cal went wrong..."); | ||
1069 | |||
1070 | // we have currently no planC :-( | ||
1071 | } | ||
1072 | } | ||
969 | GSM_ToDoEntry ToDoEntry; | 1073 | GSM_ToDoEntry ToDoEntry; |
970 | QPtrList<Todo> tl = calendar->rawTodos(); | 1074 | QPtrList<Todo> tl = calendar->rawTodos(); |
971 | Todo* to = tl.first(); | 1075 | Todo* to = tl.first(); |
972 | 1076 | ||
973 | message = i18n("Processing todo # "); | 1077 | message = i18n(" Processing todo # "); |
974 | procCount = 0; | 1078 | procCount = 0; |
975 | while ( to ) { | 1079 | planB = false; |
1080 | while ( to && ! planB ) { | ||
976 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 1081 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
1082 | qDebug("todo3 %d ", procCount); | ||
977 | status.setText ( message + QString::number ( ++procCount ) ); | 1083 | status.setText ( message + QString::number ( ++procCount ) ); |
978 | qApp->processEvents(); | 1084 | qApp->processEvents(); |
979 | todo2GSM( to, &ToDoEntry ); | 1085 | qDebug("todo5 %d ", procCount); |
1086 | todo2GSM( calendar, to, &ToDoEntry ); | ||
980 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 1087 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
981 | error=Phone->DeleteToDo(&s,&ToDoEntry); | 1088 | error=Phone->DeleteToDo(&s,&ToDoEntry); |
1089 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1090 | planB = true; | ||
1091 | qDebug("delete planB %d ", error); | ||
1092 | } | ||
982 | } | 1093 | } |
983 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new | 1094 | else if ( to->getID(mProfileName).isEmpty() ) { // add new |
984 | ; | 1095 | ; |
985 | } | 1096 | } |
986 | else { // change existing | 1097 | else { // change existing |
987 | error=Phone->SetToDo(&s,&ToDoEntry); | 1098 | error=Phone->SetToDo(&s,&ToDoEntry); |
1099 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1100 | planB = true; | ||
1101 | qDebug("set planB %d ", error); | ||
1102 | } | ||
1103 | qDebug("Old Todo. Location %d %d",ToDoEntry.Location , error ); | ||
988 | } | 1104 | } |
989 | } | 1105 | } |
@@ -993,6 +1109,8 @@ bool PhoneFormat::save( Calendar *calendar) | |||
993 | // pending get empty slots | 1109 | // pending get empty slots |
994 | to = tl.first(); | 1110 | to = tl.first(); |
995 | while ( to ) { | 1111 | while ( to && ! planB ) { |
1112 | qDebug("todo2 %d ", procCount); | ||
996 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 1113 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
1114 | qDebug("todo4 %d ", procCount); | ||
997 | if ( to->getID(mProfileName).isEmpty() ) { | 1115 | if ( to->getID(mProfileName).isEmpty() ) { |
998 | status.setText ( message + QString::number ( ++procCount ) ); | 1116 | status.setText ( message + QString::number ( ++procCount ) ); |
@@ -1000,10 +1118,14 @@ bool PhoneFormat::save( Calendar *calendar) | |||
1000 | //int newID ;//= pending | 1118 | //int newID ;//= pending |
1001 | //to->setID(mProfileName, QString::number( newID )); | 1119 | //to->setID(mProfileName, QString::number( newID )); |
1002 | todo2GSM( to, &ToDoEntry ); | 1120 | todo2GSM( calendar,to, &ToDoEntry ); |
1003 | ToDoEntry.Location = 0; | 1121 | ToDoEntry.Location = 0; |
1004 | error=Phone->AddToDo(&s,&ToDoEntry); | 1122 | error=Phone->AddToDo(&s,&ToDoEntry); |
1123 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1124 | planB = true; | ||
1125 | qDebug("new planB %d ", error); | ||
1126 | } | ||
1005 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); | 1127 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); |
1006 | afterSave( to ); | 1128 | afterSave( to ); |
1007 | qDebug("New Todo. Location %d ",ToDoEntry.Location ); | 1129 | qDebug("New Todo. Location %d %d",ToDoEntry.Location, error ); |
1008 | } else { | 1130 | } else { |
1009 | afterSave( to ); | 1131 | afterSave( to ); |
@@ -1012,4 +1134,43 @@ bool PhoneFormat::save( Calendar *calendar) | |||
1012 | to = tl.next(); | 1134 | to = tl.next(); |
1013 | } | 1135 | } |
1136 | if ( planB ) { | ||
1137 | qDebug("delete all ..."); | ||
1138 | error=Phone->DeleteAllToDo(&s); | ||
1139 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1140 | while (1) { | ||
1141 | qDebug("deleting todo ..."); | ||
1142 | error = Phone->GetNextToDo(&s,&ToDoEntry,true); | ||
1143 | if (error != ERR_NONE) break; | ||
1144 | error = Phone->DeleteToDo(&s,&ToDoEntry); | ||
1145 | } | ||
1146 | qDebug("deleting todo ... finished"); | ||
1147 | } else { | ||
1148 | qDebug("all todo deleted"); | ||
1149 | } | ||
1150 | bool planC = false; | ||
1151 | to = tl.first(); | ||
1152 | while ( to && ! planC ) { | ||
1153 | todo2GSM( calendar,to, &ToDoEntry ); | ||
1154 | ToDoEntry.Location = 0; | ||
1155 | error=Phone->AddToDo(&s,&ToDoEntry); | ||
1156 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1157 | // we have currently no planC :-( | ||
1158 | // planC = true; | ||
1159 | //qDebug("add planC %d ", error); | ||
1160 | //break; | ||
1161 | // we remove the ID such that this todo is not deleted after next sync | ||
1162 | to->removeID(mProfileName); | ||
1163 | to->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
1164 | } else { | ||
1165 | qDebug("adding %d planB %d ", ToDoEntry.Location ,error); | ||
1166 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); | ||
1167 | afterSave( to ); | ||
1168 | } | ||
1169 | to = tl.next(); | ||
1170 | } | ||
1171 | if ( planC ) { | ||
1172 | // we have currently no planC :-( | ||
1173 | } | ||
1174 | } | ||
1014 | return true; | 1175 | return true; |
1015 | } | 1176 | } |
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 33b2091..2c2e51c 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -53,6 +53,6 @@ class PhoneFormat : public QObject { | |||
53 | private: | 53 | private: |
54 | VCalFormat vfconverter; | 54 | VCalFormat vfconverter; |
55 | void event2GSM( Event* ev, GSM_CalendarEntry*Note ); | 55 | void event2GSM( Calendar *, Event* ev, GSM_CalendarEntry*Note ); |
56 | void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); | 56 | void todo2GSM( Calendar *, Todo* ev, GSM_ToDoEntry *ToDo ); |
57 | int initDevice(GSM_StateMachine *s); | 57 | int initDevice(GSM_StateMachine *s); |
58 | QString getEventString( Event* ); | 58 | QString getEventString( Event* ); |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 1167e58..076cd3f 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -46,4 +46,5 @@ using namespace KCal; | |||
46 | VCalFormat::VCalFormat() | 46 | VCalFormat::VCalFormat() |
47 | { | 47 | { |
48 | mCalendar = 0; | ||
48 | } | 49 | } |
49 | 50 | ||
@@ -166,7 +167,8 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | |||
166 | } | 167 | } |
167 | 168 | ||
168 | QString VCalFormat::eventToString( Event * event) | 169 | QString VCalFormat::eventToString( Event * event, Calendar *calendar) |
169 | { | 170 | { |
170 | if ( !event ) return QString::null; | 171 | if ( !event ) return QString::null; |
172 | mCalendar = calendar; | ||
171 | VObject *vevent = eventToVEvent( event ); | 173 | VObject *vevent = eventToVEvent( event ); |
172 | char *buf = writeMemVObject( 0, 0, vevent ); | 174 | char *buf = writeMemVObject( 0, 0, vevent ); |
@@ -175,7 +177,8 @@ QString VCalFormat::eventToString( Event * event) | |||
175 | return result; | 177 | return result; |
176 | } | 178 | } |
177 | QString VCalFormat::todoToString( Todo * todo ) | 179 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar ) |
178 | { | 180 | { |
179 | if ( !todo ) return QString::null; | 181 | if ( !todo ) return QString::null; |
182 | mCalendar = calendar; | ||
180 | VObject *vevent = eventToVTodo( todo ); | 183 | VObject *vevent = eventToVTodo( todo ); |
181 | char *buf = writeMemVObject( 0, 0, vevent ); | 184 | char *buf = writeMemVObject( 0, 0, vevent ); |
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index 8490125..7b9ca26 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h | |||
@@ -63,6 +63,6 @@ class VCalFormat : public CalFormat { | |||
63 | */ | 63 | */ |
64 | QString toString( Calendar * ); | 64 | QString toString( Calendar * ); |
65 | QString eventToString( Event * ); | 65 | QString eventToString( Event *, Calendar *calendar ); |
66 | QString todoToString( Todo * ); | 66 | QString todoToString( Todo * ,Calendar *calendar ); |
67 | 67 | ||
68 | protected: | 68 | protected: |