Merge lp:~charlesk/indicator-datetime/lp-1426519-add-tag-for-menuitem-activation-url into lp:indicator-datetime/15.10

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 411
Merged at revision: 412
Proposed branch: lp:~charlesk/indicator-datetime/lp-1426519-add-tag-for-menuitem-activation-url
Merge into: lp:indicator-datetime/15.10
Diff against target: 246 lines (+175/-5)
5 files modified
src/engine-eds.cpp (+24/-5)
tests/CMakeLists.txt (+1/-0)
tests/test-eds-tasks-config-files/.config/evolution/sources/system-proxy.source (+21/-0)
tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system/tasks.ics (+28/-0)
tests/test-eds-tasks.cpp (+101/-0)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1426519-add-tag-for-menuitem-activation-url
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+258301@code.launchpad.net

Commit message

If the "X-CANONICAL-ACTIVATION-URL" x-prop is defined in the VTODO or VEVENT, use it for url delegation.

Description of the change

Sibling 15.04 MP: https://code.launchpad.net/~charlesk/indicator-datetime/lp-1426519-add-tag-for-menuitem-activation-url/+merge/253997

If the "X-CANONICAL-ACTIVATION-URL" x-prop is defined in the VTODO or VEVENT, use it for url delegation.

Since no clients are using this key yet, a little white-box testing is necessary:

Steps
1. in clock-app, create a repeating alarm
2. $ stop indicator-datetime
3. $ pkill -f evolution-calendar-factory
4. Edit ~/.local/share/evolution/tasks/${some-unique-epoch-id-generated-by-evolution}/tasks.ics:
   After the line "BEGIN:VTODO^M", insert a new line:
   X-CANONICAL-ACTIVATION-URL:http://www.canonical.com/^M
5. $ start indicator-datetime
6. pull down the indicator menu
7. click on the alarm that you edited in step 4

