bump to 1.0.0 and clean up spec file
[platform/upstream/libical.git] / src / libical / icalproperty_cxx.cpp
1 /* -*- Mode: C++ -*- */
2
3 /**
4  * @file    icalproperty_cxx.cpp
5  * @author  fnguyen (12/10/01)
6  * @brief   Implementation of C++ Wrapper for icalproperty.c
7  *
8  * (C) COPYRIGHT 2001, Critical Path
9
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of either: 
12
13     The LGPL as published by the Free Software Foundation, version
14     2.1, available at: http://www.fsf.org/copyleft/lesser.html
15
16   Or:
17
18     The Mozilla Public License Version 1.0. You may obtain a copy of
19     the License at http://www.mozilla.org/MPL/
20  */
21
22
23 #ifndef ICALPROPERTY_CXX_H
24 #include "icalproperty_cxx.h"
25 #endif
26
27 #ifndef ICALPARAMETER_CXX_H
28 #include "icalparameter_cxx.h"
29 #endif
30
31 #ifndef ICALVALUE_CXX_H
32 #include "icalvalue_cxx.h"
33 #endif
34
35 ICalProperty::ICalProperty() : imp(icalproperty_new(ICAL_ANY_PROPERTY)){
36 }
37
38 ICalProperty::ICalProperty(const ICalProperty& v) throw(icalerrorenum){
39         imp = icalproperty_new_clone(v.imp);
40         if (!imp) throw icalerrno;
41 }
42
43 ICalProperty& ICalProperty::operator=(const ICalProperty& v) throw(icalerrorenum) {
44         if (this == &v) return *this;
45
46         if (imp != NULL)
47         {
48                 icalproperty_free(imp);
49                 imp = icalproperty_new_clone(v.imp);
50                 if (!imp) throw icalerrno;
51         }
52
53         return *this;
54 }
55 ICalProperty::~ICalProperty(){
56         if (imp != NULL) icalproperty_free(imp);
57 }
58
59 ICalProperty::ICalProperty(icalproperty* v) : imp(v) {
60 }
61
62 ICalProperty::ICalProperty(string str){
63         imp = icalproperty_new_from_string(str);
64 }
65
66 ICalProperty::ICalProperty(icalproperty_kind kind){
67         imp = icalproperty_new(kind);
68 }
69
70 string ICalProperty::as_ical_string(){
71         return (string)icalproperty_as_ical_string(imp);
72 }
73 icalproperty_kind ICalProperty::isa(){
74         return icalproperty_isa(imp);
75 }
76 int ICalProperty::isa_property(void* property){
77         return icalproperty_isa_property(property);
78 }
79
80 int ICalProperty::operator==(ICalProperty& rhs){
81         icalparameter_xliccomparetype  result;
82         ICalValue*  thisPropValue = this->get_value();
83         ICalValue*  rhsPropValue  = rhs.get_value();
84         result = icalvalue_compare((icalvalue*)*thisPropValue, (icalvalue*)*rhsPropValue);
85         return (result ==  ICAL_XLICCOMPARETYPE_EQUAL);
86 }
87
88 void ICalProperty::add_parameter(ICalParameter& parameter){
89         icalproperty_add_parameter(imp, parameter);
90 }
91 void ICalProperty::set_parameter(ICalParameter &parameter){
92         icalproperty_set_parameter(imp, parameter);
93 }
94 void ICalProperty::set_parameter_from_string(string name, string val){
95         icalproperty_set_parameter_from_string(imp, name, val);
96 }
97 string ICalProperty::get_parameter_as_string(string name){
98         return (string)icalproperty_get_parameter_as_string(imp, name);
99 }
100 void ICalProperty::remove_parameter(icalparameter_kind kind){
101         icalproperty_remove_parameter(imp, kind);
102 }
103 int ICalProperty::count_parameters(){
104         return icalproperty_count_parameters(imp);
105 }
106
107 /** Iterate through the parameters */
108 ICalParameter* ICalProperty::get_first_parameter(icalparameter_kind kind){
109         icalparameter* p = icalproperty_get_first_parameter(imp, kind);
110         return (p != NULL)? new ICalParameter(p): NULL;
111 }
112 ICalParameter* ICalProperty::get_next_parameter(icalparameter_kind kind){
113         icalparameter* p = icalproperty_get_next_parameter(imp, kind);
114         return (p != NULL)? new ICalParameter(p): NULL;
115 }
116
117 /** Access the value of the property */
118 void ICalProperty::set_value(const ICalValue& val){
119         icalproperty_set_value(imp, (ICalValue&)val);
120 }
121 void ICalProperty::set_value_from_string(string val, string kind){
122         icalproperty_set_value_from_string(imp, val, kind);
123 }
124
125 ICalValue* ICalProperty::get_value(){
126         return new ICalValue(icalproperty_get_value(imp));
127 }
128 string ICalProperty::get_value_as_string(){
129         return (string)icalproperty_get_value_as_string(imp);
130 }
131
132 /** Return the name of the property -- the type name converted to a
133  *  string, or the value of get_x_name if the type is X property
134  */
135 string ICalProperty::get_name(){
136         return (string)icalproperty_get_property_name(imp);
137 }
138
139 /* Deal with X properties */
140 void ICalProperty::set_x_name(ICalProperty &prop, string name){
141         icalproperty_set_x_name(prop, name);
142 }
143 string ICalProperty::get_x_name(ICalProperty &prop){
144         return (string)icalproperty_get_x_name(prop);
145 }
146
147 icalvalue_kind ICalProperty::icalparameter_value_to_value_kind(icalparameter_value val){
148         return icalparameter_value_to_value_kind(val);
149 }
150
151 /* Convert kinds to string and get default value type */
152 icalvalue_kind ICalProperty::kind_to_value_kind(icalproperty_kind kind){
153         return icalproperty_kind_to_value_kind(kind);
154 }
155 icalproperty_kind ICalProperty::value_kind_to_kind(icalvalue_kind kind){
156         return icalproperty_value_kind_to_kind(kind);
157 }
158 string ICalProperty::kind_to_string(icalproperty_kind kind){
159         return (string)icalproperty_kind_to_string(kind);
160 }
161 icalproperty_kind ICalProperty::string_to_kind(string str){
162         return icalproperty_string_to_kind(str);
163 }
164
165 string ICalProperty::method_to_string(icalproperty_method method){
166         return (string)icalproperty_method_to_string(method);
167 }
168 icalproperty_method ICalProperty::string_to_method(string str){
169         return icalproperty_string_to_method(str);
170 }
171
172 string ICalProperty::enum_to_string(int e){
173         return (string)icalproperty_enum_to_string(e);
174 }
175 int ICalProperty::string_to_enum(string str){
176         return icalproperty_string_to_enum(str);
177 }
178
179 string ICalProperty::status_to_string(icalproperty_status s){
180         return (string)icalproperty_status_to_string(s);
181 }
182 icalproperty_status ICalProperty::string_to_status(string str){
183         return icalproperty_string_to_status(str);
184 }
185
186 int ICalProperty::enum_belongs_to_property(icalproperty_kind kind, int e){
187         return icalproperty_enum_belongs_to_property(kind, e);
188 }
189
190 /* ACTION */
191 void ICalProperty::set_action(enum icalproperty_action val){
192         icalproperty_set_action(imp, val);
193 }
194 enum icalproperty_action ICalProperty::get_action(){
195         return icalproperty_get_action(imp);
196 }
197
198 /* ATTACH */
199 void ICalProperty::set_attach(icalattach *val){
200         icalproperty_set_attach(imp, val);
201 }
202 icalattach * ICalProperty::get_attach(){
203         return icalproperty_get_attach(imp);
204 }
205
206 /* ATTENDEE */
207 void ICalProperty::set_attendee(string val){
208         icalproperty_set_attendee(imp, val);
209 }
210 string ICalProperty::get_attendee(){
211         return (string)icalproperty_get_attendee(imp);
212 }
213
214 /* CALSCALE */
215 void ICalProperty::set_calscale(string val){
216         icalproperty_set_calscale(imp, val);
217 }
218 string ICalProperty::get_calscale(){
219         return (string)icalproperty_get_calscale(imp);
220 }
221
222 /* CATEGORIES */
223 void ICalProperty::set_categories(string val){
224         icalproperty_set_categories(imp, val);
225 }
226 string ICalProperty::get_categories(){
227         return (string)icalproperty_get_categories(imp);
228 }
229
230 /* CLASS */
231 void ICalProperty::set_class(enum icalproperty_class val){
232         icalproperty_set_class(imp, val);
233 }
234 enum icalproperty_class ICalProperty::get_class(){
235         return (enum icalproperty_class)icalproperty_get_class(imp);
236 }
237
238 /* COMMENT */
239 void ICalProperty::set_comment(string val){
240         icalproperty_set_comment(imp, val);
241 }
242 string ICalProperty::get_comment(){
243         return (string)icalproperty_get_comment(imp);
244 }
245
246 /* COMPLETED */
247 void ICalProperty::set_completed(struct icaltimetype val){
248         icalproperty_set_completed(imp, val);
249 }
250 struct icaltimetype ICalProperty::get_completed(){
251         return icalproperty_get_completed(imp);
252 }
253
254 /* CONTACT */
255 void ICalProperty::set_contact(string val){
256         icalproperty_set_contact(imp, val);
257 }
258 string ICalProperty::get_contact(){
259         return (string)icalproperty_get_contact(imp);
260 }
261
262 /* CREATED */
263 void ICalProperty::set_created(struct icaltimetype val){
264         icalproperty_set_created(imp, val);
265 }
266 struct icaltimetype ICalProperty::get_created(){
267         return icalproperty_get_created(imp);
268 }
269
270 /* DESCRIPTION */
271 void ICalProperty::set_description(string val){
272         icalproperty_set_description(imp, val);
273 }
274 string ICalProperty::get_description(){
275         return (string)icalproperty_get_description(imp);
276 }
277
278 /* DTEND */
279 void ICalProperty::set_dtend(struct icaltimetype val){
280         icalproperty_set_dtend(imp, val);
281 }
282 struct icaltimetype ICalProperty::get_dtend(){
283         return icalproperty_get_dtend(imp);
284 }
285
286 /* DTSTAMP */
287 void ICalProperty::set_dtstamp(struct icaltimetype val){
288         icalproperty_set_dtstamp(imp, val);
289 }
290 struct icaltimetype ICalProperty::get_dtstamp(){
291         return icalproperty_get_dtstamp(imp);
292 }
293
294 /* DTSTART */
295 void ICalProperty::set_dtstart(struct icaltimetype val){
296         icalproperty_set_dtstart(imp, val);
297 }
298 struct icaltimetype ICalProperty::get_dtstart(){
299         return icalproperty_get_dtstart(imp);
300 }
301
302 /* DUE */
303 void ICalProperty::set_due(struct icaltimetype val){
304         icalproperty_set_due(imp, val);
305 }
306 struct icaltimetype ICalProperty::get_due(){
307         return icalproperty_get_due(imp);
308 }
309
310 /* DURATION */
311 void ICalProperty::set_duration(struct icaldurationtype val){
312         icalproperty_set_duration(imp, val);
313 }
314 struct icaldurationtype ICalProperty::get_duration(){
315         return icalproperty_get_duration(imp);
316 }
317
318 /* EXDATE */
319 void ICalProperty::set_exdate(struct icaltimetype val){
320         icalproperty_set_exdate(imp, val);
321 }
322 struct icaltimetype ICalProperty::get_exdate(){
323         return icalproperty_get_exdate(imp);
324 }
325
326 /* EXPAND */
327 void ICalProperty::set_expand(int val){
328         icalproperty_set_expand(imp, val);
329 }
330 int ICalProperty::get_expand(){
331         return icalproperty_get_expand(imp);
332 }
333
334 /* EXRULE */
335 void ICalProperty::set_exrule(struct icalrecurrencetype val){
336         icalproperty_set_exrule(imp, val);
337 }
338 struct icalrecurrencetype ICalProperty::get_exrule(){
339         return icalproperty_get_exrule(imp);
340 }
341
342 /* FREEBUSY */
343 void ICalProperty::set_freebusy(struct icalperiodtype val){
344         icalproperty_set_freebusy(imp, val);
345 }
346 struct icalperiodtype ICalProperty::get_freebusy(){
347         return icalproperty_get_freebusy(imp);
348 }
349
350 /* GEO */
351 void ICalProperty::set_geo(struct icalgeotype val){
352         icalproperty_set_geo(imp, val);
353 }
354 struct icalgeotype ICalProperty::get_geo(){
355         return icalproperty_get_geo(imp);
356 }
357
358 /* LAST-MODIFIED */
359 void ICalProperty::set_lastmodified(struct icaltimetype val){
360         icalproperty_set_lastmodified(imp, val);
361 }
362 struct icaltimetype ICalProperty::get_lastmodified(){
363         return icalproperty_get_lastmodified(imp);
364 }
365
366 /* LOCATION */
367 void ICalProperty::set_location(string val){
368         icalproperty_set_location(imp, val);
369 }
370 string ICalProperty::get_location(){
371         return (string)icalproperty_get_location(imp);
372 }
373
374 /* MAXRESULTS */
375 void ICalProperty::set_maxresults(int val){
376         icalproperty_set_maxresults(imp, val);
377 }
378 int ICalProperty::get_maxresults(){
379         return icalproperty_get_maxresults(imp);
380 }
381
382 /* MAXRESULTSSIZE */
383 void ICalProperty::set_maxresultsize(int val){
384         icalproperty_set_maxresultssize(imp, val);
385 }
386 int ICalProperty::get_maxresultsize(){
387         return icalproperty_get_maxresultssize(imp);
388 }
389
390 /* METHOD */
391 void ICalProperty::set_method(enum icalproperty_method val){
392         icalproperty_set_method(imp, val);
393 }
394 enum icalproperty_method ICalProperty::get_method(){
395         return icalproperty_get_method(imp);
396 }
397
398 /* ORGANIZER */
399 void ICalProperty::set_organizer(string val){
400         icalproperty_set_organizer(imp, val);
401 }
402 string ICalProperty::get_organizer(){
403         return (string)icalproperty_get_organizer(imp);
404 }
405
406 /* OWNER */
407 void ICalProperty::set_owner(string val){
408         icalproperty_set_owner(imp, val);
409 }
410 string ICalProperty::get_owner(){
411         return (string)icalproperty_get_owner(imp);
412 }
413
414 /* PERCENT-COMPLETE */
415 void ICalProperty::set_percentcomplete(int val){
416         icalproperty_set_percentcomplete(imp, val);
417 }
418 int ICalProperty::get_percentcomplete(){
419         return icalproperty_get_percentcomplete(imp);
420 }
421
422 /* PRIORITY */
423 void ICalProperty::set_priority(int val){
424         icalproperty_set_priority(imp, val);
425 }
426 int ICalProperty::get_priority(){
427         return icalproperty_get_priority(imp);
428 }
429
430 /* PRODID */
431 void ICalProperty::set_prodid(string val){
432         icalproperty_set_prodid(imp, val);
433 }
434 string ICalProperty::get_prodid(){
435         return (string)icalproperty_get_prodid(imp);
436 }
437
438 /* QUERY */
439 void ICalProperty::set_query(string val){
440         icalproperty_set_query(imp, val);
441 }
442 string ICalProperty::get_query(){
443         return (string)icalproperty_get_query(imp);
444 }
445
446 /* QUERYNAME */
447 void ICalProperty::set_queryname(string val){
448         icalproperty_set_queryname(imp, val);
449 }
450 string ICalProperty::get_queryname(){
451         return (string)icalproperty_get_queryname(imp);
452 }
453
454 /* RDATE */
455 void ICalProperty::set_rdate(struct icaldatetimeperiodtype val){
456         icalproperty_set_rdate(imp, val);
457 }
458 struct icaldatetimeperiodtype ICalProperty::get_rdate(){
459         return icalproperty_get_rdate(imp);
460 }
461
462 /* RECURRENCE-ID */
463 void ICalProperty::set_recurrenceid(struct icaltimetype val){
464         icalproperty_set_recurrenceid(imp, val);
465 }
466 struct icaltimetype ICalProperty::get_recurrenceid(){
467         return icalproperty_get_recurrenceid(imp);
468 }
469
470 /* RELATED-TO */
471 void ICalProperty::set_relatedto(string val){
472         icalproperty_set_relatedto(imp, val);
473 }
474 string ICalProperty::get_relatedto(){
475         return (string)icalproperty_get_relatedto(imp);
476 }
477
478 /* RELCALID */
479 void ICalProperty::set_relcalid(string val){
480         icalproperty_set_relcalid(imp, val);
481 }
482 string ICalProperty::get_relcalid(){
483         return (string)icalproperty_get_relcalid(imp);
484 }
485
486 /* REPEAT */
487 void ICalProperty::set_repeat(int val){
488         icalproperty_set_repeat(imp, val);
489 }
490 int ICalProperty::get_repeat(){
491         return icalproperty_get_repeat(imp);
492 }
493
494 /* REQUEST-STATUS */
495 void ICalProperty::set_requeststatus(string val){
496   icalreqstattype v;
497   
498   v = icalreqstattype_from_string((char*)val);
499
500   icalproperty_set_requeststatus(imp, v);
501 }
502
503 string ICalProperty::get_requeststatus(){
504   icalreqstattype v;
505   v =   icalproperty_get_requeststatus(imp);
506   return (string)(icalreqstattype_as_string(v));
507 }
508
509 /* RESOURCES */
510 void ICalProperty::set_resources(string val){
511         icalproperty_set_resources(imp, val);
512 }
513 string ICalProperty::get_resources(){
514         return (string)icalproperty_get_resources(imp);
515 }
516
517 /* RRULE */
518 void ICalProperty::set_rrule(struct icalrecurrencetype val){
519         icalproperty_set_rrule(imp, val);
520 }
521 struct icalrecurrencetype ICalProperty::get_rrule(){
522         return icalproperty_get_rrule(imp);
523 }
524
525 /* SCOPE */
526 void ICalProperty::set_scope(string val){
527         icalproperty_set_scope(imp, val);
528 }
529 string ICalProperty::get_scope(){
530         return (string)icalproperty_get_scope(imp);
531 }
532
533 /* SEQUENCE */
534 void ICalProperty::set_sequence(int val){
535         icalproperty_set_sequence(imp, val);
536 }
537 int ICalProperty::get_sequence(){
538         return icalproperty_get_sequence(imp);
539 }
540
541 /* STATUS */
542 void ICalProperty::set_status(enum icalproperty_status val){
543         icalproperty_set_status(imp, val);
544 }
545 enum icalproperty_status ICalProperty::get_status(){
546         return icalproperty_get_status(imp);
547 }
548
549 /* SUMMARY */
550 void ICalProperty::set_summary(string val){
551         icalproperty_set_summary(imp, val);
552 }
553 string ICalProperty::get_summary(){
554         return (string)icalproperty_get_summary(imp);
555 }
556
557 /* TARGET */
558 void ICalProperty::set_target(string val){
559         icalproperty_set_target(imp, val);
560 }
561 string ICalProperty::get_target(){
562         return (string)icalproperty_get_target(imp);
563 }
564
565 /* TRANSP */
566 void ICalProperty::set_transp(enum icalproperty_transp val){
567         icalproperty_set_transp(imp, val);
568 }
569 enum icalproperty_transp ICalProperty::get_transp(){
570         return icalproperty_get_transp(imp);
571 }
572
573 /* TRIGGER */
574 void ICalProperty::set_trigger(struct icaltriggertype val){
575         icalproperty_set_trigger(imp, val);
576 }
577 struct icaltriggertype ICalProperty::get_trigger(){
578         return icalproperty_get_trigger(imp);
579 }
580
581 /* TZID */
582 void ICalProperty::set_tzid(string val){
583         icalproperty_set_tzid(imp, val);
584 }
585 string ICalProperty::get_tzid(){
586         return (string)icalproperty_get_tzid(imp);
587 }
588
589 /* TZNAME */
590 void ICalProperty::set_tzname(string val){
591         icalproperty_set_tzname(imp, val);
592 }
593 string ICalProperty::get_tzname(){
594         return (string)icalproperty_get_tzname(imp);
595 }
596
597 /* TZOFFSETFROM */
598 void ICalProperty::set_tzoffsetfrom(int val){
599         icalproperty_set_tzoffsetfrom(imp, val);
600 }
601 int ICalProperty::get_tzoffsetfrom(){
602         return icalproperty_get_tzoffsetfrom(imp);
603 }
604
605 /* TZOFFSETTO */
606 void ICalProperty::set_tzoffsetto(int val){
607         icalproperty_set_tzoffsetto(imp, val);
608 }
609 int ICalProperty::get_tzoffsetto(){
610         return icalproperty_get_tzoffsetto(imp);
611 }
612
613 /* TZURL */
614 void ICalProperty::set_tzurl(string val){
615         icalproperty_set_tzurl(imp, val);
616 }
617 string ICalProperty::get_tzurl(){
618         return (string)icalproperty_get_tzurl(imp);
619 }
620
621 /* UID */
622 void ICalProperty::set_uid(string val){
623         icalproperty_set_uid(imp, val);
624 }
625 string ICalProperty::get_uid(){
626         return (string)icalproperty_get_uid(imp);
627 }
628
629 /* URL */
630 void ICalProperty::set_url(string val){
631         icalproperty_set_url(imp, val);
632 }
633 string ICalProperty::get_url(){
634         return (string)icalproperty_get_url(imp);
635 }
636
637 /* VERSION */
638 void ICalProperty::set_version(string val){
639         icalproperty_set_version(imp, val);
640 }
641 string ICalProperty::get_version(){
642         return (string)icalproperty_get_version(imp);
643 }
644
645 /* X */
646 void ICalProperty::set_x(string val){
647         icalproperty_set_x(imp, val);
648 }
649 string ICalProperty::get_x(){
650         return (string)icalproperty_get_x(imp);
651 }
652
653 /* X-LIC-CLUSTERCOUNT */
654 void ICalProperty::set_xlicclustercount(string val){
655         icalproperty_set_xlicclustercount(imp, val);
656 }
657 string ICalProperty::get_xlicclustercount(){
658         return (string)icalproperty_get_xlicclustercount(imp);
659 }
660
661 /* X-LIC-ERROR */
662 void ICalProperty::set_xlicerror(string val){
663         icalproperty_set_xlicerror(imp, val);
664 }
665 string ICalProperty::get_xlicerror(){
666         return (string)icalproperty_get_xlicerror(imp);
667 }
668
669 /* X-LIC-MIMECHARSET */
670 void ICalProperty::set_xlicmimecharset(string val){
671         icalproperty_set_xlicmimecharset(imp, val);
672 }
673 string ICalProperty::get_xlicmimecharset(){
674         return (string)icalproperty_get_xlicmimecharset(imp);
675 }
676
677 /* X-LIC-MIMECID */
678 void ICalProperty::set_xlicmimecid(string val){
679         icalproperty_set_xlicmimecid(imp, val);
680 }
681 string ICalProperty::get_xlicmimecid(){
682         return (string)icalproperty_get_xlicmimecid(imp);
683 }
684
685 /* X-LIC-MIMECONTENTTYPE */
686 void ICalProperty::set_xlicmimecontenttype(string val){
687         icalproperty_set_xlicmimecontenttype(imp, val);
688 }
689 string ICalProperty::get_xlicmimecontenttype(){
690         return (string)icalproperty_get_xlicmimecontenttype(imp);
691 }
692
693 /* X-LIC-MIMEENCODING */
694 void ICalProperty::set_xlicmimeencoding(string val){
695         icalproperty_set_xlicmimeencoding(imp, val);
696 }
697 string ICalProperty::get_xlicmimeencoding(){
698         return (string)icalproperty_get_xlicmimeencoding(imp);
699 }
700
701 /* X-LIC-MIMEFILENAME */
702 void ICalProperty::set_xlicmimefilename(string val){
703         icalproperty_set_xlicmimefilename(imp, val);
704 }
705 string ICalProperty::get_xlicmimefilename(){
706         return (string)icalproperty_get_xlicmimefilename(imp);
707 }
708
709 /* X-LIC-MIMEOPTINFO */
710 void ICalProperty::set_xlicmimeoptinfo(string val){
711         icalproperty_set_xlicmimeoptinfo(imp, val);
712 }
713 string ICalProperty::get_xlicmimeoptinfo(){
714         return (string)icalproperty_get_xlicmimeoptinfo(imp);
715 }