fix(addressbook): handle vCard with multiple title values
parent
747ba75503
commit
96c22b6b96
|
@ -244,8 +244,7 @@
|
||||||
NSMutableString *flattenedValues;
|
NSMutableString *flattenedValues;
|
||||||
NSString *encoding, *realValue, *value;
|
NSString *encoding, *realValue, *value;
|
||||||
|
|
||||||
encoding = [[self value: 0 ofAttribute: @"encoding"]
|
encoding = [[self value: 0 ofAttribute: @"encoding"] lowercaseString];
|
||||||
lowercaseString];
|
|
||||||
|
|
||||||
flattenedValues = [NSMutableString string];
|
flattenedValues = [NSMutableString string];
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* NGVCard+SOGo.h - this file is part of SOGo
|
/* NGVCard+SOGo.h - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2017 Inverse inc.
|
* Copyright (C) 2009-2020 Inverse inc.
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -56,6 +56,9 @@
|
||||||
- (void) setNotes: (NSArray *) newNotes;
|
- (void) setNotes: (NSArray *) newNotes;
|
||||||
- (NSArray *) notes;
|
- (NSArray *) notes;
|
||||||
|
|
||||||
|
- (void) setTitles;
|
||||||
|
- (NSArray *) titles;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* NGVCARD_SOGO_H */
|
#endif /* NGVCARD_SOGO_H */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* NGVCard+SOGo.m - this file is part of SOGo
|
/* NGVCard+SOGo.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2017 Inverse inc.
|
* Copyright (C) 2009-2020 Inverse inc.
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -310,7 +310,12 @@ convention:
|
||||||
given: [ldifRecord objectForKey: @"givenname"]
|
given: [ldifRecord objectForKey: @"givenname"]
|
||||||
additional: nil prefixes: nil suffixes: nil];
|
additional: nil prefixes: nil suffixes: nil];
|
||||||
[self setNickname: [ldifRecord objectForKey: @"mozillanickname"]];
|
[self setNickname: [ldifRecord objectForKey: @"mozillanickname"]];
|
||||||
[self setTitle: [ldifRecord objectForKey: @"title"]];
|
|
||||||
|
o = [ldifRecord objectForKey: @"title"];
|
||||||
|
if ([o isKindOfClass: [NSArray class]])
|
||||||
|
[self setTitles: o];
|
||||||
|
else
|
||||||
|
[self setTitle: o];
|
||||||
|
|
||||||
fn = [ldifRecord objectForKey: @"displayname"];
|
fn = [ldifRecord objectForKey: @"displayname"];
|
||||||
if (!fn)
|
if (!fn)
|
||||||
|
@ -1001,6 +1006,42 @@ convention:
|
||||||
return flattenedNotes;
|
return flattenedNotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setTitles: (NSArray *) newTitles
|
||||||
|
{
|
||||||
|
NSArray *elements;
|
||||||
|
NSUInteger count, max;
|
||||||
|
|
||||||
|
elements = [self childrenWithTag: @"title"];
|
||||||
|
[self removeChildren: elements];
|
||||||
|
max = [newTitles count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
[self addChildWithTag: @"title"
|
||||||
|
types: nil
|
||||||
|
singleValue: [newTitles objectAtIndex: count]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) titles
|
||||||
|
{
|
||||||
|
NSArray *titles;
|
||||||
|
NSMutableArray *flattenedTitles;
|
||||||
|
NSString *title;
|
||||||
|
NSUInteger count, max;
|
||||||
|
|
||||||
|
titles = [self childrenWithTag: @"title"];
|
||||||
|
max = [titles count];
|
||||||
|
flattenedTitles = [NSMutableArray arrayWithCapacity: max];
|
||||||
|
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
title = [[titles objectAtIndex: count] flattenedValuesForKey: @""];
|
||||||
|
[flattenedTitles addObject: title];
|
||||||
|
}
|
||||||
|
|
||||||
|
return flattenedTitles;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSMutableDictionary *) quickRecordFromContent: (NSString *) theContent
|
- (NSMutableDictionary *) quickRecordFromContent: (NSString *) theContent
|
||||||
container: (id) theContainer
|
container: (id) theContainer
|
||||||
nameInContainer: (NSString *) nameInContainer
|
nameInContainer: (NSString *) nameInContainer
|
||||||
|
|
|
@ -320,9 +320,9 @@
|
||||||
|
|
||||||
o = [card nickname];
|
o = [card nickname];
|
||||||
if (o) [data setObject: o forKey: @"nickname"];
|
if (o) [data setObject: o forKey: @"nickname"];
|
||||||
o = [card title];
|
o = [card titles];
|
||||||
if ([o length] > 0)
|
if ([o count])
|
||||||
[data setObject: o forKey: @"title"];
|
[data setObject: [o componentsJoinedByString: @" / "] forKey: @"title"];
|
||||||
o = [card role];
|
o = [card role];
|
||||||
if ([o length] > 0)
|
if ([o length] > 0)
|
||||||
[data setObject: o forKey: @"role"];
|
[data setObject: o forKey: @"role"];
|
||||||
|
|
Loading…
Reference in New Issue