author | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
commit | da43dbdc6c82453228f34766fc74585615cba938 (patch) (unidiff) | |
tree | 16576932cea08bf117b2d0320b0d5f66ee8ad093 /libical/src/libicalss/icalmessage.c | |
parent | 627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff) | |
download | kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2 |
New lib ical.Some minor changes as well.
Diffstat (limited to 'libical/src/libicalss/icalmessage.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libicalss/icalmessage.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c index d5c57c1..731a2c7 100644 --- a/libical/src/libicalss/icalmessage.c +++ b/libical/src/libicalss/icalmessage.c | |||
@@ -19,49 +19,49 @@ | |||
19 | The Mozilla Public License Version 1.0. You may obtain a copy of | 19 | The Mozilla Public License Version 1.0. You may obtain a copy of |
20 | the License at http://www.mozilla.org/MPL/ | 20 | the License at http://www.mozilla.org/MPL/ |
21 | 21 | ||
22 | 22 | ||
23 | ======================================================================*/ | 23 | ======================================================================*/ |
24 | 24 | ||
25 | #ifdef HAVE_CONFIG_H | 25 | #ifdef HAVE_CONFIG_H |
26 | #include "config.h" | 26 | #include "config.h" |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | #include "icalmessage.h" | 29 | #include "icalmessage.h" |
30 | #include "icalenums.h" | 30 | #include "icalenums.h" |
31 | #include <ctype.h> /* for tolower()*/ | 31 | #include <ctype.h> /* for tolower()*/ |
32 | #include <string.h> /* for strstr */ | 32 | #include <string.h> /* for strstr */ |
33 | #include <stdlib.h> /* for free(), malloc() */ | 33 | #include <stdlib.h> /* for free(), malloc() */ |
34 | icalcomponent* icalmessage_get_inner(icalcomponent* comp) | 34 | icalcomponent* icalmessage_get_inner(icalcomponent* comp) |
35 | { | 35 | { |
36 | if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ | 36 | if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ |
37 | return icalcomponent_get_first_real_component(comp); | 37 | return icalcomponent_get_first_real_component(comp); |
38 | } else { | 38 | } else { |
39 | return comp; | 39 | return comp; |
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | char* lowercase(const char* str) | 43 | static char* lowercase(const char* str) |
44 | { | 44 | { |
45 | char* p = 0; | 45 | char* p = 0; |
46 | char* n = icalmemory_strdup(str); | 46 | char* n = icalmemory_strdup(str); |
47 | 47 | ||
48 | if(str ==0){ | 48 | if(str ==0){ |
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | for(p = n; *p!=0; p++){ | 52 | for(p = n; *p!=0; p++){ |
53 | *p = tolower(*p); | 53 | *p = tolower(*p); |
54 | } | 54 | } |
55 | 55 | ||
56 | return n; | 56 | return n; |
57 | } | 57 | } |
58 | 58 | ||
59 | icalproperty* icalmessage_find_attendee(icalcomponent* comp, const char* user) | 59 | icalproperty* icalmessage_find_attendee(icalcomponent* comp, const char* user) |
60 | { | 60 | { |
61 | icalcomponent *inner = icalmessage_get_inner(comp); | 61 | icalcomponent *inner = icalmessage_get_inner(comp); |
62 | icalproperty *p,*attendee = 0; | 62 | icalproperty *p,*attendee = 0; |
63 | char* luser = lowercase(user); | 63 | char* luser = lowercase(user); |
64 | 64 | ||
65 | for(p = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY); | 65 | for(p = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY); |
66 | p != 0; | 66 | p != 0; |
67 | p = icalcomponent_get_next_property(inner, ICAL_ATTENDEE_PROPERTY) | 67 | p = icalcomponent_get_next_property(inner, ICAL_ATTENDEE_PROPERTY) |
@@ -137,50 +137,55 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c, | |||
137 | icalmessage_copy_properties(reply,c,ICAL_SEQUENCE_PROPERTY); | 137 | icalmessage_copy_properties(reply,c,ICAL_SEQUENCE_PROPERTY); |
138 | 138 | ||
139 | icalcomponent_set_dtstamp(reply,icaltime_from_timet(time(0),0)); | 139 | icalcomponent_set_dtstamp(reply,icaltime_from_timet(time(0),0)); |
140 | 140 | ||
141 | if(msg != 0){ | 141 | if(msg != 0){ |
142 | icalcomponent_add_property(inner,icalproperty_new_comment(msg)); | 142 | icalcomponent_add_property(inner,icalproperty_new_comment(msg)); |
143 | } | 143 | } |
144 | 144 | ||
145 | /* Copy this user's attendee property */ | 145 | /* Copy this user's attendee property */ |
146 | 146 | ||
147 | attendee = icalmessage_find_attendee(c,user); | 147 | attendee = icalmessage_find_attendee(c,user); |
148 | 148 | ||
149 | if (attendee == 0){ | 149 | if (attendee == 0){ |
150 | icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); | 150 | icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); |
151 | icalcomponent_free(reply); | 151 | icalcomponent_free(reply); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | 154 | ||
155 | icalcomponent_add_property(inner,icalproperty_new_clone(attendee)); | 155 | icalcomponent_add_property(inner,icalproperty_new_clone(attendee)); |
156 | 156 | ||
157 | /* Add PRODID and VERSION */ | 157 | /* Add PRODID and VERSION */ |
158 | 158 | ||
159 | icalcomponent_add_property(reply,icalproperty_new_version("2.0")); | 159 | icalcomponent_add_property(reply,icalproperty_new_version("2.0")); |
160 | 160 | ||
161 | #ifndef WIN32 | ||
161 | sprintf(tmp, | 162 | sprintf(tmp, |
162 | "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION); | 163 | "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION); |
164 | #else | ||
165 | sprintf(tmp, | ||
166 | "-//SoftwareStudio//NONSGML %s %s //EN",ICAL_PACKAGE,ICAL_VERSION); | ||
167 | #endif | ||
163 | icalcomponent_add_property(reply,icalproperty_new_prodid(tmp)); | 168 | icalcomponent_add_property(reply,icalproperty_new_prodid(tmp)); |
164 | 169 | ||
165 | return reply; | 170 | return reply; |
166 | 171 | ||
167 | } | 172 | } |
168 | 173 | ||
169 | icalcomponent* icalmessage_new_accept_reply(icalcomponent* c, | 174 | icalcomponent* icalmessage_new_accept_reply(icalcomponent* c, |
170 | const char* user, | 175 | const char* user, |
171 | const char* msg) | 176 | const char* msg) |
172 | { | 177 | { |
173 | 178 | ||
174 | icalcomponent *reply; | 179 | icalcomponent *reply; |
175 | icalproperty *attendee; | 180 | icalproperty *attendee; |
176 | icalcomponent *inner; | 181 | icalcomponent *inner; |
177 | 182 | ||
178 | icalerror_check_arg_rz(c,"c"); | 183 | icalerror_check_arg_rz(c,"c"); |
179 | 184 | ||
180 | reply = icalmessage_new_reply_base(c,user,msg); | 185 | reply = icalmessage_new_reply_base(c,user,msg); |
181 | 186 | ||
182 | if(reply == 0){ | 187 | if(reply == 0){ |
183 | return 0; | 188 | return 0; |
184 | } | 189 | } |
185 | 190 | ||
186 | inner = icalmessage_get_inner(reply); | 191 | inner = icalmessage_get_inner(reply); |
@@ -209,53 +214,53 @@ icalcomponent* icalmessage_new_decline_reply(icalcomponent* c, | |||
209 | if(reply == 0){ | 214 | if(reply == 0){ |
210 | return 0; | 215 | return 0; |
211 | } | 216 | } |
212 | 217 | ||
213 | attendee = icalcomponent_get_first_property(inner, | 218 | attendee = icalcomponent_get_first_property(inner, |
214 | ICAL_ATTENDEE_PROPERTY); | 219 | ICAL_ATTENDEE_PROPERTY); |
215 | 220 | ||
216 | icalproperty_set_parameter(attendee, | 221 | icalproperty_set_parameter(attendee, |
217 | icalparameter_new_partstat(ICAL_PARTSTAT_DECLINED)); | 222 | icalparameter_new_partstat(ICAL_PARTSTAT_DECLINED)); |
218 | 223 | ||
219 | return reply; | 224 | return reply; |
220 | } | 225 | } |
221 | 226 | ||
222 | /* New is modified version of old */ | 227 | /* New is modified version of old */ |
223 | icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc, | 228 | icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc, |
224 | icalcomponent* newc, | 229 | icalcomponent* newc, |
225 | const char* user, | 230 | const char* user, |
226 | const char* msg) | 231 | const char* msg) |
227 | { | 232 | { |
228 | icalcomponent *reply; | 233 | icalcomponent *reply; |
229 | 234 | ||
230 | icalerror_check_arg_rz(oldc,"oldc"); | 235 | icalerror_check_arg_rz(oldc,"oldc"); |
231 | icalerror_check_arg_rz(newc,"newc"); | 236 | icalerror_check_arg_rz(newc,"newc"); |
232 | 237 | ||
233 | reply = icalcomponent_new_clone(newc); | 238 | reply = icalmessage_new_reply_base(newc,user,msg); |
234 | 239 | ||
235 | icalcomponent_set_method(reply,ICAL_METHOD_COUNTER); | 240 | icalcomponent_set_method(reply,ICAL_METHOD_COUNTER); |
236 | 241 | ||
237 | return newc; | 242 | return reply; |
238 | 243 | ||
239 | } | 244 | } |
240 | 245 | ||
241 | 246 | ||
242 | icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c, | 247 | icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c, |
243 | const char* user, | 248 | const char* user, |
244 | const char* delegatee, | 249 | const char* delegatee, |
245 | const char* msg) | 250 | const char* msg) |
246 | { | 251 | { |
247 | 252 | ||
248 | icalcomponent *reply; | 253 | icalcomponent *reply; |
249 | icalproperty *attendee; | 254 | icalproperty *attendee; |
250 | icalcomponent *inner; | 255 | icalcomponent *inner; |
251 | 256 | ||
252 | icalerror_check_arg_rz(c,"c"); | 257 | icalerror_check_arg_rz(c,"c"); |
253 | 258 | ||
254 | reply = icalmessage_new_reply_base(c,user,msg); | 259 | reply = icalmessage_new_reply_base(c,user,msg); |
255 | inner = icalmessage_get_inner(reply); | 260 | inner = icalmessage_get_inner(reply); |
256 | if(reply == 0){ | 261 | if(reply == 0){ |
257 | return 0; | 262 | return 0; |
258 | } | 263 | } |
259 | 264 | ||
260 | attendee = icalcomponent_get_first_property(inner, | 265 | attendee = icalcomponent_get_first_property(inner, |
261 | ICAL_ATTENDEE_PROPERTY); | 266 | ICAL_ATTENDEE_PROPERTY); |