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

Proposed by Renato Araujo Oliveira Filho
Status: Work in progress
Proposed branch: lp:~renatofilho/indicator-datetime/fix-1508438-2
Merge into: lp:indicator-datetime/15.10
Diff against target: 1018 lines (+450/-119)
20 files modified
CMakeLists.txt (+3/-2)
debian/control (+2/-0)
include/datetime/engine-eds.h (+3/-2)
include/datetime/myself.h (+62/-0)
src/CMakeLists.txt (+1/-0)
src/engine-eds.cpp (+139/-101)
src/main.cpp (+2/-1)
src/myself.cpp (+76/-0)
tests/CMakeLists.txt (+3/-1)
tests/run-eds-ics-test.sh (+9/-1)
tests/test-eds-ics-all-day-events.cpp (+3/-2)
tests/test-eds-ics-missing-trigger.cpp (+3/-1)
tests/test-eds-ics-non-attending-alarms.cpp (+77/-0)
tests/test-eds-ics-non-attending-alarms.ics.in (+53/-0)
tests/test-eds-ics-nonrepeating-events.cpp (+3/-2)
tests/test-eds-ics-repeating-events.cpp (+3/-2)
tests/test-eds-ics-repeating-valarms.cpp (+2/-1)
tests/test-eds-ics-tzids-2.cpp (+2/-1)
tests/test-eds-ics-tzids-utc.cpp (+2/-1)
tests/test-eds-ics-tzids.cpp (+2/-1)
To merge this branch: bzr merge lp:~renatofilho/indicator-datetime/fix-1508438-2
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+291043@code.launchpad.net

Commit message

test

To post a comment you must log in.

Unmerged revisions

449. By Renato Araujo Oliveira Filho

