Merge lp:~charlesk/indicator-datetime/lp-1387231-honor-x-canonical-disabled-tag into lp:indicator-datetime/15.04

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 389
Merged at revision: 390
Proposed branch: lp:~charlesk/indicator-datetime/lp-1387231-honor-x-canonical-disabled-tag
Merge into: lp:indicator-datetime/15.04
Diff against target: 312 lines (+53/-30)
13 files modified
include/datetime/appointment.h (+4/-1)
src/actions-live.cpp (+1/-1)
src/appointment.cpp (+3/-3)
src/engine-eds.cpp (+19/-3)
src/menu.cpp (+4/-4)
src/snap.cpp (+0/-6)
tests/manual (+10/-0)
tests/manual-test-snap.cpp (+1/-1)
tests/test-actions.cpp (+2/-2)
tests/test-alarm-queue.cpp (+2/-2)
tests/test-live-actions.cpp (+2/-2)
tests/test-menus.cpp (+4/-4)
tests/test-snap.cpp (+1/-1)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1387231-honor-x-canonical-disabled-tag
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+243938@code.launchpad.net

Commit message

Add support for x-canonical-alarm and x-canonical-disabled tags in VTODO categories so that disabled alarms will not be displayed.

Description of the change

Description of the Change
=========================

This culls the fix for bug #1387231 from my development branch so that it's easier to review and to backport in isolation.

This piece adds support for noticing the x-canonical-alarm and x-canonical-disabled tags in VTODO's categories so that the indicator will know to not show disabled alarms.

Checklist
=========

> Are there any related MPs required for this MP to build/function as expected? Please list.

No

> Is your branch in sync with latest trunk? (e.g. bzr pull lp:trunk -> no changes)

Yes

> Did the code build without warnings?

Yes

> Did the tests run successfully?

Yes

> Did you perform an exploratory manual test run of your code change and any related functionality?

Yes

> If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

N/A

> What device (or emulator) has your component test plan been executed successfully on?

Krillin running ubuntu-touch/ubuntu-rtm/14.09

> What manual tests are relevant for this MP?

indicator-datetime/disabled-alarms

> Did you include a link to the MR Review Checklist Template to make your reviewer's life easier?

