From 312ed2824fd1e94746209431dac6111de0030de9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 5 May 2010 13:45:18 +0000 Subject: [PATCH] Monotone-Parent: fcf51dfbffeff460e370282e0f739875e3414767 Monotone-Revision: f2d1ff2e80e90f3c3d73fe6006e22ee1e9d39b01 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-05-05T13:45:18 Monotone-Branch: ca.inverse.sogo --- SOPE/NGCards/ChangeLog | 11 ++- SOPE/NGCards/iCalEntityObject.h | 7 +- SOPE/NGCards/iCalEntityObject.m | 125 ++++++++++++++++---------------- 3 files changed, 77 insertions(+), 66 deletions(-) diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index 9776cecca..ac57bddf2 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -1,3 +1,12 @@ +2010-05-05 Wolfgang Sourdeau + + * iCalEntityObject.m (-resources): removed useless method. + (-nonParticipants): new method returning ATTENDEE objects having + their ROLE attribute set to "NON-PARTICIPANT". + (-isAttendee:): new method. + (-findAttendeeWithEmail): new method replacing + "findParticipantWithEmail:". + 2010-04-28 Wolfgang Sourdeau * iCalRecurrenceRule.m (-iCalRepresentationForWeekDay:): made @@ -34,7 +43,7 @@ * iCalWeeklyRecurrenceCalculator.m (-recurrenceRangesWithinCalendarDateRange:): make use of the new - iCalByDayMask class. + iCalByDayMask class. (-lastInstanceStartDate): make use of the previous method when a BYxxx mask is defined in the rule. diff --git a/SOPE/NGCards/iCalEntityObject.h b/SOPE/NGCards/iCalEntityObject.h index ba62d1ce9..36491e206 100644 --- a/SOPE/NGCards/iCalEntityObject.h +++ b/SOPE/NGCards/iCalEntityObject.h @@ -109,15 +109,16 @@ typedef enum - (void) addToAttendees: (iCalPerson *) _person; - (NSArray *) attendees; - (void) setAttendees: (NSArray *) attendees; +- (BOOL) isAttendee: (id) _email; - (void) removeFromAttendees: (iCalPerson *) oldAttendee; - (void) removeAllAttendees; -/* categorize attendees into participants and resources */ +/* categorize attendees into participants and non-participants */ - (NSArray *) participants; -- (NSArray *) resources; +- (NSArray *) nonParticipants; - (BOOL) isParticipant: (id) _email; -- (iCalPerson *) findParticipantWithEmail: (id) _email; +- (iCalPerson *) findAttendeeWithEmail: (id) email; - (void) removeAllAlarms; - (void) addToAlarms: (id) _alarm; diff --git a/SOPE/NGCards/iCalEntityObject.m b/SOPE/NGCards/iCalEntityObject.m index 11d7f82dc..bbe7fa262 100644 --- a/SOPE/NGCards/iCalEntityObject.m +++ b/SOPE/NGCards/iCalEntityObject.m @@ -330,6 +330,40 @@ return [self childrenWithTag: @"attendee"]; } +- (BOOL) isAttendee: (id) _email +{ + NSArray *attEmails; + + _email = [_email lowercaseString]; + attEmails = [[self attendees] valueForKey:@"rfc822Email"]; + attEmails = [attEmails valueForKey: @"lowercaseString"]; + return [attEmails containsObject:_email]; +} + +- (iCalPerson *) findAttendeeWithEmail: (id) email +{ + NSArray *attendees; + unsigned int count, max; + NSString *lowerEmail, *currentEmail; + iCalPerson *attendee, *currentAttendee; + + attendee = nil; + + lowerEmail = [email lowercaseString]; + attendees = [self attendees]; + max = [attendees count]; + + for (count = 0; attendee == nil && count < max; count++) + { + currentAttendee = [attendees objectAtIndex: count]; + currentEmail = [[currentAttendee rfc822Email] lowercaseString]; + if ([currentEmail isEqualToString: lowerEmail]) + attendee = currentAttendee; + } + + return attendee; +} + - (void) removeAllAlarms { [children removeObjectsInArray: [self alarms]]; @@ -406,48 +440,6 @@ } /* stuff */ - -- (NSArray *) participants -{ - return [self _filteredAttendeesThinkingOfPersons: YES]; -} - -- (NSArray *) resources -{ - return [self _filteredAttendeesThinkingOfPersons: NO]; -} - -- (NSArray *) _filteredAttendeesThinkingOfPersons: (BOOL) _persons -{ - NSArray *list; - NSMutableArray *filtered; - unsigned count, max; - iCalPerson *person; - NSString *role; - - if (_persons) - { - list = [self attendees]; - max = [list count]; - filtered = [NSMutableArray arrayWithCapacity: max]; - for (count = 0; count < max; count++) - { - person = (iCalPerson *) [list objectAtIndex: count]; - role = [[person role] uppercaseString]; - if (![role hasPrefix: @"NON-PART"]) - [filtered addObject: person]; - } - - list = filtered; - } - else - list = [self childrenWithTag: @"attendee" - andAttribute: @"role" - havingValue: @"non-part"]; - - return list; -} - - (BOOL) isOrganizer: (id) _email { NSString *organizerMail; @@ -458,6 +450,35 @@ isEqualToString: [_email lowercaseString]]; } +- (NSArray *) participants +{ + NSArray *list; + NSMutableArray *filtered; + unsigned count, max; + iCalPerson *person; + NSString *role; + + list = [self attendees]; + max = [list count]; + filtered = [NSMutableArray arrayWithCapacity: max]; + for (count = 0; count < max; count++) + { + person = [list objectAtIndex: count]; + role = [[person role] uppercaseString]; + if (![role hasPrefix: @"NON-PARTICIPANT"]) + [filtered addObject: person]; + } + + return filtered; +} + +- (NSArray *) nonParticipants +{ + return [self childrenWithTag: @"attendee" + andAttribute: @"role" + havingValue: @"non-participant"]; +} + - (BOOL) isParticipant: (id) _email { NSArray *partEmails; @@ -468,26 +489,6 @@ return [partEmails containsObject:_email]; } -- (iCalPerson *) findParticipantWithEmail: (id) _email -{ - NSArray *ps; - unsigned i, count; - - _email = [_email lowercaseString]; - ps = [self participants]; - count = [ps count]; - - for (i = 0; i < count; i++) { - iCalPerson *p; - - p = [ps objectAtIndex:i]; - if ([[[p rfc822Email] lowercaseString] isEqualToString:_email]) - return p; - } - - return nil; /* not found */ -} - - (NSComparisonResult) _compareValue: (id) selfValue withValue: (id) otherValue {