Attempt to fix.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-02-03 16:33:39 +0000
3+++ CMakeLists.txt 2016-04-05 20:43:14 +0000
4@@ -20,7 +20,7 @@
5
6 ##
7 ## GNU standard installation directories
8-##
9+##
10
11 include (GNUInstallDirs)
12 if (EXISTS "/etc/debian_version") # Workaround for libexecdir on debian
13@@ -47,7 +47,8 @@
14 gstreamer-1.0>=1.2
15 libnotify>=0.7.6
16 url-dispatcher-1>=1
17- properties-cpp>=0.0.1)
18+ properties-cpp>=0.0.1
19+ libaccounts-glib>=1.21)
20 include_directories (SYSTEM ${SERVICE_DEPS_INCLUDE_DIRS})
21
22 ##
23
24=== modified file 'debian/control'
25--- debian/control 2016-03-10 16:20:36 +0000
26+++ debian/control 2016-04-05 20:43:14 +0000
27@@ -29,6 +29,8 @@
28 gvfs-daemons,
29 # for phone alarm/calendar notification sound tests:
30 ubuntu-touch-sounds,
31+# for query user e-mails based on accounts
32+ libaccounts-glib-dev,
33 Standards-Version: 3.9.3
34 Homepage: https://launchpad.net/indicator-datetime
35 # If you aren't a member of ~indicator-applet-developers but need to upload
36
37=== modified file 'include/datetime/engine-eds.h'
38--- include/datetime/engine-eds.h 2014-12-08 02:52:50 +0000
39+++ include/datetime/engine-eds.h 2016-04-05 20:43:14 +0000
40@@ -36,16 +36,17 @@
41 /****
42 *****
43 ****/
44+class Myself;
45
46 /**
47 * Class wrapper around EDS so multiple #EdsPlanners can share resources
48- *
49+ *
50 * @see EdsPlanner
51 */
52 class EdsEngine: public Engine
53 {
54 public:
55- EdsEngine();
56+ EdsEngine(const std::shared_ptr<Myself> &myself);
57 ~EdsEngine();
58
59 void get_appointments(const DateTime& begin,
60
61=== added file 'include/datetime/myself.h'
62--- include/datetime/myself.h 1970-01-01 00:00:00 +0000
63+++ include/datetime/myself.h 2016-04-05 20:43:14 +0000
64@@ -0,0 +1,62 @@
65+/*
66+ * Copyright 2016 Canonical Ltd.
67+ *
68+ * This program is free software: you can redistribute it and/or modify it
69+ * under the terms of the GNU General Public License version 3, as published
70+ * by the Free Software Foundation.
71+ *
72+ * This program is distributed in the hope that it will be useful, but
73+ * WITHOUT ANY WARRANTY; without even the implied warranties of
74+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
75+ * PURPOSE. See the GNU General Public License for more details.
76+ *
77+ * You should have received a copy of the GNU General Public License along
78+ * with this program. If not, see <http://www.gnu.org/licenses/>.
79+ *
80+ * Authors:
81+ * Renato Araujo Oliveira Filho <renato.filho@canonical.com>
82+ */
83+
84+#ifndef INDICATOR_DATETIME_MYSELF_H
85+#define INDICATOR_DATETIME_MYSELF_H
86+
87+#include <core/property.h>
88+
89+#include <string>
90+#include <set>
91+#include <memory.h>
92+#include <glib.h>
93+
94+typedef struct _AgManager AgManager;
95+
96+namespace unity {
97+namespace indicator {
98+namespace datetime {
99+
100+class Myself
101+{
102+public:
103+ Myself();
104+
105+ const core::Property<std::set<std::string>>& emails()
106+ {
107+ return m_emails;
108+ }
109+
110+ bool isMyEmail(const std::string &email);
111+
112+private:
113+ std::shared_ptr<AgManager> m_accounts_manager;
114+ core::Property<std::set<std::string> > m_emails;
115+
116+ static void on_accounts_changed(AgManager*, guint, Myself*);
117+ void reloadEmails();
118+
119+};
120+
121+
122+} // namespace datetime
123+} // namespace indicator
124+} // namespace unity
125+
126+#endif // INDICATOR_DATETIME_MYSELF_H
127
128=== modified file 'src/CMakeLists.txt'
129--- src/CMakeLists.txt 2015-09-01 09:52:13 +0000
130+++ src/CMakeLists.txt 2016-04-05 20:43:14 +0000
131@@ -23,6 +23,7 @@
132 locations.cpp
133 locations-settings.cpp
134 menu.cpp
135+ myself.cpp
136 notifications.cpp
137 planner.cpp
138 planner-aggregate.cpp
139
140=== modified file 'src/engine-eds.cpp'
141--- src/engine-eds.cpp 2016-03-22 19:32:25 +0000
142+++ src/engine-eds.cpp 2016-04-05 20:43:14 +0000
143@@ -18,6 +18,7 @@
144 */
145
146 #include <datetime/engine-eds.h>
147+#include <datetime/myself.h>
148
149 #include <libical/ical.h>
150 #include <libical/icaltime.h>
151@@ -48,7 +49,8 @@
152 {
153 public:
154
155- Impl()
156+ Impl(const std::shared_ptr<Myself> &myself)
157+ : m_myself(myself)
158 {
159 auto cancellable_deleter = [](GCancellable * c) {
160 g_cancellable_cancel(c);
161@@ -56,8 +58,10 @@
162 };
163
164 m_cancellable = std::shared_ptr<GCancellable>(g_cancellable_new(), cancellable_deleter);
165-
166 e_source_registry_new(m_cancellable.get(), on_source_registry_ready, this);
167+ m_myself->emails().changed().connect([this](const std::set<std::string> &) {
168+ set_dirty_soon();
169+ });
170 }
171
172 ~Impl()
173@@ -125,35 +129,14 @@
174 auto extension = e_source_get_extension(source, E_SOURCE_EXTENSION_CALENDAR);
175 const auto color = e_source_selectable_get_color(E_SOURCE_SELECTABLE(extension));
176
177- auto begin_str = isodate_from_time_t(begin.to_unix());
178- auto end_str = isodate_from_time_t(end.to_unix());
179- auto sexp_fmt = g_strdup_printf("(%%s? (make-time \"%s\") (make-time \"%s\"))", begin_str, end_str);
180- g_clear_pointer(&begin_str, g_free);
181- g_clear_pointer(&end_str, g_free);
182-
183- // ask EDS about alarms that occur in this window...
184- auto sexp = g_strdup_printf(sexp_fmt, "has-alarms-in-range");
185- g_debug("%s alarm sexp is %s", G_STRLOC, sexp);
186- e_cal_client_get_object_list_as_comps(
187- client,
188- sexp,
189- m_cancellable.get(),
190- on_alarm_component_list_ready,
191- new ClientSubtask(main_task, client, m_cancellable, color));
192- g_clear_pointer(&sexp, g_free);
193-
194- // ask EDS about events that occur in this window...
195- sexp = g_strdup_printf(sexp_fmt, "occur-in-time-range");
196- g_debug("%s event sexp is %s", G_STRLOC, sexp);
197- e_cal_client_get_object_list_as_comps(
198- client,
199- sexp,
200- m_cancellable.get(),
201- on_event_component_list_ready,
202- new ClientSubtask(main_task, client, m_cancellable, color));
203- g_clear_pointer(&sexp, g_free);
204-
205- g_clear_pointer(&sexp_fmt, g_free);
206+ e_cal_client_generate_instances(
207+ client,
208+ begin.to_unix(),
209+ end.to_unix(),
210+ m_cancellable.get(),
211+ on_event_generated,
212+ new ClientSubtask(main_task, client, m_cancellable, color),
213+ on_event_generated_list_ready);
214 }
215 }
216
217@@ -591,6 +574,8 @@
218 ECalClient* client;
219 std::shared_ptr<GCancellable> cancellable;
220 std::string color;
221+ GList *components;
222+ GList *global_components;
223
224 ClientSubtask(const std::shared_ptr<Task>& task_in,
225 ECalClient* client_in,
226@@ -598,10 +583,13 @@
227 const char* color_in):
228 task(task_in),
229 client(client_in),
230- cancellable(cancellable_in)
231+ cancellable(cancellable_in),
232+ components(nullptr),
233+ global_components(nullptr)
234 {
235 if (color_in)
236 color = color_in;
237+
238 }
239 };
240
241@@ -648,77 +636,109 @@
242 return ret;
243 }
244
245+ static gboolean
246+ on_event_generated(ECalComponent *comp,
247+ time_t,
248+ time_t,
249+ gpointer gsubtask)
250+ {
251+ auto subtask = static_cast<ClientSubtask*>(gsubtask);
252+ const gchar *uid = nullptr;
253+ e_cal_component_get_uid (comp, &uid);
254+ g_debug("COMP (%p):%s", (void*) comp, uid);
255+ g_object_ref(comp);
256+ subtask->components = g_list_append(subtask->components, comp);
257+ return TRUE;
258+ }
259+
260 static void
261- on_alarm_component_list_ready(GObject * oclient,
262- GAsyncResult * res,
263- gpointer gsubtask)
264+ on_event_generated_list_ready(gpointer gsubtask)
265 {
266- GError * error = NULL;
267- GSList * comps_slist = NULL;
268 auto subtask = static_cast<ClientSubtask*>(gsubtask);
269-
270- if (e_cal_client_get_object_list_as_comps_finish(E_CAL_CLIENT(oclient),
271- res,
272- &comps_slist,
273- &error))
274+ if (g_list_length(subtask->components) > 0) {
275+ auto l = g_list_first(subtask->components);
276+ ECalComponent *comp = static_cast<ECalComponent*>(l->data);
277+ subtask->components = g_list_remove_link(subtask->components, l);
278+
279+ bool has_recurrence = e_cal_component_has_recurrences(comp);
280+ subtask->global_components = g_list_append(subtask->global_components, comp);
281+
282+ if (has_recurrence)
283+ {
284+ const gchar *uid = nullptr;
285+ e_cal_component_get_uid(comp, &uid);
286+
287+ g_debug(" GET COMPONENTS FOR UID: (%p): %s", comp, uid);
288+ e_cal_client_get_objects_for_uid(subtask->client,
289+ uid,
290+ subtask->cancellable.get(),
291+ on_event_retrieved,
292+ gsubtask);
293+ }
294+ else
295+ {
296+ on_event_generated_list_ready(gsubtask);
297+ }
298+ }
299+ else
300 {
301- // _generate_alarms takes a GList, so make a shallow one
302- GList * comps_list = nullptr;
303- for (auto l=comps_slist; l!=nullptr; l=l->next)
304- comps_list = g_list_prepend(comps_list, l->data);
305-
306+ // generate alarms
307 constexpr std::array<ECalComponentAlarmAction,1> omit = {
308 (ECalComponentAlarmAction)-1
309 }; // list of action types to omit, terminated with -1
310 GSList * comp_alarms = nullptr;
311 e_cal_util_generate_alarms_for_list(
312- comps_list,
313+ subtask->global_components,
314 subtask->task->begin.to_unix(),
315 subtask->task->end.to_unix(),
316 const_cast<ECalComponentAlarmAction*>(omit.data()),
317 &comp_alarms,
318 e_cal_client_resolve_tzid_cb,
319- oclient,
320+ subtask->client,
321 subtask->task->default_timezone);
322
323 // walk the alarms & add them
324 for (auto l=comp_alarms; l!=nullptr; l=l->next)
325 add_alarms_to_subtask(static_cast<ECalComponentAlarms*>(l->data), subtask, subtask->task->gtz);
326
327- // cleanup
328- e_cal_free_alarms(comp_alarms);
329- g_list_free(comps_list);
330- e_cal_client_free_ecalcomp_slist(comps_slist);
331- }
332- else if (error != nullptr)
333- {
334- if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
335- g_warning("can't get ecalcomponent list: %s", error->message);
336-
337- g_error_free(error);
338- }
339-
340- delete subtask;
341+
342+ // add events
343+ for (auto l=subtask->global_components; l!=nullptr; l=l->next) {
344+ auto component = static_cast<ECalComponent*>(l->data);
345+ if (!e_cal_component_has_alarms(component))
346+ add_event_to_subtask(static_cast<ECalComponent*>(l->data), subtask, subtask->task->gtz);
347+ }
348+
349+ g_list_free_full(subtask->global_components, g_object_unref);
350+
351+ g_debug("QUERY EMPTY DONE>>>>>>>>>>>>>");
352+ delete subtask;
353+ }
354 }
355
356 static void
357- on_event_component_list_ready(GObject * oclient,
358- GAsyncResult * res,
359- gpointer gsubtask)
360+ on_event_retrieved (GObject *,
361+ GAsyncResult * res,
362+ gpointer gsubtask)
363 {
364- GError * error = NULL;
365- GSList * comps_slist = NULL;
366+ GError * error = nullptr;
367+ GSList * comps_slist = nullptr;
368 auto subtask = static_cast<ClientSubtask*>(gsubtask);
369
370- if (e_cal_client_get_object_list_as_comps_finish(E_CAL_CLIENT(oclient),
371- res,
372- &comps_slist,
373- &error))
374+ if (e_cal_client_get_objects_for_uid_finish(subtask->client,
375+ res,
376+ &comps_slist,
377+ &error))
378 {
379+ g_debug("LIST::::::::::::::%d", g_slist_length(comps_slist));
380 for (auto l=comps_slist; l!=nullptr; l=l->next)
381- add_event_to_subtask(static_cast<ECalComponent*>(l->data), subtask, subtask->task->gtz);
382-
383+ {
384+ auto comp = static_cast<ECalComponent*>(l->data);
385+ g_object_ref(comp);
386+ subtask->global_components = g_list_append(subtask->global_components, comp);
387+ }
388 e_cal_client_free_ecalcomp_slist(comps_slist);
389+
390 }
391 else if (error != nullptr)
392 {
393@@ -728,9 +748,10 @@
394 g_error_free(error);
395 }
396
397- delete subtask;
398+ on_event_generated_list_ready (gsubtask);
399 }
400
401+
402 static DateTime
403 datetime_from_component_date_time(ECalClient * client,
404 std::shared_ptr<GCancellable> & cancellable,
405@@ -797,7 +818,7 @@
406 return out;
407 }
408
409- static bool
410+ bool
411 is_component_interesting(ECalComponent * component)
412 {
413 // we only want calendar events and vtodos
414@@ -823,6 +844,28 @@
415 disabled = true;
416 }
417 e_cal_component_free_categories_list(categ_list);
418+
419+ if (!disabled) {
420+ // we don't want not attending alarms
421+ // check if the user is part of attendee list if we found it check the status
422+ GSList *attendeeList = nullptr;
423+ e_cal_component_get_attendee_list(component, &attendeeList);
424+
425+ for (GSList *attendeeIter=attendeeList; attendeeIter != nullptr; attendeeIter = attendeeIter->next) {
426+ ECalComponentAttendee *attendee = static_cast<ECalComponentAttendee *>(attendeeIter->data);
427+ if (attendee->value) {
428+ if (strncmp(attendee->value, "mailto:", 7) == 0) {
429+ if (m_myself->isMyEmail(attendee->value+7)) {
430+ disabled = (attendee->status == ICAL_PARTSTAT_DECLINED);
431+ break;
432+ }
433+ }
434+ }
435+ }
436+ if (attendeeList)
437+ e_cal_component_free_attendee_list(attendeeList);
438+ }
439+
440 if (disabled)
441 return false;
442
443@@ -903,35 +946,13 @@
444 }
445
446 static void
447- add_event_to_subtask(ECalComponent * component,
448- ClientSubtask * subtask,
449- GTimeZone * gtz)
450- {
451- // events with alarms are covered by add_alarms_to_subtask(),
452- // so skip them here
453- auto auids = e_cal_component_get_alarm_uids(component);
454- const bool has_alarms = auids != nullptr;
455- cal_obj_uid_list_free(auids);
456- if (has_alarms)
457- return;
458-
459- // add it. simple, eh?
460- if (is_component_interesting(component))
461- {
462- Appointment appointment = get_appointment(subtask->client, subtask->cancellable, component, gtz);
463- appointment.color = subtask->color;
464- subtask->task->appointments.push_back(appointment);
465- }
466- }
467-
468- static void
469 add_alarms_to_subtask(ECalComponentAlarms * comp_alarms,
470 ClientSubtask * subtask,
471 GTimeZone * gtz)
472 {
473 auto& component = comp_alarms->comp;
474
475- if (!is_component_interesting(component))
476+ if (!subtask->task->p->is_component_interesting(component))
477 return;
478
479 Appointment baseline = get_appointment(subtask->client, subtask->cancellable, component, gtz);
480@@ -990,6 +1011,22 @@
481 }
482 }
483
484+ static void
485+ add_event_to_subtask(ECalComponent * component,
486+ ClientSubtask * subtask,
487+ GTimeZone * gtz)
488+ {
489+ // add it. simple, eh?
490+ if (subtask->task->p->is_component_interesting(component))
491+ {
492+ Appointment appointment = get_appointment(subtask->client, subtask->cancellable, component, gtz);
493+ appointment.color = subtask->color;
494+ subtask->task->appointments.push_back(appointment);
495+ } else {
496+ g_debug("EVENT NOT INTERESTING: (%p)", component);
497+ }
498+ }
499+
500 /***
501 ****
502 ***/
503@@ -1062,14 +1099,15 @@
504 ESourceRegistry* m_source_registry {};
505 guint m_rebuild_tag {};
506 time_t m_rebuild_deadline {};
507+ std::shared_ptr<Myself> m_myself;
508 };
509
510 /***
511 ****
512 ***/
513
514-EdsEngine::EdsEngine():
515- p(new Impl())
516+EdsEngine::EdsEngine(const std::shared_ptr<Myself> &myself):
517+ p(new Impl(myself))
518 {
519 }
520
521
522=== modified file 'src/main.cpp'
523--- src/main.cpp 2015-10-13 16:06:35 +0000
524+++ src/main.cpp 2016-04-05 20:43:14 +0000
525@@ -25,6 +25,7 @@
526 #include <datetime/exporter.h>
527 #include <datetime/locations-settings.h>
528 #include <datetime/menu.h>
529+#include <datetime/myself.h>
530 #include <datetime/planner-aggregate.h>
531 #include <datetime/planner-snooze.h>
532 #include <datetime/planner-range.h>
533@@ -58,7 +59,7 @@
534 if (!g_strcmp0("lightdm", g_get_user_name()))
535 engine.reset(new MockEngine);
536 else
537- engine.reset(new EdsEngine);
538+ engine.reset(new EdsEngine(std::shared_ptr<Myself>(new Myself)));
539
540 return engine;
541 }
542
543=== added file 'src/myself.cpp'
544--- src/myself.cpp 1970-01-01 00:00:00 +0000
545+++ src/myself.cpp 2016-04-05 20:43:14 +0000
546@@ -0,0 +1,76 @@
547+/*
548+ * Copyright 2016 Canonical Ltd.
549+ *
550+ * This program is free software: you can redistribute it and/or modify it
551+ * under the terms of the GNU General Public License version 3, as published
552+ * by the Free Software Foundation.
553+ *
554+ * This program is distributed in the hope that it will be useful, but
555+ * WITHOUT ANY WARRANTY; without even the implied warranties of
556+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
557+ * PURPOSE. See the GNU General Public License for more details.
558+ *
559+ * You should have received a copy of the GNU General Public License along
560+ * with this program. If not, see <http://www.gnu.org/licenses/>.
561+ *
562+ * Authors:
563+ * Renato Araujo Oliveira Filho <renato.filho@canonical.com>
564+ */
565+
566+#include "datetime/myself.h"
567+
568+#include <libaccounts-glib/ag-manager.h>
569+#include <libaccounts-glib/ag-account.h>
570+
571+#include <algorithm>
572+
573+namespace unity {
574+namespace indicator {
575+namespace datetime {
576+
577+Myself::Myself()
578+ : m_accounts_manager(ag_manager_new(), g_object_unref)
579+{
580+ reloadEmails();
581+ g_object_connect(m_accounts_manager.get(),
582+ "signal::account-created", on_accounts_changed, this,
583+ "signal::account-deleted", on_accounts_changed, this,
584+ "signal::account-updated", on_accounts_changed, this,
585+ nullptr);
586+}
587+
588+bool Myself::isMyEmail(const std::string &email)
589+{
590+ return m_emails.get().count(email) > 0;
591+}
592+
593+void Myself::on_accounts_changed(AgManager *, guint, Myself *self)
594+{
595+ self->reloadEmails();
596+}
597+
598+void Myself::reloadEmails()
599+{
600+ std::set<std::string> emails;
601+
602+ auto manager = m_accounts_manager.get();
603+ auto ids = ag_manager_list(manager);
604+ for (auto l=ids; l!=nullptr; l=l->next)
605+ {
606+ auto acc = ag_manager_get_account(manager, GPOINTER_TO_UINT(l->data));
607+ if (acc) {
608+ auto account_name = ag_account_get_display_name(acc);
609+ if (account_name != nullptr)
610+ emails.insert(account_name);
611+ g_object_unref(acc);
612+ }
613+ }
614+ ag_manager_list_free(ids);
615+
616+ m_emails.set(emails);
617+}
618+
619+} // namespace datetime
620+} // namespace indicator
621+} // namespace unity
622+
623
624=== modified file 'tests/CMakeLists.txt'
625--- tests/CMakeLists.txt 2016-03-22 18:51:50 +0000
626+++ tests/CMakeLists.txt 2016-04-05 20:43:14 +0000
627@@ -85,7 +85,8 @@
628 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} # arg2: test executable path
629 ${TEST_NAME} # arg3: test name
630 ${CMAKE_CURRENT_SOURCE_DIR}/test-eds-ics-config-files # arg4: base directory for config file template
631- ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.ics) # arg5: the ical file for this test
632+ ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.ics # arg5: the ical file for this test
633+ ${CMAKE_CURRENT_SOURCE_DIR}/accounts.db) # arg6: online accounts database
634 endfunction()
635 add_eds_ics_test_by_name(test-eds-ics-all-day-events)
636 add_eds_ics_test_by_name(test-eds-ics-repeating-events)
637@@ -95,6 +96,7 @@
638 add_eds_ics_test_by_name(test-eds-ics-tzids)
639 add_eds_ics_test_by_name(test-eds-ics-tzids-2)
640 add_eds_ics_test_by_name(test-eds-ics-tzids-utc)
641+add_eds_ics_test_by_name(test-eds-ics-non-attending-alarms)
642
643
644 # disabling the timezone unit tests because they require
645
646=== added file 'tests/accounts.db'
647Binary files tests/accounts.db 1970-01-01 00:00:00 +0000 and tests/accounts.db 2016-04-05 20:43:14 +0000 differ
648=== modified file 'tests/run-eds-ics-test.sh'
649--- tests/run-eds-ics-test.sh 2015-07-20 16:31:28 +0000
650+++ tests/run-eds-ics-test.sh 2016-04-05 20:43:14 +0000
651@@ -6,6 +6,7 @@
652 TEST_NAME=$3 # test name
653 CONFIG_DIR=$4 # config files
654 ICS_FILE=$5 # ical file holding test data
655+ACCOUNTS_DB=$6 # online account database
656
657 echo "this script: ${SELF}"
658 echo "test-runner: ${TEST_RUNNER}"
659@@ -54,8 +55,15 @@
660 cp --verbose --archive ${ICS_FILE} ${XDG_DATA_HOME}/evolution/tasks/system/tasks.ics
661 fi
662
663+# prepare online accounts database
664+if [ -e ${ACCOUNTS_DB} ]; then
665+ echo "copying ${ACCOUNTS_DB} into $HOME"
666+ mkdir -p ${XDG_CONFIG_HOME}/libaccounts-glib/
667+ cp --verbose --archive ${ACCOUNTS_DB} ${XDG_CONFIG_HOME}/libaccounts-glib/accounts.db
668+fi
669+
670 # run the test
671-${TEST_RUNNER} --keep-env --max-wait=90 --task ${TEST_EXEC} --task-name ${TEST_NAME} --wait-until-complete
672+${TEST_RUNNER} --keep-env --max-wait=90 --task ${TEST_EXEC} --task-name ${TEST_NAME} --wait-until-complete
673 rv=$?
674
675 # if the test passed, blow away the tmpdir
676
677=== modified file 'tests/test-eds-ics-all-day-events.cpp'
678--- tests/test-eds-ics-all-day-events.cpp 2015-05-21 12:47:24 +0000
679+++ tests/test-eds-ics-all-day-events.cpp 2016-04-05 20:43:14 +0000
680@@ -22,6 +22,7 @@
681 #include <datetime/alarm-queue-simple.h>
682 #include <datetime/clock-mock.h>
683 #include <datetime/engine-eds.h>
684+#include <datetime/myself.h>
685 #include <datetime/planner-range.h>
686
687 #include <gtest/gtest.h>
688@@ -41,7 +42,7 @@
689 TEST_F(VAlarmFixture, MultipleAppointments)
690 {
691 // start the EDS engine
692- auto engine = std::make_shared<EdsEngine>();
693+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
694
695 // we need a consistent timezone for the planner and our local DateTimes
696 constexpr char const * zone_str {"America/Chicago"};
697@@ -66,7 +67,7 @@
698 constexpr int max_wait_sec = 10;
699 wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
700 }
701-
702+
703 // what we expect to get...
704 Appointment expected_appt;
705 expected_appt.uid = "20150521T111538Z-7449-1000-3572-0@ghidorah";
706
707=== modified file 'tests/test-eds-ics-missing-trigger.cpp'
708--- tests/test-eds-ics-missing-trigger.cpp 2015-10-13 14:40:02 +0000
709+++ tests/test-eds-ics-missing-trigger.cpp 2016-04-05 20:43:14 +0000
710@@ -22,6 +22,7 @@
711 #include <datetime/alarm-queue-simple.h>
712 #include <datetime/clock-mock.h>
713 #include <datetime/engine-eds.h>
714+#include <datetime/myself.h>
715 #include <datetime/planner-range.h>
716
717 #include <gtest/gtest.h>
718@@ -41,7 +42,7 @@
719 TEST_F(VAlarmFixture, MissingTriggers)
720 {
721 // start the EDS engine
722- auto engine = std::make_shared<EdsEngine>();
723+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
724
725 // we need a consistent timezone for the planner and our local DateTimes
726 constexpr char const * zone_str {"America/Chicago"};
727@@ -109,6 +110,7 @@
728
729 // the planner should match what we've got in the calendar.ics file
730 const auto appts = planner->appointments().get();
731+ EXPECT_EQ(expected.size(), appts.size());
732 EXPECT_EQ(expected, appts);
733
734 // cleanup
735
736=== added file 'tests/test-eds-ics-non-attending-alarms.cpp'
737--- tests/test-eds-ics-non-attending-alarms.cpp 1970-01-01 00:00:00 +0000
738+++ tests/test-eds-ics-non-attending-alarms.cpp 2016-04-05 20:43:14 +0000
739@@ -0,0 +1,77 @@
740+/*
741+ * Copyright 2015 Canonical Ltd.
742+ *
743+ * This program is free software: you can redistribute it and/or modify it
744+ * under the terms of the GNU General Public License version 3, as published
745+ * by the Free Software Foundation.
746+ *
747+ * This program is distributed in the hope that it will be useful, but
748+ * WITHOUT ANY WARRANTY; without even the implied warranties of
749+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
750+ * PURPOSE. See the GNU General Public License for more details.
751+ *
752+ * You should have received a copy of the GNU General Public License along
753+ * with this program. If not, see <http://www.gnu.org/licenses/>.
754+ *
755+ * Authors:
756+ * Charles Kerr <charles.kerr@canonical.com>
757+ */
758+
759+#include <algorithm>
760+
761+#include <datetime/alarm-queue-simple.h>
762+#include <datetime/clock-mock.h>
763+#include <datetime/engine-eds.h>
764+#include <datetime/myself.h>
765+#include <datetime/planner-range.h>
766+
767+#include <gtest/gtest.h>
768+
769+#include "glib-fixture.h"
770+#include "print-to.h"
771+#include "timezone-mock.h"
772+#include "wakeup-timer-mock.h"
773+
774+using namespace unity::indicator::datetime;
775+using VAlarmFixture = GlibFixture;
776+
777+/***
778+****
779+***/
780+
781+TEST_F(VAlarmFixture, NonAttendingEvent)
782+{
783+ // start the EDS engine
784+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
785+
786+ // we need a consistent timezone for the planner and our local DateTimes
787+ constexpr char const * zone_str {"America/Recife"};
788+ auto tz = std::make_shared<MockTimezone>(zone_str);
789+ auto gtz = g_time_zone_new(zone_str);
790+
791+ // make a planner that looks at the first half of 2016 in EDS
792+ auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
793+ const DateTime range_begin {gtz, 2016,1, 1, 0, 0, 0.0};
794+ const DateTime range_end {gtz, 2016,6,31,23,59,59.5};
795+ planner->range().set(std::make_pair(range_begin, range_end));
796+
797+ // give EDS a moment to load
798+ if (planner->appointments().get().empty()) {
799+ g_message("waiting a moment for EDS to load...");
800+ auto on_appointments_changed = [this](const std::vector<Appointment>& appointments){
801+ g_message("ah, they loaded");
802+ if (!appointments.empty())
803+ g_main_loop_quit(loop);
804+ };
805+ core::ScopedConnection conn(planner->appointments().changed().connect(on_appointments_changed));
806+ constexpr int max_wait_sec = 10;
807+ wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
808+ }
809+
810+ // the planner should match what we've got in the calendar.ics file
811+ const auto appts = planner->appointments().get();
812+ ASSERT_EQ(2, appts.size());
813+
814+ // cleanup
815+ g_time_zone_unref(gtz);
816+}
817
818=== added file 'tests/test-eds-ics-non-attending-alarms.ics.in'
819--- tests/test-eds-ics-non-attending-alarms.ics.in 1970-01-01 00:00:00 +0000
820+++ tests/test-eds-ics-non-attending-alarms.ics.in 2016-04-05 20:43:14 +0000
821@@ -0,0 +1,53 @@
822+BEGIN:VCALENDAR
823+CALSCALE:GREGORIAN
824+PRODID:-//Ximian//NONSGML Evolution Calendar//EN
825+VERSION:2.0
826+X-EVOLUTION-DATA-REVISION:2015-04-05T21:32:47.354433Z(2)
827+BEGIN:VEVENT
828+STATUS:CONFIRMED
829+DTSTAMP:20160405T152128Z
830+CREATED:20160405T152128Z
831+UID:ddtvl069dn2cquo8dhg3j9c360@google.com
832+SEQUENCE:1
833+TRANSP:OPAQUE
834+SUMMARY:Every day at 4PM
835+DTSTART;TZID=/freeassociation.sourceforge.net/Tzfile/America/Recife:
836+ 20160404T160000
837+RRULE:FREQ=DAILY;UNTIL=20160406T190000Z
838+DTEND;TZID=/freeassociation.sourceforge.net/Tzfile/America/Recife:
839+ 20160404T170000
840+ATTENDEE;CN=Uphablet;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;
841+ CUTYPE=INDIVIDUAL:mailto:uphablet@ubuntu.com
842+LAST-MODIFIED:20160405T152128Z
843+BEGIN:VALARM
844+TRIGGER;VALUE=DURATION:-PT30M
845+ACTION:EMAIL
846+DESCRIPTION:This is an event reminder
847+X-EVOLUTION-ALARM-UID:20160405T152128Z-2848-32011-1844-65@ubuntu-phablet
848+END:VALARM
849+END:VEVENT
850+BEGIN:VEVENT
851+STATUS:CONFIRMED
852+DTSTAMP:20160405T152128Z
853+CREATED:20160405T151054Z
854+UID:ddtvl069dn2cquo8dhg3j9c360@google.com
855+SEQUENCE:1
856+TRANSP:OPAQUE
857+SUMMARY::Every day at 4PM
858+DTSTART;TZID=/freeassociation.sourceforge.net/Tzfile/America/Fortaleza:
859+ 20160405T160000
860+RECURRENCE-ID;TZID=/freeassociation.sourceforge.net/Tzfile/America/Recife:
861+ 20160405T160000
862+DTEND;TZID=/freeassociation.sourceforge.net/Tzfile/America/Fortaleza:
863+ 20160405T170000
864+ATTENDEE;CN=Uphablet;PARTSTAT=DECLINED;ROLE=REQ-PARTICIPANT;
865+ CUTYPE=INDIVIDUAL:mailto:uphablet@ubuntu.com
866+LAST-MODIFIED:20160405T152128Z
867+BEGIN:VALARM
868+TRIGGER;VALUE=DURATION:-PT30M
869+ACTION:EMAIL
870+DESCRIPTION:This is an event reminder
871+X-EVOLUTION-ALARM-UID:20160405T152128Z-2848-32011-1844-66@ubuntu-phablet
872+END:VALARM
873+END:VEVENT
874+END:VCALENDAR
875
876=== modified file 'tests/test-eds-ics-nonrepeating-events.cpp'
877--- tests/test-eds-ics-nonrepeating-events.cpp 2015-10-13 14:40:02 +0000
878+++ tests/test-eds-ics-nonrepeating-events.cpp 2016-04-05 20:43:14 +0000
879@@ -22,6 +22,7 @@
880 #include <datetime/alarm-queue-simple.h>
881 #include <datetime/clock-mock.h>
882 #include <datetime/engine-eds.h>
883+#include <datetime/myself.h>
884 #include <datetime/planner-range.h>
885
886 #include <gtest/gtest.h>
887@@ -41,7 +42,7 @@
888 TEST_F(VAlarmFixture, MultipleAppointments)
889 {
890 // start the EDS engine
891- auto engine = std::make_shared<EdsEngine>();
892+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
893
894 // we need a consistent timezone for the planner and our local DateTimes
895 constexpr char const * zone_str {"America/Chicago"};
896@@ -66,7 +67,7 @@
897 constexpr int max_wait_sec = 10;
898 wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
899 }
900-
901+
902 // what we expect to get...
903 Appointment expected_appt;
904 expected_appt.uid = "20150520T000726Z-3878-32011-1770-81@ubuntu-phablet";
905
906=== modified file 'tests/test-eds-ics-repeating-events.cpp'
907--- tests/test-eds-ics-repeating-events.cpp 2015-10-13 14:40:02 +0000
908+++ tests/test-eds-ics-repeating-events.cpp 2016-04-05 20:43:14 +0000
909@@ -22,6 +22,7 @@
910 #include <datetime/alarm-queue-simple.h>
911 #include <datetime/clock-mock.h>
912 #include <datetime/engine-eds.h>
913+#include <datetime/myself.h>
914 #include <datetime/planner-range.h>
915
916 #include <gtest/gtest.h>
917@@ -41,7 +42,7 @@
918 TEST_F(VAlarmFixture, MultipleAppointments)
919 {
920 // start the EDS engine
921- auto engine = std::make_shared<EdsEngine>();
922+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
923
924 // we need a consistent timezone for the planner and our local DateTimes
925 constexpr char const * zone_str {"America/Chicago"};
926@@ -66,7 +67,7 @@
927 constexpr int max_wait_sec = 10;
928 wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
929 }
930-
931+
932 // what we expect to get...
933 Appointment expected_appt;
934 expected_appt.uid = "20150507T211449Z-4262-32011-1418-1@ubuntu-phablet";
935
936=== modified file 'tests/test-eds-ics-repeating-valarms.cpp'
937--- tests/test-eds-ics-repeating-valarms.cpp 2015-05-20 23:23:32 +0000
938+++ tests/test-eds-ics-repeating-valarms.cpp 2016-04-05 20:43:14 +0000
939@@ -22,6 +22,7 @@
940 #include <datetime/alarm-queue-simple.h>
941 #include <datetime/clock-mock.h>
942 #include <datetime/engine-eds.h>
943+#include <datetime/myself.h>
944 #include <datetime/planner-range.h>
945
946 #include <gtest/gtest.h>
947@@ -41,7 +42,7 @@
948 TEST_F(VAlarmFixture, MultipleAppointments)
949 {
950 // start the EDS engine
951- auto engine = std::make_shared<EdsEngine>();
952+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
953
954 // we need a consistent timezone for the planner and our local DateTimes
955 constexpr char const * zone_str {"America/Chicago"};
956
957=== modified file 'tests/test-eds-ics-tzids-2.cpp'
958--- tests/test-eds-ics-tzids-2.cpp 2015-07-09 20:56:13 +0000
959+++ tests/test-eds-ics-tzids-2.cpp 2016-04-05 20:43:14 +0000
960@@ -22,6 +22,7 @@
961 #include <datetime/alarm-queue-simple.h>
962 #include <datetime/clock-mock.h>
963 #include <datetime/engine-eds.h>
964+#include <datetime/myself.h>
965 #include <datetime/planner-range.h>
966
967 #include <gtest/gtest.h>
968@@ -41,7 +42,7 @@
969 TEST_F(VAlarmFixture, MultipleAppointments)
970 {
971 // start the EDS engine
972- auto engine = std::make_shared<EdsEngine>();
973+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
974
975 // we need a consistent timezone for the planner and our local DateTimes
976 constexpr char const * zone_str {"America/Los_Angeles"};
977
978=== modified file 'tests/test-eds-ics-tzids-utc.cpp'
979--- tests/test-eds-ics-tzids-utc.cpp 2016-03-22 19:13:10 +0000
980+++ tests/test-eds-ics-tzids-utc.cpp 2016-04-05 20:43:14 +0000
981@@ -22,6 +22,7 @@
982 #include <datetime/alarm-queue-simple.h>
983 #include <datetime/clock-mock.h>
984 #include <datetime/engine-eds.h>
985+#include <datetime/myself.h>
986 #include <datetime/planner-range.h>
987
988 #include <gtest/gtest.h>
989@@ -41,7 +42,7 @@
990 TEST_F(VAlarmFixture, UTCAppointments)
991 {
992 // start the EDS engine
993- auto engine = std::make_shared<EdsEngine>();
994+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
995
996 // we need a consistent timezone for the planner and our local DateTimes
997 constexpr char const * zone_str {"America/Recife"};
998
999=== modified file 'tests/test-eds-ics-tzids.cpp'
1000--- tests/test-eds-ics-tzids.cpp 2015-07-09 19:14:32 +0000
1001+++ tests/test-eds-ics-tzids.cpp 2016-04-05 20:43:14 +0000
1002@@ -22,6 +22,7 @@
1003 #include <datetime/alarm-queue-simple.h>
1004 #include <datetime/clock-mock.h>
1005 #include <datetime/engine-eds.h>
1006+#include <datetime/myself.h>
1007 #include <datetime/planner-range.h>
1008
1009 #include <gtest/gtest.h>
1010@@ -41,7 +42,7 @@
1011 TEST_F(VAlarmFixture, MultipleAppointments)
1012 {
1013 // start the EDS engine
1014- auto engine = std::make_shared<EdsEngine>();
1015+ auto engine = std::make_shared<EdsEngine>(std::make_shared<Myself>());
1016
1017 // we need a consistent timezone for the planner and our local DateTimes
1018 constexpr char const * zone_str {"Europe/Berlin"};

Subscribers

People subscribed via source and target branches