-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0375fee..7310755 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -102,25 +102,25 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
103 | switch (note->Type) { | 103 | switch (note->Type) { |
104 | case GSM_CAL_REMINDER: | 104 | case GSM_CAL_REMINDER: |
105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); | 105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); |
106 | break; | 106 | break; |
107 | case GSM_CAL_MEMO: | 107 | case GSM_CAL_MEMO: |
108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
109 | break; | 109 | break; |
110 | case GSM_CAL_CALL: | 110 | case GSM_CAL_CALL: |
111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
112 | break; | 112 | break; |
113 | case GSM_CAL_BIRTHDAY: | 113 | case GSM_CAL_BIRTHDAY: |
114 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); | 114 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
115 | break; | 115 | break; |
116 | case GSM_CAL_MEETING: | 116 | case GSM_CAL_MEETING: |
117 | default: | 117 | default: |
118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); | 118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | if (note->Type == GSM_CAL_CALL) { | 121 | if (note->Type == GSM_CAL_CALL) { |
122 | buffer[0] = 0; | 122 | buffer[0] = 0; |
123 | buffer[1] = 0; | 123 | buffer[1] = 0; |
124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
125 | if (Text != -1) { | 125 | if (Text != -1) { |
126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
@@ -141,63 +141,63 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
142 | } | 142 | } |
143 | 143 | ||
144 | if (Alarm != -1) { | 144 | if (Alarm != -1) { |
145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
147 | } else { | 147 | } else { |
148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | /* Birthday is known to be recurranced */ | 152 | /* Birthday is known to be recurranced */ |
153 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { | 153 | if (Recurrance != -1 ) { |
154 | switch(note->Entries[Recurrance].Number/24) { | 154 | switch(note->Entries[Recurrance].Number/24) { |
155 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; | 155 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; |
156 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; | 156 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; |
157 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; | 157 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; |
158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; | 158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1 #0%c%c",13,10); break; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | } else if (Version == Siemens_VCalendar) { | 161 | } else if (Version == Siemens_VCalendar) { |
162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
163 | switch (note->Type) { | 163 | switch (note->Type) { |
164 | case GSM_CAL_MEETING: | 164 | case GSM_CAL_MEETING: |
165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
166 | break; | 166 | break; |
167 | case GSM_CAL_CALL: | 167 | case GSM_CAL_CALL: |
168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
169 | break; | 169 | break; |
170 | case GSM_CAL_BIRTHDAY: | 170 | case GSM_CAL_BIRTHDAY: |
171 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); | 171 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
172 | break; | 172 | break; |
173 | case GSM_CAL_MEMO: | 173 | case GSM_CAL_MEMO: |
174 | default: | 174 | default: |
175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
176 | break; | 176 | break; |
177 | } | 177 | } |
178 | 178 | ||
179 | if (Time == -1) return ERR_UNKNOWN; | 179 | if (Time == -1) return ERR_UNKNOWN; |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
181 | 181 | ||
182 | if (Alarm != -1) { | 182 | if (Alarm != -1) { |
183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
184 | } | 184 | } |
185 | 185 | ||
186 | if (Recurrance != -1) { | 186 | if (Recurrance != -1) { |
187 | switch(note->Entries[Recurrance].Number/24) { | 187 | switch(note->Entries[Recurrance].Number/24) { |
188 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; | 188 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; |
189 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; | 189 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; |
190 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; | 190 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; |
191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; | 191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1%c%c",13,10);break; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | if (note->Type == GSM_CAL_CALL) { | 195 | if (note->Type == GSM_CAL_CALL) { |
196 | buffer[0] = 0; | 196 | buffer[0] = 0; |
197 | buffer[1] = 0; | 197 | buffer[1] = 0; |
198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
199 | if (Text != -1) { | 199 | if (Text != -1) { |
200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
202 | } | 202 | } |
203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
@@ -211,25 +211,25 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
212 | break; | 212 | break; |
213 | case GSM_CAL_REMINDER: | 213 | case GSM_CAL_REMINDER: |
214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); | 214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); |
215 | break; | 215 | break; |
216 | case GSM_CAL_TRAVEL: | 216 | case GSM_CAL_TRAVEL: |
217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); | 217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); |
218 | break; | 218 | break; |
219 | case GSM_CAL_VACATION: | 219 | case GSM_CAL_VACATION: |
220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); | 220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); |
221 | break; | 221 | break; |
222 | case GSM_CAL_BIRTHDAY: | 222 | case GSM_CAL_BIRTHDAY: |
223 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); | 223 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
224 | break; | 224 | break; |
225 | case GSM_CAL_MEMO: | 225 | case GSM_CAL_MEMO: |
226 | default: | 226 | default: |
227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
228 | break; | 228 | break; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (Time == -1) return ERR_UNKNOWN; | 231 | if (Time == -1) return ERR_UNKNOWN; |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
233 | 233 | ||
234 | if (EndTime != -1) { | 234 | if (EndTime != -1) { |
235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
@@ -381,26 +381,26 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda | |||
381 | case 1: /* Calendar note */ | 381 | case 1: /* Calendar note */ |
382 | if (strstr(Line,"END:VEVENT")) { | 382 | if (strstr(Line,"END:VEVENT")) { |
383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; | 383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; |
384 | return ERR_NONE; | 384 | return ERR_NONE; |
385 | } | 385 | } |
386 | Calendar->Type = GSM_CAL_MEETING; | 386 | Calendar->Type = GSM_CAL_MEETING; |
387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; | 387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; |
388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE | 388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE |
389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE | 389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE |
390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE | 390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE |
391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; | 391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; |
392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; | 392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; |
393 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; | ||
394 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; | 393 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; |
394 | if (strstr(Line,"CATEGORIES:Birthday")) Calendar->Type = GSM_CAL_BIRTHDAY; | ||
395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; | 395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; |
396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; | 396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; |
397 | if (strstr(Line,"RRULE:D1")) { | 397 | if (strstr(Line,"RRULE:D1")) { |
398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; | 399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; |
400 | Calendar->EntriesNum++; | 400 | Calendar->EntriesNum++; |
401 | } | 401 | } |
402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { | 402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { |
403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; | 404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; |
405 | Calendar->EntriesNum++; | 405 | Calendar->EntriesNum++; |
406 | } | 406 | } |
@@ -411,24 +411,30 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda | |||
411 | } | 411 | } |
412 | if (strstr(Line,"RRULE:MD1")) { | 412 | if (strstr(Line,"RRULE:MD1")) { |
413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; | 414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; |
415 | Calendar->EntriesNum++; | 415 | Calendar->EntriesNum++; |
416 | } | 416 | } |
417 | if (strstr(Line,"RRULE:YD1")) { | 417 | if (strstr(Line,"RRULE:YD1")) { |
418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | 419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; |
420 | Calendar->EntriesNum++; | 420 | Calendar->EntriesNum++; |
421 | } | 421 | } |
422 | // LR | 422 | // LR |
423 | if (strstr(Line,"RRULE:YM1")) { | ||
424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | ||
425 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | ||
426 | Calendar->EntriesNum++; | ||
427 | } | ||
428 | // LR | ||
423 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { | 429 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { |
424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; | 430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; |
425 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 431 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
426 | Calendar->EntriesNum++; | 432 | Calendar->EntriesNum++; |
427 | } | 433 | } |
428 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { | 434 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { |
429 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; | 435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; |
430 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 436 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
431 | Calendar->EntriesNum++; | 437 | Calendar->EntriesNum++; |
432 | } | 438 | } |
433 | if (ReadVCALText(Line, "LOCATION", Buff)) { | 439 | if (ReadVCALText(Line, "LOCATION", Buff)) { |
434 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; | 440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; |