mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-18 14:44:53 +00:00
(feat) added custom fields support from Thunderbird's address book
This commit is contained in:
@@ -337,11 +337,13 @@ static Class SOGoContactGCSEntryK = Nil;
|
||||
|
||||
- (void) setAttributes: (NSDictionary *) attributes
|
||||
{
|
||||
CardElement *element;
|
||||
NSArray *elements, *values;
|
||||
NSMutableArray *orgs, *categories;
|
||||
NSDictionary *customFields;
|
||||
NSArray *elements, *values;
|
||||
NSCalendarDate *date;
|
||||
CardElement *element;
|
||||
id o;
|
||||
|
||||
unsigned int i, year, month, day;
|
||||
|
||||
[card setNWithFamily: [attributes objectForKey: @"c_sn"]
|
||||
@@ -485,6 +487,38 @@ static Class SOGoContactGCSEntryK = Nil;
|
||||
[card setCategories: categories];
|
||||
}
|
||||
|
||||
customFields = [attributes objectForKey: @"customFields"];
|
||||
if (customFields && [customFields isKindOfClass: [NSDictionary class]])
|
||||
{
|
||||
if ((o = [customFields objectForKey: @"1"]))
|
||||
{
|
||||
elements = [card childrenWithTag: @"custom1"];
|
||||
[card removeChildren: elements];
|
||||
[card addElementWithTag: @"custom1" ofType: nil withValue: o];
|
||||
}
|
||||
|
||||
if ((o = [customFields objectForKey: @"2"]))
|
||||
{
|
||||
elements = [card childrenWithTag: @"custom2"];
|
||||
[card removeChildren: elements];
|
||||
[card addElementWithTag: @"custom2" ofType: nil withValue: o];
|
||||
}
|
||||
|
||||
if ((o = [customFields objectForKey: @"3"]))
|
||||
{
|
||||
elements = [card childrenWithTag: @"custom3"];
|
||||
[card removeChildren: elements];
|
||||
[card addElementWithTag: @"custom1" ofType: nil withValue: o];
|
||||
}
|
||||
|
||||
if ((o = [customFields objectForKey: @"4"]))
|
||||
{
|
||||
elements = [card childrenWithTag: @"custom4"];
|
||||
[card removeChildren: elements];
|
||||
[card addElementWithTag: @"custom1" ofType: nil withValue: o];
|
||||
}
|
||||
}
|
||||
|
||||
[card cleanupEmptyChildren];
|
||||
}
|
||||
|
||||
|
||||
@@ -270,14 +270,15 @@
|
||||
* @apiSuccess (Success 200) {Object[]} [urls] URLs
|
||||
* @apiSuccess (Success 200) {String} urls.type Type (e.g., personal or work)
|
||||
* @apiSuccess (Success 200) {String} urls.value URL
|
||||
* @apiSuccess (Success 200) {Object[]} customFields Custom fields from Thunderbird
|
||||
*/
|
||||
- (id <WOActionResults>) dataAction
|
||||
{
|
||||
id <WOActionResults> result;
|
||||
id o;
|
||||
NSMutableDictionary *customFields, *data;
|
||||
SOGoObject <SOGoContactObject> *contact;
|
||||
id <WOActionResults> result;
|
||||
NSArray *values;
|
||||
NSMutableDictionary *data;
|
||||
id o;
|
||||
|
||||
contact = [self clientObject];
|
||||
card = [contact vCard];
|
||||
@@ -355,6 +356,23 @@
|
||||
if ([contact hasPhoto])
|
||||
[data setObject: [self photoURL] forKey: @"photoURL"];
|
||||
|
||||
// Custom fields from Thunderbird
|
||||
customFields = [NSMutableDictionary dictionary];
|
||||
if ((o = [[card uniqueChildWithTag: @"custom1"] flattenedValuesForKey: @""]) && [o length])
|
||||
[customFields setObject: o forKey: @"1"];
|
||||
|
||||
if ((o = [[card uniqueChildWithTag: @"custom2"] flattenedValuesForKey: @""]) && [o length])
|
||||
[customFields setObject: o forKey: @"2"];
|
||||
|
||||
if ((o = [[card uniqueChildWithTag: @"custom3"] flattenedValuesForKey: @""]) && [o length])
|
||||
[customFields setObject: o forKey: @"3"];
|
||||
|
||||
if ((o = [[card uniqueChildWithTag: @"custom4"] flattenedValuesForKey: @""]) && [o length])
|
||||
[customFields setObject: o forKey: @"4"];
|
||||
|
||||
if ([customFields count])
|
||||
[data setObject: customFields forKey: @"customFields"];
|
||||
|
||||
result = [self responseWithStatus: 200
|
||||
andString: [data jsonRepresentation]];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user