aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--include/datetime/appointment.h5
-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
-rw-r--r--tests/manual10
-rw-r--r--tests/manual-test-snap.cpp2
-rw-r--r--tests/test-actions.cpp4
-rw-r--r--tests/test-alarm-queue.cpp4
-rw-r--r--tests/test-live-actions.cpp4
-rw-r--r--tests/test-menus.cpp8
-rw-r--r--tests/test-snap.cpp2
13 files changed, 53 insertions, 30 deletions
diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h
index 2e406a2..ab89c2f 100644
--- a/include/datetime/appointment.h
+++ b/include/datetime/appointment.h
@@ -35,12 +35,15 @@ namespace datetime {
struct Appointment
{
public:
+ enum Type { EVENT, UBUNTU_ALARM };
+ Type type = EVENT;
+ bool is_ubuntu_alarm() const { return type == UBUNTU_ALARM; }
+
std::string color;
std::string summary;
std::string url;
std::string uid;
std::string audio_url;
- bool has_alarms = false;
DateTime begin;
DateTime end;
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());
diff --git a/tests/manual b/tests/manual
index b14a061..2062fd1 100644
--- a/tests/manual
+++ b/tests/manual
@@ -38,6 +38,16 @@ Test-case indicator-datetime/new-alarm-wakeup
<dd>If the device supports haptic feedback, confirm the alarm vibrates.</dd>
</dl>
+Test-case indicator-datetime/disabled-alarms
+<dl>
+ <dt>Create and save an upcoming alarm in ubuntu-clock-app</dt>
+ <dd>Confirm that the alarm icon appears next to the current time in unity's indicator display</dd>
+ <dt>Disable the alarm in ubuntu-clock-app</dt>
+ <dd>When all alarms are disabled or removed, the alarm icon should disappear.</dd>
+ <dt>Re-enable the alarm in ubuntu-clock-app</dt>
+ <dd>When the alarm is enabled, the alarm icon should reappear.</dd>
+</dl>
+
Test-case indicator-datetime/alarm-timezone
<dl>
<dt>In ubuntu-system-settings, change your timezone to a zone you're not in</dt>
diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp
index d4d9ec9..e0aad89 100644
--- a/tests/manual-test-snap.cpp
+++ b/tests/manual-test-snap.cpp
@@ -69,7 +69,7 @@ int main(int argc, const char* argv[])
a.summary = "Alarm";
a.url = "alarm:///hello-world";
a.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
- a.has_alarms = true;
+ a.type = Appointment::UBUNTU_ALARM;
auto begin = g_date_time_new_local(2014,12,25,0,0,0);
auto end = g_date_time_add_full(begin,0,0,1,0,0,-1);
a.begin = begin;
diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp
index aefeac0..fc89426 100644
--- a/tests/test-actions.cpp
+++ b/tests/test-actions.cpp
@@ -39,7 +39,7 @@ class ActionsFixture: public StateFixture
a1.summary = "Alarm";
a1.summary = "http://www.example.com/";
a1.uid = "example";
- a1.has_alarms = true;
+ a1.type = Appointment::UBUNTU_ALARM;
a1.begin = a1.end = tomorrow;
Appointment a2; // a non-alarm appointment
@@ -47,7 +47,7 @@ class ActionsFixture: public StateFixture
a2.summary = "Other Text";
a2.summary = "http://www.monkey.com/";
a2.uid = "monkey";
- a2.has_alarms = false;
+ a1.type = Appointment::EVENT;
a2.begin = a2.end = tomorrow;
return std::vector<Appointment>({a1, a2});
diff --git a/tests/test-alarm-queue.cpp b/tests/test-alarm-queue.cpp
index d2de8ac..12ffe92 100644
--- a/tests/test-alarm-queue.cpp
+++ b/tests/test-alarm-queue.cpp
@@ -80,7 +80,7 @@ protected:
a1.summary = "Alarm";
a1.summary = "http://www.example.com/";
a1.uid = "example";
- a1.has_alarms = true;
+ a1.type = Appointment::UBUNTU_ALARM;
a1.begin = tomorrow_begin;
a1.end = tomorrow_end;
@@ -92,7 +92,7 @@ protected:
a2.summary = "Other Text";
a2.summary = "http://www.monkey.com/";
a2.uid = "monkey";
- a2.has_alarms = false;
+ a1.type = Appointment::EVENT;
a2.begin = ubermorgen_begin;
a2.end = ubermorgen_end;
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index 2cd6eef..1197e3e 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -312,11 +312,11 @@ TEST_F(LiveActionsFixture, PhoneOpenAppointment)
a.uid = "some-uid";
a.begin = DateTime::NowLocal();
- a.has_alarms = false;
+ a.type = Appointment::EVENT;
m_actions->phone_open_appointment(a);
EXPECT_EQ(calendar_app_url, m_live_actions->last_url);
- a.has_alarms = true;
+ a.type = Appointment::UBUNTU_ALARM;
m_actions->phone_open_appointment(a);
EXPECT_EQ(clock_app_url, m_live_actions->last_url);
diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp
index 363a132..e0e63ac 100644
--- a/tests/test-menus.cpp
+++ b/tests/test-menus.cpp
@@ -191,7 +191,7 @@ private:
a1.summary = "Alarm";
a1.summary = "http://www.example.com/";
a1.uid = "example";
- a1.has_alarms = true;
+ a1.type = Appointment::UBUNTU_ALARM;
a1.begin = a1.end = tomorrow;
Appointment a2; // a non-alarm appointment
@@ -199,7 +199,7 @@ private:
a2.summary = "Other Text";
a2.summary = "http://www.monkey.com/";
a2.uid = "monkey";
- a2.has_alarms = false;
+ a1.type = Appointment::EVENT;
a2.begin = a2.end = tomorrow;
return std::vector<Appointment>({a1, a2});
@@ -212,7 +212,7 @@ private:
// confirm it has the right x-canonical-type
gchar * str = nullptr;
g_menu_model_get_item_attribute(section, index, "x-canonical-type", "s", &str);
- if (appt.has_alarms)
+ if (appt.is_ubuntu_alarm())
EXPECT_STREQ("com.canonical.indicator.alarm", str);
else
EXPECT_STREQ("com.canonical.indicator.appointment", str);
@@ -245,7 +245,7 @@ private:
g_clear_pointer(&str, g_free);
// confirm that alarms have an icon
- if (appt.has_alarms)
+ if (appt.is_ubuntu_alarm())
{
auto v = g_menu_model_get_item_attribute_value(section,
index,
diff --git a/tests/test-snap.cpp b/tests/test-snap.cpp
index 21202f4..972c493 100644
--- a/tests/test-snap.cpp
+++ b/tests/test-snap.cpp
@@ -108,7 +108,7 @@ protected:
appt.summary = "Alarm";
appt.url = "alarm:///hello-world";
appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
- appt.has_alarms = true;
+ appt.type = Appointment::EVENT;
auto begin = g_date_time_new_local(2014,12,25,0,0,0);
auto end = g_date_time_add_full(begin,0,0,1,0,0,-1);
appt.begin = begin;