-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 | |||
@@ -86,46 +86,46 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
86 | { | 86 | { |
87 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; | 87 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; |
88 | char buffer[2000]; | 88 | char buffer[2000]; |
89 | 89 | ||
90 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); | 90 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); |
91 | 91 | ||
92 | if (header) { | 92 | if (header) { |
93 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 93 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
94 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 94 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
95 | } | 95 | } |
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); |
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"); |
@@ -146,43 +146,43 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
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"); |
178 | 178 | ||
179 | if (Alarm != -1) { | 179 | if (Alarm != -1) { |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
181 | } | 181 | } |
182 | 182 | ||
183 | if (Recurrance != -1) { | 183 | if (Recurrance != -1) { |
184 | switch(note->Entries[Recurrance].Number/24) { | 184 | switch(note->Entries[Recurrance].Number/24) { |
185 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; | 185 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; |
186 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; | 186 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; |
187 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; | 187 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; |
188 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; | 188 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; |
@@ -192,70 +192,71 @@ GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note | |||
192 | if (note->Type == GSM_CAL_CALL) { | 192 | if (note->Type == GSM_CAL_CALL) { |
193 | buffer[0] = 0; | 193 | buffer[0] = 0; |
194 | buffer[1] = 0; | 194 | buffer[1] = 0; |
195 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 195 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
196 | if (Text != -1) { | 196 | if (Text != -1) { |
197 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 197 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
198 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 198 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
199 | } | 199 | } |
200 | SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); | 200 | SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); |
201 | } else { | 201 | } else { |
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 | ||
231 | if (EndTime != -1) { | 231 | if (EndTime != -1) { |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
233 | } | 233 | } |
234 | 234 | ||
235 | if (Alarm != -1) { | 235 | if (Alarm != -1) { |
236 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 236 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
237 | } | 237 | } |
238 | 238 | ||
239 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 239 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
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 | ||
252 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) | 253 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) |
253 | { | 254 | { |
254 | int i; | 255 | int i; |
255 | 256 | ||
256 | *Text = -1; | 257 | *Text = -1; |
257 | *EndTime= -1; | 258 | *EndTime= -1; |
258 | *Alarm = -1; | 259 | *Alarm = -1; |
259 | *Completed= -1; | 260 | *Completed= -1; |
260 | *Phone = -1; | 261 | *Phone = -1; |
261 | for (i = 0; i < entry->EntriesNum; i++) { | 262 | for (i = 0; i < entry->EntriesNum; i++) { |
@@ -287,120 +288,122 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h | |||
287 | int Text, Alarm, Completed, EndTime, Phone; | 288 | int Text, Alarm, Completed, EndTime, Phone; |
288 | 289 | ||
289 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); | 290 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); |
290 | 291 | ||
291 | if (header) { | 292 | if (header) { |
292 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 293 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
293 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 294 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
294 | } | 295 | } |
295 | 296 | ||
296 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); | 297 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); |
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 | ||
318 | if (Alarm != -1) { | 319 | if (Alarm != -1) { |
319 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 320 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
320 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 321 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
321 | } else { | 322 | } else { |
322 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 323 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
323 | } | 324 | } |
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; |
352 | } | 354 | } |
353 | 355 | ||
354 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) | 356 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) |
355 | { | 357 | { |
356 | unsigned char Line[2000],Buff[2000]; | 358 | unsigned char Line[2000],Buff[2000]; |
357 | int Level = 0; | 359 | int Level = 0; |
358 | 360 | ||
359 | Calendar->EntriesNum = 0; | 361 | Calendar->EntriesNum = 0; |
360 | ToDo->EntriesNum = 0; | 362 | ToDo->EntriesNum = 0; |
361 | 363 | ||
362 | while (1) { | 364 | while (1) { |
363 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); | 365 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); |
364 | if (strlen(Line) == 0) break; | 366 | if (strlen(Line) == 0) break; |
365 | switch (Level) { | 367 | switch (Level) { |
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"))) { |
397 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 400 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
398 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; | 401 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; |
399 | Calendar->EntriesNum++; | 402 | Calendar->EntriesNum++; |
400 | } | 403 | } |
401 | if (strstr(Line,"RRULE:W2")) { | 404 | if (strstr(Line,"RRULE:W2")) { |
402 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 405 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
403 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; | 406 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; |
404 | Calendar->EntriesNum++; | 407 | Calendar->EntriesNum++; |
405 | } | 408 | } |
406 | if (strstr(Line,"RRULE:MD1")) { | 409 | if (strstr(Line,"RRULE:MD1")) { |
@@ -459,42 +462,42 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_Calenda | |||
459 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 462 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
460 | ToDo->EntriesNum++; | 463 | ToDo->EntriesNum++; |
461 | } | 464 | } |
462 | if (ReadVCALText(Line, "AALARM", Buff)) { | 465 | if (ReadVCALText(Line, "AALARM", Buff)) { |
463 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | 466 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; |
464 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 467 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
465 | ToDo->EntriesNum++; | 468 | ToDo->EntriesNum++; |
466 | } | 469 | } |
467 | if (ReadVCALText(Line, "SUMMARY", Buff)) { | 470 | if (ReadVCALText(Line, "SUMMARY", Buff)) { |
468 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; | 471 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; |
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 | } |
491 | } | 494 | } |
492 | 495 | ||
493 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; | 496 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; |
494 | return ERR_NONE; | 497 | return ERR_NONE; |
495 | } | 498 | } |
496 | 499 | ||
497 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 500 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) |
498 | { | 501 | { |
499 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); | 502 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); |
500 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); | 503 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); |