diff --git a/ChangeLog b/ChangeLog index cefc413c3..8832f35d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-12-21 Ludovic Marcotte + + * UI/Contacts/UIxContactView.m + Modified -secondaryEmail so that we always get + the "last" email address in case no preferred + one was specified in the vCard. Also fixed + a memory leak in this method. + 2007-12-20 Wolfgang Sourdeau * SoObjects/SOGo/SOGoContentObject.m ([SOGoContentObject diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index dc789fa7b..ec2c8f27a 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -104,20 +104,28 @@ NSMutableArray *emails; emails = [NSMutableArray new]; + mailTo = nil; + [emails addObjectsFromArray: [card childrenWithTag: @"email"]]; [emails removeObjectsInArray: [card childrenWithTag: @"email" andAttribute: @"type" havingValue: @"pref"]]; - if ([emails count] > 1) + // We might not have a preferred item but rather something like this: + // EMAIL;TYPE=work:dd@ee.com + // EMAIL;TYPE=home:ff@gg.com + // In this case, we always return the last entry. + if ([emails count] > 0) { - email = [[emails objectAtIndex: 0] value: 0]; - mailTo = [NSString stringWithFormat: @"" - @"%@", email, email]; + email = [[emails objectAtIndex: [emails count]-1] value: 0]; + + if ([email caseInsensitiveCompare: [card preferredEMail]] != NSOrderedSame) + mailTo = [NSString stringWithFormat: @"" + @"%@", email, email]; } - else - mailTo = nil; + + [emails release]; return [self _cardStringWithLabel: @"Additional Email:" value: mailTo];