From dd4265f22ee05aab8dbe6d60f9c7a13f85818466 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 30 Mar 2016 16:52:02 -0300 Subject: Only play a sound alert if the event contains a SOUND reminder. --- src/engine-eds.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/engine-eds.cpp') diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp index becd40f..f3b08cd 100644 --- a/src/engine-eds.cpp +++ b/src/engine-eds.cpp @@ -604,13 +604,14 @@ private: } }; - static std::string get_alarm_text(ECalComponentAlarm * alarm) + static std::string get_alarm_text(ECalComponentAlarm * alarm, bool * hasText) { std::string ret; auto action = e_cal_component_alarm_get_action(alarm); if (action == E_CAL_COMPONENT_ALARM_DISPLAY) { + *hasText = true; auto text = e_cal_component_alarm_get_description(alarm); if (text != nullptr) @@ -627,13 +628,14 @@ private: return ret; } - static std::string get_alarm_sound_url(ECalComponentAlarm * alarm, const std::string & default_sound) + static std::string get_alarm_sound_url(ECalComponentAlarm * alarm, bool * hasSound) { std::string ret; auto action = e_cal_component_alarm_get_action(alarm); if (action == E_CAL_COMPONENT_ALARM_AUDIO) { + *hasSound = true; ICalAttach *attach = nullptr; auto attachments = e_cal_component_alarm_get_attachments(alarm); @@ -649,8 +651,6 @@ private: ret = url; } } - if (ret.empty()) - ret = default_sound; } return ret; @@ -1138,17 +1138,23 @@ private: DateTime{gtz, e_cal_component_alarm_instance_get_occur_end(ai)}); auto trigger_time = DateTime{gtz, e_cal_component_alarm_instance_get_time(ai)}; auto& alarm = alarms[instance_time][trigger_time]; + bool hasText = false; + bool hasSound = false; + if (alarm.text.empty()) - alarm.text = get_alarm_text(a); + alarm.text = get_alarm_text(a, &hasText); if (alarm.audio_url.empty()) - alarm.audio_url = get_alarm_sound_url(a, (baseline.is_ubuntu_alarm() ? - "file://" ALARM_DEFAULT_SOUND : - "file://" CALENDAR_DEFAULT_SOUND)); + alarm.audio_url = get_alarm_sound_url(a, &hasSound); if (!alarm.time.is_set()) alarm.time = trigger_time; + if (hasText) + alarm.type = alarm.type | Alarm::TEXT; + if (hasSound) + alarm.type = alarm.type | Alarm::SOUND; + e_cal_component_alarm_free(a); } @@ -1160,7 +1166,7 @@ private: appointment.alarms.reserve(i.second.size()); for (auto& j : i.second) { - if (j.second.has_text() || j.second.has_sound()) + if ((j.second.type & Alarm::TEXT) || (j.second.type & Alarm::SOUND)) appointment.alarms.push_back(j.second); } subtask->task->appointments.push_back(appointment); -- cgit v1.2.3