You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

  1. #include <ical/Event.h>
  2. #include <ical/Alarm.h>
  3. namespace ical {
  4. Event::Event(ical::ical_object* object, icalcomponent* event_component) {
  5. parse(object, event_component);
  6. }
  7. void Event::parse(ical::ical_object* object, icalcomponent* event_component) {
  8. dtstart = icalcomponent_get_dtstart(event_component);
  9. dtend = icalcomponent_get_dtstart(event_component);
  10. summary = std::string(icalcomponent_get_summary(event_component));
  11. parse_alarms(event_component);
  12. DEBUG << "\n" << print();
  13. object->events.push_back(this);
  14. }
  15. void Event::parse_alarms(icalcomponent* event_component) {
  16. icalcomponent* c;
  17. for(c = icalcomponent_get_first_component(event_component, ICAL_VALARM_COMPONENT);
  18. c != 0;
  19. c = icalcomponent_get_next_component(event_component, ICAL_VALARM_COMPONENT))
  20. {
  21. alarms.push_back(Alarm(c));
  22. }
  23. }
  24. std::string Event::print() const {
  25. std::string s = "";
  26. s += "DTSTART: " + std::string(icaltime_as_ical_string(dtstart)) + "\n";
  27. s += "DTEND: " + std::string(icaltime_as_ical_string(dtend)) + "\n";
  28. s += "SUMMARY: " + summary + "\n";
  29. s += "ALARMS:\n";
  30. for(auto const& a : alarms) {
  31. s += a.print();
  32. }
  33. return s;
  34. }
  35. }