From 9fb92479d6d23fa13f5bfafeda9c93a84645dd4b Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 16 Jul 2010 15:03:16 +0000 Subject: [PATCH] Monotone-Parent: 4afc986f42a77cc538d46f41f372499f825fa9c4 Monotone-Revision: 6920d8cb7745acb5c4574fa10c4101bc1a87cca7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-07-16T15:03:16 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++ .../Appointments/SOGoAppointmentObject.m | 62 +++++++++++++++---- 2 files changed, 58 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3fe3766f2..c431727be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-07-16 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoAppointmentObject.m + (_handleUpdatedEvent:fromOldEvent:): added handling of delegation + chains when resetting the participation status of the attendees. + Fixes #688. + 2010-07-15 Wolfgang Sourdeau * SoObjects/SOGo/SOGoUser.m (-personalCalendarFolderInContext:): diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 5e43eafc7..2e775624a 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -328,17 +328,56 @@ } } -- (void) _requireResponseFromAttendees: (NSArray *) attendees +- (void) _removeDelegationChain: (iCalPerson *) delegate + inEvent: (iCalEvent *) event { - NSEnumerator *enumerator; - iCalPerson *currentAttendee; + NSString *delegatedTo, *mailTo; - enumerator = [attendees objectEnumerator]; - while ((currentAttendee = [enumerator nextObject])) + delegatedTo = [delegate delegatedTo]; + if ([delegatedTo length] > 0) { + mailTo = [delegatedTo rfc822Email]; + delegate = [event findAttendeeWithEmail: mailTo]; + if (delegate) + { + [self _removeDelegationChain: delegate + inEvent: event]; + [event removeFromAttendees: delegate]; + } + else + [self errorWithFormat: + @"broken chain: delegate with email '%@' was not found", + mailTo]; + } +} + +/* This method returns YES when any attendee has been removed and NO + otherwise. */ +- (BOOL) _requireResponseFromAttendees: (iCalEvent *) event +{ + NSArray *attendees; + iCalPerson *currentAttendee; + BOOL listHasChanged; + int count, max; + + attendees = [event attendees]; + max = [attendees count]; + + for (count = 0; count < max; count++) + { + currentAttendee = [attendees objectAtIndex: count]; + if ([[currentAttendee delegatedTo] length] > 0) + { + [self _removeDelegationChain: currentAttendee + inEvent: event]; + [currentAttendee setDelegatedTo: nil]; + listHasChanged = YES; + } [currentAttendee setRsvp: @"TRUE"]; [currentAttendee setParticipationStatus: iCalPersonPartStatNeedsAction]; } + + return listHasChanged; } - (void) _handleSequenceUpdateInEvent: (iCalEvent *) newEvent @@ -400,6 +439,13 @@ iCalEventChanges *changes; changes = [newEvent getChangesRelativeToEvent: oldEvent]; + if ([changes sequenceShouldBeIncreased]) + { + // Set new attendees status to "needs action" and recompute changes when + // the list of attendees has changed. + if ([self _requireResponseFromAttendees: newEvent]) + changes = [newEvent getChangesRelativeToEvent: oldEvent]; + } attendees = [changes deletedAttendees]; if ([attendees count]) { @@ -417,8 +463,6 @@ if ([changes sequenceShouldBeIncreased]) { [newEvent increaseSequence]; - // Set new attendees status to "needs action" - [self _requireResponseFromAttendees: [newEvent attendees]]; // Update attendees calendars and send them an update // notification by email [self _handleSequenceUpdateInEvent: newEvent @@ -455,10 +499,6 @@ if ([attendees count]) { - NSArray *originalAttendees; - - originalAttendees = [NSArray arrayWithArray: [newEvent attendees]]; - // Send an invitation to new attendees [self _handleAddedUsers: attendees fromEvent: newEvent]; [self sendEMailUsingTemplateNamed: @"Invitation"