$darkmode
Libical API Documentation 4.0 STABLE VERSION Visit the v3.0 documentation
vcomponent_cxx.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2001, Critical Path
3  * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
4 */
5 
12 #ifdef HAVE_CONFIG_H
13 #include <config.h>
14 #endif
15 
16 #include "vcomponent_cxx.hpp"
17 #include "icalparameter_cxx.hpp"
18 #include "icalproperty_cxx.hpp"
19 #include "icalvalue_cxx.hpp"
20 using namespace LibICal;
21 
22 extern "C" {
23 #include "icalerror_p.h"
24 #include "icalmemory.h"
25 }
26 
27 #include <cstdlib>
28 #include <string>
29 
30 VComponent::VComponent()
32 {
33 }
34 
35 VComponent::VComponent(const VComponent &v)
36  : imp(icalcomponent_clone(v.imp))
37 {
38  if (imp == NULL) {
39  throw icalerrno;
40  }
41 }
42 
43 VComponent &VComponent::operator=(const VComponent &v)
44 {
45  if (this == &v) {
46  return *this;
47  }
48 
49  icalcomponent_free(imp);
50  imp = NULL;
51 
52  imp = icalcomponent_clone(v.imp);
53  if (imp == NULL) {
54  throw icalerrno;
55  }
56 
57  return *this;
58 }
59 
60 void VComponent::detach()
61 {
62  imp = NULL;
63 }
64 
65 VComponent::~VComponent()
66 {
67  icalcomponent_free(imp);
68 }
69 
70 VComponent::VComponent(icalcomponent *v)
71  : imp(v)
72 {
73 }
74 
75 /* char* returned is in the ring buffer. caller doesn't have to free it */
76 
86 VComponent::VComponent(const std::string &str)
87  : imp(icalcomponent_new_from_string(str.c_str()))
88 {
89  if (imp == NULL) {
90  if (!icalerrno) {
92  }
93  throw icalerrno;
94  }
95 }
96 
97 VComponent::VComponent(const icalcomponent_kind &kind)
98  : imp(icalcomponent_new(kind))
99 {
100  if (imp == NULL) {
101  throw icalerrno;
102  }
103 }
104 
105 std::string VComponent::as_ical_string()
106 {
107  const char *str = icalcomponent_as_ical_string(imp);
108 
109  if (str == NULL) {
110  throw icalerrno;
111  }
112 
113  return (str);
114 }
115 
116 bool VComponent::is_valid()
117 {
118  if (imp == NULL) {
119  return false;
120  }
121  return icalcomponent_is_valid(imp);
122 }
123 
124 icalcomponent_kind VComponent::isa()
125 {
126  return icalcomponent_isa(imp);
127 }
128 
129 /* cppcheck-suppress functionStatic */
130 bool VComponent::isa_component(const void *component) //NOLINT(readability-convert-member-functions-to-static)
131 {
132  return icalcomponent_isa_component(component);
133 }
134 
135 void VComponent::new_from_string(const std::string &str)
136 {
137  icalcomponent_free(imp);
138  imp = icalcomponent_new_from_string(str.c_str());
139 }
140 
141 /* Working with properties */
143 {
144  icalcomponent_add_property(imp, *property);
145 }
146 
147 void VComponent::remove_property(ICalProperty *property)
148 {
149  icalcomponent_remove_property(imp, *property);
150  icalproperty_free(*property);
151  property->detach(); // set imp to null, it's free already.
152 }
153 
154 int VComponent::count_properties(const icalproperty_kind &kind)
155 {
156  return icalcomponent_count_properties(imp, kind);
157 }
158 
159 /* Iterate through the properties */
160 ICalProperty *VComponent::get_current_property()
161 {
162  icalproperty *t = icalcomponent_get_current_property(imp);
163  return ((t != NULL) ? new ICalProperty(t) : NULL);
164 }
165 
166 ICalProperty *VComponent::get_first_property(const icalproperty_kind &kind)
167 {
168  icalproperty *t = icalcomponent_get_first_property(imp, kind);
169  return ((t != NULL) ? new ICalProperty(t) : NULL);
170 }
171 
172 ICalProperty *VComponent::get_next_property(const icalproperty_kind &kind)
173 {
174  icalproperty *t = icalcomponent_get_next_property(imp, kind);
175  return ((t != NULL) ? new ICalProperty(t) : NULL);
176 }
177 
178 /* Working with components */
179 /* Returns the first VEVENT, VTODO or VJOURNAL sub-component if it is one of those types */
181 {
182  return new VComponent(icalcomponent_get_inner(imp));
183 }
184 
185 void VComponent::add_component(VComponent *child)
186 {
187  icalcomponent_add_component(imp, *child);
188 }
189 
190 void VComponent::remove_component(VComponent *child)
191 {
192  icalcomponent_remove_component(imp, *child);
193 }
194 
195 int VComponent::count_components(const icalcomponent_kind &kind)
196 {
197  return icalcomponent_count_components(imp, kind);
198 }
199 
200 /* Iteration Routines. There are two forms of iterators, internal and
201  external. The internal ones came first, and are almost completely
202  sufficient, but they fail badly when you want to construct a loop that
203  removes components from the container.
204 */
205 
206 /* Iterate through components */
208 {
209  icalcomponent *t = icalcomponent_get_current_component(imp);
210  return ((t != NULL) ? new VComponent(t) : NULL);
211 }
212 
213 VComponent *VComponent::get_first_component(const icalcomponent_kind &kind)
214 {
215  VComponent *result = NULL; // NOLINT(misc-const-correctness)
216  icalcomponent *t = icalcomponent_get_first_component(imp, kind);
217  if (t != NULL) {
218  switch (kind) {
220  result = new VAlarm(t);
221  break;
223  result = new VCalendar(t);
224  break;
226  result = new VEvent(t);
227  break;
229  result = new VQuery(t);
230  break;
232  result = new VToDo(t);
233  break;
235  result = new VAgenda(t);
236  break;
237  default:
238  result = new VComponent(t);
239  }
240  }
241 
242  return (result);
243 }
244 
245 VComponent *VComponent::get_next_component(const icalcomponent_kind &kind)
246 {
247  VComponent *result = NULL; // NOLINT(misc-const-correctness)
248  icalcomponent *t = icalcomponent_get_next_component(imp, kind);
249  if (t != NULL) {
250  switch (kind) {
252  result = new VAlarm(t);
253  break;
255  result = new VCalendar(t);
256  break;
258  result = new VEvent(t);
259  break;
261  result = new VQuery(t);
262  break;
264  result = new VToDo(t);
265  break;
267  result = new VAgenda(t);
268  break;
269  default:
270  result = new VComponent(t);
271  }
272  }
273 
274  return (result);
275 }
276 
277 /* Using external iterators */
279 {
280  return icalcomponent_begin_component(imp, kind);
281 }
282 
283 icalcompiter VComponent::end_component(const icalcomponent_kind &kind)
284 {
285  return icalcomponent_end_component(imp, kind);
286 }
287 
288 VComponent *VComponent::next(icalcompiter *i)
289 {
290  return reinterpret_cast<VComponent *>(icalcompiter_next(i));
291 }
292 
293 VComponent *VComponent::prev(icalcompiter *i)
294 {
295  return reinterpret_cast<VComponent *>(icalcompiter_prior(i));
296 }
297 
298 VComponent *VComponent::current(icalcompiter *i)
299 {
300  return reinterpret_cast<VComponent *>(icalcompiter_deref(i));
301 }
302 
303 /* Working with embedded error properties */
305 {
306  return icalcomponent_count_errors(imp);
307 }
308 
309 /* Remove all X-LIC-ERROR properties*/
311 {
313 }
314 
315 /* Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/
317 {
319 }
320 
321 /* Kind conversion routines */
323 {
324  return icalcomponent_string_to_kind(str.c_str());
325 }
326 
327 std::string VComponent::kind_to_string(const icalcomponent_kind &kind)
328 {
329  return static_cast<std::string>(icalcomponent_kind_to_string(kind));
330 }
331 
332 struct icaltimetype VComponent::get_dtstart() const
333 {
334  return icalcomponent_get_dtstart(imp);
335 }
336 
337 void VComponent::set_dtstart(const struct icaltimetype &v)
338 {
340 }
341 
342 /* For the icalcomponent routines only, dtend and duration are tied
343  together. If you call the set routine for one and the other exists,
344  the routine will calculate the change to the other. That is, if
345  there is a DTEND and you call set_duration, the routine will modify
346  DTEND to be the sum of DTSTART and the duration. If you call a get
347  routine for one and the other exists, the routine will calculate
348  the return value. If you call a set routine and neither exists, the
349  routine will create the apcompriate comperty.
350 */
351 
352 struct icaltimetype VComponent::get_dtend() const
353 {
354  return icalcomponent_get_dtend(imp);
355 }
356 
357 void VComponent::set_dtend(const struct icaltimetype &v)
358 {
359  icalcomponent_set_dtend(imp, v);
360 }
361 
362 struct icaltimetype VComponent::get_due() const
363 {
364  return icalcomponent_get_due(imp);
365 }
366 
367 void VComponent::set_due(const struct icaltimetype &v)
368 {
369  icalcomponent_set_due(imp, v);
370 }
371 
372 struct icaldurationtype VComponent::get_duration() const
373 {
374  return icalcomponent_get_duration(imp);
375 }
376 
377 void VComponent::set_duration(const struct icaldurationtype &v)
378 {
380 }
381 
382 icalproperty_method VComponent::get_method() const
383 {
384  return icalcomponent_get_method(imp);
385 }
386 
387 void VComponent::set_method(const icalproperty_method &method)
388 {
389  icalcomponent_set_method(imp, method);
390 }
391 
392 struct icaltimetype VComponent::get_dtstamp() const
393 {
394  return icalcomponent_get_dtstamp(imp);
395 }
396 
397 void VComponent::set_dtstamp(const struct icaltimetype &v)
398 {
400 }
401 
402 std::string VComponent::get_summary() const
403 {
404  return static_cast<std::string>(icalcomponent_get_summary(imp));
405 }
406 
407 void VComponent::set_summary(const std::string &v)
408 {
409  icalcomponent_set_summary(imp, v.c_str());
410 }
411 
412 std::string VComponent::get_location() const
413 {
414  return static_cast<std::string>(icalcomponent_get_location(imp));
415 }
416 
417 void VComponent::set_location(const std::string &v)
418 {
419  icalcomponent_set_location(imp, v.c_str());
420 }
421 
422 std::string VComponent::get_description() const
423 {
424  return static_cast<std::string>(icalcomponent_get_description(imp));
425 }
426 
427 void VComponent::set_description(const std::string &v)
428 {
429  icalcomponent_set_description(imp, v.c_str());
430 }
431 
432 std::string VComponent::get_comment() const
433 {
434  return static_cast<std::string>(icalcomponent_get_comment(imp));
435 }
436 
437 void VComponent::set_comment(const std::string &v)
438 {
439  icalcomponent_set_comment(imp, v.c_str());
440 }
441 
442 std::string VComponent::get_uid() const
443 {
444  return static_cast<std::string>(icalcomponent_get_uid(imp));
445 }
446 
447 void VComponent::set_uid(const std::string &v)
448 {
449  icalcomponent_set_uid(imp, v.c_str());
450 }
451 
452 std::string VComponent::get_relcalid() const
453 {
454  return static_cast<std::string>(icalcomponent_get_relcalid(imp));
455 }
456 
457 void VComponent::set_relcalid(const std::string &v)
458 {
459  icalcomponent_set_relcalid(imp, v.c_str());
460 }
461 
462 struct icaltimetype VComponent::get_recurrenceid() const
463 {
464  return icalcomponent_get_recurrenceid(imp);
465 }
466 
467 void VComponent::set_recurrenceid(const struct icaltimetype &v)
468 {
470 }
471 
472 int VComponent::get_sequence() const
473 {
474  return icalcomponent_get_sequence(imp);
475 }
476 
477 void VComponent::set_sequence(const int &v)
478 {
480 }
481 
483 {
484  return icalcomponent_get_status(imp);
485 }
486 
487 void VComponent::set_status(const enum icalproperty_status &v)
488 {
489  icalcomponent_set_status(imp, v);
490 }
491 
492 /* For VCOMPONENT: Return a reference to the first VEVENT, VTODO, or VJOURNAL */
494 {
495  return reinterpret_cast<VComponent *>(icalcomponent_get_first_real_component(imp));
496 }
497 
498 /* For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end
499  times of an event in UTC */
500 struct icaltime_span VComponent::get_span()
501 {
502  return icalcomponent_get_span(imp);
503 }
504 
505 bool VComponent::recurrence_is_excluded(struct icaltimetype *dtstart,
506  struct icaltimetype *recurtime)
507 {
508  return icalproperty_recurrence_is_excluded(imp, dtstart, recurtime);
509 }
510 
511 /* ignoreValue means remove properties even if the data doesn't match */
512 bool VComponent::remove(VComponent &fromVC, bool ignoreValue)
513 {
514  /* the two components must be the same kind */
515  if (this->isa() != fromVC.isa()) {
516  return false;
517  }
518 
519  /* properties first */
520  ICalPropertyTmpPtr propToBeRemoved;
521  for (propToBeRemoved = fromVC.get_first_property(ICAL_ANY_PROPERTY);
522  propToBeRemoved != NULL;
523  propToBeRemoved = fromVC.get_next_property(ICAL_ANY_PROPERTY)) {
524  /* loop through properties from this component */
525  ICalPropertyTmpPtr next_prop;
527  for (p = this->get_first_property(propToBeRemoved->isa()); p != NULL; p = next_prop) {
528  next_prop = this->get_next_property(propToBeRemoved->isa());
529  if (ignoreValue) {
530  this->remove_property(p);
531  } else {
532  if (p == propToBeRemoved) {
533  this->remove_property(p);
534  break;
535  }
536  }
537  }
538  }
539 
540  /* components next - should remove by UID */
541  VComponentTmpPtr comp;
542  for (comp = fromVC.get_first_component(ICAL_ANY_COMPONENT); comp != NULL;
543  comp = fromVC.get_next_component(ICAL_ANY_COMPONENT)) {
544  const std::string fromCompUid = comp->get_uid();
546  for (c = this->get_first_component(comp->isa()); c != NULL;
547  c = this->get_next_component(comp->isa())) {
548  if (strcmp(fromCompUid.c_str(), c->get_uid().c_str()) == 0) {
549  // recursively go down the components
550  c->remove(*comp, ignoreValue);
551  // if all properties are removed and there is no sub-components, then
552  // remove this component
553  if ((c->count_properties(ICAL_ANY_PROPERTY) == 0) &&
554  (c->count_components(ICAL_ANY_COMPONENT) == 0)) {
555  this->remove_component(c);
556  }
557  break;
558  }
559  }
560  }
561 
562  return true;
563 }
564 
565 /* removeMissing == true: remove properties that are missing from fromC */
566 /* todo: only change the first occurrence of the property */
567 /* todo: removeMissing is not implemented */
568 bool VComponent::update(VComponent &fromC, bool removeMissing)
569 {
570  /* make sure they are the same kind */
571  if (this->isa() != fromC.isa()) {
572  return false;
573  }
574 
575  /* property first */
576  ICalPropertyTmpPtr prop;
577  for (prop = fromC.get_first_property(ICAL_ANY_PROPERTY); prop != NULL;
578  prop = fromC.get_next_property(ICAL_ANY_PROPERTY)) {
579  ICalPropertyTmpPtr thisProp;
580  thisProp = this->get_first_property(prop->isa());
581  if (thisProp == NULL) {
582  thisProp = new ICalProperty(prop->isa());
583  this->add_property(thisProp);
584  }
585  const ICalValue *tempValue = prop->get_value();
586  const ICalValue *value = new ICalValue(*tempValue); // clone the value
587  thisProp->set_value(*value);
588  delete tempValue;
589  delete value;
590  }
591 
592  /* recursively updating sub-components */
593  VComponentTmpPtr comp;
594  for (comp = fromC.get_first_component(ICAL_ANY_COMPONENT); comp != NULL;
595  comp = fromC.get_next_component(ICAL_ANY_COMPONENT)) {
596  VComponentTmpPtr thisComp;
597  thisComp = this->get_first_component(comp->isa());
598  if (thisComp == NULL) {
599  thisComp = new VComponent(comp->isa());
600  this->add_component(thisComp);
601  }
602  const bool err = thisComp->update(*comp, removeMissing);
603  if (!err) {
604  return false;
605  }
606  }
607  return true;
608 }
609 
610 /* add components and property. recursively goes down child components */
611 bool VComponent::add(VComponent &fromC)
612 {
613  /* make sure the kind are the same */
614  if (this->isa() != fromC.isa()) {
615  return false;
616  }
617 
618  /* properties first */
619  ICalPropertyTmpPtr prop;
620  for (prop = fromC.get_first_property(ICAL_ANY_PROPERTY); prop != NULL;
621  prop = fromC.get_next_property(ICAL_ANY_PROPERTY)) {
622  /* clone another property */
623  ICalProperty *p = new ICalProperty(*prop);
624  add_property(p);
625  delete p;
626  }
627 
628  /* sub-components next */
629  VComponentTmpPtr comp;
630  for (comp = fromC.get_first_component(ICAL_ANY_COMPONENT); comp != NULL;
631  comp = fromC.get_next_component(ICAL_ANY_COMPONENT)) {
632  VComponent *c = new VComponent(comp->isa());
633  add_component(c);
634  delete c;
635  }
636 
637  return true;
638 }
639 
640 VCalendar::VCalendar()
642 {
643 }
644 
645 VCalendar::VCalendar(const VCalendar &v)
646  : VComponent(v)
647 {
648 }
649 
650 VCalendar &VCalendar::operator=(const VCalendar &v)
651 {
652  if (this == &v) {
653  return *this;
654  }
655  VComponent::operator=(v);
656 
657  return *this;
658 }
659 
660 VCalendar::~VCalendar()
661 {
662 }
663 
664 VCalendar::VCalendar(icalcomponent *v)
665  : VComponent(v)
666 {
667 }
668 
669 VCalendar::VCalendar(const std::string &str)
670  : VComponent(str)
671 {
672 }
673 
674 /* VEvent */
675 
676 VEvent::VEvent()
678 {
679 }
680 
681 VEvent::VEvent(const VEvent &v)
682  : VComponent(v)
683 {
684 }
685 
686 VEvent &VEvent::operator=(const VEvent &v)
687 {
688  if (this == &v) {
689  return *this;
690  }
691  VComponent::operator=(v);
692 
693  return *this;
694 }
695 
696 VEvent::~VEvent()
697 {
698 }
699 
700 VEvent::VEvent(icalcomponent *v)
701  : VComponent(v)
702 {
703 }
704 
705 VEvent::VEvent(const std::string &str)
706  : VComponent(str)
707 {
708 }
709 
710 /* VTodo */
711 
712 VToDo::VToDo()
714 {
715 }
716 
717 VToDo::VToDo(const VToDo &v)
718  : VComponent(v)
719 {
720 }
721 
722 VToDo &VToDo::operator=(const VToDo &v)
723 {
724  if (this == &v) {
725  return *this;
726  }
727  VComponent::operator=(v);
728 
729  return *this;
730 }
731 
732 VToDo::~VToDo()
733 {
734 }
735 
736 VToDo::VToDo(icalcomponent *v)
737  : VComponent(v)
738 {
739 }
740 
741 VToDo::VToDo(const std::string &str)
742  : VComponent(str)
743 {
744 }
745 
746 /* VAgenda */
747 
748 VAgenda::VAgenda()
750 {
751 }
752 
753 VAgenda::VAgenda(const VAgenda &v)
754  : VComponent(v)
755 {
756 }
757 
758 VAgenda &VAgenda::operator=(const VAgenda &v)
759 {
760  if (this == &v) {
761  return *this;
762  }
763  VComponent::operator=(v);
764 
765  return *this;
766 }
767 
768 VAgenda::~VAgenda()
769 {
770 }
771 
772 VAgenda::VAgenda(icalcomponent *v)
773  : VComponent(v)
774 {
775 }
776 
777 VAgenda::VAgenda(const std::string &str)
778  : VComponent(str)
779 {
780 }
781 
782 /* VQuery */
783 
784 VQuery::VQuery()
786 {
787 }
788 
789 VQuery::VQuery(const VQuery &v)
790  : VComponent(v)
791 {
792 }
793 
794 VQuery &VQuery::operator=(const VQuery &v)
795 {
796  if (this == &v) {
797  return *this;
798  }
799  VComponent::operator=(v);
800 
801  return *this;
802 }
803 
804 VQuery::~VQuery()
805 {
806 }
807 
808 VQuery::VQuery(icalcomponent *v)
809  : VComponent(v)
810 {
811 }
812 
813 VQuery::VQuery(const std::string &str)
814  : VComponent(str)
815 {
816 }
817 
818 /* VJournal */
819 
820 VJournal::VJournal()
822 {
823 }
824 
825 VJournal::VJournal(const VJournal &v)
826  : VComponent(v)
827 {
828 }
829 
830 VJournal &VJournal::operator=(const VJournal &v)
831 {
832  if (this == &v) {
833  return *this;
834  }
835  VComponent::operator=(v);
836 
837  return *this;
838 }
839 
840 VJournal::~VJournal()
841 {
842 }
843 
844 VJournal::VJournal(icalcomponent *v)
845  : VComponent(v)
846 {
847 }
848 
849 VJournal::VJournal(const std::string &str)
850  : VComponent(str)
851 {
852 }
853 
854 /* VAlarm */
855 
856 VAlarm::VAlarm()
858 {
859 }
860 
861 VAlarm::VAlarm(const VAlarm &v)
862  : VComponent(v)
863 {
864 }
865 
866 VAlarm &VAlarm::operator=(const VAlarm &v)
867 {
868  if (this == &v) {
869  return *this;
870  }
871  VComponent::operator=(v);
872 
873  return *this;
874 }
875 
876 VAlarm::~VAlarm()
877 {
878 }
879 
880 VAlarm::VAlarm(icalcomponent *v)
881  : VComponent(v)
882 {
883 }
884 
885 VAlarm::VAlarm(const std::string &str)
886  : VComponent(str)
887 {
888 }
889 
891 {
892  ICalPropertyTmpPtr trigger_prop = this->get_first_property(ICAL_TRIGGER_PROPERTY);
893 
894  // all VALARMs must have a TRIGGER
895  if (trigger_prop == NULL) {
897  }
898 
899  *tr = trigger_prop->get_trigger();
900 
901  if (icaltime_is_null_time(tr->time)) {
902  struct icaltimetype tt = icaltime_null_time();
903 
904  // relative time trigger
905 
906  // TRIGGER;RELATED=END:P5M 5 minutes after END
907  // TRIGGER;RELATED=START:-P15M 15 minutes before START
908  // get RELATED parameter
909 
910  ICalParameter *related_param = trigger_prop->get_first_parameter(ICAL_RELATED_PARAMETER);
911 
912  if ((related_param != NULL) && related_param->is_valid()) {
913  // get RELATED parameter value
914  const icalparameter_related related = related_param->get_related();
915 
916  if (related != 0) {
917  switch (related) {
918  case ICAL_RELATED_END:
919  if (c.isa() == ICAL_VEVENT_COMPONENT) {
920  tt = c.get_dtend();
921 
922  // If a recurrenceid exists, use that to calculate the
923  // dtend from the dtstart.
924  const struct icaltimetype recur_time = c.get_recurrenceid();
925  if (!icaltime_is_null_time(recur_time)) {
926  const struct icaldurationtype dur = icalduration_from_times(c.get_dtstart(), tt);
927  tt = icalduration_extend(recur_time, dur);
928  }
929  } else if (c.isa() == ICAL_VTODO_COMPONENT) {
930  tt = c.get_due();
931  const struct icaltimetype recur_time = c.get_recurrenceid();
932  if (!icaltime_is_null_time(recur_time)) {
933  tt = recur_time;
934  }
935  }
936  // the c.get_dtend()/c.get_due() uses DTSTART+DURATION when neither the DTEND nor DUE is present
937  break;
938  case ICAL_RELATED_START:
939  case ICAL_RELATED_X:
940  case ICAL_RELATED_NONE:
941  default:
942  tt = c.get_dtstart();
943  const struct icaltimetype recur_time = c.get_recurrenceid();
944  if (!icaltime_is_null_time(recur_time)) {
945  tt = recur_time;
946  }
947  break;
948  }
949  }
950  } else { // no RELATED explicitly specified, the default is
951  // relative to the start of an event or to-do, rfc2445
952  // if no RELATED, we are forced to use dtstart for VEVENT,
953  // due for VTODO to calculate trigger time.
954  // If a recur time exists, use that. Recur time trumps dtstart or due.
955  const struct icaltimetype recur_time = c.get_recurrenceid();
956  if (!icaltime_is_null_time(recur_time)) {
957  tt = recur_time;
958  } else if (c.isa() == ICAL_VEVENT_COMPONENT) {
959  tt = c.get_dtstart();
960  } else if (c.isa() == ICAL_VTODO_COMPONENT) {
961  tt = c.get_due();
962  }
963  }
964 
965  delete related_param;
966 
967  // malformed? encapsulating VEVENT or VTODO MUST have DTSTART/DTEND
968  if (icaltime_is_null_time(tt)) {
970  }
971 
972  // now offset using tr.duration
973  tr->time = icalduration_extend(tt, tr->duration);
974  }
975  // else absolute time trigger
976 
978 }
979 
980 /* VFreeBusy */
981 
982 VFreeBusy::VFreeBusy()
984 {
985 }
986 
987 VFreeBusy::VFreeBusy(const VFreeBusy &v)
988  : VComponent(v)
989 {
990 }
991 
992 VFreeBusy &VFreeBusy::operator=(const VFreeBusy &v)
993 {
994  if (this == &v) {
995  return *this;
996  }
997  VComponent::operator=(v);
998 
999  return *this;
1000 }
1001 
1002 VFreeBusy::~VFreeBusy()
1003 {
1004 }
1005 
1006 VFreeBusy::VFreeBusy(icalcomponent *v)
1007  : VComponent(v)
1008 {
1009 }
1010 
1011 VFreeBusy::VFreeBusy(const std::string &str)
1012  : VComponent(str)
1013 {
1014 }
1015 
1016 /* VTimezone */
1017 
1018 VTimezone::VTimezone()
1020 {
1021 }
1022 
1023 VTimezone::VTimezone(const VTimezone &v)
1024  : VComponent(v)
1025 {
1026 }
1027 
1028 VTimezone &VTimezone::operator=(const VTimezone &v)
1029 {
1030  if (this == &v) {
1031  return *this;
1032  }
1033  VComponent::operator=(v);
1034 
1035  return *this;
1036 }
1037 
1038 VTimezone::~VTimezone()
1039 {
1040 }
1041 
1042 VTimezone::VTimezone(icalcomponent *v)
1043  : VComponent(v)
1044 {
1045 }
1046 
1047 VTimezone::VTimezone(const std::string &str)
1048  : VComponent(str)
1049 {
1050 }
1051 
1052 /* XStandard */
1053 
1054 XStandard::XStandard()
1056 {
1057 }
1058 
1059 XStandard::XStandard(const XStandard &v)
1060  : VComponent(v)
1061 {
1062 }
1063 
1064 XStandard &XStandard::operator=(const XStandard &v)
1065 {
1066  if (this == &v) {
1067  return *this;
1068  }
1069  VComponent::operator=(v);
1070 
1071  return *this;
1072 }
1073 
1074 XStandard::~XStandard()
1075 {
1076 }
1077 
1078 XStandard::XStandard(icalcomponent *v)
1079  : VComponent(v)
1080 {
1081 }
1082 
1083 XStandard::XStandard(const std::string &str)
1084  : VComponent(str)
1085 {
1086 }
1087 
1088 /* XDaylight */
1089 
1090 XDaylight::XDaylight()
1092 {
1093 }
1094 
1095 XDaylight::XDaylight(const XDaylight &v)
1096  : VComponent(v)
1097 {
1098 }
1099 
1100 XDaylight &XDaylight::operator=(const XDaylight &v)
1101 {
1102  if (this == &v) {
1103  return *this;
1104  }
1105  VComponent::operator=(v);
1106 
1107  return *this;
1108 }
1109 
1110 XDaylight::~XDaylight()
1111 {
1112 }
1113 
1114 XDaylight::XDaylight(icalcomponent *v)
1115  : VComponent(v)
1116 {
1117 }
1118 
1119 XDaylight::XDaylight(const std::string &str)
1120  : VComponent(str)
1121 {
1122 }
icalcomponent * icalcomponent_get_first_component(icalcomponent *c, icalcomponent_kind kind)
const char * icalcomponent_get_summary(icalcomponent *comp)
icalcomponent * icalcompiter_prior(icalcompiter *i)
icalcomponent_kind icalcomponent_string_to_kind(const char *string)
struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent *comp)
icalcomponent * icalcompiter_next(icalcompiter *i)
void icalcomponent_remove_property(icalcomponent *component, icalproperty *property)
const char * icalcomponent_get_uid(icalcomponent *comp)
void convert_errors()
Convert some X-LIC-ERROR properties into RETURN-STATUS properties.
void icalcomponent_set_dtend(icalcomponent *comp, struct icaltimetype v)
icalcomponent * icalcomponent_get_current_component(icalcomponent *component)
void icalcomponent_set_relcalid(icalcomponent *comp, const char *v)
Common memory management routines.
icalproperty * icalcomponent_get_next_property(icalcomponent *c, icalproperty_kind kind)
icalcomponent * icalcomponent_new_vtimezone(void)
int icalcomponent_count_errors(icalcomponent *component)
void icalcomponent_set_summary(icalcomponent *comp, const char *v)
icalrequeststatus getTriggerTime(VComponent &c, struct icaltriggertype *tr)
icalcomponent * icalcomponent_new_vcalendar(void)
void icalcomponent_set_dtstart(icalcomponent *comp, struct icaltimetype v)
int icalcomponent_count_components(icalcomponent *component, icalcomponent_kind kind)
void icalcomponent_remove_component(icalcomponent *parent, icalcomponent *child)
void icalcomponent_add_component(icalcomponent *parent, icalcomponent *child)
icalcomponent * icalcomponent_new_from_string(const char *str)
icalcomponent * icalcomponent_get_inner(icalcomponent *comp)
icalcomponent * icalcomponent_clone(const icalcomponent *old)
int count_errors()
Working with embedded error properties.
void icalcomponent_set_recurrenceid(icalcomponent *comp, struct icaltimetype v)
bool icalproperty_recurrence_is_excluded(icalcomponent *comp, struct icaltimetype *dtstart, struct icaltimetype *recurtime)
Decides if a recurrence is acceptable.
void icalcomponent_strip_errors(icalcomponent *component)
bool remove(VComponent &, bool ignoreValue)
Note: the VComponent kind have to be the same.
icalcomponent * icalcomponent_get_first_real_component(const icalcomponent *c)
void icalcomponent_set_duration(icalcomponent *comp, struct icaldurationtype v)
icalcomponent * icalcomponent_new_vtodo(void)
icalcomponent * icalcomponent_new_vevent(void)
struct icaldurationtype icalcomponent_get_duration(icalcomponent *comp)
const char * icalcomponent_get_relcalid(icalcomponent *comp)
struct icaltimetype icalcomponent_get_dtstart(icalcomponent *comp)
icalproperty_method icalcomponent_get_method(icalcomponent *comp)
void icalcomponent_set_description(icalcomponent *comp, const char *v)
void strip_errors()
Remove all X-LIC-ERROR properties.
void icalcomponent_set_dtstamp(icalcomponent *comp, struct icaltimetype v)
void icalproperty_free(icalproperty *p)
Definition: icalproperty.c:184
void add_property(ICalProperty *property)
Working with properties.
icaltime_span icalcomponent_get_span(icalcomponent *comp)
void icalcomponent_set_status(icalcomponent *comp, enum icalproperty_status v)
void icalcomponent_set_method(icalcomponent *comp, icalproperty_method method)
icalproperty * icalcomponent_get_current_property(icalcomponent *component)
icalcompiter begin_component(const icalcomponent_kind &kind)
Using external iterators.
struct icaltimetype icalduration_extend(struct icaltimetype t, struct icaldurationtype d)
Extends a time duration.
Definition: icalduration.c:297
struct icaltimetype icaltime_null_time(void)
Definition: icaltime.c:579
struct icaltimetype get_dtend() const
icalcomponent * icalcomponent_new_xstandard(void)
Definition of C++ Wrapper for icalparameter.c.
C++ classes for the icalcomponent wrapper (VToDo VEvent, etc..).
char * icalcomponent_as_ical_string(const icalcomponent *component)
void icalcomponent_set_uid(icalcomponent *comp, const char *v)
const char * icalcomponent_get_comment(icalcomponent *comp)
struct icaltimetype icalcomponent_get_dtend(icalcomponent *comp)
const char * icalcomponent_get_description(icalcomponent *comp)
icalcomponent * icalcomponent_new_vagenda(void)
icalcomponent * icalcomponent_get_next_component(icalcomponent *c, icalcomponent_kind kind)
void icalcomponent_set_sequence(icalcomponent *comp, int v)
Definition of C++ Wrapper for icalvalue.c.
void icalcomponent_set_location(icalcomponent *comp, const char *v)
void icalcomponent_set_comment(icalcomponent *comp, const char *v)
struct icaldurationtype duration
Definition: icaltypes.h:51
VComponent * get_inner()
struct icaltimetype icalcomponent_get_dtstamp(icalcomponent *comp)
bool icalcomponent_is_valid(const icalcomponent *component)
icalcomponent * icalcomponent_new(icalcomponent_kind kind)
icalcompiter icalcomponent_end_component(icalcomponent *component, icalcomponent_kind kind)
struct icaltimetype time
Definition: icaltypes.h:50
icalcomponent * icalcomponent_new_valarm(void)
struct icaltimetype icalcomponent_get_due(icalcomponent *comp)
icalcomponent_kind
Definition: icalenums.h:28
icalcomponent * icalcompiter_deref(icalcompiter *i)
icalcomponent_kind icalcomponent_isa(const icalcomponent *component)
icalcomponent * icalcomponent_new_vjournal(void)
static icalcomponent_kind string_to_kind(const std::string &str)
Kind conversion routines.
bool icalcomponent_isa_component(const void *component)
void icalcomponent_convert_errors(icalcomponent *component)
struct icaldurationtype icalduration_from_times(struct icaltimetype t1, struct icaltimetype t2)
Creates a duration from two icaltimetype endpoints.
Definition: icalduration.c:346
#define icalerrno
Access the current icalerrno value.
Definition: icalerror.h:133
icalcomponent * icalcomponent_new_vquery(void)
bool icaltime_is_null_time(const struct icaltimetype t)
Definition: icaltime.c:630
int icalcomponent_count_properties(icalcomponent *component, icalproperty_kind kind)
VComponent * get_first_real_component()
enum icalproperty_status icalcomponent_get_status(icalcomponent *comp)
icalrequeststatus
Definition: icalenums.h:78
void icalcomponent_free(icalcomponent *c)
int icalcomponent_get_sequence(icalcomponent *comp)
void icalcomponent_add_property(icalcomponent *component, icalproperty *property)
A class wrapping the libical icalcomponent functions.
const char * icalcomponent_get_location(icalcomponent *comp)
VComponent * get_current_component()
Iterate through components.
icalcomponent * icalcomponent_new_xdaylight(void)
icalcomponent * icalcomponent_new_vfreebusy(void)
Definition of C++ Wrapper for icalproperty.c.
void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v)
icalcompiter icalcomponent_begin_component(icalcomponent *component, icalcomponent_kind kind)
const char * icalcomponent_kind_to_string(icalcomponent_kind kind)
icalproperty * icalcomponent_get_first_property(icalcomponent *c, icalproperty_kind kind)