diff options
Diffstat (limited to 'src/engine-eds.cpp')
-rw-r--r-- | src/engine-eds.cpp | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp index 4396d45..7a61fc0 100644 --- a/src/engine-eds.cpp +++ b/src/engine-eds.cpp @@ -1,6 +1,6 @@ /* * Copyright 2014 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -19,6 +19,10 @@ * Robert Tari <robert@tari.in> */ +#ifndef ALARM_DEFAULT_SOUND +#define ALARM_DEFAULT_SOUND "dummy" +#endif + #include <datetime/engine-eds.h> #include <datetime/myself.h> #include <libical/ical.h> @@ -48,7 +52,7 @@ class EdsEngine::Impl { public: - Impl(const std::shared_ptr<Myself> &myself) + explicit Impl(const std::shared_ptr<Myself> &myself) : m_myself(myself) { auto cancellable_deleter = [](GCancellable * c) { @@ -473,14 +477,14 @@ private: // for each component.. for (auto l=components; l!=nullptr; l=l->next) { - bool changed = false; + bool bChanged = false; // for each alarm... auto component = E_CAL_COMPONENT(l->data); auto auids = e_cal_component_get_alarm_uids(component); - for(auto l=auids; l!=nullptr; l=l->next) + for(auto lAlarms=auids; lAlarms!=nullptr; lAlarms=lAlarms->next) { - auto auid = static_cast<const char*>(l->data); + auto auid = static_cast<const char*>(lAlarms->data); auto alarm = e_cal_component_get_alarm(component, auid); if (alarm == nullptr) continue; @@ -490,13 +494,13 @@ private: { e_cal_component_remove_alarm (component, auid); e_cal_component_add_alarm (component, new_alarm); - changed = true; + bChanged = true; g_clear_pointer (&new_alarm, e_cal_component_alarm_free); } } g_slist_free_full (auids, g_free); - if (changed) + if (bChanged) { auto icc = e_cal_component_get_icalcomponent(component); // icc owned by ecc modify_slist = g_slist_prepend(modify_slist, icc); @@ -631,19 +635,18 @@ private: auto action = e_cal_component_alarm_get_action(alarm); if (action == E_CAL_COMPONENT_ALARM_AUDIO) { - ICalAttach *attach = nullptr; auto attachments = e_cal_component_alarm_get_attachments(alarm); - if (attachments != nullptr && attachments->next != nullptr) - attach = I_CAL_ATTACH (attachments->data); + for (; attachments != nullptr; attachments = attachments->next) { + ICalAttach *attach = I_CAL_ATTACH (attachments->data); - if (attach != nullptr) - { - if (i_cal_attach_get_is_url (attach)) + if (attach != nullptr && i_cal_attach_get_is_url (attach)) { const char* url = i_cal_attach_get_url(attach); - if (url != nullptr) + if (url != nullptr) { ret = url; + break; + } } } if (ret.empty()) @@ -1071,6 +1074,34 @@ private: } g_slist_free_full(categ_list, g_free); + // Get the colour - we might need this override in the future + + /*if (icc) + { + ECalComponentPropertyBag *pBag = e_cal_component_property_bag_new_from_component (icc, NULL, NULL); + + if (pBag) + { + guint nProperties = e_cal_component_property_bag_get_count (pBag); + + for (guint nProperty = 0; nProperty < nProperties; nProperty++) + { + ICalProperty *pProperty = e_cal_component_property_bag_get (pBag, nProperty); + gchar *sName = i_cal_property_get_property_name (pProperty); + gboolean bColour = !g_strcmp0 (sName, "COLOR"); + + if (bColour) + { + baseline.color = i_cal_property_get_value_as_string (pProperty); + + break; + } + } + + e_cal_component_property_bag_free (pBag); + } + }*/ + g_debug("%s got appointment from %s to %s: %s", G_STRLOC, baseline.begin.format("%F %T %z").c_str(), baseline.end.format("%F %T %z").c_str(), @@ -1127,9 +1158,9 @@ private: alarm.text = get_alarm_text(a); if (alarm.audio_url.empty()) - alarm.audio_url = get_alarm_sound_url(a, (baseline.is_alarm() ? - "file://" ALARM_DEFAULT_SOUND : - "file://" CALENDAR_DEFAULT_SOUND)); + { + alarm.audio_url = get_alarm_sound_url(a, (baseline.is_alarm() ? "file://" ALARM_DEFAULT_SOUND : "file://" CALENDAR_DEFAULT_SOUND)); + } if (!alarm.time.is_set()) alarm.time = trigger_time; |