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
=== modified file 'src/engine-eds.cpp'
--- src/engine-eds.cpp 2015-04-06 19:58:34 +0000
+++ src/engine-eds.cpp 2015-05-08 00:22:35 +0000
@@ -34,9 +34,11 @@
34namespace indicator {34namespace indicator {
35namespace datetime {35namespace datetime {
3636
37static constexpr char const * TAG_ALARM {"x-canonical-alarm"};37static constexpr char const * TAG_ALARM {"x-canonical-alarm"};
38static constexpr char const * TAG_DISABLED {"x-canonical-disabled"};38static constexpr char const * TAG_DISABLED {"x-canonical-disabled"};
3939
40static constexpr char const * X_PROP_ACTIVATION_URL {"X-CANONICAL-ACTIVATION-URL"};
41
40/****42/****
41*****43*****
42****/44****/
@@ -537,22 +539,39 @@
537 if (text.value)539 if (text.value)
538 appointment.summary = text.value;540 appointment.summary = text.value;
539541
542 auto icc = e_cal_component_get_icalcomponent(component); // component owns icc
543 if (icc)
544 {
545 g_debug("%s", icalcomponent_as_ical_string(icc)); // libical owns this string; no leak
546
547 auto icalprop = icalcomponent_get_first_property(icc, ICAL_X_PROPERTY);
548 while (icalprop)
549 {
550 const char * x_name = icalproperty_get_x_name(icalprop);
551 if ((x_name != nullptr) && !g_ascii_strcasecmp(x_name, X_PROP_ACTIVATION_URL))
552 {
553 const char * url = icalproperty_get_value_as_string(icalprop);
554 if ((url != nullptr) && appointment.activation_url.empty())
555 appointment.activation_url = url;
556 }
557
558 icalprop = icalcomponent_get_next_property(icc, ICAL_X_PROPERTY);
559 }
560 }
561
540 appointment.begin = begin_dt;562 appointment.begin = begin_dt;
541 appointment.end = end_dt;563 appointment.end = end_dt;
542 appointment.color = subtask->color;564 appointment.color = subtask->color;
543 appointment.uid = uid;565 appointment.uid = uid;
544 appointment.type = type;566 appointment.type = type;
545567
546 icalcomponent * icc = e_cal_component_get_icalcomponent(component);
547 g_debug("%s", icalcomponent_as_ical_string(icc)); // libical owns this string; no leak
548
549 auto e_alarms = e_cal_util_generate_alarms_for_comp(component,568 auto e_alarms = e_cal_util_generate_alarms_for_comp(component,
550 subtask->begin,569 subtask->begin,
551 subtask->end,570 subtask->end,
552 const_cast<ECalComponentAlarmAction*>(omit.data()),571 const_cast<ECalComponentAlarmAction*>(omit.data()),
553 e_cal_client_resolve_tzid_cb,572 e_cal_client_resolve_tzid_cb,
554 subtask->client,573 subtask->client,
555 subtask->default_timezone);574 nullptr);
556575
557 std::map<DateTime,Alarm> alarms;576 std::map<DateTime,Alarm> alarms;
558577
559578
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-04-06 00:19:01 +0000
+++ tests/CMakeLists.txt 2015-05-08 00:22:35 +0000
@@ -93,6 +93,7 @@
93 ${GVFSD} # arg7: gvfsd exec93 ${GVFSD} # arg7: gvfsd exec
94 ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}-config-files) # arg8: canned config files94 ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}-config-files) # arg8: canned config files
95endfunction()95endfunction()
96add_eds_test_by_name(test-eds-tasks)
96add_eds_test_by_name(test-eds-valarms)97add_eds_test_by_name(test-eds-valarms)
9798
9899
99100
=== added directory 'tests/test-eds-tasks-config-files'
=== added directory 'tests/test-eds-tasks-config-files/.config'
=== added directory 'tests/test-eds-tasks-config-files/.config/evolution'
=== added directory 'tests/test-eds-tasks-config-files/.config/evolution/sources'
=== added file 'tests/test-eds-tasks-config-files/.config/evolution/sources/system-proxy.source'
--- tests/test-eds-tasks-config-files/.config/evolution/sources/system-proxy.source 1970-01-01 00:00:00 +0000
+++ tests/test-eds-tasks-config-files/.config/evolution/sources/system-proxy.source 2015-05-08 00:22:35 +0000
@@ -0,0 +1,21 @@
1
2[Data Source]
3DisplayName=Default Proxy Settings
4Enabled=true
5Parent=
6
7[Proxy]
8Method=default
9IgnoreHosts=localhost;127.0.0.0/8;::1;
10AutoconfigUrl=
11FtpHost=
12FtpPort=0
13HttpAuthPassword=
14HttpAuthUser=
15HttpHost=
16HttpPort=8080
17HttpUseAuth=false
18HttpsHost=
19HttpsPort=0
20SocksHost=
21SocksPort=0
022
=== added directory 'tests/test-eds-tasks-config-files/.local'
=== added directory 'tests/test-eds-tasks-config-files/.local/share'
=== added directory 'tests/test-eds-tasks-config-files/.local/share/evolution'
=== added directory 'tests/test-eds-tasks-config-files/.local/share/evolution/tasks'
=== added directory 'tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system'
=== added file 'tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system/tasks.ics'
--- tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system/tasks.ics 1970-01-01 00:00:00 +0000
+++ tests/test-eds-tasks-config-files/.local/share/evolution/tasks/system/tasks.ics 2015-05-08 00:22:35 +0000
@@ -0,0 +1,28 @@
1BEGIN:VCALENDAR
2CALSCALE:GREGORIAN
3PRODID:-//Ximian//NONSGML Evolution Calendar//EN
4VERSION:2.0
5X-EVOLUTION-DATA-REVISION:2015-05-07T21:14:49.315443Z(0)
6BEGIN:VTODO
7UID:20150507T211449Z-4262-32011-1418-1@ubuntu-phablet
8DTSTAMP:20150508T211449Z
9DTSTART:20150508T164000
10RRULE:FREQ=WEEKLY;BYDAY=FR
11SUMMARY:Alarm
12CATEGORIES:x-canonical-alarm
13CREATED:20150507T211449Z
14LAST-MODIFIED:20150507T211449Z
15BEGIN:VALARM
16X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-2@ubuntu-phablet
17ACTION:AUDIO
18ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg
19TRIGGER;VALUE=DURATION;RELATED=START:PT0S
20END:VALARM
21BEGIN:VALARM
22X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-3@ubuntu-phablet
23ACTION:DISPLAY
24DESCRIPTION:Alarm
25TRIGGER;VALUE=DURATION;RELATED=START:PT0S
26END:VALARM
27END:VTODO
28END:VCALENDAR
029
=== added file 'tests/test-eds-tasks.cpp'
--- tests/test-eds-tasks.cpp 1970-01-01 00:00:00 +0000
+++ tests/test-eds-tasks.cpp 2015-05-08 00:22:35 +0000
@@ -0,0 +1,101 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Charles Kerr <charles.kerr@canonical.com>
18 */
19
20#include <algorithm>
21
22#include <datetime/alarm-queue-simple.h>
23#include <datetime/clock-mock.h>
24#include <datetime/engine-eds.h>
25#include <datetime/planner-range.h>
26
27#include <gtest/gtest.h>
28
29#include "glib-fixture.h"
30#include "print-to.h"
31#include "timezone-mock.h"
32#include "wakeup-timer-mock.h"
33
34using namespace unity::indicator::datetime;
35using VAlarmFixture = GlibFixture;
36
37/***
38****
39***/
40
41TEST_F(VAlarmFixture, MultipleAppointments)
42{
43 // start the EDS engine
44 auto engine = std::make_shared<EdsEngine>();
45
46 // we need a consistent timezone for the planner and our local DateTimes
47 constexpr char const * zone_str {"America/Chicago"};
48 auto tz = std::make_shared<MockTimezone>(zone_str);
49 auto gtz = g_time_zone_new(zone_str);
50
51 // make a planner that looks at the first half of 2015 in EDS
52 auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
53 const DateTime range_begin {gtz, 2015,1, 1, 0, 0, 0.0};
54 const DateTime range_end {gtz, 2015,6,31,23,59,59.5};
55 planner->range().set(std::make_pair(range_begin, range_end));
56
57 // give EDS a moment to load
58 if (planner->appointments().get().empty()) {
59 g_message("waiting a moment for EDS to load...");
60 auto on_appointments_changed = [this](const std::vector<Appointment>& appointments){
61 g_message("ah, they loaded");
62 if (!appointments.empty())
63 g_main_loop_quit(loop);
64 };
65 core::ScopedConnection conn(planner->appointments().changed().connect(on_appointments_changed));
66 constexpr int max_wait_sec = 10;
67 wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
68 }
69
70 // what we expect to get...
71 Appointment expected_appt;
72 expected_appt.uid = "20150507T211449Z-4262-32011-1418-1@ubuntu-phablet";
73 expected_appt.color = "#becedd";
74 expected_appt.summary = "Alarm";
75 std::array<Alarm,8> expected_alarms = {
76 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5, 8,16,40,0)}),
77 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5,15,16,40,0)}),
78 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5,22,16,40,0)}),
79 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,5,29,16,40,0)}),
80 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6, 5,16,40,0)}),
81 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6,12,16,40,0)}),
82 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6,19,16,40,0)}),
83 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg", DateTime(gtz,2015,6,26,16,40,0)})
84 };
85
86 // compare it to what we actually loaded...
87 const auto appts = planner->appointments().get();
88 EXPECT_EQ(expected_alarms.size(), appts.size());
89 for (size_t i=0, n=expected_alarms.size(); i<n; i++) {
90 const auto& appt = appts[i];
91 EXPECT_EQ(expected_appt.uid, appt.uid);
92 EXPECT_EQ(expected_appt.color, appt.color);
93 EXPECT_EQ(expected_appt.summary, appt.summary);
94 EXPECT_EQ(1, appt.alarms.size());
95 EXPECT_EQ(expected_alarms[i], appt.alarms[0]);
96 }
97
98
99 // cleanup
100 g_time_zone_unref(gtz);
101}

Subscribers

People subscribed via source and target branches