Merge lp:~renatofilho/indicator-datetime/fix-1533681 into lp:indicator-datetime/15.10

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Charles Kerr
Approved revision: 454
Merged at revision: 447
Proposed branch: lp:~renatofilho/indicator-datetime/fix-1533681
Merge into: lp:indicator-datetime/15.10
Prerequisite: lp:~renatofilho/indicator-datetime/fix-1508438
Diff against target: 217 lines (+49/-26)
7 files modified
include/datetime/appointment.h (+2/-0)
src/appointment.cpp (+11/-1)
src/engine-eds.cpp (+12/-4)
src/snap.cpp (+3/-1)
tests/notification-fixture.h (+10/-10)
tests/test-eds-ics-repeating-valarms.cpp (+8/-8)
tests/test-sound.cpp (+3/-2)
To merge this branch: bzr merge lp:~renatofilho/indicator-datetime/fix-1533681
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Arthur Mello (community) Approve
Review via email: mp+290520@code.launchpad.net

Commit message

Only play a sound alert if the event contains a SOUND reminder.

Description of the change

How to Test:

1 - Create an alarm on google wit a pop-up notification at event time
2 - Create an alarm on google with e-mail notification at event time
3 - Create an alarm on google without any notification at event time
5 - Create a event with a reminder at event time on your device
4 - Sync your device with google
5 - Make sure that the event with pop-up notification does not play any sound but shows a pop up when it starts
6 - Make sure that the event with e-mail notification does not show any notification and does not play any sound
7 - Make sure the event created on device shows a notification and play a sound when it starts.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Basically the right idea, but implementation is much more complicated than necessary. See comments inline

review: Needs Fixing
449. By Renato Araujo Oliveira Filho

Remove type property from Alarm.

450. By Renato Araujo Oliveira Filho

Update tests.

451. By Renato Araujo Oliveira Filho

Does not play sound for events without a sound set.

452. By Renato Araujo Oliveira Filho

Parent merged.

453. By Renato Araujo Oliveira Filho

better code.

454. By Renato Araujo Oliveira Filho

Update tests.

Revision history for this message
Arthur Mello (artmello) wrote :

lgtm

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

to me, too

review: Approve
455. By Renato Araujo Oliveira Filho

Parent merged.

456. By Renato Araujo Oliveira Filho

Parent merged.

457. By Renato Araujo Oliveira Filho

Fixed sound file used by event alarms.

458. By Renato Araujo Oliveira Filho

Play event sound even if the event has only text reminders.

459. By Renato Araujo Oliveira Filho

revert last change.

460. By Renato Araujo Oliveira Filho

Parent merged.

461. By Renato Araujo Oliveira Filho

Only play sounds for alarms.

462. By Renato Araujo Oliveira Filho

