139
void disable_ubuntu_alarm(const Appointment& appointment)
141
if (appointment.is_ubuntu_alarm())
143
for (auto& kv : m_clients) // find the matching icalcomponent
145
e_cal_client_get_object(kv.second,
146
appointment.uid.c_str(),
149
on_object_ready_for_disable,
141
157
void set_dirty_now()
507
523
return G_SOURCE_CONTINUE;
530
static void on_object_ready_for_disable(GObject * client,
531
GAsyncResult * result,
534
icalcomponent * icc = nullptr;
535
if (e_cal_client_get_object_finish (E_CAL_CLIENT(client), result, &icc, nullptr))
537
struct icaltimetype itt = icalcomponent_get_recurrenceid(icc);
538
if (icaltime_is_null_time(itt))
540
g_debug("'%s' appears to be a one-time alarm... adding 'disabled' tag.",
541
icalcomponent_as_ical_string(icc));
543
auto ecc = e_cal_component_new_from_icalcomponent (icc); // takes ownership of icc
548
// add TAG_DISABLED to the list of categories
549
GSList * old_categories = nullptr;
550
e_cal_component_get_categories_list(ecc, &old_categories);
551
auto new_categories = g_slist_copy(old_categories);
552
new_categories = g_slist_append(new_categories, const_cast<char*>(TAG_DISABLED));
553
e_cal_component_set_categories_list(ecc, new_categories);
554
g_slist_free(new_categories);
555
e_cal_component_free_categories_list(old_categories);
556
e_cal_client_modify_object(E_CAL_CLIENT(client),
557
e_cal_component_get_icalcomponent(ecc),
559
static_cast<Impl*>(gself)->m_cancellable,
563
g_clear_object(&ecc);
567
g_clear_pointer(&icc, icalcomponent_free);
571
static void on_disable_done (GObject* gclient, GAsyncResult *res, gpointer)
573
GError * error = nullptr;
574
if (!e_cal_client_modify_object_finish (E_CAL_CLIENT(gclient), res, &error))
576
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
577
g_warning("indicator-datetime cannot mark one-time alarm as disabled: %s", error->message);
510
587
core::Signal<> m_changed;
511
588
std::set<ESource*> m_sources;
541
618
p->get_appointments(begin, end, tz, func);
621
void EdsEngine::disable_ubuntu_alarm(const Appointment& appointment)
623
p->disable_ubuntu_alarm(appointment);