https://wiki.ubuntu.com/Process/Merges/Checklists/indicator-datetime

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Makes sense.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/datetime/appointment.h'
2--- include/datetime/appointment.h 2014-06-24 01:26:09 +0000
3+++ include/datetime/appointment.h 2014-12-08 03:05:37 +0000
4@@ -35,12 +35,15 @@
5 struct Appointment
6 {
7 public:
8+ enum Type { EVENT, UBUNTU_ALARM };
9+ Type type = EVENT;
10+ bool is_ubuntu_alarm() const { return type == UBUNTU_ALARM; }
11+
12 std::string color;
13 std::string summary;
14 std::string url;
15 std::string uid;
16 std::string audio_url;
17- bool has_alarms = false;
18 DateTime begin;
19 DateTime end;
20
21
22=== modified file 'src/actions-live.cpp'
23--- src/actions-live.cpp 2014-03-25 21:28:54 +0000
24+++ src/actions-live.cpp 2014-12-08 03:05:37 +0000
25@@ -138,7 +138,7 @@
26 {
27 if (!appt.url.empty())
28 dispatch_url(appt.url);
29- else if (appt.has_alarms)
30+ else if (appt.is_ubuntu_alarm())
31 phone_open_alarm_app();
32 else
33 phone_open_calendar_app(DateTime::NowLocal());
34
35=== modified file 'src/appointment.cpp'
36--- src/appointment.cpp 2014-10-07 18:45:03 +0000
37+++ src/appointment.cpp 2014-12-08 03:05:37 +0000
38@@ -29,12 +29,12 @@
39
40 bool Appointment::operator==(const Appointment& that) const
41 {
42- return (color==that.color)
43+ return (type==that.type)
44+ && (uid==that.uid)
45+ && (color==that.color)
46 && (summary==that.summary)
47 && (url==that.url)
48 && (audio_url==that.audio_url)
49- && (uid==that.uid)
50- && (has_alarms==that.has_alarms)
51 && (begin==that.begin)
52 && (end==that.end);
53 }
54
55=== modified file 'src/engine-eds.cpp'
56--- src/engine-eds.cpp 2014-09-17 16:51:51 +0000
57+++ src/engine-eds.cpp 2014-12-08 03:05:37 +0000
58@@ -33,6 +33,9 @@
59 namespace indicator {
60 namespace datetime {
61
62+static constexpr char const * TAG_ALARM {"x-canonical-alarm"};
63+static constexpr char const * TAG_DISABLED {"x-canonical-disabled"};
64+
65 /****
66 *****
67 ****/
68@@ -375,8 +378,6 @@
69 static_cast<Impl*>(gself)->set_dirty_soon();
70 }
71
72-private:
73-
74 typedef std::function<void(const std::vector<Appointment>&)> appointment_func;
75
76 struct Task
77@@ -425,7 +426,22 @@
78 uid,
79 (int)status);
80
81+ // look for the in-house tags
82+ bool disabled = false;
83+ Appointment::Type type = Appointment::EVENT;
84+ GSList * categ_list = nullptr;
85+ e_cal_component_get_categories_list (component, &categ_list);
86+ for (GSList * l=categ_list; l!=nullptr; l=l->next) {
87+ auto tag = static_cast<const char*>(l->data);
88+ if (!g_strcmp0(tag, TAG_ALARM))
89+ type = Appointment::UBUNTU_ALARM;
90+ if (!g_strcmp0(tag, TAG_DISABLED))
91+ disabled = true;
92+ }
93+ e_cal_component_free_categories_list(categ_list);
94+
95 if ((uid != nullptr) &&
96+ (!disabled) &&
97 (status != ICAL_STATUS_COMPLETED) &&
98 (status != ICAL_STATUS_CANCELLED))
99 {
100@@ -441,12 +457,12 @@
101 appointment.end = end_dt;
102 appointment.color = subtask->color;
103 appointment.uid = uid;
104+ appointment.type = type;
105
106 // Look through all of this component's alarms
107 // for DISPLAY or AUDIO url attachments.
108 // If we find any, use them for appointment.url and audio_sound
109 auto alarm_uids = e_cal_component_get_alarm_uids(component);
110- appointment.has_alarms = alarm_uids != nullptr;
111 for(auto walk=alarm_uids; appointment.url.empty() && walk!=nullptr; walk=walk->next)
112 {
113 auto alarm = e_cal_component_get_alarm(component, static_cast<const char*>(walk->data));
114
115=== modified file 'src/menu.cpp'
116--- src/menu.cpp 2014-10-03 19:22:31 +0000
117+++ src/menu.cpp 2014-12-08 03:05:37 +0000
118@@ -316,7 +316,7 @@
119 g_menu_item_set_attribute (menu_item, "x-canonical-time", "x", unix_time);
120 g_menu_item_set_attribute (menu_item, "x-canonical-time-format", "s", fmt.c_str());
121
122- if (appt.has_alarms)
123+ if (appt.is_ubuntu_alarm())
124 {
125 g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.alarm");
126 g_menu_item_set_attribute_value(menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
127@@ -509,16 +509,16 @@
128 GVariant* create_header_state()
129 {
130 // are there alarms?
131- bool has_alarms = false;
132+ bool has_ubuntu_alarms = false;
133 for(const auto& appointment : m_upcoming)
134- if((has_alarms = appointment.has_alarms))
135+ if((has_ubuntu_alarms = appointment.is_ubuntu_alarm()))
136 break;
137
138 GVariantBuilder b;
139 g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
140 g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string (_("Time & Date")));
141 g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
142- if (has_alarms)
143+ if (has_ubuntu_alarms)
144 {
145 auto label = m_formatter->header.get();
146 auto a11y = g_strdup_printf(_("%s (has alarms)"), label.c_str());
147
148=== modified file 'src/snap.cpp'
149--- src/snap.cpp 2014-09-17 17:30:48 +0000
150+++ src/snap.cpp 2014-12-08 03:05:37 +0000
151@@ -63,12 +63,6 @@
152 appointment_func snooze,
153 appointment_func ok)
154 {
155- if (!appointment.has_alarms)
156- {
157- ok(appointment);
158- return;
159- }
160-
161 // force the system to stay awake
162 auto awake = std::make_shared<uin::Awake>(m_engine->app_name());
163
164
165=== modified file 'tests/manual'
166--- tests/manual 2014-11-03 21:03:54 +0000
167+++ tests/manual 2014-12-08 03:05:37 +0000
168@@ -38,6 +38,16 @@
169 <dd>If the device supports haptic feedback, confirm the alarm vibrates.</dd>
170 </dl>
171
172+Test-case indicator-datetime/disabled-alarms
173+<dl>
174+ <dt>Create and save an upcoming alarm in ubuntu-clock-app</dt>
175+ <dd>Confirm that the alarm icon appears next to the current time in unity's indicator display</dd>
176+ <dt>Disable the alarm in ubuntu-clock-app</dt>
177+ <dd>When all alarms are disabled or removed, the alarm icon should disappear.</dd>
178+ <dt>Re-enable the alarm in ubuntu-clock-app</dt>
179+ <dd>When the alarm is enabled, the alarm icon should reappear.</dd>
180+</dl>
181+
182 Test-case indicator-datetime/alarm-timezone
183 <dl>
184 <dt>In ubuntu-system-settings, change your timezone to a zone you're not in</dt>
185
186=== modified file 'tests/manual-test-snap.cpp'
187--- tests/manual-test-snap.cpp 2014-09-17 16:51:51 +0000
188+++ tests/manual-test-snap.cpp 2014-12-08 03:05:37 +0000
189@@ -69,7 +69,7 @@
190 a.summary = "Alarm";
191 a.url = "alarm:///hello-world";
192 a.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
193- a.has_alarms = true;
194+ a.type = Appointment::UBUNTU_ALARM;
195 auto begin = g_date_time_new_local(2014,12,25,0,0,0);
196 auto end = g_date_time_add_full(begin,0,0,1,0,0,-1);
197 a.begin = begin;
198
199=== modified file 'tests/test-actions.cpp'
200--- tests/test-actions.cpp 2014-09-17 16:51:51 +0000
201+++ tests/test-actions.cpp 2014-12-08 03:05:37 +0000
202@@ -39,7 +39,7 @@
203 a1.summary = "Alarm";
204 a1.summary = "http://www.example.com/";
205 a1.uid = "example";
206- a1.has_alarms = true;
207+ a1.type = Appointment::UBUNTU_ALARM;
208 a1.begin = a1.end = tomorrow;
209
210 Appointment a2; // a non-alarm appointment
211@@ -47,7 +47,7 @@
212 a2.summary = "Other Text";
213 a2.summary = "http://www.monkey.com/";
214 a2.uid = "monkey";
215- a2.has_alarms = false;
216+ a1.type = Appointment::EVENT;
217 a2.begin = a2.end = tomorrow;
218
219 return std::vector<Appointment>({a1, a2});
220
221=== modified file 'tests/test-alarm-queue.cpp'
222--- tests/test-alarm-queue.cpp 2014-04-25 03:34:42 +0000
223+++ tests/test-alarm-queue.cpp 2014-12-08 03:05:37 +0000
224@@ -80,7 +80,7 @@
225 a1.summary = "Alarm";
226 a1.summary = "http://www.example.com/";
227 a1.uid = "example";
228- a1.has_alarms = true;
229+ a1.type = Appointment::UBUNTU_ALARM;
230 a1.begin = tomorrow_begin;
231 a1.end = tomorrow_end;
232
233@@ -92,7 +92,7 @@
234 a2.summary = "Other Text";
235 a2.summary = "http://www.monkey.com/";
236 a2.uid = "monkey";
237- a2.has_alarms = false;
238+ a1.type = Appointment::EVENT;
239 a2.begin = ubermorgen_begin;
240 a2.end = ubermorgen_end;
241
242
243=== modified file 'tests/test-live-actions.cpp'
244--- tests/test-live-actions.cpp 2014-09-17 16:51:51 +0000
245+++ tests/test-live-actions.cpp 2014-12-08 03:05:37 +0000
246@@ -312,11 +312,11 @@
247
248 a.uid = "some-uid";
249 a.begin = DateTime::NowLocal();
250- a.has_alarms = false;
251+ a.type = Appointment::EVENT;
252 m_actions->phone_open_appointment(a);
253 EXPECT_EQ(calendar_app_url, m_live_actions->last_url);
254
255- a.has_alarms = true;
256+ a.type = Appointment::UBUNTU_ALARM;
257 m_actions->phone_open_appointment(a);
258 EXPECT_EQ(clock_app_url, m_live_actions->last_url);
259
260
261=== modified file 'tests/test-menus.cpp'
262--- tests/test-menus.cpp 2014-09-17 16:51:51 +0000
263+++ tests/test-menus.cpp 2014-12-08 03:05:37 +0000
264@@ -191,7 +191,7 @@
265 a1.summary = "Alarm";
266 a1.summary = "http://www.example.com/";
267 a1.uid = "example";
268- a1.has_alarms = true;
269+ a1.type = Appointment::UBUNTU_ALARM;
270 a1.begin = a1.end = tomorrow;
271
272 Appointment a2; // a non-alarm appointment
273@@ -199,7 +199,7 @@
274 a2.summary = "Other Text";
275 a2.summary = "http://www.monkey.com/";
276 a2.uid = "monkey";
277- a2.has_alarms = false;
278+ a1.type = Appointment::EVENT;
279 a2.begin = a2.end = tomorrow;
280
281 return std::vector<Appointment>({a1, a2});
282@@ -212,7 +212,7 @@
283 // confirm it has the right x-canonical-type
284 gchar * str = nullptr;
285 g_menu_model_get_item_attribute(section, index, "x-canonical-type", "s", &str);
286- if (appt.has_alarms)
287+ if (appt.is_ubuntu_alarm())
288 EXPECT_STREQ("com.canonical.indicator.alarm", str);
289 else
290 EXPECT_STREQ("com.canonical.indicator.appointment", str);
291@@ -245,7 +245,7 @@
292 g_clear_pointer(&str, g_free);
293
294 // confirm that alarms have an icon
295- if (appt.has_alarms)
296+ if (appt.is_ubuntu_alarm())
297 {
298 auto v = g_menu_model_get_item_attribute_value(section,
299 index,
300
301=== modified file 'tests/test-snap.cpp'
302--- tests/test-snap.cpp 2014-09-17 16:51:51 +0000
303+++ tests/test-snap.cpp 2014-12-08 03:05:37 +0000
304@@ -108,7 +108,7 @@
305 appt.summary = "Alarm";
306 appt.url = "alarm:///hello-world";
307 appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
308- appt.has_alarms = true;
309+ appt.type = Appointment::EVENT;
310 auto begin = g_date_time_new_local(2014,12,25,0,0,0);
311 auto end = g_date_time_add_full(begin,0,0,1,0,0,-1);
312 appt.begin = begin;

Subscribers

People subscribed via source and target branches