Update sound test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/datetime/appointment.h'
--- include/datetime/appointment.h 2016-03-16 14:42:06 +0000
+++ include/datetime/appointment.h 2016-04-19 16:49:39 +0000
@@ -39,6 +39,8 @@
39 DateTime time;39 DateTime time;
4040
41 bool operator== (const Alarm& that) const;41 bool operator== (const Alarm& that) const;
42 bool has_sound() const;
43 bool has_text() const;
42};44};
4345
44/**46/**
4547
=== modified file 'src/appointment.cpp'
--- src/appointment.cpp 2015-04-05 22:27:52 +0000
+++ src/appointment.cpp 2016-04-19 16:49:39 +0000
@@ -31,7 +31,17 @@
31{31{
32 return (text==that.text)32 return (text==that.text)
33 && (audio_url==that.audio_url)33 && (audio_url==that.audio_url)
34 && (this->time==that.time);34 && (this->time==that.time);
35}
36
37bool Alarm::has_sound() const
38{
39 return !audio_url.empty();
40}
41
42bool Alarm::has_text() const
43{
44 return !text.empty();
35}45}
3646
37bool Appointment::operator==(const Appointment& that) const47bool Appointment::operator==(const Appointment& that) const
3848
=== modified file 'src/engine-eds.cpp'
--- src/engine-eds.cpp 2016-04-19 16:49:39 +0000
+++ src/engine-eds.cpp 2016-04-19 16:49:39 +0000
@@ -603,7 +603,7 @@
603 return ret;603 return ret;
604 }604 }
605605
606 static std::string get_alarm_sound_url(ECalComponentAlarm * alarm)606 static std::string get_alarm_sound_url(ECalComponentAlarm * alarm, const std::string & default_sound)
607 {607 {
608 std::string ret;608 std::string ret;
609609
@@ -624,6 +624,8 @@
624624
625 icalattach_unref(attach);625 icalattach_unref(attach);
626 }626 }
627 if (ret.empty())
628 ret = default_sound;
627 }629 }
628630
629 return ret;631 return ret;
@@ -940,11 +942,14 @@
940 DateTime{gtz, ai->occur_end});942 DateTime{gtz, ai->occur_end});
941 auto trigger_time = DateTime{gtz, ai->trigger};943 auto trigger_time = DateTime{gtz, ai->trigger};
942 auto& alarm = alarms[instance_time][trigger_time];944 auto& alarm = alarms[instance_time][trigger_time];
943
944 if (alarm.text.empty())945 if (alarm.text.empty())
945 alarm.text = get_alarm_text(a);946 alarm.text = get_alarm_text(a);
947
946 if (alarm.audio_url.empty())948 if (alarm.audio_url.empty())
947 alarm.audio_url = get_alarm_sound_url(a);949 alarm.audio_url = get_alarm_sound_url(a, (baseline.is_ubuntu_alarm() ?
950 "file://" ALARM_DEFAULT_SOUND :
951 "file://" CALENDAR_DEFAULT_SOUND));
952
948 if (!alarm.time.is_set())953 if (!alarm.time.is_set())
949 alarm.time = trigger_time;954 alarm.time = trigger_time;
950955
@@ -958,7 +963,10 @@
958 appointment.end = i.first.second;963 appointment.end = i.first.second;
959 appointment.alarms.reserve(i.second.size());964 appointment.alarms.reserve(i.second.size());
960 for (auto& j : i.second)965 for (auto& j : i.second)
961 appointment.alarms.push_back(j.second);966 {
967 if (j.second.has_text() || j.second.has_sound())
968 appointment.alarms.push_back(j.second);
969 }
962 subtask->task->appointments.push_back(appointment);970 subtask->task->appointments.push_back(appointment);
963 }971 }
964 }972 }
965973
=== modified file 'src/snap.cpp'
--- src/snap.cpp 2016-02-03 17:06:31 +0000
+++ src/snap.cpp 2016-04-19 16:49:39 +0000
@@ -102,7 +102,9 @@
102102
103 // calendar events are muted in silent mode; alarm clocks never are103 // calendar events are muted in silent mode; alarm clocks never are
104 std::shared_ptr<uin::Sound> sound;104 std::shared_ptr<uin::Sound> sound;
105 if (appointment.is_ubuntu_alarm() || !silent_mode()) {105 // FIXME: only play sounds for alarms for now, we should itegrate it with
106 // system settings to decide if we should play sounds for calendar notification or not
107 if (appointment.is_ubuntu_alarm()) {
106 // create the sound.108 // create the sound.
107 const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";109 const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";
108 const auto uri = get_alarm_uri(appointment, alarm, m_settings);110 const auto uri = get_alarm_uri(appointment, alarm, m_settings);
109111
=== modified file 'tests/notification-fixture.h'
--- tests/notification-fixture.h 2016-02-10 20:48:24 +0000
+++ tests/notification-fixture.h 2016-04-19 16:49:39 +0000
@@ -53,7 +53,7 @@
53 static constexpr char const * HAPTIC_METHOD_VIBRATE_PATTERN {"VibratePattern"};53 static constexpr char const * HAPTIC_METHOD_VIBRATE_PATTERN {"VibratePattern"};
5454
55 static constexpr int SCREEN_COOKIE {8675309};55 static constexpr int SCREEN_COOKIE {8675309};
56 static constexpr char const * SCREEN_METHOD_KEEP_DISPLAY_ON {"keepDisplayOn"}; 56 static constexpr char const * SCREEN_METHOD_KEEP_DISPLAY_ON {"keepDisplayOn"};
57 static constexpr char const * SCREEN_METHOD_REMOVE_DISPLAY_ON_REQUEST {"removeDisplayOnRequest"};57 static constexpr char const * SCREEN_METHOD_REMOVE_DISPLAY_ON_REQUEST {"removeDisplayOnRequest"};
5858
59 static constexpr int POWERD_SYS_STATE_ACTIVE = 1;59 static constexpr int POWERD_SYS_STATE_ACTIVE = 1;
@@ -111,7 +111,7 @@
111 const auto christmas = unity::indicator::datetime::DateTime::Local(2015,12,25,0,0,0);111 const auto christmas = unity::indicator::datetime::DateTime::Local(2015,12,25,0,0,0);
112 appt.begin = christmas.start_of_day();112 appt.begin = christmas.start_of_day();
113 appt.end = christmas.end_of_day();113 appt.end = christmas.end_of_day();
114 appt.alarms.push_back(unity::indicator::datetime::Alarm{"Ho Ho Ho!", "", appt.begin});114 appt.alarms.push_back(unity::indicator::datetime::Alarm{"Ho Ho Ho!", CALENDAR_DEFAULT_SOUND, appt.begin});
115115
116 // init an Ubuntu Alarm116 // init an Ubuntu Alarm
117 ualarm.color = "red";117 ualarm.color = "red";
@@ -165,8 +165,8 @@
165 NOTIFY_INTERFACE,165 NOTIFY_INTERFACE,
166 &error);166 &error);
167 g_assert_no_error(error);167 g_assert_no_error(error);
168 168
169 // METHOD_GET_INFO 169 // METHOD_GET_INFO
170 str = g_strdup("ret = ('mock-notify', 'test vendor', '1.0', '1.1')");170 str = g_strdup("ret = ('mock-notify', 'test vendor', '1.0', '1.1')");
171 dbus_test_dbus_mock_object_add_method(notify_mock,171 dbus_test_dbus_mock_object_add_method(notify_mock,
172 notify_obj,172 notify_obj,
@@ -196,7 +196,7 @@
196 g_assert_no_error (error);196 g_assert_no_error (error);
197 g_free (str);197 g_free (str);
198198
199 // METHOD_CLOSE 199 // METHOD_CLOSE
200 str = g_strdup_printf("self.EmitSignal('%s', '%s', 'uu', [ args[0], %d ])",200 str = g_strdup_printf("self.EmitSignal('%s', '%s', 'uu', [ args[0], %d ])",
201 NOTIFY_INTERFACE,201 NOTIFY_INTERFACE,
202 SIGNAL_CLOSED,202 SIGNAL_CLOSED,
@@ -223,8 +223,8 @@
223 BUS_POWERD_INTERFACE,223 BUS_POWERD_INTERFACE,
224 &error);224 &error);
225 g_assert_no_error(error);225 g_assert_no_error(error);
226 226
227 str = g_strdup_printf ("ret = '%s'", POWERD_COOKIE); 227 str = g_strdup_printf ("ret = '%s'", POWERD_COOKIE);
228 dbus_test_dbus_mock_object_add_method(powerd_mock,228 dbus_test_dbus_mock_object_add_method(powerd_mock,
229 powerd_obj,229 powerd_obj,
230 POWERD_METHOD_REQUEST_SYS_STATE,230 POWERD_METHOD_REQUEST_SYS_STATE,
@@ -256,8 +256,8 @@
256 BUS_SCREEN_INTERFACE,256 BUS_SCREEN_INTERFACE,
257 &error);257 &error);
258 g_assert_no_error(error);258 g_assert_no_error(error);
259 259
260 str = g_strdup_printf ("ret = %d", SCREEN_COOKIE); 260 str = g_strdup_printf ("ret = %d", SCREEN_COOKIE);
261 dbus_test_dbus_mock_object_add_method(screen_mock,261 dbus_test_dbus_mock_object_add_method(screen_mock,
262 screen_obj,262 screen_obj,
263 SCREEN_METHOD_KEEP_DISPLAY_ON,263 SCREEN_METHOD_KEEP_DISPLAY_ON,
@@ -287,7 +287,7 @@
287 BUS_HAPTIC_PATH,287 BUS_HAPTIC_PATH,
288 BUS_HAPTIC_INTERFACE,288 BUS_HAPTIC_INTERFACE,
289 &error);289 &error);
290 290
291 dbus_test_dbus_mock_object_add_method(haptic_mock,291 dbus_test_dbus_mock_object_add_method(haptic_mock,
292 haptic_obj,292 haptic_obj,
293 HAPTIC_METHOD_VIBRATE_PATTERN,293 HAPTIC_METHOD_VIBRATE_PATTERN,
294294
=== modified file 'tests/test-eds-ics-repeating-valarms.cpp'
--- tests/test-eds-ics-repeating-valarms.cpp 2016-04-19 16:49:39 +0000
+++ tests/test-eds-ics-repeating-valarms.cpp 2016-04-19 16:49:39 +0000
@@ -73,14 +73,14 @@
73 ASSERT_EQ(1, appts.size());73 ASSERT_EQ(1, appts.size());
74 const auto& appt = appts.front();74 const auto& appt = appts.front();
75 ASSERT_EQ(8, appt.alarms.size());75 ASSERT_EQ(8, appt.alarms.size());
76 EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,35,0)}), appt.alarms[0]);76 EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,35,0)}), appt.alarms[0]);
77 EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,37,0)}), appt.alarms[1]);77 EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,37,0)}), appt.alarms[1]);
78 EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,39,0)}), appt.alarms[2]);78 EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,39,0)}), appt.alarms[2]);
79 EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,41,0)}), appt.alarms[3]);79 EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,41,0)}), appt.alarms[3]);
80 EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,35,0)}), appt.alarms[4]);80 EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,35,0)}), appt.alarms[4]);
81 EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,37,0)}), appt.alarms[5]);81 EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,37,0)}), appt.alarms[5]);
82 EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,39,0)}), appt.alarms[6]);82 EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,39,0)}), appt.alarms[6]);
83 EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,41,0)}), appt.alarms[7]);83 EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,41,0)}), appt.alarms[7]);
8484
85 // now let's try this out with AlarmQueue...85 // now let's try this out with AlarmQueue...
86 // hook the planner up to a SimpleAlarmQueue and confirm that it triggers for each of the reminders86 // hook the planner up to a SimpleAlarmQueue and confirm that it triggers for each of the reminders
8787
=== modified file 'tests/test-sound.cpp'
--- tests/test-sound.cpp 2016-02-10 20:49:01 +0000
+++ tests/test-sound.cpp 2016-04-19 16:49:39 +0000
@@ -155,8 +155,9 @@
155 std::string expected_role;155 std::string expected_role;
156 std::string expected_uri;156 std::string expected_uri;
157 } test_cases[] = {157 } test_cases[] = {
158 { ualarm, "alarm", path_to_uri(ALARM_DEFAULT_SOUND) },158 { ualarm, "alarm", path_to_uri(ALARM_DEFAULT_SOUND) }
159 { appt, "alert", path_to_uri(CALENDAR_DEFAULT_SOUND) }159 // No sound for appointments
160 // { appt, "alert", path_to_uri(CALENDAR_DEFAULT_SOUND) }
160 };161 };
161162
162 auto snap = create_snap(ne, sb, settings);163 auto snap = create_snap(ne, sb, settings);

Subscribers

People subscribed via source and target branches