#include #include namespace ical { Alarm::Alarm(icalcomponent* alarm_component) { parse(alarm_component); } void Alarm::parse(icalcomponent* alarm_component) { parse_action(alarm_component); parse_description(alarm_component); parse_trigger(alarm_component); DEBUG << "\n" << print(); } void Alarm::parse_action(icalcomponent* alarm_component) { DEBUG << icalproperty_get_value_as_string(icalcomponent_get_first_property(alarm_component, ICAL_ACTION_PROPERTY)); } void Alarm::parse_description(icalcomponent* alarm_component) { icalproperty* description_property = icalcomponent_get_first_property(alarm_component, ICAL_DESCRIPTION_PROPERTY); if(description_property != 0) { description = icalproperty_get_value_as_string(description_property); } } void Alarm::parse_trigger(icalcomponent* alarm_component) { icalproperty* trigger_property = icalcomponent_get_first_property(alarm_component, ICAL_TRIGGER_PROPERTY); struct icaltriggertype tr; if(trigger_property != 0) { tr = icalproperty_get_trigger(trigger_property); if (!icaltime_is_null_time(tr.time)) { trigger = ical::trigger_type::ABSOLUTE; } else { trigger = ical::trigger_type::RELATIVE; } } } std::string Alarm::print() const { std::string s = ""; s += "DESCRIPTION: " + description + "\n"; s += trigger == ical::trigger_type::ABSOLUTE ? "ABSOLUTE: " : "RELATIVE: "; return s; } }