|
@ -1,8 +1,11 @@ |
|
|
#include <ical/Alarm.h>
|
|
|
#include <ical/Alarm.h>
|
|
|
#include <libical/icalproperty_cxx.h>
|
|
|
#include <libical/icalproperty_cxx.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <db/db.h>
|
|
|
|
|
|
|
|
|
namespace ical { |
|
|
namespace ical { |
|
|
Alarm::Alarm(icalcomponent* alarm_component) { |
|
|
|
|
|
|
|
|
Alarm::Alarm(icalcomponent* alarm_component, const uint32_t& event_dtstart) : m_event_dtstart(event_dtstart) { |
|
|
|
|
|
DEBUG << "Parsing ALARM"; |
|
|
parse(alarm_component); |
|
|
parse(alarm_component); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -20,7 +23,7 @@ namespace ical { |
|
|
void Alarm::parse_description(icalcomponent* alarm_component) { |
|
|
void Alarm::parse_description(icalcomponent* alarm_component) { |
|
|
icalproperty* description_property = icalcomponent_get_first_property(alarm_component, ICAL_DESCRIPTION_PROPERTY); |
|
|
icalproperty* description_property = icalcomponent_get_first_property(alarm_component, ICAL_DESCRIPTION_PROPERTY); |
|
|
if(description_property != 0) { |
|
|
if(description_property != 0) { |
|
|
description = icalproperty_get_value_as_string(description_property); |
|
|
|
|
|
|
|
|
m_description = icalproperty_get_value_as_string(description_property); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -30,17 +33,46 @@ namespace ical { |
|
|
if(trigger_property != 0) { |
|
|
if(trigger_property != 0) { |
|
|
tr = icalproperty_get_trigger(trigger_property); |
|
|
tr = icalproperty_get_trigger(trigger_property); |
|
|
if (!icaltime_is_null_time(tr.time)) { |
|
|
if (!icaltime_is_null_time(tr.time)) { |
|
|
trigger = ical::trigger_type::ABSOLUTE; |
|
|
|
|
|
|
|
|
m_trigger = ical::trigger_type::ABSOLUTE; |
|
|
|
|
|
DEBUG << icaltime_as_ical_string(tr.time); |
|
|
} else { |
|
|
} else { |
|
|
trigger = ical::trigger_type::RELATIVE; |
|
|
|
|
|
|
|
|
m_trigger = ical::trigger_type::RELATIVE; |
|
|
|
|
|
DEBUG << icaldurationtype_as_int(tr.duration); |
|
|
|
|
|
m_absolute_trigger = m_event_dtstart + icaldurationtype_as_int(tr.duration); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string Alarm::get_action() const { |
|
|
|
|
|
//switch(m_action) {
|
|
|
|
|
|
// case ical::action::DISPLAY: return "display";
|
|
|
|
|
|
// case ical::action::AUDIO: return "audio";
|
|
|
|
|
|
// case ical::action::EMAIL: return "email";
|
|
|
|
|
|
// case ical::action::PROC: return "proc";
|
|
|
|
|
|
// default: return "";
|
|
|
|
|
|
//}
|
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string Alarm::get_trigger_type() const { |
|
|
|
|
|
switch(m_trigger) { |
|
|
|
|
|
case ical::trigger_type::ABSOLUTE: return "absolute"; |
|
|
|
|
|
case ical::trigger_type::RELATIVE: return "relative"; |
|
|
|
|
|
default: return ""; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> Alarm::get_db_row() const { |
|
|
|
|
|
return {db_safe(get_action()), |
|
|
|
|
|
db_safe(m_description), |
|
|
|
|
|
db_safe(std::to_string(m_absolute_trigger))}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
std::string Alarm::print() const { |
|
|
std::string Alarm::print() const { |
|
|
std::string s = ""; |
|
|
std::string s = ""; |
|
|
s += "DESCRIPTION: " + description + "\n"; |
|
|
|
|
|
s += trigger == ical::trigger_type::ABSOLUTE ? "ABSOLUTE: " : "RELATIVE: "; |
|
|
|
|
|
|
|
|
//s += "DESCRIPTION: " + m_description + "\n";
|
|
|
|
|
|
////s += m_trigger == ical::trigger_type::ABSOLUTE ? "ABSOLUTE: " : "RELATIVE: ";
|
|
|
|
|
|
//s += "ABSOLUTE_TRIGGER: " + std::to_string(m_absolute_trigger) + "\n";
|
|
|
return s; |
|
|
return s; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |