author | zautrix <zautrix> | 2004-10-14 06:42:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-14 06:42:01 (UTC) |
commit | a6dff815a9c6d3a91094573d23c28a8553fc7cc2 (patch) (unidiff) | |
tree | a8830e9adcd72faa8178d4ee2517bfc31cda8653 /gammu | |
parent | 909d25797c50fc38c435834a68aaf60bf87e32f9 (diff) | |
download | kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.zip kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.tar.gz kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.tar.bz2 |
fixes umlaute in beaming
-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 15 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmcal.h | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0ea8e06..0375fee 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -1,298 +1,301 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | 4 | ||
5 | #include "gsmcal.h" | 5 | #include "gsmcal.h" |
6 | #include "gsmmisc.h" | 6 | #include "gsmmisc.h" |
7 | #include "../misc/coding/coding.h" | 7 | #include "../misc/coding/coding.h" |
8 | 8 | ||
9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) | 9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) |
10 | { | 10 | { |
11 | bool Past = true; | 11 | bool Past = true; |
12 | int i; | 12 | int i; |
13 | GSM_DateTimeDT; | 13 | GSM_DateTimeDT; |
14 | 14 | ||
15 | GSM_GetCurrentDateTime (&DT); | 15 | GSM_GetCurrentDateTime (&DT); |
16 | for (i = 0; i < note->EntriesNum; i++) { | 16 | for (i = 0; i < note->EntriesNum; i++) { |
17 | switch (note->Entries[i].EntryType) { | 17 | switch (note->Entries[i].EntryType) { |
18 | case CAL_RECURRANCE: | 18 | case CAL_RECURRANCE: |
19 | Past = false; | 19 | Past = false; |
20 | break; | 20 | break; |
21 | case CAL_START_DATETIME : | 21 | case CAL_START_DATETIME : |
22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; | 22 | if (note->Entries[i].Date.Year > DT.Year) Past = false; |
23 | if (note->Entries[i].Date.Year == DT.Year && | 23 | if (note->Entries[i].Date.Year == DT.Year && |
24 | note->Entries[i].Date.Month > DT.Month) Past = false; | 24 | note->Entries[i].Date.Month > DT.Month) Past = false; |
25 | if (note->Entries[i].Date.Year == DT.Year && | 25 | if (note->Entries[i].Date.Year == DT.Year && |
26 | note->Entries[i].Date.Month == DT.Month && | 26 | note->Entries[i].Date.Month == DT.Month && |
27 | note->Entries[i].Date.Day > DT.Day) Past = false; | 27 | note->Entries[i].Date.Day > DT.Day) Past = false; |
28 | break; | 28 | break; |
29 | default: | 29 | default: |
30 | break; | 30 | break; |
31 | } | 31 | } |
32 | if (!Past) break; | 32 | if (!Past) break; |
33 | } | 33 | } |
34 | switch (note->Type) { | 34 | switch (note->Type) { |
35 | case GSM_CAL_BIRTHDAY: | 35 | case GSM_CAL_BIRTHDAY: |
36 | Past = false; | 36 | Past = false; |
37 | break; | 37 | break; |
38 | default: | 38 | default: |
39 | break; | 39 | break; |
40 | } | 40 | } |
41 | return Past; | 41 | return Past; |
42 | } | 42 | } |
43 | 43 | ||
44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) | 44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) |
45 | { | 45 | { |
46 | int i; | 46 | int i; |
47 | 47 | ||
48 | *Text = -1; | 48 | *Text = -1; |
49 | *Time = -1; | 49 | *Time = -1; |
50 | *Alarm = -1; | 50 | *Alarm = -1; |
51 | *Phone = -1; | 51 | *Phone = -1; |
52 | *Recurrance= -1; | 52 | *Recurrance= -1; |
53 | *EndTime= -1; | 53 | *EndTime= -1; |
54 | *Location= -1; | 54 | *Location= -1; |
55 | for (i = 0; i < entry->EntriesNum; i++) { | 55 | for (i = 0; i < entry->EntriesNum; i++) { |
56 | switch (entry->Entries[i].EntryType) { | 56 | switch (entry->Entries[i].EntryType) { |
57 | case CAL_START_DATETIME : | 57 | case CAL_START_DATETIME : |
58 | if (*Time == -1) *Time = i; | 58 | if (*Time == -1) *Time = i; |
59 | break; | 59 | break; |
60 | case CAL_END_DATETIME : | 60 | case CAL_END_DATETIME : |
61 | if (*EndTime == -1) *EndTime = i; | 61 | if (*EndTime == -1) *EndTime = i; |
62 | break; | 62 | break; |
63 | case CAL_ALARM_DATETIME : | 63 | case CAL_ALARM_DATETIME : |
64 | case CAL_SILENT_ALARM_DATETIME: | 64 | case CAL_SILENT_ALARM_DATETIME: |
65 | if (*Alarm == -1) *Alarm = i; | 65 | if (*Alarm == -1) *Alarm = i; |
66 | break; | 66 | break; |
67 | case CAL_RECURRANCE: | 67 | case CAL_RECURRANCE: |
68 | if (*Recurrance == -1) *Recurrance = i; | 68 | if (*Recurrance == -1) *Recurrance = i; |
69 | break; | 69 | break; |
70 | case CAL_TEXT: | 70 | case CAL_TEXT: |
71 | *Text = i; | ||
72 | break; | ||
73 | case CAL_DESCRIPTION: | ||
71 | if (*Text == -1) *Text = i; | 74 | if (*Text == -1) *Text = i; |
72 | break; | 75 | break; |
73 | case CAL_PHONE: | 76 | case CAL_PHONE: |
74 | if (*Phone == -1) *Phone = i; | 77 | if (*Phone == -1) *Phone = i; |
75 | break; | 78 | break; |
76 | case CAL_LOCATION: | 79 | case CAL_LOCATION: |
77 | if (*Location == -1) *Location = i; | 80 | if (*Location == -1) *Location = i; |
78 | break; | 81 | break; |
79 | default: | 82 | default: |
80 | break; | 83 | break; |
81 | } | 84 | } |
82 | } | 85 | } |
83 | } | 86 | } |
84 | 87 | ||
85 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) | 88 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) |
86 | { | 89 | { |
87 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; | 90 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; |
88 | char buffer[2000]; | 91 | char buffer[2000]; |
89 | 92 | ||
90 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); | 93 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); |
91 | 94 | ||
92 | if (header) { | 95 | if (header) { |
93 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 96 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
94 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 97 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
95 | } | 98 | } |
96 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); | 99 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); |
97 | 100 | ||
98 | if (Version == Nokia_VCalendar) { | 101 | if (Version == Nokia_VCalendar) { |
99 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
100 | switch (note->Type) { | 103 | switch (note->Type) { |
101 | case GSM_CAL_REMINDER: | 104 | case GSM_CAL_REMINDER: |
102 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); | 105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); |
103 | break; | 106 | break; |
104 | case GSM_CAL_MEMO: | 107 | case GSM_CAL_MEMO: |
105 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
106 | break; | 109 | break; |
107 | case GSM_CAL_CALL: | 110 | case GSM_CAL_CALL: |
108 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
109 | break; | 112 | break; |
110 | case GSM_CAL_BIRTHDAY: | 113 | case GSM_CAL_BIRTHDAY: |
111 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); | 114 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); |
112 | break; | 115 | break; |
113 | case GSM_CAL_MEETING: | 116 | case GSM_CAL_MEETING: |
114 | default: | 117 | default: |
115 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); | 118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); |
116 | break; | 119 | break; |
117 | } | 120 | } |
118 | if (note->Type == GSM_CAL_CALL) { | 121 | if (note->Type == GSM_CAL_CALL) { |
119 | buffer[0] = 0; | 122 | buffer[0] = 0; |
120 | buffer[1] = 0; | 123 | buffer[1] = 0; |
121 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
122 | if (Text != -1) { | 125 | if (Text != -1) { |
123 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
124 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 127 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
125 | } | 128 | } |
126 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 129 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
127 | } else { | 130 | } else { |
128 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 131 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
129 | } | 132 | } |
130 | if (note->Type == GSM_CAL_MEETING && Location != -1) { | 133 | if (note->Type == GSM_CAL_MEETING && Location != -1) { |
131 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 134 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
132 | } | 135 | } |
133 | 136 | ||
134 | if (Time == -1) return ERR_UNKNOWN; | 137 | if (Time == -1) return ERR_UNKNOWN; |
135 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
136 | 139 | ||
137 | if (EndTime != -1) { | 140 | if (EndTime != -1) { |
138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
139 | } | 142 | } |
140 | 143 | ||
141 | if (Alarm != -1) { | 144 | if (Alarm != -1) { |
142 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
143 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
144 | } else { | 147 | } else { |
145 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
146 | } | 149 | } |
147 | } | 150 | } |
148 | 151 | ||
149 | /* Birthday is known to be recurranced */ | 152 | /* Birthday is known to be recurranced */ |
150 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { | 153 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { |
151 | switch(note->Entries[Recurrance].Number/24) { | 154 | switch(note->Entries[Recurrance].Number/24) { |
152 | 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; |
153 | 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; |
154 | 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; |
155 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; | 158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; |
156 | } | 159 | } |
157 | } | 160 | } |
158 | } else if (Version == Siemens_VCalendar) { | 161 | } else if (Version == Siemens_VCalendar) { |
159 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
160 | switch (note->Type) { | 163 | switch (note->Type) { |
161 | case GSM_CAL_MEETING: | 164 | case GSM_CAL_MEETING: |
162 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
163 | break; | 166 | break; |
164 | case GSM_CAL_CALL: | 167 | case GSM_CAL_CALL: |
165 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
166 | break; | 169 | break; |
167 | case GSM_CAL_BIRTHDAY: | 170 | case GSM_CAL_BIRTHDAY: |
168 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); | 171 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); |
169 | break; | 172 | break; |
170 | case GSM_CAL_MEMO: | 173 | case GSM_CAL_MEMO: |
171 | default: | 174 | default: |
172 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
173 | break; | 176 | break; |
174 | } | 177 | } |
175 | 178 | ||
176 | if (Time == -1) return ERR_UNKNOWN; | 179 | if (Time == -1) return ERR_UNKNOWN; |
177 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
178 | 181 | ||
179 | if (Alarm != -1) { | 182 | if (Alarm != -1) { |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
181 | } | 184 | } |
182 | 185 | ||
183 | if (Recurrance != -1) { | 186 | if (Recurrance != -1) { |
184 | switch(note->Entries[Recurrance].Number/24) { | 187 | switch(note->Entries[Recurrance].Number/24) { |
185 | 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; |
186 | 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; |
187 | 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; |
188 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; | 191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; |
189 | } | 192 | } |
190 | } | 193 | } |
191 | 194 | ||
192 | if (note->Type == GSM_CAL_CALL) { | 195 | if (note->Type == GSM_CAL_CALL) { |
193 | buffer[0] = 0; | 196 | buffer[0] = 0; |
194 | buffer[1] = 0; | 197 | buffer[1] = 0; |
195 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
196 | if (Text != -1) { | 199 | if (Text != -1) { |
197 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
198 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
199 | } | 202 | } |
200 | SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); | 203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
201 | } else { | 204 | } else { |
202 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); | 205 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
203 | } | 206 | } |
204 | } else if (Version == SonyEricsson_VCalendar) { | 207 | } else if (Version == SonyEricsson_VCalendar) { |
205 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 208 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
206 | switch (note->Type) { | 209 | switch (note->Type) { |
207 | case GSM_CAL_MEETING: | 210 | case GSM_CAL_MEETING: |
208 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
209 | break; | 212 | break; |
210 | case GSM_CAL_REMINDER: | 213 | case GSM_CAL_REMINDER: |
211 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); | 214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); |
212 | break; | 215 | break; |
213 | case GSM_CAL_TRAVEL: | 216 | case GSM_CAL_TRAVEL: |
214 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); | 217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); |
215 | break; | 218 | break; |
216 | case GSM_CAL_VACATION: | 219 | case GSM_CAL_VACATION: |
217 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); | 220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); |
218 | break; | 221 | break; |
219 | case GSM_CAL_BIRTHDAY: | 222 | case GSM_CAL_BIRTHDAY: |
220 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); | 223 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); |
221 | break; | 224 | break; |
222 | case GSM_CAL_MEMO: | 225 | case GSM_CAL_MEMO: |
223 | default: | 226 | default: |
224 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
225 | break; | 228 | break; |
226 | } | 229 | } |
227 | 230 | ||
228 | if (Time == -1) return ERR_UNKNOWN; | 231 | if (Time == -1) return ERR_UNKNOWN; |
229 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
230 | 233 | ||
231 | if (EndTime != -1) { | 234 | if (EndTime != -1) { |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
233 | } | 236 | } |
234 | 237 | ||
235 | if (Alarm != -1) { | 238 | if (Alarm != -1) { |
236 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 239 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
237 | } | 240 | } |
238 | 241 | ||
239 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 242 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
240 | 243 | ||
241 | if (Location != -1) { | 244 | if (Location != -1) { |
242 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 245 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
243 | } | 246 | } |
244 | } | 247 | } |
245 | 248 | ||
246 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 249 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
247 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); | 250 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); |
248 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 251 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
249 | 252 | ||
250 | return ERR_NONE; | 253 | return ERR_NONE; |
251 | } | 254 | } |
252 | 255 | ||
253 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) | 256 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) |
254 | { | 257 | { |
255 | int i; | 258 | int i; |
256 | 259 | ||
257 | *Text = -1; | 260 | *Text = -1; |
258 | *EndTime= -1; | 261 | *EndTime= -1; |
259 | *Alarm = -1; | 262 | *Alarm = -1; |
260 | *Completed= -1; | 263 | *Completed= -1; |
261 | *Phone = -1; | 264 | *Phone = -1; |
262 | for (i = 0; i < entry->EntriesNum; i++) { | 265 | for (i = 0; i < entry->EntriesNum; i++) { |
263 | switch (entry->Entries[i].EntryType) { | 266 | switch (entry->Entries[i].EntryType) { |
264 | case TODO_END_DATETIME : | 267 | case TODO_END_DATETIME : |
265 | if (*EndTime == -1) *EndTime = i; | 268 | if (*EndTime == -1) *EndTime = i; |
266 | break; | 269 | break; |
267 | case TODO_ALARM_DATETIME : | 270 | case TODO_ALARM_DATETIME : |
268 | case TODO_SILENT_ALARM_DATETIME: | 271 | case TODO_SILENT_ALARM_DATETIME: |
269 | if (*Alarm == -1) *Alarm = i; | 272 | if (*Alarm == -1) *Alarm = i; |
270 | break; | 273 | break; |
271 | case TODO_TEXT: | 274 | case TODO_TEXT: |
272 | if (*Text == -1) *Text = i; | 275 | if (*Text == -1) *Text = i; |
273 | break; | 276 | break; |
274 | case TODO_COMPLETED: | 277 | case TODO_COMPLETED: |
275 | if (*Completed == -1) *Completed = i; | 278 | if (*Completed == -1) *Completed = i; |
276 | break; | 279 | break; |
277 | case TODO_PHONE: | 280 | case TODO_PHONE: |
278 | if (*Phone == -1) *Phone = i; | 281 | if (*Phone == -1) *Phone = i; |
279 | break; | 282 | break; |
280 | default: | 283 | default: |
281 | break; | 284 | break; |
282 | } | 285 | } |
283 | } | 286 | } |
284 | } | 287 | } |
285 | 288 | ||
286 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) | 289 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) |
287 | { | 290 | { |
288 | int Text, Alarm, Completed, EndTime, Phone; | 291 | int Text, Alarm, Completed, EndTime, Phone; |
289 | 292 | ||
290 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); | 293 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); |
291 | 294 | ||
292 | if (header) { | 295 | if (header) { |
293 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 296 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
294 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 297 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
295 | } | 298 | } |
296 | 299 | ||
297 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); | 300 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); |
298 | 301 | ||
@@ -323,190 +326,196 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h | |||
323 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 326 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
324 | } | 327 | } |
325 | } | 328 | } |
326 | } else if (Version == SonyEricsson_VToDo) { | 329 | } else if (Version == SonyEricsson_VToDo) { |
327 | if (Text == -1) return ERR_UNKNOWN; | 330 | if (Text == -1) return ERR_UNKNOWN; |
328 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 331 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
329 | 332 | ||
330 | if (Completed == -1) { | 333 | if (Completed == -1) { |
331 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 334 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
332 | } else { | 335 | } else { |
333 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 336 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
334 | } | 337 | } |
335 | 338 | ||
336 | switch (note->Priority) { | 339 | switch (note->Priority) { |
337 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; | 340 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
338 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 341 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
339 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 342 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
340 | } | 343 | } |
341 | 344 | ||
342 | if (Alarm != -1) { | 345 | if (Alarm != -1) { |
343 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 346 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
344 | } | 347 | } |
345 | } | 348 | } |
346 | 349 | ||
347 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 350 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
348 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); | 351 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); |
349 | 352 | ||
350 | if (header) { | 353 | if (header) { |
351 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 354 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
352 | } | 355 | } |
353 | return ERR_NONE; | 356 | return ERR_NONE; |
354 | } | 357 | } |
355 | 358 | ||
356 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) | 359 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) |
357 | { | 360 | { |
358 | unsigned char Line[2000],Buff[2000]; | 361 | unsigned char Line[2000],Buff[2000]; |
359 | int Level = 0; | 362 | int Level = 0; |
360 | 363 | ||
361 | Calendar->EntriesNum = 0; | 364 | Calendar->EntriesNum = 0; |
362 | ToDo->EntriesNum = 0; | 365 | ToDo->EntriesNum = 0; |
363 | 366 | ||
364 | while (1) { | 367 | while (1) { |
365 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); | 368 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); |
366 | if (strlen(Line) == 0) break; | 369 | if (strlen(Line) == 0) break; |
367 | switch (Level) { | 370 | switch (Level) { |
368 | case 0: | 371 | case 0: |
369 | if (strstr(Line,"BEGIN:VEVENT")) { | 372 | if (strstr(Line,"BEGIN:VEVENT")) { |
370 | Calendar->Type = GSM_CAL_MEMO; | 373 | Calendar->Type = GSM_CAL_MEMO; |
371 | Level = 1; | 374 | Level = 1; |
372 | } | 375 | } |
373 | if (strstr(Line,"BEGIN:VTODO")) { | 376 | if (strstr(Line,"BEGIN:VTODO")) { |
374 | ToDo->Priority = GSM_Priority_Medium; | 377 | ToDo->Priority = GSM_Priority_Medium; |
375 | Level = 2; | 378 | Level = 2; |
376 | } | 379 | } |
377 | break; | 380 | break; |
378 | case 1: /* Calendar note */ | 381 | case 1: /* Calendar note */ |
379 | if (strstr(Line,"END:VEVENT")) { | 382 | if (strstr(Line,"END:VEVENT")) { |
380 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; | 383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; |
381 | return ERR_NONE; | 384 | return ERR_NONE; |
382 | } | 385 | } |
383 | Calendar->Type = GSM_CAL_MEETING; | 386 | Calendar->Type = GSM_CAL_MEETING; |
384 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; | 387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; |
385 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE | 388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE |
386 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE | 389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE |
387 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE | 390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE |
388 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; | 391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; |
389 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; | 392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; |
390 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; | 393 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; |
391 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; | 394 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; |
392 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; | 395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; |
393 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; | 396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; |
394 | if (strstr(Line,"RRULE:D1")) { | 397 | if (strstr(Line,"RRULE:D1")) { |
395 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
396 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; | 399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; |
397 | Calendar->EntriesNum++; | 400 | Calendar->EntriesNum++; |
398 | } | 401 | } |
399 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { | 402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { |
400 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
401 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; | 404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; |
402 | Calendar->EntriesNum++; | 405 | Calendar->EntriesNum++; |
403 | } | 406 | } |
404 | if (strstr(Line,"RRULE:W2")) { | 407 | if (strstr(Line,"RRULE:W2")) { |
405 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 408 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
406 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; | 409 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; |
407 | Calendar->EntriesNum++; | 410 | Calendar->EntriesNum++; |
408 | } | 411 | } |
409 | if (strstr(Line,"RRULE:MD1")) { | 412 | if (strstr(Line,"RRULE:MD1")) { |
410 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
411 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; | 414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; |
412 | Calendar->EntriesNum++; | 415 | Calendar->EntriesNum++; |
413 | } | 416 | } |
414 | if (strstr(Line,"RRULE:YD1")) { | 417 | if (strstr(Line,"RRULE:YD1")) { |
415 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
416 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | 419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; |
417 | Calendar->EntriesNum++; | 420 | Calendar->EntriesNum++; |
418 | } | 421 | } |
419 | if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { | 422 | // LR |
423 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { | ||
420 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; | 424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; |
421 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 425 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
422 | Calendar->EntriesNum++; | 426 | Calendar->EntriesNum++; |
423 | } | 427 | } |
428 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { | ||
429 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; | ||
430 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | ||
431 | Calendar->EntriesNum++; | ||
432 | } | ||
424 | if (ReadVCALText(Line, "LOCATION", Buff)) { | 433 | if (ReadVCALText(Line, "LOCATION", Buff)) { |
425 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; | 434 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; |
426 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 435 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
427 | Calendar->EntriesNum++; | 436 | Calendar->EntriesNum++; |
428 | } | 437 | } |
429 | if (ReadVCALText(Line, "DTSTART", Buff)) { | 438 | if (ReadVCALText(Line, "DTSTART", Buff)) { |
430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; | 439 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; |
431 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 440 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
432 | Calendar->EntriesNum++; | 441 | Calendar->EntriesNum++; |
433 | } | 442 | } |
434 | if (ReadVCALText(Line, "DTEND", Buff)) { | 443 | if (ReadVCALText(Line, "DTEND", Buff)) { |
435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; | 444 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; |
436 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 445 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
437 | Calendar->EntriesNum++; | 446 | Calendar->EntriesNum++; |
438 | } | 447 | } |
439 | if (ReadVCALText(Line, "DALARM", Buff)) { | 448 | if (ReadVCALText(Line, "DALARM", Buff)) { |
440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; | 449 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; |
441 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 450 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
442 | Calendar->EntriesNum++; | 451 | Calendar->EntriesNum++; |
443 | } | 452 | } |
444 | if (ReadVCALText(Line, "AALARM", Buff)) { | 453 | if (ReadVCALText(Line, "AALARM", Buff)) { |
445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; | 454 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; |
446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 455 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
447 | Calendar->EntriesNum++; | 456 | Calendar->EntriesNum++; |
448 | } | 457 | } |
449 | break; | 458 | break; |
450 | case 2: /* ToDo note */ | 459 | case 2: /* ToDo note */ |
451 | if (strstr(Line,"END:VTODO")) { | 460 | if (strstr(Line,"END:VTODO")) { |
452 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; | 461 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; |
453 | return ERR_NONE; | 462 | return ERR_NONE; |
454 | } | 463 | } |
455 | if (ReadVCALText(Line, "DUE", Buff)) { | 464 | if (ReadVCALText(Line, "DUE", Buff)) { |
456 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; | 465 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; |
457 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 466 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
458 | ToDo->EntriesNum++; | 467 | ToDo->EntriesNum++; |
459 | } | 468 | } |
460 | if (ReadVCALText(Line, "DALARM", Buff)) { | 469 | if (ReadVCALText(Line, "DALARM", Buff)) { |
461 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; | 470 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; |
462 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 471 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
463 | ToDo->EntriesNum++; | 472 | ToDo->EntriesNum++; |
464 | } | 473 | } |
465 | if (ReadVCALText(Line, "AALARM", Buff)) { | 474 | if (ReadVCALText(Line, "AALARM", Buff)) { |
466 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | 475 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; |
467 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 476 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
468 | ToDo->EntriesNum++; | 477 | ToDo->EntriesNum++; |
469 | } | 478 | } |
470 | if (ReadVCALText(Line, "SUMMARY", Buff)) { | 479 | if (ReadVCALText(Line, "SUMMARY", Buff)) { |
471 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; | 480 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; |
472 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); | 481 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); |
473 | ToDo->EntriesNum++; | 482 | ToDo->EntriesNum++; |
474 | } | 483 | } |
475 | if (ReadVCALText(Line, "PRIORITY", Buff)) { | 484 | if (ReadVCALText(Line, "PRIORITY", Buff)) { |
476 | if (ToDoVer == SonyEricsson_VToDo) { | 485 | if (ToDoVer == SonyEricsson_VToDo) { |
477 | ToDo->Priority = GSM_Priority_Medium; | 486 | ToDo->Priority = GSM_Priority_Medium; |
478 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 487 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
479 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 488 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
480 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); | 489 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); |
481 | } else if (ToDoVer == Nokia_VToDo) { | 490 | } else if (ToDoVer == Nokia_VToDo) { |
482 | ToDo->Priority = GSM_Priority_Medium; | 491 | ToDo->Priority = GSM_Priority_Medium; |
483 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 492 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
484 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 493 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
485 | } | 494 | } |
486 | } | 495 | } |
487 | if (strstr(Line,"PERCENT-COMPLETE:100")) { | 496 | if (strstr(Line,"PERCENT-COMPLETE:100")) { |
488 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; | 497 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; |
489 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | 498 | ToDo->Entries[ToDo->EntriesNum].Number = 1; |
490 | ToDo->EntriesNum++; | 499 | ToDo->EntriesNum++; |
491 | } | 500 | } |
492 | break; | 501 | break; |
493 | } | 502 | } |
494 | } | 503 | } |
495 | 504 | ||
496 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; | 505 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; |
497 | return ERR_NONE; | 506 | return ERR_NONE; |
498 | } | 507 | } |
499 | 508 | ||
500 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 509 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) |
501 | { | 510 | { |
502 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); | 511 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); |
503 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); | 512 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); |
504 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); | 513 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); |
505 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); | 514 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); |
506 | 515 | ||
507 | return ERR_NONE; | 516 | return ERR_NONE; |
508 | } | 517 | } |
509 | 518 | ||
510 | /* How should editor hadle tabs in this file? Add editor commands here. | 519 | /* How should editor hadle tabs in this file? Add editor commands here. |
511 | * vim: noexpandtab sw=8 ts=8 sts=8: | 520 | * vim: noexpandtab sw=8 ts=8 sts=8: |
512 | */ | 521 | */ |
diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h index 0a41b7b..c69fdbe 100644 --- a/gammu/emb/common/service/gsmcal.h +++ b/gammu/emb/common/service/gsmcal.h | |||
@@ -64,192 +64,193 @@ typedef enum { | |||
64 | */ | 64 | */ |
65 | GSM_CAL_T_DANC, | 65 | GSM_CAL_T_DANC, |
66 | /** | 66 | /** |
67 | * Training - Extreme Sports | 67 | * Training - Extreme Sports |
68 | */ | 68 | */ |
69 | GSM_CAL_T_EXTR, | 69 | GSM_CAL_T_EXTR, |
70 | /** | 70 | /** |
71 | * Training - Football | 71 | * Training - Football |
72 | */ | 72 | */ |
73 | GSM_CAL_T_FOOT, | 73 | GSM_CAL_T_FOOT, |
74 | /** | 74 | /** |
75 | * Training - Golf | 75 | * Training - Golf |
76 | */ | 76 | */ |
77 | GSM_CAL_T_GOLF, | 77 | GSM_CAL_T_GOLF, |
78 | /** | 78 | /** |
79 | * Training - Gym | 79 | * Training - Gym |
80 | */ | 80 | */ |
81 | GSM_CAL_T_GYM, | 81 | GSM_CAL_T_GYM, |
82 | /** | 82 | /** |
83 | * Training - Horse Race | 83 | * Training - Horse Race |
84 | */ | 84 | */ |
85 | GSM_CAL_T_HORS, | 85 | GSM_CAL_T_HORS, |
86 | /** | 86 | /** |
87 | * Training - Hockey | 87 | * Training - Hockey |
88 | */ | 88 | */ |
89 | GSM_CAL_T_HOCK, | 89 | GSM_CAL_T_HOCK, |
90 | /** | 90 | /** |
91 | * Training - Races | 91 | * Training - Races |
92 | */ | 92 | */ |
93 | GSM_CAL_T_RACE, | 93 | GSM_CAL_T_RACE, |
94 | /** | 94 | /** |
95 | * Training - Rugby | 95 | * Training - Rugby |
96 | */ | 96 | */ |
97 | GSM_CAL_T_RUGB, | 97 | GSM_CAL_T_RUGB, |
98 | /** | 98 | /** |
99 | * Training - Sailing | 99 | * Training - Sailing |
100 | */ | 100 | */ |
101 | GSM_CAL_T_SAIL, | 101 | GSM_CAL_T_SAIL, |
102 | /** | 102 | /** |
103 | * Training - Street Games | 103 | * Training - Street Games |
104 | */ | 104 | */ |
105 | GSM_CAL_T_STRE, | 105 | GSM_CAL_T_STRE, |
106 | /** | 106 | /** |
107 | * Training - Swimming | 107 | * Training - Swimming |
108 | */ | 108 | */ |
109 | GSM_CAL_T_SWIM, | 109 | GSM_CAL_T_SWIM, |
110 | /** | 110 | /** |
111 | * Training - Tennis | 111 | * Training - Tennis |
112 | */ | 112 | */ |
113 | GSM_CAL_T_TENN, | 113 | GSM_CAL_T_TENN, |
114 | /** | 114 | /** |
115 | * Training - Travels | 115 | * Training - Travels |
116 | */ | 116 | */ |
117 | GSM_CAL_T_TRAV, | 117 | GSM_CAL_T_TRAV, |
118 | /** | 118 | /** |
119 | * Training - Winter Games | 119 | * Training - Winter Games |
120 | */ | 120 | */ |
121 | GSM_CAL_T_WINT, | 121 | GSM_CAL_T_WINT, |
122 | /** | 122 | /** |
123 | * Alarm | 123 | * Alarm |
124 | */ | 124 | */ |
125 | GSM_CAL_ALARM, | 125 | GSM_CAL_ALARM, |
126 | /** | 126 | /** |
127 | * Alarm repeating each day. | 127 | * Alarm repeating each day. |
128 | */ | 128 | */ |
129 | GSM_CAL_DAILY_ALARM | 129 | GSM_CAL_DAILY_ALARM |
130 | } GSM_CalendarNoteType; | 130 | } GSM_CalendarNoteType; |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * One value of calendar event. | 133 | * One value of calendar event. |
134 | */ | 134 | */ |
135 | typedef enum { | 135 | typedef enum { |
136 | /** | 136 | /** |
137 | * Date and time of event start. | 137 | * Date and time of event start. |
138 | */ | 138 | */ |
139 | CAL_START_DATETIME = 1, | 139 | CAL_START_DATETIME = 1, |
140 | /** | 140 | /** |
141 | * Date and time of event end. | 141 | * Date and time of event end. |
142 | */ | 142 | */ |
143 | CAL_END_DATETIME, | 143 | CAL_END_DATETIME, |
144 | /** | 144 | /** |
145 | * Alarm date and time. | 145 | * Alarm date and time. |
146 | */ | 146 | */ |
147 | CAL_ALARM_DATETIME, | 147 | CAL_ALARM_DATETIME, |
148 | /** | 148 | /** |
149 | * Date and time of silent alarm. | 149 | * Date and time of silent alarm. |
150 | */ | 150 | */ |
151 | CAL_SILENT_ALARM_DATETIME, | 151 | CAL_SILENT_ALARM_DATETIME, |
152 | /** | 152 | /** |
153 | * Recurrance. | 153 | * Recurrance. |
154 | */ | 154 | */ |
155 | CAL_RECURRANCE, | 155 | CAL_RECURRANCE, |
156 | /** | 156 | /** |
157 | * Text. | 157 | * Text. |
158 | */ | 158 | */ |
159 | CAL_TEXT, | 159 | CAL_TEXT, |
160 | CAL_DESCRIPTION, // LR added | ||
160 | /** | 161 | /** |
161 | * Location. | 162 | * Location. |
162 | */ | 163 | */ |
163 | CAL_LOCATION, | 164 | CAL_LOCATION, |
164 | /** | 165 | /** |
165 | * Phone number. | 166 | * Phone number. |
166 | */ | 167 | */ |
167 | CAL_PHONE, | 168 | CAL_PHONE, |
168 | /** | 169 | /** |
169 | * Whether this entry is private. | 170 | * Whether this entry is private. |
170 | */ | 171 | */ |
171 | CAL_PRIVATE, | 172 | CAL_PRIVATE, |
172 | /** | 173 | /** |
173 | * Related contact id. | 174 | * Related contact id. |
174 | */ | 175 | */ |
175 | CAL_CONTACTID, | 176 | CAL_CONTACTID, |
176 | /** | 177 | /** |
177 | * Repeat each x'th day of week. | 178 | * Repeat each x'th day of week. |
178 | */ | 179 | */ |
179 | CAL_REPEAT_DAYOFWEEK, | 180 | CAL_REPEAT_DAYOFWEEK, |
180 | /** | 181 | /** |
181 | * Repeat each x'th day of month. | 182 | * Repeat each x'th day of month. |
182 | */ | 183 | */ |
183 | CAL_REPEAT_DAY, | 184 | CAL_REPEAT_DAY, |
184 | /** | 185 | /** |
185 | * Repeat x'th week of month. | 186 | * Repeat x'th week of month. |
186 | */ | 187 | */ |
187 | CAL_REPEAT_WEEKOFMONTH, | 188 | CAL_REPEAT_WEEKOFMONTH, |
188 | /** | 189 | /** |
189 | * Repeat x'th month. | 190 | * Repeat x'th month. |
190 | */ | 191 | */ |
191 | CAL_REPEAT_MONTH, | 192 | CAL_REPEAT_MONTH, |
192 | /** | 193 | /** |
193 | * Repeating frequency. | 194 | * Repeating frequency. |
194 | */ | 195 | */ |
195 | CAL_REPEAT_FREQUENCY, | 196 | CAL_REPEAT_FREQUENCY, |
196 | /** | 197 | /** |
197 | * Repeating start. | 198 | * Repeating start. |
198 | */ | 199 | */ |
199 | CAL_REPEAT_STARTDATE, | 200 | CAL_REPEAT_STARTDATE, |
200 | /** | 201 | /** |
201 | * Repeating end. | 202 | * Repeating end. |
202 | */ | 203 | */ |
203 | CAL_REPEAT_STOPDATE | 204 | CAL_REPEAT_STOPDATE |
204 | } GSM_CalendarType; | 205 | } GSM_CalendarType; |
205 | 206 | ||
206 | /** | 207 | /** |
207 | * One value of calendar event. | 208 | * One value of calendar event. |
208 | */ | 209 | */ |
209 | typedef struct { | 210 | typedef struct { |
210 | /** | 211 | /** |
211 | * Type of value. | 212 | * Type of value. |
212 | */ | 213 | */ |
213 | GSM_CalendarTypeEntryType; | 214 | GSM_CalendarTypeEntryType; |
214 | /** | 215 | /** |
215 | * Text of value, if applicable. | 216 | * Text of value, if applicable. |
216 | */ | 217 | */ |
217 | unsigned char Text[(MAX_CALENDAR_TEXT_LENGTH + 1)*2]; | 218 | unsigned char Text[(MAX_CALENDAR_TEXT_LENGTH + 1)*2]; |
218 | /** | 219 | /** |
219 | * Date and time of value, if applicable. | 220 | * Date and time of value, if applicable. |
220 | */ | 221 | */ |
221 | GSM_DateTime Date; | 222 | GSM_DateTime Date; |
222 | /** | 223 | /** |
223 | * Number of value, if applicable. | 224 | * Number of value, if applicable. |
224 | */ | 225 | */ |
225 | unsigned int Number; | 226 | unsigned int Number; |
226 | } GSM_SubCalendarEntry; | 227 | } GSM_SubCalendarEntry; |
227 | 228 | ||
228 | /** | 229 | /** |
229 | * Calendar note values. | 230 | * Calendar note values. |
230 | */ | 231 | */ |
231 | typedef struct { | 232 | typedef struct { |
232 | /** | 233 | /** |
233 | * Type of calendar note. | 234 | * Type of calendar note. |
234 | */ | 235 | */ |
235 | GSM_CalendarNoteType Type; | 236 | GSM_CalendarNoteType Type; |
236 | /** | 237 | /** |
237 | * Location in memory. | 238 | * Location in memory. |
238 | */ | 239 | */ |
239 | int Location; | 240 | int Location; |
240 | /** | 241 | /** |
241 | * Number of entries. | 242 | * Number of entries. |
242 | */ | 243 | */ |
243 | int EntriesNum; | 244 | int EntriesNum; |
244 | /** | 245 | /** |
245 | * Values of entries. | 246 | * Values of entries. |
246 | */ | 247 | */ |
247 | GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]; | 248 | GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]; |
248 | } GSM_CalendarEntry; | 249 | } GSM_CalendarEntry; |
249 | 250 | ||
250 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location); | 251 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location); |
251 | 252 | ||
252 | typedef enum { | 253 | typedef enum { |
253 | Nokia_VCalendar = 1, | 254 | Nokia_VCalendar = 1, |
254 | Siemens_VCalendar, | 255 | Siemens_VCalendar, |
255 | SonyEricsson_VCalendar | 256 | SonyEricsson_VCalendar |