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.

38 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. for(auto& a : alarms) {
  14. DEBUG << "\n" << a.print();
  15. }
  16. object->events.push_back(this);
  17. }
  18. void Event::parse_alarms(icalcomponent* event_component) {
  19. icalcomponent* c;
  20. for(c = icalcomponent_get_first_component(event_component, ICAL_VALARM_COMPONENT);
  21. c != 0;
  22. c = icalcomponent_get_next_component(event_component, ICAL_VALARM_COMPONENT))
  23. {
  24. alarms.push_back(Alarm(c));
  25. }
  26. }
  27. std::string Event::print() {
  28. std::string s = "";
  29. s += "DTSTART: " + std::string(icaltime_as_ical_string(dtstart)) + "\n";
  30. s += "DTEND: " + std::string(icaltime_as_ical_string(dtend)) + "\n";
  31. s += "SUMMARY: " + summary + "\n";
  32. return s;
  33. }
  34. }