From 9a87a9ff789115cfa55316b14dea6393cd4e9bce Mon Sep 17 00:00:00 2001 From: Peter Teichman Date: Mon, 2 Aug 1999 07:20:18 +0000 Subject: do deletion of appointments correctly, when they are deleted on the pilot * calendar-pilot-sync.c (sync_pilot): do deletion of appointments correctly, when they are deleted on the pilot (conduit_free_Appointment): protect against double-freeing parts of the Appointment structure (update_record): all-day events from the pilot are handled a bit more reasonably svn path=/trunk/; revision=1063 --- calendar/gui/calendar-pilot-sync.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'calendar/gui') diff --git a/calendar/gui/calendar-pilot-sync.c b/calendar/gui/calendar-pilot-sync.c index 12f15d33ad..9461278e8b 100644 --- a/calendar/gui/calendar-pilot-sync.c +++ b/calendar/gui/calendar-pilot-sync.c @@ -56,6 +56,18 @@ const struct poptOption calendar_sync_options [] = { { NULL, '\0', 0, NULL, 0 } }; +static void +conduit_free_Appointment (struct Appointment *a) +{ + /* free_Appointment is brain-dead with respect to guarding against + double-frees */ + + free_Appointment (a); + a->exception = 0; + a->description = 0; + a->note = 0; +} + static int setup_connection (void) { @@ -156,8 +168,21 @@ update_record (GNOME_Calendar_Repository repo, int id, struct Appointment *a, in /* * Begin and end */ + + if (a->event) + { + /* turn day-long events into a full day's appointment */ + a->begin.tm_sec = 0; + a->begin.tm_min = 0; + a->begin.tm_hour = 6; + + a->end.tm_sec = 0; + a->end.tm_min = 0; + a->end.tm_hour = 10; + } + obj->dtstart = mktime (&a->begin); - obj->dtend = mktime (&a->end); + obj->dtend = mktime (&a->end); /* Special case: daily repetitions are converted to a multi-day event */ if (a->repeatType == repeatDaily){ @@ -455,7 +480,7 @@ sync_object_to_pilot (GNOME_Calendar_Repository repo, iCalObject *obj, int pilot GNOME_Calendar_Repository_update_pilot_id (repo, obj->uid, new_id, ICAL_PILOT_SYNC_NONE, &ev); - free_Appointment (a); + conduit_free_Appointment (a); g_free (a); } @@ -546,9 +571,10 @@ sync_pilot (GNOME_Calendar_Repository repo, int pilot_fd) /* If the object was deleted, remove it from the database */ if (attr & dlpRecAttrDeleted){ - printf ("Deleting\n"); + printf ("Deleting id %ld\n", id); delete_record (repo, id); - free_Appointment (&a); + conduit_free_Appointment (&a); + dlp_DeleteRecord (pilot_fd, db, 0, id); continue; } @@ -559,8 +585,7 @@ sync_pilot (GNOME_Calendar_Repository repo, int pilot_fd) printf ("updating record\n"); update_record (repo, id, &a, attr); } - - free_Appointment (&a); + conduit_free_Appointment (&a); } } -- cgit v1.2.3