Expected result:
Browser should launch to http://www.canonical.com/

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) :
review: Approve
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 'src/engine-eds.cpp'
2--- src/engine-eds.cpp 2015-04-06 19:58:34 +0000
3+++ src/engine-eds.cpp 2015-05-08 00:22:35 +0000
4@@ -34,9 +34,11 @@
5 namespace indicator {
6 namespace datetime {
7
8-static constexpr char const * TAG_ALARM {"x-canonical-alarm"};
9+static constexpr char const * TAG_ALARM {"x-canonical-alarm"};
10 static constexpr char const * TAG_DISABLED {"x-canonical-disabled"};
11
12+static constexpr char const * X_PROP_ACTIVATION_URL {"X-CANONICAL-ACTIVATION-URL"};
13+
14 /****
15 *****
16 ****/
17@@ -537,22 +539,39 @@
18 if (text.value)
19 appointment.summary = text.value;
20
21+ auto icc = e_cal_component_get_icalcomponent(component); // component owns icc
22+ if (icc)
23+ {
24+ g_debug("%s", icalcomponent_as_ical_string(icc)); // libical owns this string; no leak
25+
26+ auto icalprop = icalcomponent_get_first_property(icc, ICAL_X_PROPERTY);
27+ while (icalprop)
28+ {
29+ const char * x_name = icalproperty_get_x_name(icalprop);
30+ if ((x_name != nullptr) && !g_ascii_strcasecmp(x_name, X_PROP_ACTIVATION_URL))
31+ {
32+ const char * url = icalproperty_get_value_as_string(icalprop);
33+ if ((url != nullptr) && appointment.activation_url.empty())
34+ appointment.activation_url = url;
35+ }
36+
37+ icalprop = icalcomponent_get_next_property(icc, ICAL_X_PROPERTY);
38+ }
39+ }
40+
41 appointment.begin = begin_dt;
42 appointment.end = end_dt;
43 appointment.color = subtask->color;
44 appointment.uid = uid;
45 appointment.type = type;
46
47- icalcomponent * icc = e_cal_component_get_icalcomponent(component);
48- g_debug("%s", icalcomponent_as_ical_string(icc)); // libical owns this string; no leak
49-
50 auto e_alarms = e_cal_util_generate_alarms_for_comp(component,
51 subtask->begin,
52 subtask->end,
53 const_cast<ECalComponentAlarmAction*>(omit.data()),
54 e_cal_client_resolve_tzid_cb,
55 subtask->client,
56- subtask->default_timezone);
57+ nullptr);
58
59 std::map<DateTime,Alarm> alarms;
60
61
62=== modified file 'tests/CMakeLists.txt'
63--- tests/CMakeLists.txt 2015-04-06 00:19:01 +0000
64+++ tests/CMakeLists.txt 2015-05-08 00:22:35 +0000
65@@ -93,6 +93,7 @@
66 ${GVFSD} # arg7: gvfsd exec
67 ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}-config-files) # arg8: canned config files
68 endfunction()
69+add_eds_test_by_name(test-eds-tasks)
70 add_eds_test_by_name(test-eds-valarms)
71
72
73
74=== added directory 'tests/test-eds-tasks-config-files'
75=== added directory 'tests/test-eds-tasks-config-files/.config'
76=== added directory 'tests/test-eds-tasks-config-files/.config/evolution'
77=== added directory 'tests/test-eds-tasks-config-files/.config/evolution/sources'
78=== added file 'tests/test-eds-tasks-config-files/.config/evolution/sources/system-proxy.source'
79--- tests/test-eds-tasks-config-files/.config/evolution/sources/system-proxy.source 1970-01-01 00:00:00 +0000
80+++ tests/test-eds-tasks-config-files/.config/evolution/sources/system-proxy.source 2015-05-08 00:22:35 +0000
81@@ -0,0 +1,21 @@
82+
83+[Data Source]
84+DisplayName=Default Proxy Settings
85+Enabled=true
86+Parent=
87+
88+[Proxy]
89+Method=default
90+IgnoreHosts=localhost;127.0.0.0/8;::1;
91+AutoconfigUrl=
92+FtpHost=
93+FtpPort=0
94+HttpAuthPassword=
95+HttpAuthUser=
96+HttpHost=
97+HttpPort=8080
98+HttpUseAuth=false
99+HttpsHost=
100+HttpsPort=0
101+SocksHost=
102+SocksPort=0
103
104=== added directory 'tests/test-eds-tasks-config-files/.local'
105=== added directory 'tests/test-eds-tasks-config-files/.local/share'
106=== added directory 'tests/test-eds-tasks-config-files/.local/share/evolution'
107=== added directory 'tests/test-eds-tasks-config-files/.local/share/evolution/tasks'
108=== added directory 'tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system'
109=== added file 'tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system/tasks.ics'
110--- tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system/tasks.ics 1970-01-01 00:00:00 +0000
111+++ tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system/tasks.ics 2015-05-08 00:22:35 +0000
112@@ -0,0 +1,28 @@
113+BEGIN:VCALENDAR
114+CALSCALE:GREGORIAN
115+PRODID:-//Ximian//NONSGML Evolution Calendar//EN
116+VERSION:2.0
117+X-EVOLUTION-DATA-REVISION:2015-05-07T21:14:49.315443Z(0)
118+BEGIN:VTODO
119+UID:20150507T211449Z-4262-32011-1418-1@ubuntu-phablet
120+DTSTAMP:20150508T211449Z
121+DTSTART:20150508T164000
122+RRULE:FREQ=WEEKLY;BYDAY=FR
123+SUMMARY:Alarm
124+CATEGORIES:x-canonical-alarm
125+CREATED:20150507T211449Z
126+LAST-MODIFIED:20150507T211449Z
127+BEGIN:VALARM
128+X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-2@ubuntu-phablet
129+ACTION:AUDIO
130+ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg
131+TRIGGER;VALUE=DURATION;RELATED=START:PT0S
132+END:VALARM
133+BEGIN:VALARM
134+X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-3@ubuntu-phablet
135+ACTION:DISPLAY
136+DESCRIPTION:Alarm
137+TRIGGER;VALUE=DURATION;RELATED=START:PT0S
138+END:VALARM
139+END:VTODO
140+END:VCALENDAR
141
142=== added file 'tests/test-eds-tasks.cpp'
143--- tests/test-eds-tasks.cpp 1970-01-01 00:00:00 +0000
144+++ tests/test-eds-tasks.cpp 2015-05-08 00:22:35 +0000
145@@ -0,0 +1,101 @@
146+/*
147+ * Copyright 2015 Canonical Ltd.
148+ *
149+ * This program is free software: you can redistribute it and/or modify it
150+ * under the terms of the GNU General Public License version 3, as published
151+ * by the Free Software Foundation.
152+ *
153+ * This program is distributed in the hope that it will be useful, but
154+ * WITHOUT ANY WARRANTY; without even the implied warranties of
155+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
156+ * PURPOSE. See the GNU General Public License for more details.
157+ *
158+ * You should have received a copy of the GNU General Public License along
159+ * with this program. If not, see <http://www.gnu.org/licenses/>.
160+ *
161+ * Authors:
162+ * Charles Kerr <charles.kerr@canonical.com>
163+ */
164+
165+#include <algorithm>
166+
167+#include <datetime/alarm-queue-simple.h>
168+#include <datetime/clock-mock.h>
169+#include <datetime/engine-eds.h>
170+#include <datetime/planner-range.h>
171+
172+#include <gtest/gtest.h>
173+
174+#include "glib-fixture.h"
175+#include "print-to.h"
176+#include "timezone-mock.h"
177+#include "wakeup-timer-mock.h"
178+
179+using namespace unity::indicator::datetime;
180+using VAlarmFixture = GlibFixture;
181+
182+/***
183+****
184+***/
185+
186+TEST_F(VAlarmFixture, MultipleAppointments)
187+{
188+ // start the EDS engine
189+ auto engine = std::make_shared<EdsEngine>();
190+
191+ // we need a consistent timezone for the planner and our local DateTimes
192+ constexpr char const * zone_str {"America/Chicago"};
193+ auto tz = std::make_shared<MockTimezone>(zone_str);
194+ auto gtz = g_time_zone_new(zone_str);
195+
196+ // make a planner that looks at the first half of 2015 in EDS
197+ auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
198+ const DateTime range_begin {gtz, 2015,1, 1, 0, 0, 0.0};
199+ const DateTime range_end {gtz, 2015,6,31,23,59,59.5};
200+ planner->range().set(std::make_pair(range_begin, range_end));
201+
202+ // give EDS a moment to load
203+ if (planner->appointments().get().empty()) {
204+ g_message("waiting a moment for EDS to load...");
205+ auto on_appointments_changed = [this](const std::vector<Appointment>& appointments){
206+ g_message("ah, they loaded");
207+ if (!appointments.empty())
208+ g_main_loop_quit(loop);
209+ };
210+ core::ScopedConnection conn(planner->appointments().changed().connect(on_appointments_changed));
211+ constexpr int max_wait_sec = 10;
212+ wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
213+ }
214+
215+ // what we expect to get...
216+ Appointment expected_appt;
217+ expected_appt.uid = "20150507T211449Z-4262-32011-1418-1@ubuntu-phablet";
218+ expected_appt.color = "#becedd";
219+ expected_appt.summary = "Alarm";
220+ std::array<Alarm,8> expected_alarms = {
221+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5, 8,16,40,0)}),
222+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5,15,16,40,0)}),
223+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5,22,16,40,0)}),
224+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5,29,16,40,0)}),
225+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6, 5,16,40,0)}),
226+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6,12,16,40,0)}),
227+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6,19,16,40,0)}),
228+ Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6,26,16,40,0)})
229+ };
230+
231+ // compare it to what we actually loaded...
232+ const auto appts = planner->appointments().get();
233+ EXPECT_EQ(expected_alarms.size(), appts.size());
234+ for (size_t i=0, n=expected_alarms.size(); i<n; i++) {
235+ const auto& appt = appts[i];
236+ EXPECT_EQ(expected_appt.uid, appt.uid);
237+ EXPECT_EQ(expected_appt.color, appt.color);
238+ EXPECT_EQ(expected_appt.summary, appt.summary);
239+ EXPECT_EQ(1, appt.alarms.size());
240+ EXPECT_EQ(expected_alarms[i], appt.alarms[0]);
241+ }
242+
243+
244+ // cleanup
245+ g_time_zone_unref(gtz);
246+}

Subscribers

People subscribed via source and target branches