From f6bff0a7bd663ee9982d64ba9b69fe9e8952553c Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 21 Dec 2007 16:57:11 +0000 Subject: [PATCH 1/2] see changelog Monotone-Parent: 98c12fec2aa59fdb212078c989152e071dfdd714 Monotone-Revision: 7b7bd2c2a5b03397fa881da7976214adc4635a4a Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2007-12-21T16:57:11 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++++++++ UI/Contacts/UIxContactView.m | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) 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..1dfd11d41 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -105,13 +105,18 @@ emails = [NSMutableArray new]; [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]; + email = [[emails objectAtIndex: [emails count]-1] value: 0]; mailTo = [NSString stringWithFormat: @"" @"%@", email, email]; @@ -119,6 +124,8 @@ else mailTo = nil; + [emails release]; + return [self _cardStringWithLabel: @"Additional Email:" value: mailTo]; } From 6f6b695abe032e25ca0deb29e6c9058e7d541828 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 21 Dec 2007 18:23:48 +0000 Subject: [PATCH 2/2] small fix in previous commit Monotone-Parent: 7b7bd2c2a5b03397fa881da7976214adc4635a4a Monotone-Revision: 46e53471ba15a415a840ddb058785b89b6415704 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2007-12-21T18:23:48 Monotone-Branch: ca.inverse.sogo --- UI/Contacts/UIxContactView.m | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index 1dfd11d41..ec2c8f27a 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -104,8 +104,9 @@ NSMutableArray *emails; emails = [NSMutableArray new]; - [emails addObjectsFromArray: [card childrenWithTag: @"email"]]; + mailTo = nil; + [emails addObjectsFromArray: [card childrenWithTag: @"email"]]; [emails removeObjectsInArray: [card childrenWithTag: @"email" andAttribute: @"type" havingValue: @"pref"]]; @@ -117,12 +118,12 @@ if ([emails count] > 0) { email = [[emails objectAtIndex: [emails count]-1] value: 0]; - mailTo = [NSString stringWithFormat: @"" - @"%@", email, email]; + + if ([email caseInsensitiveCompare: [card preferredEMail]] != NSOrderedSame) + mailTo = [NSString stringWithFormat: @"" + @"%@", email, email]; } - else - mailTo = nil; [emails release];