aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2003-03-22 04:29:55 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-03-22 04:29:55 +0800
commitf1cfc02875041a11d9e0b353687d36d0d759d55d (patch)
tree420d10f1ec76d423d79e4a9feead4d920b8dad29 /calendar
parent911fdb7885bba5043b823f99896e7d9b62b52b1f (diff)
downloadgsoc2013-evolution-f1cfc02875041a11d9e0b353687d36d0d759d55d.tar
gsoc2013-evolution-f1cfc02875041a11d9e0b353687d36d0d759d55d.tar.gz
gsoc2013-evolution-f1cfc02875041a11d9e0b353687d36d0d759d55d.tar.bz2
gsoc2013-evolution-f1cfc02875041a11d9e0b353687d36d0d759d55d.tar.lz
gsoc2013-evolution-f1cfc02875041a11d9e0b353687d36d0d759d55d.tar.xz
gsoc2013-evolution-f1cfc02875041a11d9e0b353687d36d0d759d55d.tar.zst
gsoc2013-evolution-f1cfc02875041a11d9e0b353687d36d0d759d55d.zip
Fixes #31660
2003-03-21 JP Rosevear <jpr@ximian.com> Fixes #31660 * conduits/calendar/calendar-conduit.c (rrules_mostly_equal): check if the rrules are equal other than until/count (find_last_cb): update the data with the start timet (local_record_from_comp): handle the case where the recurrence rule ends after a certain number occurrences (comp_from_remote_record): same svn path=/trunk/; revision=20458
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c90
2 files changed, 88 insertions, 11 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ea77c1ab76..84343f98eb 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,12 @@
+2003-03-21 JP Rosevear <jpr@ximian.com>
+
+ * conduits/calendar/calendar-conduit.c (rrules_mostly_equal):
+ check if the rrules are equal other than until/count
+ (find_last_cb): update the data with the start timet
+ (local_record_from_comp): handle the case where the recurrence
+ rule ends after a certain number occurrences
+ (comp_from_remote_record): same
+
2003-03-20 JP Rosevear <jpr@ximian.com>
* conduits/calendar/calendar-conduit.c
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 94bc2c3fd0..80ef758edd 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -701,6 +701,33 @@ compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *ui
}
}
+static gboolean
+rrules_mostly_equal (struct icalrecurrencetype *a, struct icalrecurrencetype *b)
+{
+ struct icalrecurrencetype acopy, bcopy;
+
+ acopy = *a;
+ bcopy = *b;
+
+ acopy.until = bcopy.until = icaltime_null_time ();
+ acopy.count = bcopy.count = 0;
+
+ if (!memcmp (&acopy, &bcopy, sizeof (struct icalrecurrencetype)))
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean
+find_last_cb (CalComponent *comp, time_t start, time_t end, gpointer data)
+{
+ time_t *last = data;
+
+ *last = start;
+
+ return TRUE;
+}
+
static GnomePilotRecord
local_record_to_pilot_record (ECalLocalRecord *local,
ECalConduitContext *ctxt)
@@ -879,14 +906,24 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
local->appt->repeatFrequency = recur->interval;
}
- if (icaltime_is_null_time (recur->until)) {
- local->appt->repeatForever = 1;
- } else {
+ if (!icaltime_is_null_time (recur->until)) {
+ local->appt->repeatForever = 0;
+ local->appt->repeatEnd = icaltimetype_to_tm_with_zone (&recur->until,
+ icaltimezone_get_utc_timezone (),
+ default_tz);
+ } else if (recur->count > 0) {
+ time_t last = -1;
+ struct icaltimetype itt;
+
+ /* The palm does not support count recurrences */
local->appt->repeatForever = 0;
- icaltimezone_convert_time (&recur->until,
- icaltimezone_get_utc_timezone (),
- default_tz);
- local->appt->repeatEnd = icaltimetype_to_tm (&recur->until);
+ cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last,
+ cal_client_resolve_tzid_cb, ctxt->client,
+ default_tz);
+ itt = icaltime_from_timet_with_zone (last, TRUE, default_tz);
+ local->appt->repeatEnd = icaltimetype_to_tm (&itt);
+ } else {
+ local->appt->repeatForever = 1;
}
cal_component_free_recur_list (list);
@@ -995,6 +1032,7 @@ static CalComponent *
comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GnomePilotRecord *remote,
CalComponent *in_comp,
+ CalClient *client,
icaltimezone *timezone)
{
CalComponent *comp;
@@ -1115,17 +1153,47 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
}
if (recur.freq != ICAL_NO_RECURRENCE) {
- GSList *list = NULL;
+ GSList *list = NULL, *existing;
+ struct icalrecurrencetype *erecur;
/* recurrence start of week */
recur.week_start = get_ical_day (appt.repeatWeekstart);
if (!appt.repeatForever) {
- recur.until = tm_to_icaltimetype (&appt.repeatEnd, TRUE);
+ recur.until = tm_to_icaltimetype (&appt.repeatEnd, TRUE);
}
list = g_slist_append (list, &recur);
cal_component_set_rrule_list (comp, list);
+
+ /* If the desktop uses count and rrules are
+ * equivalent, use count still on the desktop */
+ if (!appt.repeatForever && cal_component_has_rrules (in_comp)) {
+ cal_component_get_rrule_list (in_comp, &existing);
+ erecur = existing->data;
+
+ /* If the rules are otherwise the same and the existing uses count,
+ see if they end at the same point */
+ if (rrules_mostly_equal (&recur, erecur) &&
+ icaltime_is_null_time (erecur->until) && erecur->count > 0) {
+ time_t last, elast;
+
+ cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last,
+ cal_client_resolve_tzid_cb, client,
+ timezone);
+ cal_recur_generate_instances (in_comp, -1, -1, find_last_cb, &elast,
+ cal_client_resolve_tzid_cb, client,
+ timezone);
+
+
+ if (last == elast) {
+ recur.until = icaltime_null_time ();
+ recur.count = erecur->count;
+ cal_component_set_rrule_list (comp, list);
+ }
+ }
+ }
+
g_slist_free (list);
} else {
cal_component_set_rrule_list (comp, NULL);
@@ -1594,7 +1662,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
LOG ("add_record: adding %s to desktop\n", print_remote (remote));
- comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone);
+ comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->client, ctxt->timezone);
/* Give it a new UID otherwise it will be the uid of the default comp */
uid = cal_component_gen_uid ();
@@ -1624,7 +1692,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
LOG ("replace_record: replace %s with %s\n",
print_local (local), print_remote (remote));
- new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone);
+ new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->client, ctxt->timezone);
g_object_unref (local->comp);
local->comp = new_comp;
update_comp (conduit, local->comp, ctxt);