-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 950e35e..598292c 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -96,26 +96,26 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
96 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); | 96 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); |
97 | 97 | ||
98 | if (Version == Nokia_VCalendar) { | 98 | if (Version == Nokia_VCalendar) { |
99 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 99 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
100 | switch (note->Type) { | 100 | switch (note->Type) { |
101 | case GSM_CAL_REMINDER: | 101 | case GSM_CAL_REMINDER: |
102 | *Length+=sprintf(Buffer+(*Length), "REMINDER%c%c",13,10); | 102 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); |
103 | break; | 103 | break; |
104 | case GSM_CAL_MEMO: | 104 | case GSM_CAL_MEMO: |
105 | *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); | 105 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
106 | break; | 106 | break; |
107 | case GSM_CAL_CALL: | 107 | case GSM_CAL_CALL: |
108 | *Length+=sprintf(Buffer+(*Length), "PHONE CALL%c%c",13,10); | 108 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
109 | break; | 109 | break; |
110 | case GSM_CAL_BIRTHDAY: | 110 | case GSM_CAL_BIRTHDAY: |
111 | *Length+=sprintf(Buffer+(*Length), "SPECIAL OCCASION%c%c",13,10); | 111 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); |
112 | break; | 112 | break; |
113 | case GSM_CAL_MEETING: | 113 | case GSM_CAL_MEETING: |
114 | default: | 114 | default: |
115 | *Length+=sprintf(Buffer+(*Length), "MEETING%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); |
@@ -156,23 +156,23 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
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"); |
178 | 178 | ||
@@ -202,29 +202,29 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
202 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); | 202 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); |
203 | } | 203 | } |
204 | } else if (Version == SonyEricsson_VCalendar) { | 204 | } else if (Version == SonyEricsson_VCalendar) { |
205 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 205 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
206 | switch (note->Type) { | 206 | switch (note->Type) { |
207 | case GSM_CAL_MEETING: | 207 | case GSM_CAL_MEETING: |
208 | *Length+=sprintf(Buffer+(*Length), "MEETING%c%c",13,10); | 208 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
209 | break; | 209 | break; |
210 | case GSM_CAL_REMINDER: | 210 | case GSM_CAL_REMINDER: |
211 | *Length+=sprintf(Buffer+(*Length), "DATE%c%c",13,10); | 211 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); |
212 | break; | 212 | break; |
213 | case GSM_CAL_TRAVEL: | 213 | case GSM_CAL_TRAVEL: |
214 | *Length+=sprintf(Buffer+(*Length), "TRAVEL%c%c",13,10); | 214 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); |
215 | break; | 215 | break; |
216 | case GSM_CAL_VACATION: | 216 | case GSM_CAL_VACATION: |
217 | *Length+=sprintf(Buffer+(*Length), "VACATION%c%c",13,10); | 217 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); |
218 | break; | 218 | break; |
219 | case GSM_CAL_BIRTHDAY: | 219 | case GSM_CAL_BIRTHDAY: |
220 | *Length+=sprintf(Buffer+(*Length), "ANNIVERSARY%c%c",13,10); | 220 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); |
221 | break; | 221 | break; |
222 | case GSM_CAL_MEMO: | 222 | case GSM_CAL_MEMO: |
223 | default: | 223 | default: |
224 | *Length+=sprintf(Buffer+(*Length), "MISCELLANEOUS%c%c",13,10); | 224 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (Time == -1) return ERR_UNKNOWN; | 228 | if (Time == -1) return ERR_UNKNOWN; |
229 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 229 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
230 | 230 | ||
@@ -240,12 +240,13 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
240 | 240 | ||
241 | if (Location != -1) { | 241 | if (Location != -1) { |
242 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 242 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | ||
246 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); | 247 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); |
247 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 248 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
248 | 249 | ||
249 | return ERR_NONE; | 250 | return ERR_NONE; |
250 | } | 251 | } |
251 | 252 | ||
@@ -297,21 +298,21 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h | |||
297 | 298 | ||
298 | if (Version == Nokia_VToDo) { | 299 | if (Version == Nokia_VToDo) { |
299 | if (Text == -1) return ERR_UNKNOWN; | 300 | if (Text == -1) return ERR_UNKNOWN; |
300 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 301 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
301 | 302 | ||
302 | if (Completed == -1) { | 303 | if (Completed == -1) { |
303 | *Length+=sprintf(Buffer+(*Length), "STATUS:NEEDS ACTION%c%c",13,10); | 304 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
304 | } else { | 305 | } else { |
305 | *Length+=sprintf(Buffer+(*Length), "STATUS:COMPLETED%c%c",13,10); | 306 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
306 | } | 307 | } |
307 | 308 | ||
308 | switch (note->Priority) { | 309 | switch (note->Priority) { |
309 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 310 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
310 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:2%c%c",13,10); break; | 311 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
311 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 312 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
312 | } | 313 | } |
313 | 314 | ||
314 | if (EndTime != -1) { | 315 | if (EndTime != -1) { |
315 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); | 316 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); |
316 | } | 317 | } |
317 | 318 | ||
@@ -324,28 +325,29 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h | |||
324 | } | 325 | } |
325 | } else if (Version == SonyEricsson_VToDo) { | 326 | } else if (Version == SonyEricsson_VToDo) { |
326 | if (Text == -1) return ERR_UNKNOWN; | 327 | if (Text == -1) return ERR_UNKNOWN; |
327 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 328 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
328 | 329 | ||
329 | if (Completed == -1) { | 330 | if (Completed == -1) { |
330 | *Length+=sprintf(Buffer+(*Length), "STATUS:NEEDS ACTION%c%c",13,10); | 331 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
331 | } else { | 332 | } else { |
332 | *Length+=sprintf(Buffer+(*Length), "STATUS:COMPLETED%c%c",13,10); | 333 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
333 | } | 334 | } |
334 | 335 | ||
335 | switch (note->Priority) { | 336 | switch (note->Priority) { |
336 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 337 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
337 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:2%c%c",13,10); break; | 338 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
338 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 339 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
339 | } | 340 | } |
340 | 341 | ||
341 | if (Alarm != -1) { | 342 | if (Alarm != -1) { |
342 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 343 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
343 | } | 344 | } |
344 | } | 345 | } |
345 | 346 | ||
347 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | ||
346 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); | 348 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); |
347 | 349 | ||
348 | if (header) { | 350 | if (header) { |
349 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 351 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
350 | } | 352 | } |
351 | return ERR_NONE; | 353 | return ERR_NONE; |
@@ -366,31 +368,32 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda | |||
366 | case 0: | 368 | case 0: |
367 | if (strstr(Line,"BEGIN:VEVENT")) { | 369 | if (strstr(Line,"BEGIN:VEVENT")) { |
368 | Calendar->Type = GSM_CAL_MEMO; | 370 | Calendar->Type = GSM_CAL_MEMO; |
369 | Level = 1; | 371 | Level = 1; |
370 | } | 372 | } |
371 | if (strstr(Line,"BEGIN:VTODO")) { | 373 | if (strstr(Line,"BEGIN:VTODO")) { |
372 | ToDo->Priority = GSM_Priority_Low; | 374 | ToDo->Priority = GSM_Priority_Medium; |
373 | Level = 2; | 375 | Level = 2; |
374 | } | 376 | } |
375 | break; | 377 | break; |
376 | case 1: /* Calendar note */ | 378 | case 1: /* Calendar note */ |
377 | if (strstr(Line,"END:VEVENT")) { | 379 | if (strstr(Line,"END:VEVENT")) { |
378 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; | 380 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; |
379 | return ERR_NONE; | 381 | return ERR_NONE; |
380 | } | 382 | } |
381 | if (strstr(Line,"CATEGORIES:REMINDER")) Calendar->Type = GSM_CAL_REMINDER; | 383 | Calendar->Type = GSM_CAL_MEETING; |
382 | if (strstr(Line,"CATEGORIES:DATE")) Calendar->Type = GSM_CAL_REMINDER;//SE | 384 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; |
383 | if (strstr(Line,"CATEGORIES:TRAVEL")) Calendar->Type = GSM_CAL_TRAVEL; //SE | 385 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE |
384 | if (strstr(Line,"CATEGORIES:VACATION")) Calendar->Type = GSM_CAL_VACATION;//SE | 386 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE |
385 | if (strstr(Line,"CATEGORIES:MISCELLANEOUS")) Calendar->Type = GSM_CAL_MEMO; | 387 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE |
386 | if (strstr(Line,"CATEGORIES:PHONE CALL")) Calendar->Type = GSM_CAL_CALL; | 388 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; |
387 | if (strstr(Line,"CATEGORIES:SPECIAL OCCASION")) Calendar->Type = GSM_CAL_BIRTHDAY; | 389 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; |
388 | if (strstr(Line,"CATEGORIES:ANNIVERSARY")) Calendar->Type = GSM_CAL_BIRTHDAY; | 390 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; |
389 | if (strstr(Line,"CATEGORIES:MEETING")) Calendar->Type = GSM_CAL_MEETING; | 391 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; |
390 | if (strstr(Line,"CATEGORIES:APPOINTMENT")) Calendar->Type = GSM_CAL_MEETING; | 392 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; |
393 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; | ||
391 | if (strstr(Line,"RRULE:D1")) { | 394 | if (strstr(Line,"RRULE:D1")) { |
392 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 395 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
393 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; | 396 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; |
394 | Calendar->EntriesNum++; | 397 | Calendar->EntriesNum++; |
395 | } | 398 | } |
396 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { | 399 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { |
@@ -469,22 +472,22 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda | |||
469 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); | 472 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); |
470 | ToDo->EntriesNum++; | 473 | ToDo->EntriesNum++; |
471 | } | 474 | } |
472 | if (ReadVCALText(Line, "PRIORITY", Buff)) { | 475 | if (ReadVCALText(Line, "PRIORITY", Buff)) { |
473 | if (ToDoVer == SonyEricsson_VToDo) { | 476 | if (ToDoVer == SonyEricsson_VToDo) { |
474 | ToDo->Priority = GSM_Priority_Low; | 477 | ToDo->Priority = GSM_Priority_Low; |
475 | if (atoi(DecodeUnicodeString(Buff))==2) ToDo->Priority = GSM_Priority_Medium; | 478 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
476 | if (atoi(DecodeUnicodeString(Buff))==1) ToDo->Priority = GSM_Priority_High; | 479 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
477 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); | 480 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); |
478 | } else if (ToDoVer == Nokia_VToDo) { | 481 | } else if (ToDoVer == Nokia_VToDo) { |
479 | ToDo->Priority = GSM_Priority_Low; | 482 | ToDo->Priority = GSM_Priority_Low; |
480 | if (atoi(DecodeUnicodeString(Buff))==2) ToDo->Priority = GSM_Priority_Medium; | 483 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
481 | if (atoi(DecodeUnicodeString(Buff))==3) ToDo->Priority = GSM_Priority_High; | 484 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
482 | } | 485 | } |
483 | } | 486 | } |
484 | if (strstr(Line,"STATUS:COMPLETED")) { | 487 | if (strstr(Line,"PERCENT-COMPLETE:100")) { |
485 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; | 488 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; |
486 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | 489 | ToDo->Entries[ToDo->EntriesNum].Number = 1; |
487 | ToDo->EntriesNum++; | 490 | ToDo->EntriesNum++; |
488 | } | 491 | } |
489 | break; | 492 | break; |
490 | } | 493 | } |