From 3e119374a27c333e2e85f2887668eb309edbe183 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 2 Feb 2014 15:28:10 -0600 Subject: add an ECalClientView for each ECalClient to listen for changes to its components. --- src/planner-eds.cpp | 169 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 122 insertions(+), 47 deletions(-) (limited to 'src/planner-eds.cpp') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index cb42d6e..22e834f 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -26,6 +26,9 @@ #include #include +#include +#include + namespace unity { namespace indicator { namespace datetime { @@ -34,9 +37,6 @@ namespace datetime { ***** ****/ -G_DEFINE_QUARK("source-client", source_client) - - class PlannerEds::Impl { public: @@ -48,11 +48,11 @@ public: e_source_registry_new(m_cancellable, on_source_registry_ready, this); m_owner.time.changed().connect([this](const DateTime& dt) { - g_debug("planner's datetime property changed to %s; calling rebuildSoon()", dt.format("%F %T").c_str()); - rebuildSoon(); + g_debug("planner's datetime property changed to %s; calling rebuild_soon()", dt.format("%F %T").c_str()); + rebuild_soon(); }); - rebuildSoon(); + rebuild_soon(); } ~Impl() @@ -60,6 +60,9 @@ public: g_cancellable_cancel(m_cancellable); g_clear_object(&m_cancellable); + while(!m_sources.empty()) + remove_source(*m_sources.begin()); + if (m_rebuild_tag) g_source_remove(m_rebuild_tag); @@ -102,7 +105,7 @@ private: static void on_source_added(ESourceRegistry* registry, ESource* source, gpointer gself) { - auto self = static_cast(gself); + auto self = static_cast(gself); self->m_sources.insert(E_SOURCE(g_object_ref(source))); @@ -112,8 +115,9 @@ private: static void on_source_enabled(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) { - auto self = static_cast(gself); + auto self = static_cast(gself); + g_debug("connecting a client to source %s", e_source_get_uid(source)); e_cal_client_connect(source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, self->m_cancellable, @@ -134,45 +138,118 @@ private: } else { - // we've got a new connected ECalClient, so store it & notify clients - g_object_set_qdata_full(G_OBJECT(e_client_get_source(client)), - source_client_quark(), - client, - g_object_unref); - - g_debug("client connected; calling rebuildSoon()"); - static_cast(gself)->rebuildSoon(); + // add the client to our collection + auto self = static_cast(gself); + g_debug("got a client for %s", e_cal_client_get_local_attachment_store(E_CAL_CLIENT(client))); + self->m_clients[e_client_get_source(client)] = E_CAL_CLIENT(client); + + // now create a view for it so that we can listen for changes + e_cal_client_get_view (E_CAL_CLIENT(client), + "#t", // match all + self->m_cancellable, + on_client_view_ready, + self); + + g_debug("client connected; calling rebuild_soon()"); + self->rebuild_soon(); } } - static void on_source_disabled(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) + static void on_client_view_ready (GObject* client, GAsyncResult* res, gpointer gself) { - gpointer e_cal_client; + GError* error = nullptr; + ECalClientView* view = nullptr; - // if this source has a connected ECalClient, remove it & notify clients - if ((e_cal_client = g_object_steal_qdata(G_OBJECT(source), source_client_quark()))) + if (e_cal_client_get_view_finish (E_CAL_CLIENT(client), res, &view, &error)) { - g_object_unref(e_cal_client); + // add the view to our collection + e_cal_client_view_start(view, &error); + g_debug("got a view for %s", e_cal_client_get_local_attachment_store(E_CAL_CLIENT(client))); + auto self = static_cast(gself); + self->m_views[e_client_get_source(E_CLIENT(client))] = view;//G_CAL_CLIENT(client)] = view;//.insert(view); - g_debug("source disabled; calling rebuildSoon()"); - static_cast(gself)->rebuildSoon(); + g_signal_connect(view, "objects-added", G_CALLBACK(on_view_objects_added), self); + g_signal_connect(view, "objects-modified", G_CALLBACK(on_view_objects_modified), self); + g_signal_connect(view, "objects-removed", G_CALLBACK(on_view_objects_removed), self); + g_debug("view connected; calling rebuild_soon()"); + self->rebuild_soon(); } + else if(error != nullptr) + { + if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_warning("indicator-datetime cannot get View to EDS client: %s", error->message); + + g_error_free(error); + } + } + + static void on_view_objects_added(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) + { + g_debug("%s", G_STRFUNC); + static_cast(gself)->rebuild_soon(); + } + static void on_view_objects_modified(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) + { + g_debug("%s", G_STRFUNC); + static_cast(gself)->rebuild_soon(); + } + static void on_view_objects_removed(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) + { + g_debug("%s", G_STRFUNC); + static_cast(gself)->rebuild_soon(); } - static void on_source_removed(ESourceRegistry* registry, ESource* source, gpointer gself) + static void on_source_disabled(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) + { + static_cast(gself)->disable_source(source); + } + void disable_source(ESource* source) { - auto self = static_cast(gself); + // if an ECalClientView is associated with this source, remove it + auto vit = m_views.find(source); + if (vit != m_views.end()) + { + auto& view = vit->second; + e_cal_client_view_stop(view, nullptr); + const auto n_disconnected = g_signal_handlers_disconnect_by_data(view, this); + g_warn_if_fail(n_disconnected == 3); + g_object_unref(view); + m_views.erase(vit); + rebuild_soon(); + } - on_source_disabled(registry, source, gself); + // if an ECalClient is associated with this source, remove it + auto cit = m_clients.find(source); + if (cit != m_clients.end()) + { + auto& client = cit->second; + g_object_unref(client); + m_clients.erase(cit); + rebuild_soon(); + } + } - self->m_sources.erase(source); - g_object_unref(source); + static void on_source_removed(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) + { + static_cast(gself)->remove_source(source); + } + void remove_source(ESource* source) + { + disable_source(source); + + auto sit = m_sources.find(source); + if (sit != m_sources.end()) + { + g_object_unref(*sit); + m_sources.erase(sit); + rebuild_soon(); + } } static void on_source_changed(ESourceRegistry* /*registry*/, ESource* /*source*/, gpointer gself) { - g_debug("source changed; calling rebuildSoon()"); - static_cast(gself)->rebuildSoon(); + g_debug("source changed; calling rebuild_soon()"); + static_cast(gself)->rebuild_soon(); } private: @@ -196,23 +273,23 @@ private: task(task_in), client(client_in), color(color_in) {} }; - void rebuildSoon() + void rebuild_soon() { const static guint ARBITRARY_INTERVAL_SECS = 2; if (m_rebuild_tag == 0) - m_rebuild_tag = g_timeout_add_seconds(ARBITRARY_INTERVAL_SECS, rebuildNowStatic, this); + m_rebuild_tag = g_timeout_add_seconds(ARBITRARY_INTERVAL_SECS, rebuild_now_static, this); } - static gboolean rebuildNowStatic(gpointer gself) + static gboolean rebuild_now_static(gpointer gself) { auto self = static_cast(gself); self->m_rebuild_tag = 0; - self->rebuildNow(); + self->rebuild_now(); return G_SOURCE_REMOVE; } - void rebuildNow() + void rebuild_now() { const auto calendar_date = m_owner.time.get().get(); GDateTime* begin; @@ -225,7 +302,7 @@ private: end = g_date_time_new_local(y, m, g_date_get_days_in_month(GDateMonth(m),GDateYear(y)), 23, 59, 59.9); if (begin && end) { - getAppointments(begin, end, [this](const std::vector& appointments) { + get_appointments(begin, end, [this](const std::vector& appointments) { g_debug("got %d appointments in this calendar month", (int)appointments.size()); m_owner.this_month.set(appointments); }); @@ -238,7 +315,7 @@ private: end = g_date_time_add_months(begin, 1); if (begin && end) { - getAppointments(begin, end, [this](const std::vector& appointments) { + get_appointments(begin, end, [this](const std::vector& appointments) { g_debug("got %d upcoming appointments", (int)appointments.size()); m_owner.upcoming.set(appointments); }); @@ -247,7 +324,7 @@ private: g_clear_pointer(&end, g_date_time_unref); } - void getAppointments(GDateTime* begin_dt, GDateTime* end_dt, appointment_func func) + void get_appointments(GDateTime* begin_dt, GDateTime* end_dt, appointment_func func) { const auto begin = g_date_time_to_unix(begin_dt); const auto end = g_date_time_to_unix(end_dt); @@ -286,16 +363,14 @@ private: delete task; }); - for (auto& source : m_sources) + for (auto& kv : m_clients) { - auto client = E_CAL_CLIENT(g_object_get_qdata(G_OBJECT(source), source_client_quark())); - if (client == nullptr) - continue; - + auto& client = kv.second; if (default_timezone != nullptr) e_cal_client_set_default_timezone(client, default_timezone); // start a new subtask to enumerate all the components in this client. + auto& source = kv.first; auto extension = e_source_get_extension(source, E_SOURCE_EXTENSION_CALENDAR); const auto color = e_source_selectable_get_color(E_SOURCE_SELECTABLE(extension)); g_debug("calling e_cal_client_generate_instances for %p", (void*)client); @@ -407,12 +482,12 @@ private: delete subtask; } -private: - PlannerEds& m_owner; std::set m_sources; - GCancellable * m_cancellable = nullptr; - ESourceRegistry * m_source_registry = nullptr; + std::map m_clients; + std::map m_views; + GCancellable* m_cancellable = nullptr; + ESourceRegistry* m_source_registry = nullptr; guint m_rebuild_tag = 0; }; -- cgit v1.2.3 From a03811363619c178fd5156fa94eb5d5a4897afa5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 2 Feb 2014 19:23:08 -0600 Subject: aha! ubntu-ui-toolkit stores its alarms in E_SOURCE_EXTENSION_TASK_LIST instead of E_SOURCE_EXTENSION_CALENDAR. Let's handle both in indicator-datetime. --- src/planner-eds.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/planner-eds.cpp') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index 22e834f..79b340a 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -86,23 +86,28 @@ private: } else { - auto self = static_cast(gself); - - g_signal_connect(r, "source-added", G_CALLBACK(on_source_added), self); - g_signal_connect(r, "source-removed", G_CALLBACK(on_source_removed), self); - g_signal_connect(r, "source-changed", G_CALLBACK(on_source_changed), self); - g_signal_connect(r, "source-disabled", G_CALLBACK(on_source_disabled), self); - g_signal_connect(r, "source-enabled", G_CALLBACK(on_source_enabled), self); + g_signal_connect(r, "source-added", G_CALLBACK(on_source_added), gself); + g_signal_connect(r, "source-removed", G_CALLBACK(on_source_removed), gself); + g_signal_connect(r, "source-changed", G_CALLBACK(on_source_changed), gself); + g_signal_connect(r, "source-disabled", G_CALLBACK(on_source_disabled), gself); + g_signal_connect(r, "source-enabled", G_CALLBACK(on_source_enabled), gself); + auto self = static_cast(gself); self->m_source_registry = r; - - GList* sources = e_source_registry_list_sources(r, E_SOURCE_EXTENSION_CALENDAR); - for (auto l=sources; l!=nullptr; l=l->next) - on_source_added(r, E_SOURCE(l->data), gself); - g_list_free_full(sources, g_object_unref); + self->add_sources_by_extension(E_SOURCE_EXTENSION_CALENDAR); + self->add_sources_by_extension(E_SOURCE_EXTENSION_TASK_LIST); } } + void add_sources_by_extension(const char* extension) + { + auto& r = m_source_registry; + auto sources = e_source_registry_list_sources(r, extension); + for (auto l=sources; l!=nullptr; l=l->next) + on_source_added(r, E_SOURCE(l->data), this); + g_list_free_full(sources, g_object_unref); + } + static void on_source_added(ESourceRegistry* registry, ESource* source, gpointer gself) { auto self = static_cast(gself); -- cgit v1.2.3 From 2934ddcc6b2c56d12eda6fcf12d8264f43bc0a12 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 2 Feb 2014 23:01:20 -0600 Subject: when connecting to an ECalClient, use the proper source types for events/tasks --- src/planner-eds.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/planner-eds.cpp') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index 79b340a..06b29d3 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -121,10 +121,18 @@ private: static void on_source_enabled(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) { auto self = static_cast(gself); + ECalClientSourceType source_type; + + if (e_source_has_extension(source, E_SOURCE_EXTENSION_CALENDAR)) + source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; + else if (e_source_has_extension(source, E_SOURCE_EXTENSION_TASK_LIST)) + source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; + else + g_assert_not_reached(); g_debug("connecting a client to source %s", e_source_get_uid(source)); e_cal_client_connect(source, - E_CAL_CLIENT_SOURCE_TYPE_EVENTS, + source_type, self->m_cancellable, on_client_connected, gself); -- cgit v1.2.3 From 86fb7d453df01b80f73a82b690626ff35477ad4b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 3 Feb 2014 01:02:24 -0600 Subject: copyediting: remove a piece of dead code --- src/planner-eds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/planner-eds.cpp') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index 06b29d3..9048f52 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -179,7 +179,7 @@ private: e_cal_client_view_start(view, &error); g_debug("got a view for %s", e_cal_client_get_local_attachment_store(E_CAL_CLIENT(client))); auto self = static_cast(gself); - self->m_views[e_client_get_source(E_CLIENT(client))] = view;//G_CAL_CLIENT(client)] = view;//.insert(view); + self->m_views[e_client_get_source(E_CLIENT(client))] = view; g_signal_connect(view, "objects-added", G_CALLBACK(on_view_objects_added), self); g_signal_connect(view, "objects-modified", G_CALLBACK(on_view_objects_modified), self); -- cgit v1.2.3 From 894c0c625ff1e2f2d031f48f157a3008302cb5a7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 4 Feb 2014 00:10:17 -0600 Subject: pin the planner's upcoming appointments to the live clock time, rather than the calendar's time, so that they always update correctly in real-time --- src/planner-eds.cpp | 117 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 47 deletions(-) (limited to 'src/planner-eds.cpp') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index 9048f52..7d9416c 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -41,18 +41,24 @@ class PlannerEds::Impl { public: - Impl(PlannerEds& owner): + Impl(PlannerEds& owner, const std::shared_ptr& clock): m_owner(owner), + m_clock(clock), m_cancellable(g_cancellable_new()) { e_source_registry_new(m_cancellable, on_source_registry_ready, this); + m_clock->minute_changed.connect([this](){ + g_debug("rebuilding upcoming because the clock's minute_changed"); + rebuild_soon(UPCOMING); + }); + m_owner.time.changed().connect([this](const DateTime& dt) { g_debug("planner's datetime property changed to %s; calling rebuild_soon()", dt.format("%F %T").c_str()); - rebuild_soon(); + rebuild_soon(MONTH); }); - rebuild_soon(); + rebuild_soon(ALL); } ~Impl() @@ -164,7 +170,7 @@ private: self); g_debug("client connected; calling rebuild_soon()"); - self->rebuild_soon(); + self->rebuild_soon(ALL); } } @@ -185,7 +191,7 @@ private: g_signal_connect(view, "objects-modified", G_CALLBACK(on_view_objects_modified), self); g_signal_connect(view, "objects-removed", G_CALLBACK(on_view_objects_removed), self); g_debug("view connected; calling rebuild_soon()"); - self->rebuild_soon(); + self->rebuild_soon(ALL); } else if(error != nullptr) { @@ -199,17 +205,17 @@ private: static void on_view_objects_added(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) { g_debug("%s", G_STRFUNC); - static_cast(gself)->rebuild_soon(); + static_cast(gself)->rebuild_soon(ALL); } static void on_view_objects_modified(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) { g_debug("%s", G_STRFUNC); - static_cast(gself)->rebuild_soon(); + static_cast(gself)->rebuild_soon(ALL); } static void on_view_objects_removed(ECalClientView* /*view*/, gpointer /*objects*/, gpointer gself) { g_debug("%s", G_STRFUNC); - static_cast(gself)->rebuild_soon(); + static_cast(gself)->rebuild_soon(ALL); } static void on_source_disabled(ESourceRegistry* /*registry*/, ESource* source, gpointer gself) @@ -228,7 +234,7 @@ private: g_warn_if_fail(n_disconnected == 3); g_object_unref(view); m_views.erase(vit); - rebuild_soon(); + rebuild_soon(ALL); } // if an ECalClient is associated with this source, remove it @@ -238,7 +244,7 @@ private: auto& client = cit->second; g_object_unref(client); m_clients.erase(cit); - rebuild_soon(); + rebuild_soon(ALL); } } @@ -255,14 +261,14 @@ private: { g_object_unref(*sit); m_sources.erase(sit); - rebuild_soon(); + rebuild_soon(ALL); } } static void on_source_changed(ESourceRegistry* /*registry*/, ESource* /*source*/, gpointer gself) { g_debug("source changed; calling rebuild_soon()"); - static_cast(gself)->rebuild_soon(); + static_cast(gself)->rebuild_soon(ALL); } private: @@ -286,9 +292,11 @@ private: task(task_in), client(client_in), color(color_in) {} }; - void rebuild_soon() + void rebuild_soon(int rebuild_flags) { - const static guint ARBITRARY_INTERVAL_SECS = 2; + static const guint ARBITRARY_INTERVAL_SECS = 2; + + m_rebuild_flags |= rebuild_flags; if (m_rebuild_tag == 0) m_rebuild_tag = g_timeout_add_seconds(ARBITRARY_INTERVAL_SECS, rebuild_now_static, this); @@ -297,44 +305,56 @@ private: static gboolean rebuild_now_static(gpointer gself) { auto self = static_cast(gself); + const auto flags = self->m_rebuild_flags; self->m_rebuild_tag = 0; - self->rebuild_now(); + self->m_rebuild_flags = 0; + self->rebuild_now(flags); return G_SOURCE_REMOVE; } - void rebuild_now() + void rebuild_now(int rebuild_flags) { - const auto calendar_date = m_owner.time.get().get(); - GDateTime* begin; - GDateTime* end; - int y, m, d; - - // get all the appointments in the calendar month - g_date_time_get_ymd(calendar_date, &y, &m, &d); - begin = g_date_time_new_local(y, m, 1, 0, 0, 0.1); - end = g_date_time_new_local(y, m, g_date_get_days_in_month(GDateMonth(m),GDateYear(y)), 23, 59, 59.9); - if (begin && end) - { - get_appointments(begin, end, [this](const std::vector& appointments) { - g_debug("got %d appointments in this calendar month", (int)appointments.size()); - m_owner.this_month.set(appointments); - }); - } - g_clear_pointer(&begin, g_date_time_unref); - g_clear_pointer(&end, g_date_time_unref); + if (rebuild_flags & UPCOMING) + rebuild_upcoming(); - // get the upcoming appointments - begin = g_date_time_ref(calendar_date); - end = g_date_time_add_months(begin, 1); - if (begin && end) - { - get_appointments(begin, end, [this](const std::vector& appointments) { - g_debug("got %d upcoming appointments", (int)appointments.size()); - m_owner.upcoming.set(appointments); - }); - } - g_clear_pointer(&begin, g_date_time_unref); - g_clear_pointer(&end, g_date_time_unref); + if (rebuild_flags & MONTH) + rebuild_month(); + } + + void rebuild_month() + { + const auto ref = m_owner.time.get().get(); + auto month_begin = g_date_time_add_full(ref, + 0, // subtract no years + 0, // subtract no months + -(g_date_time_get_day_of_month(ref)-1), + -g_date_time_get_hour(ref), + -g_date_time_get_minute(ref), + -g_date_time_get_seconds(ref)); + auto month_end = g_date_time_add_full(month_begin, 0, 1, 0, 0, 0, -0.1); + + get_appointments(month_begin, month_end, [this](const std::vector& appointments) { + g_debug("got %d appointments in this calendar month", (int)appointments.size()); + m_owner.this_month.set(appointments); + }); + + g_date_time_unref(month_end); + g_date_time_unref(month_begin); + } + + void rebuild_upcoming() + { + const auto ref = m_clock->localtime(); + const auto begin = g_date_time_add_minutes(ref.get(),-10); + const auto end = g_date_time_add_months(begin,1); + + get_appointments(begin, end, [this](const std::vector& appointments) { + g_debug("got %d upcoming appointments", (int)appointments.size()); + m_owner.upcoming.set(appointments); + }); + + g_date_time_unref(end); + g_date_time_unref(begin); } void get_appointments(GDateTime* begin_dt, GDateTime* end_dt, appointment_func func) @@ -496,15 +516,18 @@ private: } PlannerEds& m_owner; + std::shared_ptr m_clock; std::set m_sources; std::map m_clients; std::map m_views; GCancellable* m_cancellable = nullptr; ESourceRegistry* m_source_registry = nullptr; guint m_rebuild_tag = 0; + guint m_rebuild_flags = 0; + enum { UPCOMING=(1<<0), MONTH=(1<<1), ALL=UPCOMING|MONTH }; }; -PlannerEds::PlannerEds(): p(new Impl(*this)) {} +PlannerEds::PlannerEds(const std::shared_ptr& clock): p(new Impl(*this, clock)) {} PlannerEds::~PlannerEds() =default; -- cgit v1.2.3 From 613cbb1d468fe99767a5541956266191511ec9ef Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 5 Feb 2014 16:26:34 -0600 Subject: remove alarms from the menu once they've been shown in a snap decision. --- src/planner-eds.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/planner-eds.cpp') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index 7d9416c..e9452f0 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -77,6 +77,12 @@ public: g_clear_object(&m_source_registry); } + void block_appointment(const Appointment& appointment) + { + m_blocked.insert(appointment.uid); + rebuild_soon(UPCOMING); + } + private: static void on_source_registry_ready(GObject* /*source*/, GAsyncResult* res, gpointer gself) @@ -348,9 +354,13 @@ private: const auto begin = g_date_time_add_minutes(ref.get(),-10); const auto end = g_date_time_add_months(begin,1); - get_appointments(begin, end, [this](const std::vector& appointments) { - g_debug("got %d upcoming appointments", (int)appointments.size()); - m_owner.upcoming.set(appointments); + get_appointments(begin, end, [this](const std::vector& all) { + std::vector unblocked; + for(const auto& a : all) + if (m_blocked.count(a.uid) == 0) + unblocked.push_back(a); + g_debug("got %d upcoming appointments, %d of which are unblocked", (int)all.size(), (int)unblocked.size()); + m_owner.upcoming.set(unblocked); }); g_date_time_unref(end); @@ -520,6 +530,7 @@ private: std::set m_sources; std::map m_clients; std::map m_views; + std::set m_blocked; GCancellable* m_cancellable = nullptr; ESourceRegistry* m_source_registry = nullptr; guint m_rebuild_tag = 0; @@ -531,6 +542,11 @@ PlannerEds::PlannerEds(const std::shared_ptr& clock): p(new Impl(*this, c PlannerEds::~PlannerEds() =default; +void PlannerEds::block_appointment(const Appointment& appointment) +{ + p->block_appointment(appointment); +} + } // namespace datetime } // namespace indicator } // namespace unity -- cgit v1.2.3 From 4f27e42b0a517fac386042c67efc721463115bb9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 5 Feb 2014 16:52:57 -0600 Subject: revert r400; we can't block alarms by UID because that would hide recurring alarms --- src/planner-eds.cpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'src/planner-eds.cpp') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index e9452f0..7d9416c 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -77,12 +77,6 @@ public: g_clear_object(&m_source_registry); } - void block_appointment(const Appointment& appointment) - { - m_blocked.insert(appointment.uid); - rebuild_soon(UPCOMING); - } - private: static void on_source_registry_ready(GObject* /*source*/, GAsyncResult* res, gpointer gself) @@ -354,13 +348,9 @@ private: const auto begin = g_date_time_add_minutes(ref.get(),-10); const auto end = g_date_time_add_months(begin,1); - get_appointments(begin, end, [this](const std::vector& all) { - std::vector unblocked; - for(const auto& a : all) - if (m_blocked.count(a.uid) == 0) - unblocked.push_back(a); - g_debug("got %d upcoming appointments, %d of which are unblocked", (int)all.size(), (int)unblocked.size()); - m_owner.upcoming.set(unblocked); + get_appointments(begin, end, [this](const std::vector& appointments) { + g_debug("got %d upcoming appointments", (int)appointments.size()); + m_owner.upcoming.set(appointments); }); g_date_time_unref(end); @@ -530,7 +520,6 @@ private: std::set m_sources; std::map m_clients; std::map m_views; - std::set m_blocked; GCancellable* m_cancellable = nullptr; ESourceRegistry* m_source_registry = nullptr; guint m_rebuild_tag = 0; @@ -542,11 +531,6 @@ PlannerEds::PlannerEds(const std::shared_ptr& clock): p(new Impl(*this, c PlannerEds::~PlannerEds() =default; -void PlannerEds::block_appointment(const Appointment& appointment) -{ - p->block_appointment(appointment); -} - } // namespace datetime } // namespace indicator } // namespace unity -- cgit v1.2.3