author | zautrix <zautrix> | 2004-09-12 13:11:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 13:11:10 (UTC) |
commit | b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26 (patch) (unidiff) | |
tree | a25dbba0cac09b7a7892405b11eb08c7d02e6b6b | |
parent | 3c954091cb8d90c185403c68a8bbbb2a961f67fe (diff) | |
download | kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.zip kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.tar.gz kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.tar.bz2 |
many phonesync fixes
-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 2 | ||||
-rw-r--r-- | gammu/emb/gammu/gammu.c | 41 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 53 |
3 files changed, 80 insertions, 16 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 598292c..ddf9790 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -113,65 +113,65 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
113 | case GSM_CAL_MEETING: | 113 | case GSM_CAL_MEETING: |
114 | default: | 114 | default: |
115 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); | 115 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | if (note->Type == GSM_CAL_CALL) { | 118 | if (note->Type == GSM_CAL_CALL) { |
119 | buffer[0] = 0; | 119 | buffer[0] = 0; |
120 | buffer[1] = 0; | 120 | buffer[1] = 0; |
121 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 121 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
122 | if (Text != -1) { | 122 | if (Text != -1) { |
123 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 123 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
124 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 124 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
125 | } | 125 | } |
126 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 126 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
127 | } else { | 127 | } else { |
128 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 128 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
129 | } | 129 | } |
130 | if (note->Type == GSM_CAL_MEETING && Location != -1) { | 130 | if (note->Type == GSM_CAL_MEETING && Location != -1) { |
131 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 131 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
132 | } | 132 | } |
133 | 133 | ||
134 | if (Time == -1) return ERR_UNKNOWN; | 134 | if (Time == -1) return ERR_UNKNOWN; |
135 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 135 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
136 | 136 | ||
137 | if (EndTime != -1) { | 137 | if (EndTime != -1) { |
138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
139 | } | 139 | } |
140 | 140 | ||
141 | if (Alarm != -1) { | 141 | if (Alarm != -1) { |
142 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 142 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
143 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 143 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
144 | } else { | 144 | } else { |
145 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 145 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | /* Birthday is known to be recurranced */ | 149 | /* Birthday is known to be recurranced */ |
150 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { | 150 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { |
151 | switch(note->Entries[Recurrance].Number/24) { | 151 | switch(note->Entries[Recurrance].Number/24) { |
152 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; | 152 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; |
153 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; | 153 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; |
154 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; | 154 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; |
155 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; | 155 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | } else if (Version == Siemens_VCalendar) { | 158 | } else if (Version == Siemens_VCalendar) { |
159 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 159 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
160 | switch (note->Type) { | 160 | switch (note->Type) { |
161 | case GSM_CAL_MEETING: | 161 | case GSM_CAL_MEETING: |
162 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 162 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
163 | break; | 163 | break; |
164 | case GSM_CAL_CALL: | 164 | case GSM_CAL_CALL: |
165 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 165 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
166 | break; | 166 | break; |
167 | case GSM_CAL_BIRTHDAY: | 167 | case GSM_CAL_BIRTHDAY: |
168 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); | 168 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); |
169 | break; | 169 | break; |
170 | case GSM_CAL_MEMO: | 170 | case GSM_CAL_MEMO: |
171 | default: | 171 | default: |
172 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 172 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
173 | break; | 173 | break; |
174 | } | 174 | } |
175 | 175 | ||
176 | if (Time == -1) return ERR_UNKNOWN; | 176 | if (Time == -1) return ERR_UNKNOWN; |
177 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 177 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c index 5163d81..a3b93a8 100644 --- a/gammu/emb/gammu/gammu.c +++ b/gammu/emb/gammu/gammu.c | |||
@@ -8212,190 +8212,217 @@ int main(int argc, char *argv[]) | |||
8212 | static intonly_config ; | 8212 | static intonly_config ; |
8213 | #if !defined(WIN32) && defined(LOCALE_PATH) | 8213 | #if !defined(WIN32) && defined(LOCALE_PATH) |
8214 | static char*locale, locale_file[201]; | 8214 | static char*locale, locale_file[201]; |
8215 | #endif | 8215 | #endif |
8216 | static char*cp; | 8216 | static char*cp; |
8217 | static boolcount_failed; | 8217 | static boolcount_failed; |
8218 | z = 0; | 8218 | z = 0; |
8219 | start=0;only_config = -1;count_failed = false; | 8219 | start=0;only_config = -1;count_failed = false; |
8220 | s.opened = false; | 8220 | s.opened = false; |
8221 | s.msg = NULL; | 8221 | s.msg = NULL; |
8222 | s.ConfigNum = 0; | 8222 | s.ConfigNum = 0; |
8223 | 8223 | ||
8224 | setlocale(LC_ALL, ""); | 8224 | setlocale(LC_ALL, ""); |
8225 | #ifdef DEBUG | 8225 | #ifdef DEBUG |
8226 | di.dl = DL_TEXTALL; | 8226 | di.dl = DL_TEXTALL; |
8227 | di.df = stdout; | 8227 | di.df = stdout; |
8228 | #endif | 8228 | #endif |
8229 | //#if 0 | 8229 | //#if 0 |
8230 | /* Any parameters? */ | 8230 | /* Any parameters? */ |
8231 | if (argc == 1) { | 8231 | if (argc == 1) { |
8232 | HelpGeneral(); | 8232 | HelpGeneral(); |
8233 | printmsg("Too few parameters!\n"); | 8233 | printmsg("Too few parameters!\n"); |
8234 | exit(1); | 8234 | exit(1); |
8235 | } | 8235 | } |
8236 | 8236 | ||
8237 | /* Help? */ | 8237 | /* Help? */ |
8238 | if (strncmp(argv[1 + start], "--help", 6) == 0) { | 8238 | if (strncmp(argv[1 + start], "--help", 6) == 0) { |
8239 | Help(argc - start, argv + start); | 8239 | Help(argc - start, argv + start); |
8240 | exit(1); | 8240 | exit(1); |
8241 | } | 8241 | } |
8242 | 8242 | ||
8243 | /* Is first parameter numeric? If so treat it as config that should be loaded. */ | 8243 | /* Is first parameter numeric? If so treat it as config that should be loaded. */ |
8244 | if (isdigit(argv[1][0])) { | 8244 | //if (isdigit(argv[1][0])) { |
8245 | only_config = atoi(argv[1]); | 8245 | //only_config = atoi(argv[1]); |
8246 | if (only_config >= 0) start++; else only_config = -1; | 8246 | //if (only_config >= 0) start++; else only_config = -1; |
8247 | } | 8247 | //} |
8248 | 8248 | only_config = 0;; | |
8249 | #if 0 | ||
8249 | GSM_ReadConfig(NULL, &s.Config[0], 0); | 8250 | GSM_ReadConfig(NULL, &s.Config[0], 0); |
8250 | s.ConfigNum = 1; | 8251 | s.ConfigNum = 1; |
8251 | GSM_Config *con = &s.Config[0]; | 8252 | GSM_Config *con = &s.Config[0]; |
8252 | 8253 | ||
8253 | char* tempC; | 8254 | char* tempC; |
8254 | tempC = argv[argc-1]+2; | 8255 | tempC = argv[argc-1]+2; |
8255 | if ( *tempC != 0 ) { | 8256 | if ( *tempC != 0 ) { |
8256 | fprintf(stderr,"Using model %s \n",tempC); | 8257 | fprintf(stderr,"Using model %s \n",tempC); |
8257 | strcpy(con->Model,tempC ); | 8258 | strcpy(con->Model,tempC ); |
8258 | } | 8259 | } |
8259 | tempC = argv[argc-2]+2; | 8260 | tempC = argv[argc-2]+2; |
8260 | if ( *tempC != 0 ) { | 8261 | if ( *tempC != 0 ) { |
8261 | fprintf(stderr,"Using device %s \n",tempC); | 8262 | fprintf(stderr,"Using device %s \n",tempC); |
8262 | con->Device = strdup(tempC); | 8263 | con->Device = strdup(tempC); |
8263 | con->DefaultDevice = false; | 8264 | con->DefaultDevice = false; |
8264 | } | 8265 | } |
8265 | tempC = argv[argc-3]+2; | 8266 | tempC = argv[argc-3]+2; |
8266 | if ( *tempC != 0 ) { | 8267 | if ( *tempC != 0 ) { |
8267 | fprintf(stderr,"Using connection %s \n",tempC); | 8268 | fprintf(stderr,"Using connection %s \n",tempC); |
8268 | con->Connection = strdup(tempC); | 8269 | con->Connection = strdup(tempC); |
8269 | con->DefaultConnection = false; | 8270 | con->DefaultConnection = false; |
8270 | } | 8271 | } |
8271 | argc = argc-3; | 8272 | argc = argc-3; |
8272 | #if 0 | 8273 | //#if 0 |
8273 | if ( ! mConnection.isEmpty() ) { | 8274 | if ( ! mConnection.isEmpty() ) { |
8274 | cfg->Connection = strdup(mConnection.latin1()); | 8275 | cfg->Connection = strdup(mConnection.latin1()); |
8275 | cfg->DefaultConnection = false; | 8276 | cfg->DefaultConnection = false; |
8276 | qDebug("Connection set %s ", cfg->Connection ); | 8277 | qDebug("Connection set %s ", cfg->Connection ); |
8277 | 8278 | ||
8278 | } | 8279 | } |
8279 | if ( ! mDevice.isEmpty() ) { | 8280 | if ( ! mDevice.isEmpty() ) { |
8280 | cfg->Device = strdup(mDevice.latin1()); | 8281 | cfg->Device = strdup(mDevice.latin1()); |
8281 | cfg->DefaultDevice = false; | 8282 | cfg->DefaultDevice = false; |
8282 | qDebug("Device set %s ", cfg->Device); | 8283 | qDebug("Device set %s ", cfg->Device); |
8283 | 8284 | ||
8284 | } | 8285 | } |
8285 | if ( ! mModel.isEmpty() ) { | 8286 | if ( ! mModel.isEmpty() ) { |
8286 | strcpy(cfg->Model,mModel.latin1() ); | 8287 | strcpy(cfg->Model,mModel.latin1() ); |
8287 | cfg->DefaultModel = false; | 8288 | cfg->DefaultModel = false; |
8288 | qDebug("Model set %s ",cfg->Model ); | 8289 | qDebug("Model set %s ",cfg->Model ); |
8289 | } | 8290 | } |
8290 | 8291 | ||
8291 | #endif | 8292 | #endif |
8292 | 8293 | ||
8293 | #if 0 | 8294 | |
8294 | cfg=GSM_FindGammuRC(); | 8295 | cfg=GSM_FindGammuRC(); |
8295 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | 8296 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { |
8296 | if (cfg!=NULL) { | 8297 | if (cfg!=NULL) { |
8297 | cp = INI_GetValue(cfg, "gammu", "gammucoding", false); | 8298 | cp = INI_GetValue(cfg, "gammu", "gammucoding", false); |
8298 | if (cp) di.coding = cp; | 8299 | if (cp) di.coding = cp; |
8299 | 8300 | ||
8300 | s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); | 8301 | s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); |
8301 | if (s.Config[i].Localize) { | 8302 | if (s.Config[i].Localize) { |
8302 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | 8303 | s.msg=INI_ReadFile(s.Config[i].Localize, true); |
8303 | } else { | 8304 | } else { |
8304 | #if !defined(WIN32) && defined(LOCALE_PATH) | 8305 | #if !defined(WIN32) && defined(LOCALE_PATH) |
8305 | locale = setlocale(LC_MESSAGES, NULL); | 8306 | locale = setlocale(LC_MESSAGES, NULL); |
8306 | if (locale != NULL) { | 8307 | if (locale != NULL) { |
8307 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", | 8308 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", |
8308 | LOCALE_PATH, | 8309 | LOCALE_PATH, |
8309 | tolower(locale[0]), | 8310 | tolower(locale[0]), |
8310 | tolower(locale[1])); | 8311 | tolower(locale[1])); |
8311 | s.msg = INI_ReadFile(locale_file, true); | 8312 | s.msg = INI_ReadFile(locale_file, true); |
8312 | } | 8313 | } |
8313 | #endif | 8314 | #endif |
8314 | } | 8315 | } |
8315 | } | 8316 | } |
8316 | 8317 | ||
8317 | /* Wanted user specific configuration? */ | 8318 | /* Wanted user specific configuration? */ |
8319 | |||
8318 | if (only_config != -1) { | 8320 | if (only_config != -1) { |
8319 | /* Here we get only in first for loop */ | 8321 | /* Here we get only in first for loop */ |
8320 | if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; | 8322 | if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; |
8321 | } else { | 8323 | } else { |
8322 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; | 8324 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; |
8323 | } | 8325 | } |
8324 | s.ConfigNum++; | 8326 | s.ConfigNum++; |
8325 | 8327 | ||
8326 | /* We want to use only one file descriptor for global and state machine debug output */ | 8328 | /* We want to use only one file descriptor for global and state machine debug output */ |
8327 | s.Config[i].UseGlobalDebugFile = true; | 8329 | s.Config[i].UseGlobalDebugFile = true; |
8328 | 8330 | ||
8329 | /* It makes no sense to open several debug logs... */ | 8331 | /* It makes no sense to open several debug logs... */ |
8330 | if (i != 0) { | 8332 | if (i != 0) { |
8331 | strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); | 8333 | strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel); |
8332 | free(s.Config[i].DebugFile); | 8334 | free(s.Config[i].DebugFile); |
8333 | s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); | 8335 | s.Config[i].DebugFile = strdup(s.Config[0].DebugFile); |
8334 | } else { | 8336 | } else { |
8335 | /* Just for first config */ | 8337 | /* Just for first config */ |
8336 | /* When user gave debug level on command line */ | 8338 | /* When user gave debug level on command line */ |
8337 | if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { | 8339 | if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) { |
8338 | /* Debug level from command line will be used with phone too */ | 8340 | /* Debug level from command line will be used with phone too */ |
8339 | strcpy(s.Config[i].DebugLevel,argv[1 + start]); | 8341 | strcpy(s.Config[i].DebugLevel,argv[1 + start]); |
8340 | start++; | 8342 | start++; |
8341 | } else { | 8343 | } else { |
8342 | /* Try to set debug level from config file */ | 8344 | /* Try to set debug level from config file */ |
8343 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); | 8345 | GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); |
8344 | } | 8346 | } |
8345 | /* If user gave debug file in gammurc, we will use it */ | 8347 | /* If user gave debug file in gammurc, we will use it */ |
8346 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); | 8348 | error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); |
8347 | Print_Error(error); | 8349 | Print_Error(error); |
8348 | } | 8350 | } |
8349 | 8351 | ||
8350 | /* We wanted to read just user specified configuration. */ | 8352 | /* We wanted to read just user specified configuration. */ |
8351 | if (only_config != -1) {break;} | 8353 | if (only_config != -1) {break;} |
8352 | } | 8354 | } |
8355 | #if 0 | ||
8356 | GSM_Config *con = &s.Config[0]; | ||
8357 | |||
8358 | char* tempC; | ||
8359 | tempC = argv[argc-1]+2; | ||
8360 | if ( *tempC != 0 ) { | ||
8361 | fprintf(stderr,"Using model %s \n",tempC); | ||
8362 | strcpy(con->Model,tempC ); | ||
8363 | } | ||
8364 | tempC = argv[argc-2]+2; | ||
8365 | if ( *tempC != 0 ) { | ||
8366 | fprintf(stderr,"Using device %s \n",tempC); | ||
8367 | con->Device = strdup(tempC); | ||
8368 | con->DefaultDevice = false; | ||
8369 | } | ||
8370 | tempC = argv[argc-3]+2; | ||
8371 | if ( *tempC != 0 ) { | ||
8372 | fprintf(stderr,"Using connection %s \n",tempC); | ||
8373 | con->Connection = strdup(tempC); | ||
8374 | con->DefaultConnection = false; | ||
8375 | } | ||
8353 | #endif | 8376 | #endif |
8377 | argc = argc-3; | ||
8378 | |||
8379 | |||
8354 | /* Do we have enough parameters? */ | 8380 | /* Do we have enough parameters? */ |
8355 | if (argc == 1 + start) { | 8381 | if (argc == 1 + start) { |
8356 | HelpGeneral(); | 8382 | HelpGeneral(); |
8357 | printmsg("Too few parameters!\n"); | 8383 | printmsg("Too few parameters!\n"); |
8358 | exit(-2); | 8384 | exit(-2); |
8359 | } | 8385 | } |
8360 | 8386 | ||
8361 | /* Check used version vs. compiled */ | 8387 | /* Check used version vs. compiled */ |
8362 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { | 8388 | if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { |
8363 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", | 8389 | printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", |
8364 | GetGammuVersion(),VERSION); | 8390 | GetGammuVersion(),VERSION); |
8365 | exit(-1); | 8391 | exit(-1); |
8366 | } | 8392 | } |
8367 | 8393 | ||
8368 | /* Check parameters */ | 8394 | /* Check parameters */ |
8369 | while (Parameters[z].Function != NULL) { | 8395 | while (Parameters[z].Function != NULL) { |
8370 | if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { | 8396 | if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { |
8371 | if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { | 8397 | if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { |
8398 | fprintf(stderr,"Executing \n"); | ||
8372 | Parameters[z].Function(argc - start, argv + start); | 8399 | Parameters[z].Function(argc - start, argv + start); |
8373 | break; | 8400 | break; |
8374 | } else { | 8401 | } else { |
8375 | count_failed = true; | 8402 | count_failed = true; |
8376 | } | 8403 | } |
8377 | } | 8404 | } |
8378 | z++; | 8405 | z++; |
8379 | } | 8406 | } |
8380 | 8407 | ||
8381 | /* Tell user when we did nothing */ | 8408 | /* Tell user when we did nothing */ |
8382 | if (Parameters[z].Function == NULL) { | 8409 | if (Parameters[z].Function == NULL) { |
8383 | HelpGeneral(); | 8410 | HelpGeneral(); |
8384 | if (count_failed) { | 8411 | if (count_failed) { |
8385 | printmsg("Bad parameter count!\n"); | 8412 | printmsg("Bad parameter count!\n"); |
8386 | } else { | 8413 | } else { |
8387 | printmsg("Bad option!\n"); | 8414 | printmsg("Bad option!\n"); |
8388 | } | 8415 | } |
8389 | } | 8416 | } |
8390 | 8417 | ||
8391 | /* Close debug output if opened */ | 8418 | /* Close debug output if opened */ |
8392 | if (di.df!=stdout) fclose(di.df); | 8419 | if (di.df!=stdout) fclose(di.df); |
8393 | //#endif // 0 | 8420 | //#endif // 0 |
8394 | fprintf(stderr,"kammu: Success. End. \n"); | 8421 | fprintf(stderr,"kammu: Success. End. \n"); |
8395 | exit(0); | 8422 | exit(0); |
8396 | } | 8423 | } |
8397 | 8424 | ||
8398 | /* How should editor hadle tabs in this file? Add editor commands here. | 8425 | /* How should editor hadle tabs in this file? Add editor commands here. |
8399 | * vim: noexpandtab sw=8 ts=8 sts=8: | 8426 | * vim: noexpandtab sw=8 ts=8 sts=8: |
8400 | */ | 8427 | */ |
8401 | 8428 | ||
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 2ad1b5a..6df639f 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -6,64 +6,65 @@ | |||
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 | #include <kmessagebox.h> | ||
38 | 39 | ||
39 | #include "calendar.h" | 40 | #include "calendar.h" |
40 | #include "alarm.h" | 41 | #include "alarm.h" |
41 | #include "recurrence.h" | 42 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 43 | #include "calendarlocal.h" |
43 | 44 | ||
44 | #include "phoneformat.h" | 45 | #include "phoneformat.h" |
45 | #include "syncdefines.h" | 46 | #include "syncdefines.h" |
46 | 47 | ||
47 | using namespace KCal; | 48 | using namespace KCal; |
48 | class PhoneParser : public QObject | 49 | class PhoneParser : public QObject |
49 | { | 50 | { |
50 | public: | 51 | public: |
51 | PhoneParser( ) { | 52 | PhoneParser( ) { |
52 | ; | 53 | ; |
53 | } | 54 | } |
54 | 55 | ||
55 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) | 56 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
56 | { | 57 | { |
57 | QString datestr; | 58 | QString datestr; |
58 | QString timestr; | 59 | QString timestr; |
59 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 60 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
60 | QDateTime dt; | 61 | QDateTime dt; |
61 | if (useTZ) | 62 | if (useTZ) |
62 | dt = dti.addSecs ( -(offset*60)); | 63 | dt = dti.addSecs ( -(offset*60)); |
63 | else | 64 | else |
64 | dt = dti; | 65 | dt = dti; |
65 | if(dt.date().isValid()){ | 66 | if(dt.date().isValid()){ |
66 | const QDate& date = dt.date(); | 67 | const QDate& date = dt.date(); |
67 | datestr.sprintf("%04d%02d%02d", | 68 | datestr.sprintf("%04d%02d%02d", |
68 | date.year(), date.month(), date.day()); | 69 | date.year(), date.month(), date.day()); |
69 | } | 70 | } |
@@ -217,133 +218,149 @@ ulong PhoneFormat::getCsumEvent( Event* event ) | |||
217 | writeEndDate = true; | 218 | writeEndDate = true; |
218 | break; | 219 | break; |
219 | case Recurrence::rYearlyMonth://4 | 220 | case Recurrence::rYearlyMonth://4 |
220 | list.append( "4" ); | 221 | list.append( "4" ); |
221 | list.append( QString::number( rec->frequency()) );//12 | 222 | list.append( QString::number( rec->frequency()) );//12 |
222 | list.append( "0" ); | 223 | list.append( "0" ); |
223 | list.append( "0" ); | 224 | list.append( "0" ); |
224 | writeEndDate = true; | 225 | writeEndDate = true; |
225 | break; | 226 | break; |
226 | 227 | ||
227 | default: | 228 | default: |
228 | list.append( "255" ); | 229 | list.append( "255" ); |
229 | list.append( QString() ); | 230 | list.append( QString() ); |
230 | list.append( "0" ); | 231 | list.append( "0" ); |
231 | list.append( QString() ); | 232 | list.append( QString() ); |
232 | list.append( "0" ); | 233 | list.append( "0" ); |
233 | list.append( "20991231T000000" ); | 234 | list.append( "20991231T000000" ); |
234 | break; | 235 | break; |
235 | } | 236 | } |
236 | if ( writeEndDate ) { | 237 | if ( writeEndDate ) { |
237 | 238 | ||
238 | if ( rec->endDate().isValid() ) { // 15 + 16 | 239 | if ( rec->endDate().isValid() ) { // 15 + 16 |
239 | list.append( "1" ); | 240 | list.append( "1" ); |
240 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 241 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
241 | } else { | 242 | } else { |
242 | list.append( "0" ); | 243 | list.append( "0" ); |
243 | list.append( "20991231T000000" ); | 244 | list.append( "20991231T000000" ); |
244 | } | 245 | } |
245 | 246 | ||
246 | } | 247 | } |
247 | attList << list.join(""); | 248 | attList << list.join(""); |
248 | attList << event->categoriesStr(); | 249 | attList << event->categoriesStr(); |
250 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | ||
251 | |||
249 | attList << event->secrecyStr(); | 252 | attList << event->secrecyStr(); |
250 | return PhoneFormat::getCsum(attList ); | 253 | return PhoneFormat::getCsum(attList ); |
251 | } | 254 | } |
252 | ulong PhoneFormat::getCsum( const QStringList & attList) | 255 | ulong PhoneFormat::getCsum( const QStringList & attList) |
253 | { | 256 | { |
254 | int max = attList.count() -1; | 257 | int max = attList.count() -1; |
255 | ulong cSum = 0; | 258 | ulong cSum = 0; |
256 | int j,k,i; | 259 | int j,k,i; |
257 | int add; | 260 | int add; |
258 | for ( i = 1; i < max ; ++i ) { | 261 | for ( i = 1; i < max ; ++i ) { |
259 | QString s = attList[i]; | 262 | QString s = attList[i]; |
260 | if ( ! s.isEmpty() ){ | 263 | if ( ! s.isEmpty() ){ |
261 | j = s.length(); | 264 | j = s.length(); |
262 | for ( k = 0; k < j; ++k ) { | 265 | for ( k = 0; k < j; ++k ) { |
263 | int mul = k +1; | 266 | int mul = k +1; |
264 | add = s[k].unicode (); | 267 | add = s[k].unicode (); |
265 | if ( k < 16 ) | 268 | if ( k < 16 ) |
266 | mul = mul * mul; | 269 | mul = mul * mul; |
267 | add = add * mul *i*i*i; | 270 | add = add * mul *i*i*i; |
268 | cSum += add; | 271 | cSum += add; |
269 | } | 272 | } |
270 | } | 273 | } |
271 | } | 274 | } |
275 | //QString dump = attList.join(","); | ||
276 | //qDebug("csum: %s", dump.latin1()); | ||
277 | |||
272 | return cSum; | 278 | return cSum; |
273 | 279 | ||
274 | } | 280 | } |
275 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 281 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
276 | #include <stdlib.h> | 282 | #include <stdlib.h> |
277 | #define DEBUGMODE false | 283 | #define DEBUGMODE false |
278 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 284 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
279 | { | 285 | { |
280 | 286 | ||
281 | QString fileName; | 287 | QString fileName; |
282 | #ifdef _WIN32_ | 288 | #ifdef _WIN32_ |
283 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 289 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
284 | #else | 290 | #else |
285 | fileName = "/tmp/kdepimtemp.vcs"; | 291 | fileName = "/tmp/kdepimtemp.vcs"; |
286 | #endif | 292 | #endif |
287 | QString command ="./kammu --backup " + fileName + " -yes -C" + | 293 | QString command ="./kammu --backup " + fileName + " -yes -C" + |
288 | mConnection +" -D" + mDevice +" -M" + mModel; | 294 | mConnection +" -D" + mDevice +" -M" + mModel; |
289 | int ret = system ( command.latin1() ); | 295 | int ret = system ( command.latin1() ); |
290 | if ( ret != 0 ) | 296 | if ( ret != 0 ) { |
297 | qDebug("Error::command returned %d", ret); | ||
291 | return false; | 298 | return false; |
299 | } | ||
300 | qDebug("Command returned %d", ret); | ||
292 | VCalFormat vfload; | 301 | VCalFormat vfload; |
293 | vfload.setLocalTime ( true ); | 302 | vfload.setLocalTime ( true ); |
303 | qDebug("loading file ..."); | ||
304 | |||
294 | if ( ! vfload.load( calendar, fileName ) ) | 305 | if ( ! vfload.load( calendar, fileName ) ) |
295 | return false; | 306 | return false; |
296 | QPtrList<Event> er = calendar->rawEvents(); | 307 | QPtrList<Event> er = calendar->rawEvents(); |
297 | Event* ev = er.first(); | 308 | Event* ev = er.first(); |
309 | qDebug("reading events... "); | ||
298 | while ( ev ) { | 310 | while ( ev ) { |
311 | QStringList cat = ev->categories(); | ||
312 | if ( cat.contains( "MeetingDEF" )) { | ||
313 | ev->setCategories( QStringList() ); | ||
314 | } | ||
299 | int id = ev->pilotId(); | 315 | int id = ev->pilotId(); |
300 | Event *event; | 316 | Event *event; |
301 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 317 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
302 | if ( event ) { | 318 | if ( event ) { |
303 | event = (Event*)event->clone(); | 319 | event = (Event*)event->clone(); |
304 | copyEvent( event, ev ); | 320 | copyEvent( event, ev ); |
305 | calendar->deleteEvent( ev ); | 321 | calendar->deleteEvent( ev ); |
306 | calendar->addEvent( event); | 322 | calendar->addEvent( event); |
307 | } | 323 | } |
308 | else | 324 | else |
309 | event = ev; | 325 | event = ev; |
310 | uint cSum; | 326 | uint cSum; |
311 | cSum = PhoneFormat::getCsumEvent( event ); | 327 | cSum = PhoneFormat::getCsumEvent( event ); |
312 | event->setCsum( mProfileName, QString::number( cSum )); | 328 | event->setCsum( mProfileName, QString::number( cSum )); |
313 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 329 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
314 | event->setID( mProfileName,QString::number( id ) ); | 330 | event->setID( mProfileName,QString::number( id ) ); |
315 | ev = er.next(); | 331 | ev = er.next(); |
316 | } | 332 | } |
317 | { | 333 | { |
334 | qDebug("reading todos... "); | ||
318 | QPtrList<Todo> tr = calendar->rawTodos(); | 335 | QPtrList<Todo> tr = calendar->rawTodos(); |
319 | Todo* ev = tr.first(); | 336 | Todo* ev = tr.first(); |
320 | while ( ev ) { | 337 | while ( ev ) { |
321 | 338 | ||
322 | QStringList cat = ev->categories(); | 339 | QStringList cat = ev->categories(); |
323 | if ( cat.contains( "MeetingDEF" )) { | 340 | if ( cat.contains( "MeetingDEF" )) { |
324 | ev->setCategories( QStringList() ); | 341 | ev->setCategories( QStringList() ); |
325 | } | 342 | } |
326 | int id = ev->pilotId(); | 343 | int id = ev->pilotId(); |
327 | Todo *event; | 344 | Todo *event; |
328 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 345 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
329 | if ( event ) { | 346 | if ( event ) { |
330 | event = (Todo*)event->clone(); | 347 | event = (Todo*)event->clone(); |
331 | copyTodo( event, ev ); | 348 | copyTodo( event, ev ); |
332 | calendar->deleteTodo( ev ); | 349 | calendar->deleteTodo( ev ); |
333 | calendar->addTodo( event); | 350 | calendar->addTodo( event); |
334 | } | 351 | } |
335 | else | 352 | else |
336 | event = ev; | 353 | event = ev; |
337 | uint cSum; | 354 | uint cSum; |
338 | cSum = PhoneFormat::getCsumTodo( event ); | 355 | cSum = PhoneFormat::getCsumTodo( event ); |
339 | event->setCsum( mProfileName, QString::number( cSum )); | 356 | event->setCsum( mProfileName, QString::number( cSum )); |
340 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 357 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
341 | event->setID( mProfileName,QString::number( id ) ); | 358 | event->setID( mProfileName,QString::number( id ) ); |
342 | ev = tr.next(); | 359 | ev = tr.next(); |
343 | } | 360 | } |
344 | } | 361 | } |
345 | return true; | 362 | return true; |
346 | } | 363 | } |
347 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 364 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
348 | { | 365 | { |
349 | if ( from->dtStart().isValid() ) | 366 | if ( from->dtStart().isValid() ) |
@@ -453,130 +470,150 @@ bool PhoneFormat::save( Calendar *calendar) | |||
453 | int dh = QApplication::desktop()->height(); | 470 | int dh = QApplication::desktop()->height(); |
454 | status.setCaption(i18n("Writing to phone...") ); | 471 | status.setCaption(i18n("Writing to phone...") ); |
455 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 472 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
456 | status.show(); | 473 | status.show(); |
457 | status.raise(); | 474 | status.raise(); |
458 | qApp->processEvents(); | 475 | qApp->processEvents(); |
459 | QString message; | 476 | QString message; |
460 | #ifdef _WIN32_ | 477 | #ifdef _WIN32_ |
461 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 478 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
462 | #else | 479 | #else |
463 | QString fileName = "/tmp/kdepimtemp.vcs"; | 480 | QString fileName = "/tmp/kdepimtemp.vcs"; |
464 | #endif | 481 | #endif |
465 | 482 | ||
466 | // 1 remove events which should be deleted | 483 | // 1 remove events which should be deleted |
467 | QPtrList<Event> er = calendar->rawEvents(); | 484 | QPtrList<Event> er = calendar->rawEvents(); |
468 | Event* ev = er.first(); | 485 | Event* ev = er.first(); |
469 | while ( ev ) { | 486 | while ( ev ) { |
470 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 487 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
471 | calendar->deleteEvent( ev ); | 488 | calendar->deleteEvent( ev ); |
472 | } else { | 489 | } else { |
473 | 490 | ||
474 | } | 491 | } |
475 | ev = er.next(); | 492 | ev = er.next(); |
476 | } | 493 | } |
477 | // 2 remove todos which should be deleted | 494 | // 2 remove todos which should be deleted |
478 | QPtrList<Todo> tl = calendar->rawTodos(); | 495 | QPtrList<Todo> tl = calendar->rawTodos(); |
479 | Todo* to = tl.first(); | 496 | Todo* to = tl.first(); |
480 | while ( to ) { | 497 | while ( to ) { |
481 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 498 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
482 | calendar->deleteTodo( to ); | 499 | calendar->deleteTodo( to ); |
483 | } | 500 | } |
484 | to = tl.next(); | 501 | to = tl.next(); |
485 | } | 502 | } |
486 | // 3 save file | 503 | // 3 save file |
487 | VCalFormat vfsave; | 504 | VCalFormat vfsave; |
488 | vfsave.setLocalTime ( true ); | 505 | vfsave.setLocalTime ( true ); |
489 | if ( ! vfsave.save( calendar, fileName ) ) | 506 | if ( ! vfsave.save( calendar, fileName ) ) |
490 | return false; | 507 | return false; |
491 | // 4 call kammu | 508 | // 4 call kammu |
492 | QString command ="./kammu --restore " + fileName + " -C" + | 509 | QString command ="./kammu --restore " + fileName + " -C" + |
493 | mConnection +" -D" + mDevice +" -M" + mModel;; | 510 | mConnection +" -D" + mDevice +" -M" + mModel; |
494 | int ret = system ( command.latin1() ); | 511 | int ret; |
495 | if ( ret != 0 ) | 512 | while ( (ret = system ( command.latin1())) != 0 ) { |
513 | qDebug("Error S::command returned %d. asking users", ret); | ||
514 | int retval = KMessageBox::warningContinueCancel(0, | ||
515 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); | ||
516 | if ( retval != KMessageBox::Continue ) | ||
517 | return false; | ||
518 | } | ||
519 | if ( ret != 0 ) { | ||
520 | qDebug("Error S::command returned %d", ret); | ||
496 | return false; | 521 | return false; |
522 | } | ||
497 | // 5 reread data | 523 | // 5 reread data |
498 | message = i18n(" Rereading all data ... "); | 524 | message = i18n(" Rereading all data ... "); |
499 | status.setText ( message ); | 525 | status.setText ( message ); |
500 | qApp->processEvents(); | 526 | qApp->processEvents(); |
501 | CalendarLocal* calendarTemp = new CalendarLocal(); | 527 | CalendarLocal* calendarTemp = new CalendarLocal(); |
502 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 528 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
503 | if ( ! load( calendarTemp,calendar) ){ | 529 | if ( ! load( calendarTemp,calendar) ){ |
504 | qDebug("error reloading calendar "); | 530 | qDebug("error reloading calendar "); |
505 | delete calendarTemp; | 531 | delete calendarTemp; |
506 | return false; | 532 | return false; |
507 | } | 533 | } |
508 | // 6 compare data | 534 | // 6 compare data |
509 | 535 | ||
510 | //algo 6 compare event | 536 | //algo 6 compare event |
511 | er = calendar->rawEvents(); | 537 | er = calendar->rawEvents(); |
512 | ev = er.first(); | 538 | ev = er.first(); |
513 | message = i18n(" Comparing event # "); | 539 | message = i18n(" Comparing event # "); |
514 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 540 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
515 | Event* ev1; | 541 | Event* ev1; |
516 | int procCount = 0; | 542 | int procCount = 0; |
517 | while ( ev ) { | 543 | while ( ev ) { |
518 | qDebug("event new ID "); | 544 | //qDebug("event new ID %s",ev->summary().latin1()); |
519 | status.setText ( message + QString::number ( ++procCount ) ); | 545 | status.setText ( message + QString::number ( ++procCount ) ); |
520 | qApp->processEvents(); | 546 | qApp->processEvents(); |
521 | QString cSum = ev->getCsum(mProfileName); | 547 | uint csum; |
548 | csum = PhoneFormat::getCsumEvent( ev ); | ||
549 | QString cSum = QString::number( csum ); | ||
550 | ev->setCsum( mProfileName, cSum ); | ||
551 | //qDebug("Event cSum %s ", cSum.latin1()); | ||
522 | ev1 = er1.first(); | 552 | ev1 = er1.first(); |
523 | while ( ev1 ) { | 553 | while ( ev1 ) { |
524 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 554 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
525 | er1.remove( ev1 ); | 555 | er1.remove( ev1 ); |
526 | afterSave( ev ); | 556 | afterSave( ev ); |
527 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | 557 | ev->setID(mProfileName, ev1->getID(mProfileName) ); |
558 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | ||
559 | |||
528 | break; | 560 | break; |
529 | } | 561 | } |
530 | ev1 = er1.next(); | 562 | ev1 = er1.next(); |
531 | } | 563 | } |
532 | if ( ! ev1 ) { | 564 | if ( ! ev1 ) { |
533 | ev->removeID(mProfileName); | 565 | ev->removeID(mProfileName); |
534 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 566 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
535 | } | 567 | } |
536 | 568 | ||
537 | 569 | ||
538 | ev = er.next(); | 570 | ev = er.next(); |
539 | } | 571 | } |
540 | //algo 6 compare todo | 572 | //algo 6 compare todo |
573 | tl = calendar->rawTodos(); | ||
541 | to = tl.first(); | 574 | to = tl.first(); |
542 | procCount = 0; | 575 | procCount = 0; |
543 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 576 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
544 | Todo* to1 ; | 577 | Todo* to1 ; |
545 | message = i18n(" Comparing todo # "); | 578 | message = i18n(" Comparing todo # "); |
546 | while ( to ) { | 579 | while ( to ) { |
547 | qDebug("todo2 %d ", procCount); | 580 | qDebug("todo2 %d ", procCount); |
548 | status.setText ( message + QString::number ( ++procCount ) ); | 581 | status.setText ( message + QString::number ( ++procCount ) ); |
549 | qApp->processEvents(); | 582 | qApp->processEvents(); |
550 | QString cSum = to->getCsum(mProfileName); | 583 | uint csum; |
584 | csum = PhoneFormat::getCsumTodo( to ); | ||
585 | QString cSum = QString::number( csum ); | ||
586 | to->setCsum( mProfileName, cSum ); | ||
587 | qDebug("Todo cSum %s ", cSum.latin1()); | ||
551 | Todo* to1 = tl1.first(); | 588 | Todo* to1 = tl1.first(); |
552 | while ( to1 ) { | 589 | while ( to1 ) { |
553 | if ( to1->getCsum( mProfileName ) == cSum ) { | 590 | if ( to1->getCsum( mProfileName ) == cSum ) { |
554 | tl1.remove( to1 ); | 591 | tl1.remove( to1 ); |
555 | afterSave( to ); | 592 | afterSave( to ); |
556 | to->setID(mProfileName, to1->getID(mProfileName) ); | 593 | to->setID(mProfileName, to1->getID(mProfileName) ); |
557 | break; | 594 | break; |
558 | } | 595 | } |
559 | to1 = tl1.next(); | 596 | to1 = tl1.next(); |
560 | } | 597 | } |
561 | if ( ! to1 ) { | 598 | if ( ! to1 ) { |
562 | to->removeID(mProfileName); | 599 | to->removeID(mProfileName); |
563 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
564 | } | 601 | } |
565 | 602 | ||
566 | to = tl.next(); | 603 | to = tl.next(); |
567 | } | 604 | } |
568 | delete calendarTemp; | 605 | delete calendarTemp; |
569 | return true; | 606 | return true; |
570 | 607 | ||
571 | 608 | ||
572 | 609 | ||
573 | } | 610 | } |
574 | 611 | ||
575 | 612 | ||
576 | QString PhoneFormat::toString( Calendar * ) | 613 | QString PhoneFormat::toString( Calendar * ) |
577 | { | 614 | { |
578 | return QString::null; | 615 | return QString::null; |
579 | } | 616 | } |
580 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
581 | { | 618 | { |
582 | return false; | 619 | return false; |