1 /* -*- Mode: C++ -*- */
4 * @file icalproperty_cxx.cpp
5 * @author fnguyen (12/10/01)
6 * @brief Implementation of C++ Wrapper for icalproperty.c
8 * (C) COPYRIGHT 2001, Critical Path
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of either:
13 The LGPL as published by the Free Software Foundation, version
14 2.1, available at: http://www.fsf.org/copyleft/lesser.html
18 The Mozilla Public License Version 1.0. You may obtain a copy of
19 the License at http://www.mozilla.org/MPL/
23 #ifndef ICALPROPERTY_CXX_H
24 #include "icalproperty_cxx.h"
27 #ifndef ICALPARAMETER_CXX_H
28 #include "icalparameter_cxx.h"
31 #ifndef ICALVALUE_CXX_H
32 #include "icalvalue_cxx.h"
35 ICalProperty::ICalProperty() : imp(icalproperty_new(ICAL_ANY_PROPERTY)){
38 ICalProperty::ICalProperty(const ICalProperty& v) throw(icalerrorenum){
39 imp = icalproperty_new_clone(v.imp);
40 if (!imp) throw icalerrno;
43 ICalProperty& ICalProperty::operator=(const ICalProperty& v) throw(icalerrorenum) {
44 if (this == &v) return *this;
48 icalproperty_free(imp);
49 imp = icalproperty_new_clone(v.imp);
50 if (!imp) throw icalerrno;
55 ICalProperty::~ICalProperty(){
56 if (imp != NULL) icalproperty_free(imp);
59 ICalProperty::ICalProperty(icalproperty* v) : imp(v) {
62 ICalProperty::ICalProperty(string str){
63 imp = icalproperty_new_from_string(str);
66 ICalProperty::ICalProperty(icalproperty_kind kind){
67 imp = icalproperty_new(kind);
70 string ICalProperty::as_ical_string(){
71 return (string)icalproperty_as_ical_string(imp);
73 icalproperty_kind ICalProperty::isa(){
74 return icalproperty_isa(imp);
76 int ICalProperty::isa_property(void* property){
77 return icalproperty_isa_property(property);
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);
88 void ICalProperty::add_parameter(ICalParameter& parameter){
89 icalproperty_add_parameter(imp, parameter);
91 void ICalProperty::set_parameter(ICalParameter ¶meter){
92 icalproperty_set_parameter(imp, parameter);
94 void ICalProperty::set_parameter_from_string(string name, string val){
95 icalproperty_set_parameter_from_string(imp, name, val);
97 string ICalProperty::get_parameter_as_string(string name){
98 return (string)icalproperty_get_parameter_as_string(imp, name);
100 void ICalProperty::remove_parameter(icalparameter_kind kind){
101 icalproperty_remove_parameter(imp, kind);
103 int ICalProperty::count_parameters(){
104 return icalproperty_count_parameters(imp);
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;
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;
117 /** Access the value of the property */
118 void ICalProperty::set_value(const ICalValue& val){
119 icalproperty_set_value(imp, (ICalValue&)val);
121 void ICalProperty::set_value_from_string(string val, string kind){
122 icalproperty_set_value_from_string(imp, val, kind);
125 ICalValue* ICalProperty::get_value(){
126 return new ICalValue(icalproperty_get_value(imp));
128 string ICalProperty::get_value_as_string(){
129 return (string)icalproperty_get_value_as_string(imp);
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
135 string ICalProperty::get_name(){
136 return (string)icalproperty_get_property_name(imp);
139 /* Deal with X properties */
140 void ICalProperty::set_x_name(ICalProperty &prop, string name){
141 icalproperty_set_x_name(prop, name);
143 string ICalProperty::get_x_name(ICalProperty &prop){
144 return (string)icalproperty_get_x_name(prop);
147 icalvalue_kind ICalProperty::icalparameter_value_to_value_kind(icalparameter_value val){
148 return icalparameter_value_to_value_kind(val);
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);
155 icalproperty_kind ICalProperty::value_kind_to_kind(icalvalue_kind kind){
156 return icalproperty_value_kind_to_kind(kind);
158 string ICalProperty::kind_to_string(icalproperty_kind kind){
159 return (string)icalproperty_kind_to_string(kind);
161 icalproperty_kind ICalProperty::string_to_kind(string str){
162 return icalproperty_string_to_kind(str);
165 string ICalProperty::method_to_string(icalproperty_method method){
166 return (string)icalproperty_method_to_string(method);
168 icalproperty_method ICalProperty::string_to_method(string str){
169 return icalproperty_string_to_method(str);
172 string ICalProperty::enum_to_string(int e){
173 return (string)icalproperty_enum_to_string(e);
175 int ICalProperty::string_to_enum(string str){
176 return icalproperty_string_to_enum(str);
179 string ICalProperty::status_to_string(icalproperty_status s){
180 return (string)icalproperty_status_to_string(s);
182 icalproperty_status ICalProperty::string_to_status(string str){
183 return icalproperty_string_to_status(str);
186 int ICalProperty::enum_belongs_to_property(icalproperty_kind kind, int e){
187 return icalproperty_enum_belongs_to_property(kind, e);
191 void ICalProperty::set_action(enum icalproperty_action val){
192 icalproperty_set_action(imp, val);
194 enum icalproperty_action ICalProperty::get_action(){
195 return icalproperty_get_action(imp);
199 void ICalProperty::set_attach(icalattach *val){
200 icalproperty_set_attach(imp, val);
202 icalattach * ICalProperty::get_attach(){
203 return icalproperty_get_attach(imp);
207 void ICalProperty::set_attendee(string val){
208 icalproperty_set_attendee(imp, val);
210 string ICalProperty::get_attendee(){
211 return (string)icalproperty_get_attendee(imp);
215 void ICalProperty::set_calscale(string val){
216 icalproperty_set_calscale(imp, val);
218 string ICalProperty::get_calscale(){
219 return (string)icalproperty_get_calscale(imp);
223 void ICalProperty::set_categories(string val){
224 icalproperty_set_categories(imp, val);
226 string ICalProperty::get_categories(){
227 return (string)icalproperty_get_categories(imp);
231 void ICalProperty::set_class(enum icalproperty_class val){
232 icalproperty_set_class(imp, val);
234 enum icalproperty_class ICalProperty::get_class(){
235 return (enum icalproperty_class)icalproperty_get_class(imp);
239 void ICalProperty::set_comment(string val){
240 icalproperty_set_comment(imp, val);
242 string ICalProperty::get_comment(){
243 return (string)icalproperty_get_comment(imp);
247 void ICalProperty::set_completed(struct icaltimetype val){
248 icalproperty_set_completed(imp, val);
250 struct icaltimetype ICalProperty::get_completed(){
251 return icalproperty_get_completed(imp);
255 void ICalProperty::set_contact(string val){
256 icalproperty_set_contact(imp, val);
258 string ICalProperty::get_contact(){
259 return (string)icalproperty_get_contact(imp);
263 void ICalProperty::set_created(struct icaltimetype val){
264 icalproperty_set_created(imp, val);
266 struct icaltimetype ICalProperty::get_created(){
267 return icalproperty_get_created(imp);
271 void ICalProperty::set_description(string val){
272 icalproperty_set_description(imp, val);
274 string ICalProperty::get_description(){
275 return (string)icalproperty_get_description(imp);
279 void ICalProperty::set_dtend(struct icaltimetype val){
280 icalproperty_set_dtend(imp, val);
282 struct icaltimetype ICalProperty::get_dtend(){
283 return icalproperty_get_dtend(imp);
287 void ICalProperty::set_dtstamp(struct icaltimetype val){
288 icalproperty_set_dtstamp(imp, val);
290 struct icaltimetype ICalProperty::get_dtstamp(){
291 return icalproperty_get_dtstamp(imp);
295 void ICalProperty::set_dtstart(struct icaltimetype val){
296 icalproperty_set_dtstart(imp, val);
298 struct icaltimetype ICalProperty::get_dtstart(){
299 return icalproperty_get_dtstart(imp);
303 void ICalProperty::set_due(struct icaltimetype val){
304 icalproperty_set_due(imp, val);
306 struct icaltimetype ICalProperty::get_due(){
307 return icalproperty_get_due(imp);
311 void ICalProperty::set_duration(struct icaldurationtype val){
312 icalproperty_set_duration(imp, val);
314 struct icaldurationtype ICalProperty::get_duration(){
315 return icalproperty_get_duration(imp);
319 void ICalProperty::set_exdate(struct icaltimetype val){
320 icalproperty_set_exdate(imp, val);
322 struct icaltimetype ICalProperty::get_exdate(){
323 return icalproperty_get_exdate(imp);
327 void ICalProperty::set_expand(int val){
328 icalproperty_set_expand(imp, val);
330 int ICalProperty::get_expand(){
331 return icalproperty_get_expand(imp);
335 void ICalProperty::set_exrule(struct icalrecurrencetype val){
336 icalproperty_set_exrule(imp, val);
338 struct icalrecurrencetype ICalProperty::get_exrule(){
339 return icalproperty_get_exrule(imp);
343 void ICalProperty::set_freebusy(struct icalperiodtype val){
344 icalproperty_set_freebusy(imp, val);
346 struct icalperiodtype ICalProperty::get_freebusy(){
347 return icalproperty_get_freebusy(imp);
351 void ICalProperty::set_geo(struct icalgeotype val){
352 icalproperty_set_geo(imp, val);
354 struct icalgeotype ICalProperty::get_geo(){
355 return icalproperty_get_geo(imp);
359 void ICalProperty::set_lastmodified(struct icaltimetype val){
360 icalproperty_set_lastmodified(imp, val);
362 struct icaltimetype ICalProperty::get_lastmodified(){
363 return icalproperty_get_lastmodified(imp);
367 void ICalProperty::set_location(string val){
368 icalproperty_set_location(imp, val);
370 string ICalProperty::get_location(){
371 return (string)icalproperty_get_location(imp);
375 void ICalProperty::set_maxresults(int val){
376 icalproperty_set_maxresults(imp, val);
378 int ICalProperty::get_maxresults(){
379 return icalproperty_get_maxresults(imp);
383 void ICalProperty::set_maxresultsize(int val){
384 icalproperty_set_maxresultssize(imp, val);
386 int ICalProperty::get_maxresultsize(){
387 return icalproperty_get_maxresultssize(imp);
391 void ICalProperty::set_method(enum icalproperty_method val){
392 icalproperty_set_method(imp, val);
394 enum icalproperty_method ICalProperty::get_method(){
395 return icalproperty_get_method(imp);
399 void ICalProperty::set_organizer(string val){
400 icalproperty_set_organizer(imp, val);
402 string ICalProperty::get_organizer(){
403 return (string)icalproperty_get_organizer(imp);
407 void ICalProperty::set_owner(string val){
408 icalproperty_set_owner(imp, val);
410 string ICalProperty::get_owner(){
411 return (string)icalproperty_get_owner(imp);
414 /* PERCENT-COMPLETE */
415 void ICalProperty::set_percentcomplete(int val){
416 icalproperty_set_percentcomplete(imp, val);
418 int ICalProperty::get_percentcomplete(){
419 return icalproperty_get_percentcomplete(imp);
423 void ICalProperty::set_priority(int val){
424 icalproperty_set_priority(imp, val);
426 int ICalProperty::get_priority(){
427 return icalproperty_get_priority(imp);
431 void ICalProperty::set_prodid(string val){
432 icalproperty_set_prodid(imp, val);
434 string ICalProperty::get_prodid(){
435 return (string)icalproperty_get_prodid(imp);
439 void ICalProperty::set_query(string val){
440 icalproperty_set_query(imp, val);
442 string ICalProperty::get_query(){
443 return (string)icalproperty_get_query(imp);
447 void ICalProperty::set_queryname(string val){
448 icalproperty_set_queryname(imp, val);
450 string ICalProperty::get_queryname(){
451 return (string)icalproperty_get_queryname(imp);
455 void ICalProperty::set_rdate(struct icaldatetimeperiodtype val){
456 icalproperty_set_rdate(imp, val);
458 struct icaldatetimeperiodtype ICalProperty::get_rdate(){
459 return icalproperty_get_rdate(imp);
463 void ICalProperty::set_recurrenceid(struct icaltimetype val){
464 icalproperty_set_recurrenceid(imp, val);
466 struct icaltimetype ICalProperty::get_recurrenceid(){
467 return icalproperty_get_recurrenceid(imp);
471 void ICalProperty::set_relatedto(string val){
472 icalproperty_set_relatedto(imp, val);
474 string ICalProperty::get_relatedto(){
475 return (string)icalproperty_get_relatedto(imp);
479 void ICalProperty::set_relcalid(string val){
480 icalproperty_set_relcalid(imp, val);
482 string ICalProperty::get_relcalid(){
483 return (string)icalproperty_get_relcalid(imp);
487 void ICalProperty::set_repeat(int val){
488 icalproperty_set_repeat(imp, val);
490 int ICalProperty::get_repeat(){
491 return icalproperty_get_repeat(imp);
495 void ICalProperty::set_requeststatus(string val){
498 v = icalreqstattype_from_string((char*)val);
500 icalproperty_set_requeststatus(imp, v);
503 string ICalProperty::get_requeststatus(){
505 v = icalproperty_get_requeststatus(imp);
506 return (string)(icalreqstattype_as_string(v));
510 void ICalProperty::set_resources(string val){
511 icalproperty_set_resources(imp, val);
513 string ICalProperty::get_resources(){
514 return (string)icalproperty_get_resources(imp);
518 void ICalProperty::set_rrule(struct icalrecurrencetype val){
519 icalproperty_set_rrule(imp, val);
521 struct icalrecurrencetype ICalProperty::get_rrule(){
522 return icalproperty_get_rrule(imp);
526 void ICalProperty::set_scope(string val){
527 icalproperty_set_scope(imp, val);
529 string ICalProperty::get_scope(){
530 return (string)icalproperty_get_scope(imp);
534 void ICalProperty::set_sequence(int val){
535 icalproperty_set_sequence(imp, val);
537 int ICalProperty::get_sequence(){
538 return icalproperty_get_sequence(imp);
542 void ICalProperty::set_status(enum icalproperty_status val){
543 icalproperty_set_status(imp, val);
545 enum icalproperty_status ICalProperty::get_status(){
546 return icalproperty_get_status(imp);
550 void ICalProperty::set_summary(string val){
551 icalproperty_set_summary(imp, val);
553 string ICalProperty::get_summary(){
554 return (string)icalproperty_get_summary(imp);
558 void ICalProperty::set_target(string val){
559 icalproperty_set_target(imp, val);
561 string ICalProperty::get_target(){
562 return (string)icalproperty_get_target(imp);
566 void ICalProperty::set_transp(enum icalproperty_transp val){
567 icalproperty_set_transp(imp, val);
569 enum icalproperty_transp ICalProperty::get_transp(){
570 return icalproperty_get_transp(imp);
574 void ICalProperty::set_trigger(struct icaltriggertype val){
575 icalproperty_set_trigger(imp, val);
577 struct icaltriggertype ICalProperty::get_trigger(){
578 return icalproperty_get_trigger(imp);
582 void ICalProperty::set_tzid(string val){
583 icalproperty_set_tzid(imp, val);
585 string ICalProperty::get_tzid(){
586 return (string)icalproperty_get_tzid(imp);
590 void ICalProperty::set_tzname(string val){
591 icalproperty_set_tzname(imp, val);
593 string ICalProperty::get_tzname(){
594 return (string)icalproperty_get_tzname(imp);
598 void ICalProperty::set_tzoffsetfrom(int val){
599 icalproperty_set_tzoffsetfrom(imp, val);
601 int ICalProperty::get_tzoffsetfrom(){
602 return icalproperty_get_tzoffsetfrom(imp);
606 void ICalProperty::set_tzoffsetto(int val){
607 icalproperty_set_tzoffsetto(imp, val);
609 int ICalProperty::get_tzoffsetto(){
610 return icalproperty_get_tzoffsetto(imp);
614 void ICalProperty::set_tzurl(string val){
615 icalproperty_set_tzurl(imp, val);
617 string ICalProperty::get_tzurl(){
618 return (string)icalproperty_get_tzurl(imp);
622 void ICalProperty::set_uid(string val){
623 icalproperty_set_uid(imp, val);
625 string ICalProperty::get_uid(){
626 return (string)icalproperty_get_uid(imp);
630 void ICalProperty::set_url(string val){
631 icalproperty_set_url(imp, val);
633 string ICalProperty::get_url(){
634 return (string)icalproperty_get_url(imp);
638 void ICalProperty::set_version(string val){
639 icalproperty_set_version(imp, val);
641 string ICalProperty::get_version(){
642 return (string)icalproperty_get_version(imp);
646 void ICalProperty::set_x(string val){
647 icalproperty_set_x(imp, val);
649 string ICalProperty::get_x(){
650 return (string)icalproperty_get_x(imp);
653 /* X-LIC-CLUSTERCOUNT */
654 void ICalProperty::set_xlicclustercount(string val){
655 icalproperty_set_xlicclustercount(imp, val);
657 string ICalProperty::get_xlicclustercount(){
658 return (string)icalproperty_get_xlicclustercount(imp);
662 void ICalProperty::set_xlicerror(string val){
663 icalproperty_set_xlicerror(imp, val);
665 string ICalProperty::get_xlicerror(){
666 return (string)icalproperty_get_xlicerror(imp);
669 /* X-LIC-MIMECHARSET */
670 void ICalProperty::set_xlicmimecharset(string val){
671 icalproperty_set_xlicmimecharset(imp, val);
673 string ICalProperty::get_xlicmimecharset(){
674 return (string)icalproperty_get_xlicmimecharset(imp);
678 void ICalProperty::set_xlicmimecid(string val){
679 icalproperty_set_xlicmimecid(imp, val);
681 string ICalProperty::get_xlicmimecid(){
682 return (string)icalproperty_get_xlicmimecid(imp);
685 /* X-LIC-MIMECONTENTTYPE */
686 void ICalProperty::set_xlicmimecontenttype(string val){
687 icalproperty_set_xlicmimecontenttype(imp, val);
689 string ICalProperty::get_xlicmimecontenttype(){
690 return (string)icalproperty_get_xlicmimecontenttype(imp);
693 /* X-LIC-MIMEENCODING */
694 void ICalProperty::set_xlicmimeencoding(string val){
695 icalproperty_set_xlicmimeencoding(imp, val);
697 string ICalProperty::get_xlicmimeencoding(){
698 return (string)icalproperty_get_xlicmimeencoding(imp);
701 /* X-LIC-MIMEFILENAME */
702 void ICalProperty::set_xlicmimefilename(string val){
703 icalproperty_set_xlicmimefilename(imp, val);
705 string ICalProperty::get_xlicmimefilename(){
706 return (string)icalproperty_get_xlicmimefilename(imp);
709 /* X-LIC-MIMEOPTINFO */
710 void ICalProperty::set_xlicmimeoptinfo(string val){
711 icalproperty_set_xlicmimeoptinfo(imp, val);
713 string ICalProperty::get_xlicmimeoptinfo(){
714 return (string)icalproperty_get_xlicmimeoptinfo(imp);