aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-12-07 20:38:44 -0600
committerCharles Kerr <charles.kerr@canonical.com>2014-12-07 20:38:44 -0600
commit95bc85d108e3564d98f26b7ad17fcc72b2966371 (patch)
treead0d9724caab0b7badf49cd668ff22fce342b4ae /src
parent56e88207113e57eae7b24a718fa1ab177c6c9367 (diff)
downloadayatana-indicator-datetime-95bc85d108e3564d98f26b7ad17fcc72b2966371.tar.gz
ayatana-indicator-datetime-95bc85d108e3564d98f26b7ad17fcc72b2966371.tar.bz2
ayatana-indicator-datetime-95bc85d108e3564d98f26b7ad17fcc72b2966371.zip
ensure that disabled alarms aren't shown in indicator-datetime and that notifications aren't shown for them.
Diffstat (limited to 'src')
-rw-r--r--src/actions-live.cpp2
-rw-r--r--src/appointment.cpp6
-rw-r--r--src/engine-eds.cpp22
-rw-r--r--src/menu.cpp8
-rw-r--r--src/snap.cpp6
5 files changed, 27 insertions, 17 deletions
diff --git a/src/actions-live.cpp b/src/actions-live.cpp
index 1f4fc8c..7efc2b2 100644
--- a/src/actions-live.cpp
+++ b/src/actions-live.cpp
@@ -138,7 +138,7 @@ void LiveActions::phone_open_appointment(const Appointment& appt)
{
if (!appt.url.empty())
dispatch_url(appt.url);
- else if (appt.has_alarms)
+ else if (appt.is_ubuntu_alarm())
phone_open_alarm_app();
else
phone_open_calendar_app(DateTime::NowLocal());
diff --git a/src/appointment.cpp b/src/appointment.cpp
index f98e155..ae71459 100644
--- a/src/appointment.cpp
+++ b/src/appointment.cpp
@@ -29,12 +29,12 @@ namespace datetime {
bool Appointment::operator==(const Appointment& that) const
{
- return (color==that.color)
+ return (type==that.type)
+ && (uid==that.uid)
+ && (color==that.color)
&& (summary==that.summary)
&& (url==that.url)
&& (audio_url==that.audio_url)
- && (uid==that.uid)
- && (has_alarms==that.has_alarms)
&& (begin==that.begin)
&& (end==that.end);
}
diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp
index c282a5c..23e2883 100644
--- a/src/engine-eds.cpp
+++ b/src/engine-eds.cpp
@@ -33,6 +33,9 @@ namespace unity {
namespace indicator {
namespace datetime {
+static constexpr char const * TAG_ALARM {"x-canonical-alarm"};
+static constexpr char const * TAG_DISABLED {"x-canonical-disabled"};
+
/****
*****
****/
@@ -375,8 +378,6 @@ private:
static_cast<Impl*>(gself)->set_dirty_soon();
}
-private:
-
typedef std::function<void(const std::vector<Appointment>&)> appointment_func;
struct Task
@@ -425,7 +426,22 @@ private:
uid,
(int)status);
+ // look for the in-house tags
+ bool disabled = false;
+ Appointment::Type type = Appointment::EVENT;
+ GSList * categ_list = nullptr;
+ e_cal_component_get_categories_list (component, &categ_list);
+ for (GSList * l=categ_list; l!=nullptr; l=l->next) {
+ auto tag = static_cast<const char*>(l->data);
+ if (!g_strcmp0(tag, TAG_ALARM))
+ type = Appointment::UBUNTU_ALARM;
+ if (!g_strcmp0(tag, TAG_DISABLED))
+ disabled = true;
+ }
+ e_cal_component_free_categories_list(categ_list);
+
if ((uid != nullptr) &&
+ (!disabled) &&
(status != ICAL_STATUS_COMPLETED) &&
(status != ICAL_STATUS_CANCELLED))
{
@@ -441,12 +457,12 @@ private:
appointment.end = end_dt;
appointment.color = subtask->color;
appointment.uid = uid;
+ appointment.type = type;
// Look through all of this component's alarms
// for DISPLAY or AUDIO url attachments.
// If we find any, use them for appointment.url and audio_sound
auto alarm_uids = e_cal_component_get_alarm_uids(component);
- appointment.has_alarms = alarm_uids != nullptr;
for(auto walk=alarm_uids; appointment.url.empty() && walk!=nullptr; walk=walk->next)
{
auto alarm = e_cal_component_get_alarm(component, static_cast<const char*>(walk->data));
diff --git a/src/menu.cpp b/src/menu.cpp
index 6dcac27..f11de77 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -316,7 +316,7 @@ private:
g_menu_item_set_attribute (menu_item, "x-canonical-time", "x", unix_time);
g_menu_item_set_attribute (menu_item, "x-canonical-time-format", "s", fmt.c_str());
- if (appt.has_alarms)
+ if (appt.is_ubuntu_alarm())
{
g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.alarm");
g_menu_item_set_attribute_value(menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
@@ -509,16 +509,16 @@ protected:
GVariant* create_header_state()
{
// are there alarms?
- bool has_alarms = false;
+ bool has_ubuntu_alarms = false;
for(const auto& appointment : m_upcoming)
- if((has_alarms = appointment.has_alarms))
+ if((has_ubuntu_alarms = appointment.is_ubuntu_alarm()))
break;
GVariantBuilder b;
g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string (_("Time & Date")));
g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
- if (has_alarms)
+ if (has_ubuntu_alarms)
{
auto label = m_formatter->header.get();
auto a11y = g_strdup_printf(_("%s (has alarms)"), label.c_str());
diff --git a/src/snap.cpp b/src/snap.cpp
index f84d9b3..6d2957d 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -63,12 +63,6 @@ public:
appointment_func snooze,
appointment_func ok)
{
- if (!appointment.has_alarms)
- {
- ok(appointment);
- return;
- }
-
// force the system to stay awake
auto awake = std::make_shared<uin::Awake>(m_engine->app_name());