diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2016-03-31 15:51:29 -0300 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-07-05 01:41:04 +0200 |
commit | b1031b1de834f246bba806cd51bfbb22f5c15b16 (patch) | |
tree | 721bedfc5523c1f124c32e850bdb3354928ec011 /src | |
parent | 7965d5b411db00de44f5c43dffac935e70347ec6 (diff) | |
download | ayatana-indicator-datetime-b1031b1de834f246bba806cd51bfbb22f5c15b16.tar.gz ayatana-indicator-datetime-b1031b1de834f246bba806cd51bfbb22f5c15b16.tar.bz2 ayatana-indicator-datetime-b1031b1de834f246bba806cd51bfbb22f5c15b16.zip |
Remove type property from Alarm.
Diffstat (limited to 'src')
-rw-r--r-- | src/appointment.cpp | 17 | ||||
-rw-r--r-- | src/engine-eds.cpp | 22 | ||||
-rw-r--r-- | src/snap.cpp | 5 |
3 files changed, 15 insertions, 29 deletions
diff --git a/src/appointment.cpp b/src/appointment.cpp index e014a85..ebd5a47 100644 --- a/src/appointment.cpp +++ b/src/appointment.cpp @@ -27,22 +27,21 @@ namespace datetime { ***** ****/ -Alarm::Alarm() - : type(Alarm::None) +bool Alarm::operator==(const Alarm& that) const { + return (text==that.text) + && (audio_url==that.audio_url) + && (this->time==that.time); } -Alarm::Alarm(int type_, const std::string &text_, const std::string& audio_url_, const DateTime &time_) - : type(type_), text(text_), audio_url(audio_url_), time(time_) +bool Alarm::has_sound() const { + return !audio_url.empty(); } -bool Alarm::operator==(const Alarm& that) const +bool Alarm::has_text() const { - return (type==that.type) - && (text==that.text) - && (audio_url==that.audio_url) - && (this->time==that.time); + return !text.empty(); } bool Appointment::operator==(const Appointment& that) const diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp index bd94251..68e2bdd 100644 --- a/src/engine-eds.cpp +++ b/src/engine-eds.cpp @@ -604,14 +604,13 @@ private: } }; - static std::string get_alarm_text(ECalComponentAlarm * alarm, bool * hasText) + static std::string get_alarm_text(ECalComponentAlarm * alarm) { 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) @@ -628,14 +627,14 @@ private: return ret; } - static std::string get_alarm_sound_url(ECalComponentAlarm * alarm, bool * hasSound) + static std::string get_alarm_sound_url(ECalComponentAlarm * alarm, const std::string & default_sound) { std::string ret; auto action = e_cal_component_alarm_get_action(alarm); if (action == E_CAL_COMPONENT_ALARM_AUDIO) { - *hasSound = true; + ret = default_sound; ICalAttach *attach = nullptr; auto attachments = e_cal_component_alarm_get_attachments(alarm); @@ -1138,23 +1137,16 @@ 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, &hasText); + alarm.text = get_alarm_text(a); if (alarm.audio_url.empty()) - alarm.audio_url = get_alarm_sound_url(a, &hasSound); + alarm.audio_url = get_alarm_sound_url(a, baseline.is_ubuntu_alarm() ? + ALARM_DEFAULT_SOUND : CALENDAR_DEFAULT_SOUND); 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); } @@ -1166,7 +1158,7 @@ private: appointment.alarms.reserve(i.second.size()); for (auto& j : i.second) { - if ((j.second.type & Alarm::TEXT) || (j.second.type & Alarm::SOUND)) + if (j.second.has_text() || (j.second.has_sound())) appointment.alarms.push_back(j.second); } subtask->task->appointments.push_back(appointment); diff --git a/src/snap.cpp b/src/snap.cpp index 72d68a2..97fcbab 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -226,11 +226,6 @@ private: }; std::string uri; - - // does not play any sound if alarm is not set as sound - if (!is_alarm && !(alarm.type & Alarm::SOUND)) - return uri; - for(const auto& candidate : candidates) { if (gst_uri_is_valid (candidate.c_str())) |