author | zautrix <zautrix> | 2004-08-20 04:28:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-20 04:28:28 (UTC) |
commit | 93decd4185adc7197008e8397cf753a5ab674d99 (patch) (unidiff) | |
tree | 0d701d0a687c22cfe2894121f8540d60a5fbe7a9 /libkcal/phoneformat.cpp | |
parent | f7a401f03c18ef96eb40dc5540b31cd10880e845 (diff) | |
download | kdepimpi-93decd4185adc7197008e8397cf753a5ab674d99.zip kdepimpi-93decd4185adc7197008e8397cf753a5ab674d99.tar.gz kdepimpi-93decd4185adc7197008e8397cf753a5ab674d99.tar.bz2 |
Bugfixes for syncing
-rw-r--r-- | libkcal/phoneformat.cpp | 336 |
1 files changed, 284 insertions, 52 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 6bbc0a3..6276498 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -478,17 +478,17 @@ public: | |||
478 | event->setCsum( mProfileName, QString::number( cSum )); | 478 | event->setCsum( mProfileName, QString::number( cSum )); |
479 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 479 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
480 | mCalendar->addEvent( event); | 480 | mCalendar->addEvent( event); |
481 | 481 | ||
482 | return true; | 482 | return true; |
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { | 486 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = false ) { |
487 | QDateTime dt; | 487 | QDateTime dt; |
488 | int y,m,t,h,min,sec; | 488 | int y,m,t,h,min,sec; |
489 | y = dtp->Year; | 489 | y = dtp->Year; |
490 | m = dtp->Month; | 490 | m = dtp->Month; |
491 | t = dtp->Day; | 491 | t = dtp->Day; |
492 | h = dtp->Hour; | 492 | h = dtp->Hour; |
493 | min = dtp->Minute; | 493 | min = dtp->Minute; |
494 | sec = dtp->Second; | 494 | sec = dtp->Second; |
@@ -777,59 +777,17 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
777 | int h = status.sizeHint().height()+20 ; | 777 | int h = status.sizeHint().height()+20 ; |
778 | int dw = QApplication::desktop()->width(); | 778 | int dw = QApplication::desktop()->width(); |
779 | int dh = QApplication::desktop()->height(); | 779 | int dh = QApplication::desktop()->height(); |
780 | status.setCaption(i18n("Reading phone...") ); | 780 | status.setCaption(i18n("Reading phone...") ); |
781 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 781 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
782 | status.show(); | 782 | status.show(); |
783 | status.raise(); | 783 | status.raise(); |
784 | qApp->processEvents(); | 784 | qApp->processEvents(); |
785 | #if 0 | ||
786 | static char*cp; | ||
787 | static INI_Section *cfg = NULL; | ||
788 | cfg=GSM_FindGammuRC(); | ||
789 | int i; | ||
790 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | ||
791 | if (cfg!=NULL) { | ||
792 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); | ||
793 | if (cp) di.coding = cp; | ||
794 | |||
795 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); | ||
796 | if (s.Config[i].Localize) { | ||
797 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | ||
798 | } else { | ||
799 | #if !defined(WIN32) && defined(LOCALE_PATH) | ||
800 | locale = setlocale(LC_MESSAGES, NULL); | ||
801 | if (locale != NULL) { | ||
802 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", | ||
803 | LOCALE_PATH, | ||
804 | tolower(locale[0]), | ||
805 | tolower(locale[1])); | ||
806 | s.msg = INI_ReadFile(locale_file, true); | ||
807 | } | ||
808 | #endif | ||
809 | } | ||
810 | } | ||
811 | |||
812 | /* Wanted user specific configuration? */ | ||
813 | |||
814 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; | ||
815 | |||
816 | s.ConfigNum++; | ||
817 | |||
818 | /* We want to use only one file descriptor for global and state machine debug output */ | ||
819 | s.Config[i].UseGlobalDebugFile = true; | ||
820 | |||
821 | |||
822 | 785 | ||
823 | /* We wanted to read just user specified configuration. */ | ||
824 | {break;} | ||
825 | } | ||
826 | |||
827 | #endif | ||
828 | int error=initDevice(&s); | 786 | int error=initDevice(&s); |
829 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); | 787 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); |
830 | if ( error != ERR_NONE ) | 788 | if ( error != ERR_NONE ) |
831 | return false; | 789 | return false; |
832 | GSM_Phone_Functions*Phone; | 790 | GSM_Phone_Functions*Phone; |
833 | GSM_CalendarEntrynote; | 791 | GSM_CalendarEntrynote; |
834 | bool start = true; | 792 | bool start = true; |
835 | Phone=s.Phone.Functions; | 793 | Phone=s.Phone.Functions; |
@@ -908,27 +866,28 @@ void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo ) | |||
908 | if ( !loc.isEmpty() ){ | 866 | if ( !loc.isEmpty() ){ |
909 | gsmTodo->Location = loc.toInt(); | 867 | gsmTodo->Location = loc.toInt(); |
910 | } | 868 | } |
911 | 869 | ||
912 | } | 870 | } |
913 | void PhoneFormat::afterSave( Incidence* inc) | 871 | void PhoneFormat::afterSave( Incidence* inc) |
914 | { | 872 | { |
915 | uint csum; | 873 | uint csum; |
874 | inc->removeID( mProfileName ); | ||
916 | if ( inc->type() == "Event") | 875 | if ( inc->type() == "Event") |
917 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 876 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
918 | else | 877 | else |
919 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 878 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
920 | inc->setCsum( mProfileName, QString::number( csum )); | 879 | inc->setCsum( mProfileName, QString::number( csum )); |
921 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 880 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
922 | 881 | ||
923 | } | 882 | } |
924 | bool PhoneFormat::save( Calendar *calendar) | 883 | bool PhoneFormat::save( Calendar *calendar) |
925 | { | 884 | { |
926 | return true; | 885 | |
927 | GSM_StateMachines; | 886 | GSM_StateMachines; |
928 | qDebug(" save "); | 887 | qDebug(" save "); |
929 | s.opened = false; | 888 | s.opened = false; |
930 | s.msg = NULL; | 889 | s.msg = NULL; |
931 | s.ConfigNum = 0; | 890 | s.ConfigNum = 0; |
932 | QLabel status ( i18n(" Opening device ..."), 0 ); | 891 | QLabel status ( i18n(" Opening device ..."), 0 ); |
933 | int w = status.sizeHint().width()+20 ; | 892 | int w = status.sizeHint().width()+20 ; |
934 | if ( w < 200 ) w = 230; | 893 | if ( w < 200 ) w = 230; |
@@ -947,53 +906,325 @@ bool PhoneFormat::save( Calendar *calendar) | |||
947 | return false; | 906 | return false; |
948 | GSM_Phone_Functions*Phone; | 907 | GSM_Phone_Functions*Phone; |
949 | GSM_CalendarEntryNote; | 908 | GSM_CalendarEntryNote; |
950 | bool start = true; | 909 | bool start = true; |
951 | Phone=s.Phone.Functions; | 910 | Phone=s.Phone.Functions; |
952 | bool gshutdown = false; | 911 | bool gshutdown = false; |
953 | QPtrList<Event> er = calendar->rawEvents(); | 912 | QPtrList<Event> er = calendar->rawEvents(); |
954 | Event* ev = er.first(); | 913 | Event* ev = er.first(); |
955 | QString message = i18n(" Processing event # "); | 914 | QString message = i18n(" Deleting event # "); |
956 | int procCount = 0; | 915 | int procCount = 0; |
957 | bool planB = true;// false; | 916 | int diffProc = 0; |
917 | bool setPossible = true; | ||
918 | #ifdef _WIN32_ | ||
919 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | ||
920 | #else | ||
921 | QString fileName = "/tmp/kdepimtemp.vcs"; | ||
922 | #endif | ||
923 | //algo 1 delete event | ||
924 | while ( ev ) { | ||
925 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one | ||
926 | |||
927 | status.setText ( message + QString::number ( ++procCount ) ); | ||
928 | qApp->processEvents(); | ||
929 | qDebug("del event1 %d ", procCount); | ||
930 | //event2GSM( calendar, ev, &Note ); | ||
931 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | ||
932 | |||
933 | QString loc = ev->getID(mProfileName); | ||
934 | if ( !loc.isEmpty() ){ | ||
935 | Note.Location = loc.toInt(); | ||
936 | } else { | ||
937 | qDebug("error: loc is empty "); | ||
938 | } | ||
939 | error = Phone->DeleteCalendar(&s, &Note); | ||
940 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
941 | qDebug(" e error delete1 planB %d ", error); | ||
942 | break; | ||
943 | } | ||
944 | } | ||
945 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new | ||
946 | // we have to do this later after deleting | ||
947 | |||
948 | } | ||
949 | else { // change existing | ||
950 | |||
951 | QString loc = ev->getID(mProfileName); | ||
952 | if ( !loc.isEmpty() ){ | ||
953 | Note.Location = loc.toInt(); | ||
954 | } else { | ||
955 | qDebug("error3: loc is empty "); | ||
956 | } | ||
957 | error = Phone->DeleteCalendar(&s, &Note); | ||
958 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
959 | qDebug(" e error delete2 planB %d ", error); | ||
960 | break; | ||
961 | } | ||
962 | ev->removeID( mProfileName ); | ||
963 | } | ||
964 | } | ||
965 | ev = er.next(); | ||
966 | } | ||
967 | //algo 1 delete todo | ||
968 | GSM_ToDoEntry ToDoEntry; | ||
969 | QPtrList<Todo> tl = calendar->rawTodos(); | ||
970 | Todo* to = tl.first(); | ||
971 | message = i18n(" Deleting todo # "); | ||
972 | procCount = 0; | ||
973 | while ( to ) { | ||
974 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
975 | qDebug("todo3 %d ", procCount); | ||
976 | status.setText ( message + QString::number ( ++procCount ) ); | ||
977 | qApp->processEvents(); | ||
978 | qDebug("todo5 %d ", procCount); | ||
979 | // todo2GSM( calendar, to, &ToDoEntry ); | ||
980 | QString loc = to->getID(mProfileName); | ||
981 | if ( !loc.isEmpty() ){ | ||
982 | ToDoEntry.Location = loc.toInt(); | ||
983 | } else { | ||
984 | qDebug("error2: loc is empty "); | ||
985 | } | ||
986 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | ||
987 | error=Phone->DeleteToDo(&s,&ToDoEntry); | ||
988 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
989 | qDebug("delete planB %d ", error); | ||
990 | } | ||
991 | } | ||
992 | else if ( to->getID(mProfileName).isEmpty() ) { // add new | ||
993 | ; | ||
994 | } | ||
995 | else { // change existing | ||
996 | error=Phone->DeleteToDo(&s,&ToDoEntry); | ||
997 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
998 | qDebug("set planB %d ", error); | ||
999 | } | ||
1000 | to->removeID( mProfileName ); | ||
1001 | } | ||
1002 | } | ||
1003 | to = tl.next(); | ||
1004 | } | ||
1005 | //algo 2 add event | ||
1006 | ev = er.first(); | ||
1007 | QString filec; | ||
1008 | message = i18n(" Preparing event # "); | ||
1009 | procCount = 0; | ||
1010 | while ( ev ) { | ||
1011 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | ||
1012 | if ( ev->getID(mProfileName).isEmpty() ) { | ||
1013 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1014 | qApp->processEvents(); | ||
1015 | filec += vfconverter.eventToString( ev, calendar )+ "\n"; | ||
1016 | afterSave ( ev ); | ||
1017 | |||
1018 | } | ||
1019 | } | ||
1020 | ev = er.next(); | ||
1021 | } | ||
1022 | //algo 2 add todo | ||
1023 | to = tl.first(); | ||
1024 | procCount = 0; | ||
1025 | message = i18n(" Preparing todo # "); | ||
1026 | while ( to ) { | ||
1027 | qDebug("todo2 %d ", procCount); | ||
1028 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | ||
1029 | qDebug("todo4 %d ", procCount); | ||
1030 | if ( to->getID(mProfileName).isEmpty() ) { | ||
1031 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1032 | qApp->processEvents(); | ||
1033 | filec += vfconverter.todoToString( to, calendar )+ "\n"; | ||
1034 | afterSave ( to ); | ||
1035 | } | ||
1036 | } | ||
1037 | to = tl.next(); | ||
1038 | } | ||
1039 | if ( filec.isEmpty() ) { | ||
1040 | qDebug("Nothing to write back.Finished. "); | ||
1041 | error=GSM_TerminateConnection(&s); | ||
1042 | return true; | ||
1043 | } | ||
1044 | //algo 3 saving file | ||
1045 | message = i18n(" Saving temp file ... "); | ||
1046 | status.setText ( message ); | ||
1047 | qApp->processEvents(); | ||
1048 | QFile file( fileName ); | ||
1049 | if (!file.open( IO_WriteOnly ) ) { | ||
1050 | qDebug("error open file "); | ||
1051 | error=GSM_TerminateConnection(&s); | ||
1052 | return false; | ||
1053 | } | ||
1054 | QTextStream ts( &file ); | ||
1055 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
1056 | ts << filec ; | ||
1057 | file.close(); | ||
1058 | |||
1059 | |||
1060 | message = i18n(" Parsing temp file ... "); | ||
1061 | status.setText ( message ); | ||
1062 | qApp->processEvents(); | ||
1063 | GSM_Backup Backup; | ||
1064 | error=GSM_ReadBackupFile( (char*) fileName.latin1() ,&Backup); | ||
1065 | qDebug("Read file result %d ",error ); | ||
1066 | //algo 4 writing event | ||
1067 | int max, i; | ||
1068 | procCount = 0; | ||
1069 | message = i18n(" Writing event # "); | ||
1070 | if (Backup.Calendar[0] != NULL) { | ||
1071 | max = 0; | ||
1072 | while (Backup.Calendar[max]!=NULL) max++; | ||
1073 | for (i=0;i<max;i++) { | ||
1074 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1075 | qApp->processEvents(); | ||
1076 | Note = *Backup.Calendar[i]; | ||
1077 | Note.Location = 0; | ||
1078 | error=Phone->AddCalendar(&s,&Note); | ||
1079 | qDebug("add event %d %d", error, Note.Location ); | ||
1080 | } | ||
1081 | } | ||
1082 | //algo 4 writing todo | ||
1083 | procCount = 0; | ||
1084 | message = i18n(" Writing todo # "); | ||
1085 | if (Backup.ToDo[0] != NULL) { | ||
1086 | max = 0; | ||
1087 | while (Backup.ToDo[max]!=NULL) max++; | ||
1088 | for (i=0;i<max;i++) { | ||
1089 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1090 | qApp->processEvents(); | ||
1091 | ToDoEntry = *Backup.ToDo[i]; | ||
1092 | error = Phone->AddToDo(&s,&ToDoEntry); | ||
1093 | qDebug("add todo %d ", error); | ||
1094 | } | ||
1095 | } | ||
1096 | //algo 5 reread | ||
1097 | message = i18n(" Rereading all data ... "); | ||
1098 | status.setText ( message ); | ||
1099 | qApp->processEvents(); | ||
1100 | error=GSM_TerminateConnection(&s); | ||
1101 | CalendarLocal* calendarTemp = new CalendarLocal(); | ||
1102 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | ||
1103 | if ( ! load( calendarTemp,calendar) ){ | ||
1104 | qDebug("error reloading calendar "); | ||
1105 | delete calendarTemp; | ||
1106 | return false; | ||
1107 | } | ||
1108 | |||
1109 | |||
1110 | //algo 6 compare event | ||
1111 | ev = er.first(); | ||
1112 | message = i18n(" Comparing event # "); | ||
1113 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | ||
1114 | Event* ev1; | ||
1115 | procCount = 0; | ||
1116 | while ( ev ) { | ||
1117 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) { | ||
1118 | qDebug("event new ID "); | ||
1119 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1120 | qApp->processEvents(); | ||
1121 | QString cSum = ev->getCsum(mProfileName); | ||
1122 | ev1 = er1.first(); | ||
1123 | while ( ev1 ) { | ||
1124 | if ( ev1->getCsum( mProfileName ) == cSum ) { | ||
1125 | er1.remove( ev1 ); | ||
1126 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | ||
1127 | break; | ||
1128 | } | ||
1129 | ev1 = er1.next(); | ||
1130 | } | ||
1131 | if ( ! ev1 ) { | ||
1132 | ev->removeID(mProfileName); | ||
1133 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | ||
1134 | qDebug("Probably writing back of events not supported "); | ||
1135 | } | ||
1136 | |||
1137 | } | ||
1138 | ev = er.next(); | ||
1139 | } | ||
1140 | //algo 6 compare todo | ||
1141 | to = tl.first(); | ||
1142 | procCount = 0; | ||
1143 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | ||
1144 | Todo* to1 ; | ||
1145 | message = i18n(" Comparing todo # "); | ||
1146 | while ( to ) { | ||
1147 | qDebug("todo2 %d ", procCount); | ||
1148 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) { | ||
1149 | status.setText ( message + QString::number ( ++procCount ) ); | ||
1150 | qApp->processEvents(); | ||
1151 | QString cSum = to->getCsum(mProfileName); | ||
1152 | Todo* to1 = tl1.first(); | ||
1153 | while ( to1 ) { | ||
1154 | if ( to1->getCsum( mProfileName ) == cSum ) { | ||
1155 | tl1.remove( to1 ); | ||
1156 | to->setID(mProfileName, to1->getID(mProfileName) ); | ||
1157 | break; | ||
1158 | } | ||
1159 | to1 = tl1.next(); | ||
1160 | } | ||
1161 | if ( ! to1 ) { | ||
1162 | to->removeID(mProfileName); | ||
1163 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | ||
1164 | qDebug("Probably writing back of todos not supported "); | ||
1165 | } | ||
1166 | } | ||
1167 | to = tl.next(); | ||
1168 | } | ||
1169 | delete calendarTemp; | ||
1170 | return true; | ||
1171 | // ******************************************************************* | ||
1172 | // ******************************************************************* | ||
1173 | // ******************************************************************* | ||
1174 | #if 0 | ||
958 | while ( ev && ! planB) { | 1175 | while ( ev && ! planB) { |
959 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one | 1176 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one |
960 | 1177 | ||
961 | status.setText ( message + QString::number ( ++procCount ) ); | 1178 | status.setText ( message + QString::number ( ++procCount ) ); |
962 | qApp->processEvents(); | 1179 | qApp->processEvents(); |
963 | qDebug("event1 %d ", procCount); | 1180 | qDebug("event1 %d ", procCount); |
964 | event2GSM( calendar, ev, &Note ); | 1181 | event2GSM( calendar, ev, &Note ); |
965 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 1182 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
966 | error = Phone->DeleteCalendar(&s, &Note); | 1183 | error = Phone->DeleteCalendar(&s, &Note); |
967 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1184 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
968 | planB = true; | 1185 | planB = true; |
969 | qDebug(" e delete planB %d ", error); | 1186 | qDebug(" e delete1 planB %d ", error); |
970 | break; | 1187 | break; |
971 | } | 1188 | } |
972 | } | 1189 | } |
973 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new | 1190 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new |
974 | // we have to do this later after deleting | 1191 | // we have to do this later after deleting |
975 | 1192 | ||
976 | } | 1193 | } |
977 | else { // change existing | 1194 | else { // change existing |
978 | error = Phone->SetCalendar(&s, &Note); | 1195 | if ( setPossible ) { |
979 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1196 | error = Phone->SetCalendar(&s, &Note); |
980 | planB = true; | 1197 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
981 | qDebug(" e change planB %d ", error); | 1198 | setPossible = false; |
982 | break; | 1199 | ++diffProc; |
1200 | qDebug("Set cal not supported %d ", error); | ||
1201 | break; | ||
1202 | } | ||
1203 | } | ||
1204 | if ( ! setPossible) { | ||
1205 | ++diffProc; | ||
1206 | error = Phone->DeleteCalendar(&s, &Note); | ||
1207 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | ||
1208 | planB = true; | ||
1209 | qDebug(" e delete2 planB %d ", error); | ||
1210 | break; | ||
1211 | } | ||
1212 | ev->removeID( mProfileName ); | ||
983 | } | 1213 | } |
984 | qDebug("Change Calendar. Location %d status: %d",Note.Location, error ); | 1214 | qDebug("Change Calendar. Location %d status: %d",Note.Location, error ); |
985 | } | 1215 | } |
986 | } | 1216 | } |
987 | ev = er.next(); | 1217 | ev = er.next(); |
988 | } | 1218 | } |
989 | ev = er.first(); | 1219 | ev = er.first(); |
990 | // pending get empty slots | 1220 | // pending get empty slots |
991 | int loc = 0; | 1221 | int loc = 0; |
1222 | procCount -= diffProc; | ||
992 | while ( ev && ! planB) { | 1223 | while ( ev && ! planB) { |
993 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 1224 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
994 | qDebug("event2 %d ", procCount); | 1225 | qDebug("event2 %d ", procCount); |
995 | if ( ev->getID(mProfileName).isEmpty() ) { | 1226 | if ( ev->getID(mProfileName).isEmpty() ) { |
996 | status.setText ( message + QString::number ( ++procCount ) ); | 1227 | status.setText ( message + QString::number ( ++procCount ) ); |
997 | qApp->processEvents(); | 1228 | qApp->processEvents(); |
998 | //int newID ;//= pending | 1229 | //int newID ;//= pending |
999 | //ev->setID(mProfileName, QString::number( newID )); | 1230 | //ev->setID(mProfileName, QString::number( newID )); |
@@ -1168,16 +1399,17 @@ bool PhoneFormat::save( Calendar *calendar) | |||
1168 | } | 1399 | } |
1169 | to = tl.next(); | 1400 | to = tl.next(); |
1170 | } | 1401 | } |
1171 | if ( planC ) { | 1402 | if ( planC ) { |
1172 | // we have currently no planC :-( | 1403 | // we have currently no planC :-( |
1173 | } | 1404 | } |
1174 | } | 1405 | } |
1175 | return true; | 1406 | return true; |
1407 | #endif | ||
1176 | } | 1408 | } |
1177 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) | 1409 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) |
1178 | { | 1410 | { |
1179 | QString datestr; | 1411 | QString datestr; |
1180 | QString timestr; | 1412 | QString timestr; |
1181 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 1413 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
1182 | QDateTime dt; | 1414 | QDateTime dt; |
1183 | if (useTZ) | 1415 | if (useTZ) |