From 8e7b9bcaa0c8489fdb12335a340801666fb746c0 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 3 Dec 2008 23:08:37 +0000 Subject: [PATCH] Monotone-Parent: ddcadf6f0cf1825abb4b35c686982d748a8e22c0 Monotone-Revision: 1f0eab41427c479dcc5668b7a84e8ade40eae514 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2008-12-03T23:08:37 Monotone-Branch: ca.inverse.sogo --- .../Appointments/SOGoAppointmentObject.m | 51 ++++++++++++++++--- .../Appointments/SOGoCalendarComponent.h | 2 - .../Appointments/SOGoComponentOccurence.m | 1 + 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 2ac9ebe84..5163f0a7e 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -205,24 +205,56 @@ } } +#warning what about occurences? - (void) _removeEventFromUID: (NSString *) theUID owner: (NSString *) theOwner + withRecurrenceId: (NSCalendarDate *) recurrenceId { if (![theUID isEqualToString: theOwner]) { SOGoAppointmentFolder *folder; SOGoAppointmentObject *object; + iCalEntityObject *occurence; + iCalRepeatableEntityObject *event; + iCalCalendar *calendar; + NSString *recurrenceTime, *calendarContent; folder = [container lookupCalendarFolderForUID: theUID]; object = [folder lookupName: nameInContainer inContext: context acquire: NO]; if (![object isKindOfClass: [NSException class]]) - [object delete]; + { + if (recurrenceId == nil) + [object delete]; + else + { + // If recurrenceId is defined, find the specified occurence + // within the repeating vEvent. + recurrenceTime = [NSString stringWithFormat: @"%f", [recurrenceId timeIntervalSince1970]]; + occurence = [object lookupOccurence: recurrenceTime]; + if (occurence != nil) + { + // The occurence is defined -- remove it. + calendar = [occurence parent]; + [[calendar children] removeObject: occurence]; + } + + // Add an date exception + calendar = [object calendar: NO secure: NO]; + event = (iCalRepeatableEntityObject*)[calendar firstChildWithTag: [object componentTag]]; + [event addToExceptionDates: recurrenceId]; + + // We generate the updated iCalendar file and we save it + // in the database. + calendarContent = [calendar versitString]; + [object saveContentString: calendarContent]; + } + } } } -#warning what about occurences? - (void) _handleRemovedUsers: (NSArray *) attendees + withRecurrenceId: (NSCalendarDate *) recurrenceId { NSEnumerator *enumerator; iCalPerson *currentAttendee; @@ -234,7 +266,8 @@ currentUID = [currentAttendee uid]; if (currentUID) [self _removeEventFromUID: currentUID - owner: owner]; + owner: owner + withRecurrenceId: recurrenceId]; } } @@ -308,7 +341,8 @@ attendees = [changes deletedAttendees]; if ([attendees count]) { - [self _handleRemovedUsers: attendees]; + [self _handleRemovedUsers: attendees + withRecurrenceId: [newEvent recurrenceId]]; [self sendEMailUsingTemplateNamed: @"Deletion" forObject: [newEvent itipEntryWithMethod: @"cancel"] previousObject: oldEvent @@ -735,7 +769,8 @@ if (uid) [self _removeEventFromUID: uid owner: [[LDAPUserManager sharedUserManager] - getUIDForEmail: originator]]; + getUIDForEmail: originator] + withRecurrenceId: [event recurrenceId]]; #warning fix this when sendEmailUsing blabla has been cleaned up [self sendEMailUsingTemplateNamed: @"Deletion" forObject: event @@ -973,13 +1008,17 @@ // The organizer deletes an occurence. currentUser = [context activeUser]; attendees = [occurence attendeesWithoutUser: currentUser]; + +#warning Make sure this is correct .. if (![attendees count] && event != occurence) attendees = [event attendeesWithoutUser: currentUser]; + if ([attendees count]) { // Remove the event from all attendees calendars // and send them an email. - [self _handleRemovedUsers: attendees]; + [self _handleRemovedUsers: attendees + withRecurrenceId: recurrenceId]; [self sendEMailUsingTemplateNamed: @"Deletion" forObject: [occurence itipEntryWithMethod: @"cancel"] previousObject: nil diff --git a/SoObjects/Appointments/SOGoCalendarComponent.h b/SoObjects/Appointments/SOGoCalendarComponent.h index 79d42d76f..1292647ff 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.h +++ b/SoObjects/Appointments/SOGoCalendarComponent.h @@ -55,8 +55,6 @@ // - (NSException *) primarySaveContentString: (NSString *) _iCalString; // - (NSException *) primaryDelete; -// - (NSException *) delete; - - (void) saveComponent: (iCalRepeatableEntityObject *) newObject; /* mail notifications */ diff --git a/SoObjects/Appointments/SOGoComponentOccurence.m b/SoObjects/Appointments/SOGoComponentOccurence.m index ba750d3f2..bf6b111ee 100644 --- a/SoObjects/Appointments/SOGoComponentOccurence.m +++ b/SoObjects/Appointments/SOGoComponentOccurence.m @@ -148,6 +148,7 @@ { if ([container respondsToSelector: @selector (prepareDeleteOccurence:)]) [container prepareDeleteOccurence: component]; + [master addToExceptionDates: [component startDate]]; parent = [component parent]; [[parent children] removeObject: component];