[evolution-data-server] Update X-EVOLUTION-ENDDATE before saving changes to events



commit 2ca8407982a85a55288dbcb671632f9610e317a6
Author: Milan Crha <mcrha redhat com>
Date:   Tue Nov 18 13:41:34 2014 +0100

    Update X-EVOLUTION-ENDDATE before saving changes to events
    
    Outdated X-EVOLUTION-ENDDATE could cause missing instances
    of the recurring events, or too many instances being generated.

 calendar/backends/caldav/e-cal-backend-caldav.c |    5 +++++
 calendar/backends/file/e-cal-backend-file.c     |    6 ++++++
 calendar/libecal/e-cal-recur.c                  |    3 +++
 3 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 92ca0b8..d3e835f 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -4153,6 +4153,7 @@ do_modify_objects (ECalBackendCalDAV *cbdav,
                }
                break;
        case E_CAL_OBJ_MOD_ALL:
+               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, cbdav);
                cache_comp = replace_master (cbdav, cache_comp, icalcomponent_new_clone 
(e_cal_component_get_icalcomponent (comp)));
                break;
        case E_CAL_OBJ_MOD_THIS_AND_PRIOR:
@@ -4177,6 +4178,7 @@ do_modify_objects (ECalBackendCalDAV *cbdav,
                                        icalcomponent_remove_property (icalcomp, prop);
 
                                e_cal_component_rescan (comp);
+                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, cbdav);
 
                                /* Then do it like for "mod_all" */
                                cache_comp = replace_master (cbdav, cache_comp, icalcomponent_new_clone 
(e_cal_component_get_icalcomponent (comp)));
@@ -4206,6 +4208,7 @@ do_modify_objects (ECalBackendCalDAV *cbdav,
                                rid = icaltime_convert_to_zone (rid, icaltimezone_get_utc_timezone ());
                                e_cal_util_remove_instances (master_comp, rid, mod);
                                e_cal_component_rescan (mcomp);
+                               e_cal_recur_ensure_end_dates (mcomp, TRUE, resolve_tzid, cbdav);
 
                                if (new_components) {
                                        *new_components = g_slist_prepend (*new_components,
@@ -4227,6 +4230,8 @@ do_modify_objects (ECalBackendCalDAV *cbdav,
 
                                g_warn_if_fail (e_cal_component_set_icalcomponent (comp, split_icalcomp));
 
+                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, cbdav);
+
                                /* sanitize the component */
                                sanitize_component ((ECalBackend *) cbdav, comp);
 
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index b39505f..e777379 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -2452,6 +2452,8 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                                /* add the new object */
                                obj_data->full_object = comp;
 
+                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, priv->icalcomp);
+
                                icalcomponent_add_component (
                                        priv->icalcomp,
                                        e_cal_component_get_icalcomponent (obj_data->full_object));
@@ -2557,6 +2559,7 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                                        rid_struct = icaltime_convert_to_zone (rid_struct, 
icaltimezone_get_utc_timezone ());
                                        e_cal_util_remove_instances (e_cal_component_get_icalcomponent 
(obj_data->full_object), rid_struct, mod);
                                        e_cal_component_rescan (obj_data->full_object);
+                                       e_cal_recur_ensure_end_dates (obj_data->full_object, TRUE, 
resolve_tzid, priv->icalcomp);
 
                                        e_cal_backend_notify_component_modified (E_CAL_BACKEND (backend), 
prev_comp, obj_data->full_object);
 
@@ -2581,6 +2584,7 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
                                g_free (new_uid);
 
                                g_warn_if_fail (e_cal_component_set_icalcomponent (comp, split_icalcomp));
+                               e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, priv->icalcomp);
 
                                /* sanitize the component */
                                sanitize_component (cbfile, comp);
@@ -2606,6 +2610,8 @@ e_cal_backend_file_modify_objects (ECalBackendSync *backend,
 
                        remove_component (cbfile, comp_uid, obj_data);
 
+                       e_cal_recur_ensure_end_dates (comp, TRUE, resolve_tzid, priv->icalcomp);
+
                        /* Add the new object */
                        add_component (cbfile, comp, TRUE);
 
diff --git a/calendar/libecal/e-cal-recur.c b/calendar/libecal/e-cal-recur.c
index 54e8212..9e090dd 100644
--- a/calendar/libecal/e-cal-recur.c
+++ b/calendar/libecal/e-cal-recur.c
@@ -3900,6 +3900,9 @@ e_cal_recur_ensure_rule_end_date (ECalComponent *comp,
        if (!refresh) {
                if (e_cal_recur_get_rule_end_date (prop, NULL) != -1)
                        return FALSE;
+       } else {
+               /* Remove the property parameter, thus it'll not influence the regeneration */
+               icalproperty_remove_parameter_by_name (prop, EVOLUTION_END_DATE_PARAMETER);
        }
 
        /* Calculate the end date. Note that we initialize end_date to 0, so


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]