From 513d81eb5947c92dacc44a029df8862389f5e736 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 21 Apr 2017 12:31:18 -0400 Subject: [PATCH] (fix) LDIF to vCard conversion for non-handled multi-value attributes (fixes #4086) --- NEWS | 1 + SOPE/NGCards/CardElement.h | 4 +- SOPE/NGCards/CardElement.m | 9 +++- SoObjects/Contacts/NGVCard+SOGo.m | 56 +++++++++++------------ SoObjects/Contacts/SOGoContactLDIFEntry.h | 2 +- SoObjects/Contacts/SOGoContactLDIFEntry.m | 2 +- SoObjects/SOGo/NSDictionary+Utilities.h | 4 +- SoObjects/SOGo/NSDictionary+Utilities.m | 4 +- UI/Contacts/UIxContactView.m | 12 +++-- 9 files changed, 49 insertions(+), 45 deletions(-) diff --git a/NEWS b/NEWS index 52ab4681e..25e9ece41 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ Bug fixes - [core] fix sogo-tool restore potentially crashing on corrupted data (#4048) - [core] handle properly mails using windows-1255 charset (#4124) - [core] fixed email reminders sent multiple times (#4100) + - [core] fixed LDIF to vCard conversion for non-handled multi-value attributes (#4086) - [eas] set reply/forwarded flags when ReplaceMime is set (#4133) - [eas] remove alarms over EAS if we don't want them (#4059) - [eas] correctly set RSVP on event invitations diff --git a/SOPE/NGCards/CardElement.h b/SOPE/NGCards/CardElement.h index 92ad9a61b..f987c2f98 100644 --- a/SOPE/NGCards/CardElement.h +++ b/SOPE/NGCards/CardElement.h @@ -1,6 +1,6 @@ /* CardElement.h - this file is part of SOPE * - * Copyright (C) 2006-2014 Inverse inc. + * Copyright (C) 2006-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,7 +64,7 @@ - (NSMutableDictionary *) values; /* ELEM:...;value1,value2,...;... */ -- (void) setValues: (NSMutableArray *) newValues +- (void) setValues: (id) newValues atIndex: (NSUInteger) idx forKey: (NSString *) key; diff --git a/SOPE/NGCards/CardElement.m b/SOPE/NGCards/CardElement.m index 96d158b44..d87b65509 100644 --- a/SOPE/NGCards/CardElement.m +++ b/SOPE/NGCards/CardElement.m @@ -1,6 +1,6 @@ /* CardElement.m - this file is part of SOPE * - * Copyright (C) 2006-2014 Inverse inc. + * Copyright (C) 2006-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,12 +130,17 @@ return values; } -- (void) setValues: (NSMutableArray *) newValues +- (void) setValues: (id) newValues atIndex: (NSUInteger) idx forKey: (NSString *) key { NSMutableArray *oldValues, *subValues; + if ([newValues isKindOfClass: [NSString class]]) + return [self setSingleValue: (NSString *)newValues + atIndex: idx + forKey: key]; + oldValues = [self valuesForKey: key]; if (!oldValues) { diff --git a/SoObjects/Contacts/NGVCard+SOGo.m b/SoObjects/Contacts/NGVCard+SOGo.m index 10e8455fb..48419ebec 100644 --- a/SoObjects/Contacts/NGVCard+SOGo.m +++ b/SoObjects/Contacts/NGVCard+SOGo.m @@ -277,32 +277,32 @@ convention: [self setFn: fn]; element = [self elementWithTag: @"adr" ofType: @"home"]; - [element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet2"] - atIndex: 1 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet"] - atIndex: 2 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"mozillahomelocalityname"] - atIndex: 3 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"mozillahomestate"] - atIndex: 4 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"mozillahomepostalcode"] - atIndex: 5 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"mozillahomecountryname"] - atIndex: 6 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"mozillahomestreet2"] + atIndex: 1 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"mozillahomestreet"] + atIndex: 2 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"mozillahomelocalityname"] + atIndex: 3 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"mozillahomestate"] + atIndex: 4 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"mozillahomepostalcode"] + atIndex: 5 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"mozillahomecountryname"] + atIndex: 6 forKey: @""]; element = [self elementWithTag: @"adr" ofType: @"work"]; - [element setSingleValue: [ldifRecord objectForKey: @"mozillaworkstreet2"] - atIndex: 1 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"street"] - atIndex: 2 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"l"] - atIndex: 3 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"st"] - atIndex: 4 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"postalcode"] - atIndex: 5 forKey: @""]; - [element setSingleValue: [ldifRecord objectForKey: @"c"] - atIndex: 6 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"mozillaworkstreet2"] + atIndex: 1 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"street"] + atIndex: 2 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"l"] + atIndex: 3 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"st"] + atIndex: 4 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"postalcode"] + atIndex: 5 forKey: @""]; + [element setValues: [ldifRecord objectForKey: @"c"] + atIndex: 6 forKey: @""]; ou = [ldifRecord objectForKey: @"ou"]; if ([ou isKindOfClass: [NSArray class]]) @@ -321,13 +321,13 @@ convention: [self _setPhoneValues: ldifRecord]; [self _setEmails: ldifRecord]; [[self elementWithTag: @"url" ofType: @"home"] - setSingleValue: [ldifRecord objectForKey: @"mozillahomeurl"] forKey: @""]; + setValues: [ldifRecord objectForKey: @"mozillahomeurl"] forKey: @""]; [[self elementWithTag: @"url" ofType: @"work"] - setSingleValue: [ldifRecord objectForKey: @"mozillaworkurl"] forKey: @""]; + setValues: [ldifRecord objectForKey: @"mozillaworkurl"] forKey: @""]; [[self uniqueChildWithTag: @"x-aim"] - setSingleValue: [ldifRecord objectForKey: @"nsaimid"] - forKey: @""]; + setValues: [ldifRecord objectForKey: @"nsaimid"] + forKey: @""]; now = [NSCalendarDate date]; year = [[ldifRecord objectForKey: @"birthyear"] intValue]; diff --git a/SoObjects/Contacts/SOGoContactLDIFEntry.h b/SoObjects/Contacts/SOGoContactLDIFEntry.h index 581bf85c2..1f3d889a9 100644 --- a/SoObjects/Contacts/SOGoContactLDIFEntry.h +++ b/SoObjects/Contacts/SOGoContactLDIFEntry.h @@ -1,6 +1,6 @@ /* SOGoContactLDIFEntry.h - this file is part of SOGo * - * Copyright (C) 2006-2016 Inverse inc. + * Copyright (C) 2006-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/SoObjects/Contacts/SOGoContactLDIFEntry.m b/SoObjects/Contacts/SOGoContactLDIFEntry.m index c11d09566..f91580b54 100644 --- a/SoObjects/Contacts/SOGoContactLDIFEntry.m +++ b/SoObjects/Contacts/SOGoContactLDIFEntry.m @@ -1,6 +1,6 @@ /* SOGoContactLDIFEntry.m - this file is part of SOGo * - * Copyright (C) 2006-2016 Inverse inc. + * Copyright (C) 2006-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/SoObjects/SOGo/NSDictionary+Utilities.h b/SoObjects/SOGo/NSDictionary+Utilities.h index 92fe50f34..ea1073582 100644 --- a/SoObjects/SOGo/NSDictionary+Utilities.h +++ b/SoObjects/SOGo/NSDictionary+Utilities.h @@ -1,8 +1,6 @@ /* NSDictionary+Utilities.h - this file is part of SOGo * - * Copyright (C) 2007 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/SoObjects/SOGo/NSDictionary+Utilities.m b/SoObjects/SOGo/NSDictionary+Utilities.m index 44cdc3b51..78e447106 100644 --- a/SoObjects/SOGo/NSDictionary+Utilities.m +++ b/SoObjects/SOGo/NSDictionary+Utilities.m @@ -1,8 +1,6 @@ /* NSDictionary+Utilities.m - this file is part of SOGo * - * Copyright (C) 2007-2011 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index b84b99cc2..bfec54742 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -165,16 +165,17 @@ - (NSArray *) deliveryAddresses { - NSMutableArray *addresses; - NSMutableDictionary *address; - NSArray *elements; NSString *type, *postoffice, *street, *street2, *locality, *region, *postalcode, *country; + NSMutableDictionary *address; + NSMutableArray *addresses; + NSArray *elements; CardElement *adr; + NSUInteger count, max; elements = [card childrenWithTag: @"adr"]; - //values = [org valuesForKey: @""]; max = [elements count]; + if (max > 0) { addresses = [NSMutableArray arrayWithCapacity: max]; @@ -189,7 +190,8 @@ region = [adr flattenedValueAtIndex: 4 forKey: @""]; postalcode = [adr flattenedValueAtIndex: 5 forKey: @""]; country = [adr flattenedValueAtIndex: 6 forKey: @""]; - address = [NSMutableDictionary dictionaryWithObject: type forKey: @"type"]; + + address = [NSMutableDictionary dictionaryWithObject: type forKey: @"type"]; if (postoffice) [address setObject: postoffice forKey: @"postoffice"]; if (street2) [address setObject: street2 forKey: @"street2"]; if (street) [address setObject: street forKey: @"street"];