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

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 389
Merged at revision: 387
Proposed branch: lp:~charlesk/indicator-datetime/lp-1387231-honor-x-canonical-disabled-tag
Merge into: lp:indicator-datetime/rtm-14.09
Diff against target: 373 lines (+65/-40)
14 files modified
debian/changelog (+7/-0)
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 (+15/-10)
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
Review via email: mp+244251@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

Same MP as proposed for Vivid @ https://code.launchpad.net/~charlesk/indicator-datetime/lp-1387231-honor-x-canonical-disabled-tag/+merge/243938

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-proposed image 173

> 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
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-10-09 13:35:54 +0000
3+++ debian/changelog 2014-12-10 04:00:35 +0000
4@@ -1,3 +1,10 @@
5+indicator-datetime (13.10.0+15.04.20141103-0ubuntu1) vivid; urgency=low
6+
7+ [ Ted Gould ]
8+ * Small tag typo in integration test
9+
10+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 03 Nov 2014 21:04:05 +0000
11+
12 indicator-datetime (13.10.0+14.10.20141009-0ubuntu1) utopic; urgency=low
13
14 [ Charles Kerr ]
15
16=== modified file 'include/datetime/appointment.h'
17--- include/datetime/appointment.h 2014-06-24 01:26:09 +0000
18+++ include/datetime/appointment.h 2014-12-10 04:00:35 +0000
19@@ -35,12 +35,15 @@
20 struct Appointment
21 {
22 public:
23+ enum Type { EVENT, UBUNTU_ALARM };
24+ Type type = EVENT;
25+ bool is_ubuntu_alarm() const { return type == UBUNTU_ALARM; }
26+
27 std::string color;
28 std::string summary;
29 std::string url;
30 std::string uid;
31 std::string audio_url;
32- bool has_alarms = false;
33 DateTime begin;
34 DateTime end;
35
36
37=== modified file 'src/actions-live.cpp'
38--- src/actions-live.cpp 2014-03-25 21:28:54 +0000
39+++ src/actions-live.cpp 2014-12-10 04:00:35 +0000
40@@ -138,7 +138,7 @@
41 {
42 if (!appt.url.empty())
43 dispatch_url(appt.url);
44- else if (appt.has_alarms)
45+ else if (appt.is_ubuntu_alarm())
46 phone_open_alarm_app();
47 else
48 phone_open_calendar_app(DateTime::NowLocal());
49
50=== modified file 'src/appointment.cpp'
51--- src/appointment.cpp 2014-10-07 18:45:03 +0000
52+++ src/appointment.cpp 2014-12-10 04:00:35 +0000
53@@ -29,12 +29,12 @@
54
55 bool Appointment::operator==(const Appointment& that) const
56 {
57- return (color==that.color)
58+ return (type==that.type)
59+ && (uid==that.uid)
60+ && (color==that.color)
61 && (summary==that.summary)
62 && (url==that.url)
63 && (audio_url==that.audio_url)
64- && (uid==that.uid)
65- && (has_alarms==that.has_alarms)
66 && (begin==that.begin)
67 && (end==that.end);
68 }
69
70=== modified file 'src/engine-eds.cpp'
71--- src/engine-eds.cpp 2014-09-17 16:51:51 +0000
72+++ src/engine-eds.cpp 2014-12-10 04:00:35 +0000
73@@ -33,6 +33,9 @@
74 namespace indicator {
75 namespace datetime {
76
77+static constexpr char const * TAG_ALARM {"x-canonical-alarm"};
78+static constexpr char const * TAG_DISABLED {"x-canonical-disabled"};
79+
80 /****
81 *****
82 ****/
83@@ -375,8 +378,6 @@
84 static_cast<Impl*>(gself)->set_dirty_soon();
85 }
86
87-private:
88-
89 typedef std::function<void(const std::vector<Appointment>&)> appointment_func;
90
91 struct Task
92@@ -425,7 +426,22 @@
93 uid,
94 (int)status);
95
96+ // look for the in-house tags
97+ bool disabled = false;
98+ Appointment::Type type = Appointment::EVENT;
99+ GSList * categ_list = nullptr;
100+ e_cal_component_get_categories_list (component, &categ_list);
101+ for (GSList * l=categ_list; l!=nullptr; l=l->next) {
102+ auto tag = static_cast<const char*>(l->data);
103+ if (!g_strcmp0(tag, TAG_ALARM))
104+ type = Appointment::UBUNTU_ALARM;
105+ if (!g_strcmp0(tag, TAG_DISABLED))
106+ disabled = true;
107+ }
108+ e_cal_component_free_categories_list(categ_list);
109+
110 if ((uid != nullptr) &&
111+ (!disabled) &&
112 (status != ICAL_STATUS_COMPLETED) &&
113 (status != ICAL_STATUS_CANCELLED))
114 {
115@@ -441,12 +457,12 @@
116 appointment.end = end_dt;
117 appointment.color = subtask->color;
118 appointment.uid = uid;
119+ appointment.type = type;
120
121 // Look through all of this component's alarms
122 // for DISPLAY or AUDIO url attachments.
123 // If we find any, use them for appointment.url and audio_sound
124 auto alarm_uids = e_cal_component_get_alarm_uids(component);
125- appointment.has_alarms = alarm_uids != nullptr;
126 for(auto walk=alarm_uids; appointment.url.empty() && walk!=nullptr; walk=walk->next)
127 {
128 auto alarm = e_cal_component_get_alarm(component, static_cast<const char*>(walk->data));
129
130=== modified file 'src/menu.cpp'
131--- src/menu.cpp 2014-10-03 19:22:31 +0000
132+++ src/menu.cpp 2014-12-10 04:00:35 +0000
133@@ -316,7 +316,7 @@
134 g_menu_item_set_attribute (menu_item, "x-canonical-time", "x", unix_time);
135 g_menu_item_set_attribute (menu_item, "x-canonical-time-format", "s", fmt.c_str());
136
137- if (appt.has_alarms)
138+ if (appt.is_ubuntu_alarm())
139 {
140 g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.alarm");
141 g_menu_item_set_attribute_value(menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
142@@ -509,16 +509,16 @@
143 GVariant* create_header_state()
144 {
145 // are there alarms?
146- bool has_alarms = false;
147+ bool has_ubuntu_alarms = false;
148 for(const auto& appointment : m_upcoming)
149- if((has_alarms = appointment.has_alarms))
150+ if((has_ubuntu_alarms = appointment.is_ubuntu_alarm()))
151 break;
152
153 GVariantBuilder b;
154 g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
155 g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string (_("Time & Date")));
156 g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
157- if (has_alarms)
158+ if (has_ubuntu_alarms)
159 {
160 auto label = m_formatter->header.get();
161 auto a11y = g_strdup_printf(_("%s (has alarms)"), label.c_str());
162
163=== modified file 'src/snap.cpp'
164--- src/snap.cpp 2014-09-17 17:30:48 +0000
165+++ src/snap.cpp 2014-12-10 04:00:35 +0000
166@@ -63,12 +63,6 @@
167 appointment_func snooze,
168 appointment_func ok)
169 {
170- if (!appointment.has_alarms)
171- {
172- ok(appointment);
173- return;
174- }
175-
176 // force the system to stay awake
177 auto awake = std::make_shared<uin::Awake>(m_engine->app_name());
178
179
180=== modified file 'tests/manual'
181--- tests/manual 2014-10-09 13:35:42 +0000
182+++ tests/manual 2014-12-10 04:00:35 +0000
183@@ -25,7 +25,7 @@
184 Test-case indicator-datetime/timestamp-wakeup
185 <dl>
186 <dt>Unplug the phone from any USB connection and put it to sleep</dt>
187- <dd>Reawaken the device.</dt>
188+ <dt>Reawaken the device.</dt>
189 <dd>The indicator should be showing the correct time.</dd>
190 </dl>
191
192@@ -33,13 +33,21 @@
193 <dl>
194 <dt>Create and save an upcoming alarm in ubuntu-clock-app</dt>
195 <dt>Unplug the phone from any USB connection and put it to sleep</dt>
196- <dd>Confirm that the alarm sounds on time even if the phone is asleep.
197- (Note: if in doubt about sleep you can see in the syslog whether the
198- device actually suspended or whether the suspend was aborted)</dd>
199+ <dd>Confirm that the alarm sounds on time even if the phone is asleep. (Note: if in doubt about sleep you can see in the syslog whether the device actually suspended or whether the suspend was aborted)</dd>
200 <dd>Confirm that the screen comes on when the alarm is triggered.<dd>
201 <dd>If the device supports haptic feedback, confirm the alarm vibrates.</dd>
202 </dl>
203
204+Test-case indicator-datetime/disabled-alarms
205+<dl>
206+ <dt>Create and save an upcoming alarm in ubuntu-clock-app</dt>
207+ <dd>Confirm that the alarm icon appears next to the current time in unity's indicator display</dd>
208+ <dt>Disable the alarm in ubuntu-clock-app</dt>
209+ <dd>When all alarms are disabled or removed, the alarm icon should disappear.</dd>
210+ <dt>Re-enable the alarm in ubuntu-clock-app</dt>
211+ <dd>When the alarm is enabled, the alarm icon should reappear.</dd>
212+</dl>
213+
214 Test-case indicator-datetime/alarm-timezone
215 <dl>
216 <dt>In ubuntu-system-settings, change your timezone to a zone you're not in</dt>
217@@ -53,8 +61,7 @@
218 <dl>
219 <dt>Create and save an upcoming alarm in ubuntu-clock-app</dt>
220 <dt>When the alarm goes off, press the 'Snooze' button</dt>
221- <dd>The alarm should go away, then reappear N minutes later.
222- By default the N is 5 minutes but will be configurable from ubuntu-clock-app.</dd>
223+ <dd>The alarm should go away, then reappear N minutes later. By default the N is 5 minutes but will be configurable from ubuntu-clock-app.</dd>
224 <dt>When the snoozed alarm reappears, press the 'OK' button</dt>
225 <dd>This time when the alarm is dismissed, it should not reappear.</dd>
226 </dl>
227@@ -63,16 +70,14 @@
228 <dl>
229 <dt>Edit an alarm that's already passed. (see previous test)</dt>
230 <dt>Unplug the phone from any USB connection and put it to sleep</dt>
231- <dd>Confirm that the alarm sounds on time even if the phone is asleep.
232- (Note: if in doubt about sleep you can see in the syslog whether the
233- device actually suspended or whether the suspend was aborted)</dd>
234+ <dd>Confirm that the alarm sounds on time even if the phone is asleep. (Note: if in doubt about sleep you can see in the syslog whether the device actually suspended or whether the suspend was aborted)</dd>
235 <dd>Confirm that the screen comes on when the alarm is triggered.<dd>
236 <dd>If the device supports haptic feedback, confirm the alarm vibrates.</dd>
237 </dl>
238
239 Test-case indicator-datetime/tell-snap-decision-to-dismiss
240 <dl>
241- <dt>Set an alarm and wait for it to arrive.</td>
242+ <dt>Set an alarm and wait for it to arrive.</dt>
243 <dd>Alarm should go off at the specified time</dd>
244 <dt>Press the 'Dismiss' button in the alarm's snap decision popup before the sound stops.</dt>
245 <dd>Popup should disappear</dd>
246
247=== modified file 'tests/manual-test-snap.cpp'
248--- tests/manual-test-snap.cpp 2014-09-17 16:51:51 +0000
249+++ tests/manual-test-snap.cpp 2014-12-10 04:00:35 +0000
250@@ -69,7 +69,7 @@
251 a.summary = "Alarm";
252 a.url = "alarm:///hello-world";
253 a.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
254- a.has_alarms = true;
255+ a.type = Appointment::UBUNTU_ALARM;
256 auto begin = g_date_time_new_local(2014,12,25,0,0,0);
257 auto end = g_date_time_add_full(begin,0,0,1,0,0,-1);
258 a.begin = begin;
259
260=== modified file 'tests/test-actions.cpp'
261--- tests/test-actions.cpp 2014-09-17 16:51:51 +0000
262+++ tests/test-actions.cpp 2014-12-10 04:00:35 +0000
263@@ -39,7 +39,7 @@
264 a1.summary = "Alarm";
265 a1.summary = "http://www.example.com/";
266 a1.uid = "example";
267- a1.has_alarms = true;
268+ a1.type = Appointment::UBUNTU_ALARM;
269 a1.begin = a1.end = tomorrow;
270
271 Appointment a2; // a non-alarm appointment
272@@ -47,7 +47,7 @@
273 a2.summary = "Other Text";
274 a2.summary = "http://www.monkey.com/";
275 a2.uid = "monkey";
276- a2.has_alarms = false;
277+ a1.type = Appointment::EVENT;
278 a2.begin = a2.end = tomorrow;
279
280 return std::vector<Appointment>({a1, a2});
281
282=== modified file 'tests/test-alarm-queue.cpp'
283--- tests/test-alarm-queue.cpp 2014-04-25 03:34:42 +0000
284+++ tests/test-alarm-queue.cpp 2014-12-10 04:00:35 +0000
285@@ -80,7 +80,7 @@
286 a1.summary = "Alarm";
287 a1.summary = "http://www.example.com/";
288 a1.uid = "example";
289- a1.has_alarms = true;
290+ a1.type = Appointment::UBUNTU_ALARM;
291 a1.begin = tomorrow_begin;
292 a1.end = tomorrow_end;
293
294@@ -92,7 +92,7 @@
295 a2.summary = "Other Text";
296 a2.summary = "http://www.monkey.com/";
297 a2.uid = "monkey";
298- a2.has_alarms = false;
299+ a1.type = Appointment::EVENT;
300 a2.begin = ubermorgen_begin;
301 a2.end = ubermorgen_end;
302
303
304=== modified file 'tests/test-live-actions.cpp'
305--- tests/test-live-actions.cpp 2014-09-17 16:51:51 +0000
306+++ tests/test-live-actions.cpp 2014-12-10 04:00:35 +0000
307@@ -312,11 +312,11 @@
308
309 a.uid = "some-uid";
310 a.begin = DateTime::NowLocal();
311- a.has_alarms = false;
312+ a.type = Appointment::EVENT;
313 m_actions->phone_open_appointment(a);
314 EXPECT_EQ(calendar_app_url, m_live_actions->last_url);
315
316- a.has_alarms = true;
317+ a.type = Appointment::UBUNTU_ALARM;
318 m_actions->phone_open_appointment(a);
319 EXPECT_EQ(clock_app_url, m_live_actions->last_url);
320
321
322=== modified file 'tests/test-menus.cpp'
323--- tests/test-menus.cpp 2014-09-17 16:51:51 +0000
324+++ tests/test-menus.cpp 2014-12-10 04:00:35 +0000
325@@ -191,7 +191,7 @@
326 a1.summary = "Alarm";
327 a1.summary = "http://www.example.com/";
328 a1.uid = "example";
329- a1.has_alarms = true;
330+ a1.type = Appointment::UBUNTU_ALARM;
331 a1.begin = a1.end = tomorrow;
332
333 Appointment a2; // a non-alarm appointment
334@@ -199,7 +199,7 @@
335 a2.summary = "Other Text";
336 a2.summary = "http://www.monkey.com/";
337 a2.uid = "monkey";
338- a2.has_alarms = false;
339+ a1.type = Appointment::EVENT;
340 a2.begin = a2.end = tomorrow;
341
342 return std::vector<Appointment>({a1, a2});
343@@ -212,7 +212,7 @@
344 // confirm it has the right x-canonical-type
345 gchar * str = nullptr;
346 g_menu_model_get_item_attribute(section, index, "x-canonical-type", "s", &str);
347- if (appt.has_alarms)
348+ if (appt.is_ubuntu_alarm())
349 EXPECT_STREQ("com.canonical.indicator.alarm", str);
350 else
351 EXPECT_STREQ("com.canonical.indicator.appointment", str);
352@@ -245,7 +245,7 @@
353 g_clear_pointer(&str, g_free);
354
355 // confirm that alarms have an icon
356- if (appt.has_alarms)
357+ if (appt.is_ubuntu_alarm())
358 {
359 auto v = g_menu_model_get_item_attribute_value(section,
360 index,
361
362=== modified file 'tests/test-snap.cpp'
363--- tests/test-snap.cpp 2014-09-17 16:51:51 +0000
364+++ tests/test-snap.cpp 2014-12-10 04:00:35 +0000
365@@ -108,7 +108,7 @@
366 appt.summary = "Alarm";
367 appt.url = "alarm:///hello-world";
368 appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
369- appt.has_alarms = true;
370+ appt.type = Appointment::EVENT;
371 auto begin = g_date_time_new_local(2014,12,25,0,0,0);
372 auto end = g_date_time_add_full(begin,0,0,1,0,0,-1);
373 appt.begin = begin;

Subscribers

People subscribed via source and target branches