2006-06-15 21:34:10 +02:00
|
|
|
/*
|
2015-06-11 19:14:19 +02:00
|
|
|
Copyright (C) 2005-2015 Inverse inc.
|
2010-06-30 18:53:23 +02:00
|
|
|
|
|
|
|
This file is part of SOGo.
|
2009-10-28 20:38:56 +01:00
|
|
|
|
2010-06-30 18:53:23 +02:00
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
2006-06-15 21:34:10 +02:00
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
2009-10-28 20:38:56 +01:00
|
|
|
|
2010-06-30 18:53:23 +02:00
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
2006-06-15 21:34:10 +02:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2009-10-28 20:38:56 +01:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2010-07-16 21:35:25 +02:00
|
|
|
#import <Foundation/NSURL.h>
|
2014-06-19 21:51:57 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2010-07-16 21:35:25 +02:00
|
|
|
|
2007-08-06 16:46:38 +02:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2006-09-13 23:30:37 +02:00
|
|
|
#import <NGCards/NSArray+NGCards.h>
|
2006-09-19 16:09:03 +02:00
|
|
|
#import <NGExtensions/NSString+Ext.h>
|
2014-02-07 21:52:43 +01:00
|
|
|
#import <NGExtensions/NSString+misc.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
#import <SOGo/NSArray+Utilities.h>
|
2013-01-30 14:40:27 +01:00
|
|
|
#import <SOGo/NSCalendarDate+SOGo.h>
|
2014-06-19 21:51:57 +02:00
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
2013-01-30 14:40:27 +01:00
|
|
|
#import <SOGo/SOGoUser.h>
|
2014-06-19 21:51:57 +02:00
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2014-01-22 17:27:27 +01:00
|
|
|
|
|
|
|
#import <Contacts/NGVCard+SOGo.h>
|
2010-07-16 21:35:25 +02:00
|
|
|
#import <Contacts/SOGoContactObject.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-09-13 23:30:37 +02:00
|
|
|
#import "UIxContactView.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
@implementation UIxContactView
|
|
|
|
|
2010-07-16 21:35:25 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
photosURL = nil;
|
2010-10-27 17:18:14 +02:00
|
|
|
card = nil;
|
|
|
|
phones = nil;
|
|
|
|
homeAdr = nil;
|
|
|
|
workAdr = nil;
|
2010-07-16 21:35:25 +02:00
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-07-16 21:35:25 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
[card release];
|
2010-07-16 21:35:25 +02:00
|
|
|
[photosURL release];
|
|
|
|
[super dealloc];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2010-07-16 21:35:25 +02:00
|
|
|
/* accessors */
|
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) _cardStringWithLabel: (NSString *) label
|
|
|
|
// value: (NSString *) value
|
|
|
|
// byEscapingHTMLString: (BOOL) escapeHTML
|
|
|
|
// asLinkScheme: (NSString *) scheme
|
|
|
|
// withLinkAttributes: (NSString *) attrs
|
|
|
|
// {
|
|
|
|
// NSMutableString *cardString;
|
|
|
|
|
|
|
|
// cardString = [NSMutableString stringWithCapacity: 80];
|
|
|
|
// value = [value stringByReplacingString: @"\r" withString: @""];
|
|
|
|
// if ([value length] > 0)
|
|
|
|
// {
|
|
|
|
// if (escapeHTML)
|
|
|
|
// value = [value stringByEscapingHTMLString];
|
|
|
|
// if ([scheme length] > 0)
|
|
|
|
// value = [NSString stringWithFormat: @"<a href=\"%@%@\" %@>%@</a>", scheme, value, attrs, value];
|
|
|
|
|
|
|
|
// if (label)
|
|
|
|
// [cardString appendFormat: @"<dt>%@</dt><dd>%@</dd>\n",
|
|
|
|
// [self labelForKey: label], value];
|
|
|
|
// else
|
|
|
|
// [cardString appendFormat: @"<dt></dt><dd>%@</dd>\n", value];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return cardString;
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) _cardStringWithLabel: (NSString *) label
|
|
|
|
// value: (NSString *) value
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: label
|
|
|
|
// value: value
|
|
|
|
// byEscapingHTMLString: YES
|
|
|
|
// asLinkScheme: nil
|
|
|
|
// withLinkAttributes: nil];
|
|
|
|
// }
|
2014-02-13 18:11:25 +01:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) _cardStringWithLabel: (NSString *) label
|
|
|
|
// value: (NSString *) value
|
|
|
|
// asLinkScheme: (NSString *) scheme
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: label
|
|
|
|
// value: value
|
|
|
|
// byEscapingHTMLString: YES
|
|
|
|
// asLinkScheme: scheme
|
|
|
|
// withLinkAttributes: nil];
|
|
|
|
// }
|
2011-11-14 17:07:04 +01:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) displayName
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Display Name:"
|
|
|
|
// value: [card fn]];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) nickName
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Nickname:"
|
|
|
|
// value: [card nickname]];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) fullName
|
|
|
|
// {
|
|
|
|
// return [card fullName];
|
|
|
|
// }
|
2008-08-21 19:42:31 +02:00
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
- (NSArray *) _languageContactsCategories
|
|
|
|
{
|
|
|
|
NSArray *categoryLabels;
|
|
|
|
|
|
|
|
categoryLabels = [[self labelForKey: @"contacts_category_labels"] componentsSeparatedByString: @","];
|
|
|
|
if (!categoryLabels)
|
|
|
|
categoryLabels = [NSArray array];
|
|
|
|
|
|
|
|
return [categoryLabels trimmedComponents];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _fetchAndCombineCategoriesList
|
|
|
|
{
|
|
|
|
NSString *ownerLogin;
|
|
|
|
SOGoUserDefaults *ud;
|
|
|
|
NSArray *cats, *newCats, *contactCategories;
|
|
|
|
|
|
|
|
ownerLogin = [[self clientObject] ownerInContext: context];
|
|
|
|
ud = [[SOGoUser userWithLogin: ownerLogin] userDefaults];
|
|
|
|
cats = [ud contactsCategories];
|
|
|
|
if (!cats)
|
|
|
|
cats = [self _languageContactsCategories];
|
|
|
|
|
|
|
|
contactCategories = [card categories];
|
|
|
|
if (contactCategories)
|
|
|
|
{
|
2015-04-27 19:18:05 +02:00
|
|
|
newCats = [cats mergedArrayWithArray: [contactCategories trimmedComponents]];
|
2014-06-19 21:51:57 +02:00
|
|
|
if ([newCats count] != [cats count])
|
|
|
|
{
|
|
|
|
cats = [newCats sortedArrayUsingSelector:
|
|
|
|
@selector (localizedCaseInsensitiveCompare:)];
|
|
|
|
[ud setContactsCategories: cats];
|
|
|
|
[ud synchronize];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cats;
|
|
|
|
}
|
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) primaryEmail
|
|
|
|
// {
|
|
|
|
// NSString *email, *fn, *attrs;
|
|
|
|
|
|
|
|
// email = [card preferredEMail];
|
|
|
|
// if ([email length] > 0)
|
|
|
|
// {
|
|
|
|
// fn = [card fn];
|
|
|
|
// if ([fn length] > 0)
|
|
|
|
// attrs = [NSString stringWithFormat: @"%@ <%@>", fn, email];
|
|
|
|
// else
|
|
|
|
// attrs = email;
|
|
|
|
// attrs = [attrs stringByReplacingString: @"'" withString: @"\\'"];
|
|
|
|
// attrs = [attrs stringByReplacingString: @"\"" withString: @"\\\""];
|
|
|
|
// attrs = [NSString stringWithFormat: @"onclick=\"return openMailTo('%@');\"", attrs];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// attrs = nil;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return [self _cardStringWithLabel: @"Email:"
|
|
|
|
// value: email
|
|
|
|
// byEscapingHTMLString: YES
|
|
|
|
// asLinkScheme: @"mailto:"
|
|
|
|
// withLinkAttributes: attrs];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSArray *) secondaryEmails
|
|
|
|
// {
|
|
|
|
// NSMutableArray *secondaryEmails;
|
|
|
|
// NSString *email, *fn, *attrs;
|
|
|
|
// NSArray *emails;
|
|
|
|
|
|
|
|
// emails = [card secondaryEmails];
|
|
|
|
// secondaryEmails = [NSMutableArray array];
|
|
|
|
// attrs = nil;
|
|
|
|
|
|
|
|
// // We might not have a preferred item but rather something like this:
|
|
|
|
// // EMAIL;TYPE=work:dd@ee.com
|
|
|
|
// // EMAIL;TYPE=home:ff@gg.com
|
|
|
|
// //
|
|
|
|
// // or:
|
|
|
|
// //
|
|
|
|
// // EMAIL;TYPE=INTERNET:a@a.com
|
|
|
|
// // EMAIL;TYPE=INTERNET,HOME:b@b.com
|
|
|
|
// //
|
|
|
|
// // In this case, we always return the entry NOT matching the primaryEmail
|
|
|
|
// if ([emails count] > 0)
|
|
|
|
// {
|
|
|
|
// int i;
|
|
|
|
|
|
|
|
// for (i = 0; i < [emails count]; i++)
|
|
|
|
// {
|
|
|
|
// email = [[emails objectAtIndex: i] flattenedValuesForKey: @""];
|
|
|
|
// if ([email length])
|
|
|
|
// {
|
|
|
|
// fn = [card fn];
|
|
|
|
// if ([fn length])
|
|
|
|
// attrs = [NSString stringWithFormat: @"%@ <%@>", fn, email];
|
|
|
|
// else
|
|
|
|
// attrs = email;
|
|
|
|
// attrs = [attrs stringByReplacingString: @"'" withString: @"\\'"];
|
|
|
|
// attrs = [attrs stringByReplacingString: @"\"" withString: @"\\\""];
|
|
|
|
// attrs = [NSString stringWithFormat: @"onclick=\"return openMailTo('%@');\"", attrs];
|
|
|
|
|
|
|
|
// [secondaryEmails addObject: [self _cardStringWithLabel: nil
|
|
|
|
// value: email
|
|
|
|
// byEscapingHTMLString: YES
|
|
|
|
// asLinkScheme: @"mailto:"
|
|
|
|
// withLinkAttributes: attrs]];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// [secondaryEmails addObject: [self _cardStringWithLabel: nil
|
|
|
|
// value: nil]];
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// return secondaryEmails;
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) screenName
|
|
|
|
// {
|
|
|
|
// NSString *screenName;
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// screenName = [[card uniqueChildWithTag: @"x-aim"] flattenedValuesForKey: @""];
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// return [self _cardStringWithLabel: @"Screen Name:"
|
|
|
|
// value: screenName
|
|
|
|
// asLinkScheme: @"aim:goim?screenname="];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) preferredTel
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Phone Number:"
|
|
|
|
// value: [card preferredTel] asLinkScheme: @"tel:"];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) preferredAddress
|
|
|
|
// {
|
|
|
|
// return @"";
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (BOOL) hasTelephones
|
|
|
|
// {
|
|
|
|
// if (!phones)
|
|
|
|
// phones = [card childrenWithTag: @"tel"];
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// return ([phones count] > 0);
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) workPhone
|
|
|
|
// {
|
|
|
|
// // We do this (exclude FAX) in order to avoid setting the WORK number as the FAX
|
|
|
|
// // one if we do see the FAX field BEFORE the WORK number.
|
|
|
|
// return [self _cardStringWithLabel: @"Work:" value: [card workPhone] asLinkScheme: @"tel:"];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) homePhone
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Home:" value: [card homePhone] asLinkScheme: @"tel:"];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) fax
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Fax:" value: [card fax] asLinkScheme: @"tel:"];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) mobile
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Mobile:" value: [card mobile] asLinkScheme: @"tel:"];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) pager
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Pager:" value: [card pager] asLinkScheme: @"tel:"];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (BOOL) hasHomeInfos
|
|
|
|
// {
|
|
|
|
// BOOL result;
|
|
|
|
// NSArray *elements;
|
|
|
|
|
|
|
|
// elements = [card childrenWithTag: @"adr"
|
|
|
|
// andAttribute: @"type"
|
|
|
|
// havingValue: @"home"];
|
|
|
|
// if ([elements count] > 0)
|
|
|
|
// {
|
|
|
|
// result = YES;
|
|
|
|
// homeAdr = [elements objectAtIndex: 0];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// result = ([[card childrenWithTag: @"url"
|
|
|
|
// andAttribute: @"type"
|
|
|
|
// havingValue: @"home"] count] > 0);
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) homePobox
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: nil
|
|
|
|
// value: [homeAdr flattenedValueAtIndex: 0
|
|
|
|
// forKey: @""]];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) homeExtendedAddress
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: nil
|
|
|
|
// value: [homeAdr flattenedValueAtIndex: 1
|
|
|
|
// forKey: @""]];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) homeStreetAddress
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: nil
|
|
|
|
// value: [homeAdr flattenedValueAtIndex: 2
|
|
|
|
// forKey: @""]];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) homeCityAndProv
|
|
|
|
// {
|
|
|
|
// NSString *city, *prov;
|
|
|
|
// NSMutableString *data;
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// city = [homeAdr flattenedValueAtIndex: 3 forKey: @""];
|
|
|
|
// prov = [homeAdr flattenedValueAtIndex: 4 forKey: @""];
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// data = [NSMutableString string];
|
|
|
|
// [data appendString: city];
|
|
|
|
// if ([city length] > 0 && [prov length] > 0)
|
|
|
|
// [data appendString: @", "];
|
|
|
|
// [data appendString: prov];
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// return [self _cardStringWithLabel: nil value: data];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) homePostalCodeAndCountry
|
|
|
|
// {
|
|
|
|
// NSString *postalCode, *country;
|
|
|
|
// NSMutableString *data;
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// postalCode = [homeAdr flattenedValueAtIndex: 5 forKey: @""];
|
|
|
|
// country = [homeAdr flattenedValueAtIndex: 6 forKey: @""];
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// data = [NSMutableString string];
|
|
|
|
// [data appendString: postalCode];
|
|
|
|
// if ([postalCode length] > 0 && [country length] > 0)
|
|
|
|
// [data appendFormat: @", "];
|
|
|
|
// [data appendString: country];
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// return [self _cardStringWithLabel: nil value: data];
|
|
|
|
// }
|
2010-06-30 22:30:30 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) _formattedURL: (NSString *) url
|
|
|
|
// {
|
|
|
|
// NSRange schemaR;
|
|
|
|
// NSString *schema, *data;
|
|
|
|
|
|
|
|
// if ([url length] > 0)
|
|
|
|
// {
|
|
|
|
// schemaR = [url rangeOfString: @"://"];
|
|
|
|
// if (schemaR.length > 0)
|
|
|
|
// {
|
|
|
|
// schema = [url substringToIndex: schemaR.location + schemaR.length];
|
|
|
|
// data = [url substringFromIndex: schemaR.location + schemaR.length];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// schema = @"http://";
|
|
|
|
// data = url;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// schema = nil;
|
|
|
|
// data = nil;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return [self _cardStringWithLabel: nil
|
|
|
|
// value: data
|
|
|
|
// byEscapingHTMLString: YES
|
|
|
|
// asLinkScheme: schema
|
|
|
|
// withLinkAttributes: @"target=\"_blank\""];
|
|
|
|
// }
|
2010-06-30 22:30:30 +02:00
|
|
|
|
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) _urlOfType: (NSString *) aType
|
|
|
|
// {
|
|
|
|
// NSArray *elements;
|
|
|
|
// NSString *url;
|
|
|
|
|
|
|
|
// elements = [card childrenWithTag: @"url"
|
|
|
|
// andAttribute: @"type"
|
|
|
|
// havingValue: aType];
|
|
|
|
// if ([elements count] > 0)
|
|
|
|
// url = [[elements objectAtIndex: 0] flattenedValuesForKey: @""];
|
|
|
|
// else
|
|
|
|
// url = nil;
|
|
|
|
|
|
|
|
// return [self _formattedURL: url];
|
|
|
|
// }
|
2010-06-30 22:30:30 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) homeUrl
|
|
|
|
// {
|
|
|
|
// NSString *s;
|
2010-06-30 22:30:30 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// s = [self _urlOfType: @"home"];
|
2010-06-30 22:30:30 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// if (!s || [s length] == 0)
|
|
|
|
// {
|
|
|
|
// NSArray *elements;
|
|
|
|
// NSString *workURL;
|
|
|
|
// int i;
|
2010-06-30 22:30:30 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// elements = [card childrenWithTag: @"url"
|
|
|
|
// andAttribute: @"type"
|
|
|
|
// havingValue: @"work"];
|
|
|
|
// workURL = nil;
|
|
|
|
|
|
|
|
// if ([elements count] > 0)
|
|
|
|
// workURL = [[elements objectAtIndex: 0] flattenedValuesForKey: @""];
|
|
|
|
|
|
|
|
// elements = [card childrenWithTag: @"url"];
|
|
|
|
|
|
|
|
// if (workURL && [elements count] > 1)
|
|
|
|
// {
|
|
|
|
// for (i = 0; i < [elements count]; i++)
|
|
|
|
// {
|
|
|
|
// if ([[[elements objectAtIndex: i] flattenedValuesForKey: @""]
|
|
|
|
// caseInsensitiveCompare: workURL] != NSOrderedSame)
|
|
|
|
// {
|
|
|
|
// s = [[elements objectAtIndex: i] flattenedValuesForKey: @""];
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
2010-06-30 22:30:30 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// }
|
|
|
|
// else if (!workURL && [elements count] > 0)
|
|
|
|
// {
|
|
|
|
// s = [[elements objectAtIndex: 0] flattenedValuesForKey: @""];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (s && [s length] > 0)
|
|
|
|
// s = [self _formattedURL: s];
|
|
|
|
// }
|
2010-06-30 22:30:30 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// return s;
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (BOOL) hasWorkInfos
|
|
|
|
// {
|
|
|
|
// BOOL result;
|
|
|
|
// NSArray *elements;
|
|
|
|
|
|
|
|
// elements = [card childrenWithTag: @"adr"
|
|
|
|
// andAttribute: @"type"
|
|
|
|
// havingValue: @"work"];
|
|
|
|
// if ([elements count] > 0)
|
|
|
|
// {
|
|
|
|
// result = YES;
|
|
|
|
// workAdr = [elements objectAtIndex: 0];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// result = (([[card childrenWithTag: @"url"
|
|
|
|
// andAttribute: @"type"
|
|
|
|
// havingValue: @"work"] count] > 0)
|
|
|
|
// || [[card childrenWithTag: @"org"] count] > 0);
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) workTitle
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: nil value: [card title]];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
- (NSArray *) orgUnits
|
|
|
|
{
|
|
|
|
NSMutableArray *orgUnits;
|
|
|
|
NSArray *values;
|
|
|
|
CardElement *org;
|
|
|
|
NSString *service;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
org = [card org];
|
|
|
|
values = [org valuesForKey: @""];
|
|
|
|
max = [values count];
|
|
|
|
if (max > 1)
|
|
|
|
{
|
|
|
|
orgUnits = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
for (count = 1; count < max; count++)
|
|
|
|
{
|
|
|
|
service = [org flattenedValueAtIndex: count forKey: @""];
|
|
|
|
if ([service length] > 0)
|
|
|
|
[orgUnits addObject: [NSDictionary dictionaryWithObject: service forKey: @"value"]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
orgUnits = nil;
|
|
|
|
|
|
|
|
return orgUnits;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) categories
|
|
|
|
{
|
|
|
|
NSMutableArray *categories;
|
|
|
|
NSArray *values;
|
|
|
|
NSString *category;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
values = [card categories];
|
|
|
|
max = [values count];
|
|
|
|
if (max > 0)
|
|
|
|
{
|
|
|
|
categories = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
category = [values objectAtIndex: count];
|
|
|
|
if ([category length] > 0)
|
|
|
|
[categories addObject: [NSDictionary dictionaryWithObject: category forKey: @"value"]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
categories = nil;
|
|
|
|
|
|
|
|
return categories;
|
|
|
|
}
|
|
|
|
|
2016-03-01 22:53:08 +01:00
|
|
|
- (NSArray *) urls
|
|
|
|
{
|
|
|
|
NSMutableArray *urls;
|
|
|
|
NSMutableDictionary *attrs;
|
|
|
|
NSArray *values;
|
|
|
|
NSString *type, *value;
|
|
|
|
NSURL *url;
|
|
|
|
CardElement *element;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
values = [card childrenWithTag: @"url"];
|
|
|
|
max = [values count];
|
|
|
|
if (max > 0)
|
|
|
|
{
|
|
|
|
urls = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
attrs = [NSMutableDictionary dictionary];
|
|
|
|
element = [values objectAtIndex: count];
|
|
|
|
type = [element value: 0 ofAttribute: @"type"];
|
|
|
|
if ([type length])
|
|
|
|
[attrs setObject: type forKey: @"type"];
|
|
|
|
value = [element flattenedValuesForKey: @""];
|
|
|
|
url = [NSURL URLWithString: value];
|
|
|
|
if (![url scheme] && [value length] > 0)
|
|
|
|
url = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@", value]];
|
|
|
|
[attrs setObject: [url absoluteString] forKey: @"value"];
|
|
|
|
|
|
|
|
[urls addObject: attrs];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
urls = nil;
|
|
|
|
|
|
|
|
return urls;
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
- (NSArray *) deliveryAddresses
|
|
|
|
{
|
|
|
|
NSMutableArray *addresses;
|
|
|
|
NSMutableDictionary *address;
|
|
|
|
NSArray *elements;
|
|
|
|
NSString *type, *postoffice, *street, *street2, *locality, *region, *postalcode, *country;
|
|
|
|
CardElement *adr;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
elements = [card childrenWithTag: @"adr"];
|
|
|
|
//values = [org valuesForKey: @""];
|
|
|
|
max = [elements count];
|
|
|
|
if (max > 0)
|
|
|
|
{
|
|
|
|
addresses = [NSMutableArray arrayWithCapacity: max];
|
2014-08-06 22:06:58 +02:00
|
|
|
for (count = 0; count < max; count++)
|
2014-06-19 21:51:57 +02:00
|
|
|
{
|
|
|
|
adr = [elements objectAtIndex: count];
|
|
|
|
type = [adr value: 0 ofAttribute: @"type"];
|
|
|
|
postoffice = [adr flattenedValueAtIndex: 0 forKey: @""];
|
|
|
|
street2 = [adr flattenedValueAtIndex: 1 forKey: @""];
|
|
|
|
street = [adr flattenedValueAtIndex: 2 forKey: @""];
|
|
|
|
locality = [adr flattenedValueAtIndex: 3 forKey: @""];
|
|
|
|
region = [adr flattenedValueAtIndex: 4 forKey: @""];
|
|
|
|
postalcode = [adr flattenedValueAtIndex: 5 forKey: @""];
|
|
|
|
country = [adr flattenedValueAtIndex: 6 forKey: @""];
|
|
|
|
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"];
|
|
|
|
if (locality) [address setObject: locality forKey: @"locality"];
|
|
|
|
if (region) [address setObject: region forKey: @"region"];
|
|
|
|
if (postalcode) [address setObject: postalcode forKey: @"postalcode"];
|
|
|
|
if (country) [address setObject: country forKey: @"country"];
|
|
|
|
if ([[address allKeys] count] > 1) [addresses addObject: address];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
addresses = nil;
|
|
|
|
|
|
|
|
return addresses;
|
|
|
|
}
|
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) workService
|
|
|
|
// {
|
|
|
|
// NSMutableArray *orgServices;
|
|
|
|
// NSArray *values;
|
|
|
|
// CardElement *org;
|
|
|
|
// NSString *service, *services;
|
|
|
|
// NSUInteger count, max;
|
|
|
|
|
|
|
|
// org = [card org];
|
|
|
|
// values = [org valuesForKey: @""];
|
|
|
|
// max = [values count];
|
|
|
|
// if (max > 1)
|
|
|
|
// {
|
|
|
|
// orgServices = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
// for (count = 1; count < max; count++)
|
|
|
|
// {
|
|
|
|
// service = [org flattenedValueAtIndex: count forKey: @""];
|
|
|
|
// if ([service length] > 0)
|
|
|
|
// [orgServices addObject: service];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// services = [orgServices componentsJoinedByString: @", "];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// services = nil;
|
|
|
|
|
|
|
|
// return [self _cardStringWithLabel: nil value: services];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) workUrl
|
|
|
|
// {
|
|
|
|
// return [self _urlOfType: @"work"];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (BOOL) hasOtherInfos
|
|
|
|
// {
|
|
|
|
// return ([[card note] length] > 0
|
|
|
|
// || [[card bday] length] > 0
|
|
|
|
// || [[card tz] length] > 0);
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) bday
|
|
|
|
// {
|
|
|
|
// SOGoDateFormatter *dateFormatter;
|
|
|
|
// NSCalendarDate *date;
|
|
|
|
// NSString *bday;
|
2014-01-22 17:27:27 +01:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// date = [card birthday];
|
|
|
|
// bday = nil;
|
2013-01-30 14:40:27 +01:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// if (date)
|
|
|
|
// {
|
|
|
|
// dateFormatter = [[[self context] activeUser] dateFormatterInContext: context];
|
|
|
|
// bday = [dateFormatter formattedDate: date];
|
|
|
|
// }
|
2013-01-30 14:40:27 +01:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// return bday;
|
|
|
|
// //return [self _cardStringWithLabel: @"Birthday:" value: bday];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
// - (NSString *) tz
|
|
|
|
// {
|
|
|
|
// return [self _cardStringWithLabel: @"Timezone:" value: [card tz]];
|
|
|
|
// }
|
2006-09-13 23:30:37 +02:00
|
|
|
|
|
|
|
- (NSString *) note
|
|
|
|
{
|
2006-09-19 16:09:03 +02:00
|
|
|
NSString *note;
|
|
|
|
|
|
|
|
note = [card note];
|
|
|
|
if (note)
|
|
|
|
{
|
2014-10-05 06:30:27 +02:00
|
|
|
note = [note stringByEscapingHTMLString];
|
2006-09-19 16:09:03 +02:00
|
|
|
note = [note stringByReplacingString: @"\r\n"
|
|
|
|
withString: @"<br />"];
|
|
|
|
note = [note stringByReplacingString: @"\n"
|
|
|
|
withString: @"<br />"];
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
return note;
|
|
|
|
//return [self _cardStringWithLabel: @"Note:" value: note];
|
2006-09-13 23:30:37 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* hrefs */
|
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *) completeHrefForMethod: (NSString *) _method
|
|
|
|
// withParameter: (NSString *) _param
|
|
|
|
// forKey: (NSString *) _key
|
|
|
|
// {
|
|
|
|
// NSString *href;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// [self setQueryParameter:_param forKey:_key];
|
|
|
|
// href = [self completeHrefForMethod:[self ownMethodName]];
|
|
|
|
// [self setQueryParameter:nil forKey:_key];
|
2006-09-19 16:50:11 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// return href;
|
|
|
|
// }
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2015-11-27 16:58:56 +01:00
|
|
|
// - (NSString *)attributesTabLink {
|
|
|
|
// return [self completeHrefForMethod:[self ownMethodName]
|
|
|
|
// withParameter:@"attributes"
|
|
|
|
// forKey:@"tab"];
|
|
|
|
// }
|
|
|
|
// - (NSString *)debugTabLink {
|
|
|
|
// return [self completeHrefForMethod:[self ownMethodName]
|
|
|
|
// withParameter:@"debug"
|
|
|
|
// forKey:@"tab"];
|
|
|
|
// }
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/* action */
|
|
|
|
|
2006-09-13 23:30:37 +02:00
|
|
|
- (id <WOActionResults>) defaultAction
|
|
|
|
{
|
|
|
|
card = [[self clientObject] vCard];
|
2006-09-16 00:25:43 +02:00
|
|
|
if (card)
|
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
[card retain];
|
2006-09-16 00:25:43 +02:00
|
|
|
phones = nil;
|
|
|
|
homeAdr = nil;
|
|
|
|
workAdr = nil;
|
|
|
|
}
|
|
|
|
else
|
2006-09-19 16:50:11 +02:00
|
|
|
return [NSException exceptionWithHTTPStatus: 404 /* Not Found */
|
|
|
|
reason: @"could not locate contact"];
|
2006-09-13 23:30:37 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2015-01-22 15:15:44 +01:00
|
|
|
/**
|
|
|
|
* @api {get} /so/:username/Contacts/:addressbookId/:cardId/view Get card
|
|
|
|
* @apiVersion 1.0.0
|
|
|
|
* @apiName GetData
|
|
|
|
* @apiGroup Contacts
|
|
|
|
* @apiExample {curl} Example usage:
|
|
|
|
* curl -i http://localhost/SOGo/so/sogo1/Contacts/personal/1BC8-52F53F80-1-38C52040.vcf/view
|
|
|
|
*
|
|
|
|
* @apiSuccess (Success 200) {String} id Card ID
|
|
|
|
* @apiSuccess (Success 200) {String} pid Address book ID (card's container)
|
2015-07-27 18:47:40 +02:00
|
|
|
* @apiSuccess (Success 200) {String} c_component Either vcard or vlist
|
|
|
|
* @apiSuccess (Success 200) {String} [c_givenname] Firstname
|
2015-01-22 15:15:44 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [nickname] Nickname
|
2015-07-27 18:47:40 +02:00
|
|
|
* @apiSuccess (Success 200) {String} [c_sn] Lastname
|
|
|
|
* @apiSuccess (Success 200) {String} [c_fn] Fullname
|
2015-11-27 16:58:56 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [c_screenname] Screen Name (X-AIM for now)
|
2015-01-22 15:15:44 +01:00
|
|
|
* @apiSuccess (Success 200) {String} [tz] Timezone
|
|
|
|
* @apiSuccess (Success 200) {String} [note] Note
|
|
|
|
* @apiSuccess (Success 200) {String[]} allCategories All available categories
|
|
|
|
* @apiSuccess (Success 200) {Object[]} [categories] Categories assigned to the card
|
|
|
|
* @apiSuccess (Success 200) {String} categories.value Category name
|
|
|
|
* @apiSuccess (Success 200) {Object[]} [addresses] Postal addresses
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.type Type (e.g., home or work)
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.postoffice Post office box
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.street Street address
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.street2 Extended address (e.g., apartment or suite number)
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.locality Locality (e.g., city)
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.region Region (e.g., state or province)
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.postalcode Postal code
|
|
|
|
* @apiSuccess (Success 200) {String} addresses.country Country name
|
|
|
|
* @apiSuccess (Success 200) {Object[]} [emails] Email addresses
|
|
|
|
* @apiSuccess (Success 200) {String} emails.type Type (e.g., home or work)
|
|
|
|
* @apiSuccess (Success 200) {String} emails.value Email address
|
|
|
|
* @apiSuccess (Success 200) {Object[]} [phones] Phone numbers
|
|
|
|
* @apiSuccess (Success 200) {String} phones.type Type (e.g., mobile or work)
|
|
|
|
* @apiSuccess (Success 200) {String} phones.value Phone number
|
|
|
|
* @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
|
|
|
|
*/
|
2014-06-19 21:51:57 +02:00
|
|
|
- (id <WOActionResults>) dataAction
|
|
|
|
{
|
|
|
|
id <WOActionResults> result;
|
|
|
|
id o;
|
|
|
|
SOGoObject <SOGoContactObject> *contact;
|
|
|
|
NSMutableDictionary *data;
|
|
|
|
|
|
|
|
contact = [self clientObject];
|
|
|
|
card = [contact vCard];
|
|
|
|
if (card)
|
|
|
|
{
|
|
|
|
[card retain];
|
|
|
|
phones = nil;
|
|
|
|
homeAdr = nil;
|
|
|
|
workAdr = nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return [NSException exceptionWithHTTPStatus: 404 /* Not Found */
|
|
|
|
reason: @"could not locate contact"];
|
|
|
|
|
|
|
|
data = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
[[contact container] nameInContainer], @"pid",
|
|
|
|
[contact nameInContainer], @"id",
|
2015-07-27 18:47:40 +02:00
|
|
|
[[card tag] lowercaseString], @"c_component",
|
2014-06-19 21:51:57 +02:00
|
|
|
nil];
|
|
|
|
o = [card fn];
|
2015-07-27 18:47:40 +02:00
|
|
|
if (o) [data setObject: o forKey: @"c_cn"];
|
2014-06-19 21:51:57 +02:00
|
|
|
o = [card n];
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
NSString *lastName = [o flattenedValueAtIndex: 0 forKey: @""];
|
|
|
|
NSString *firstName = [o flattenedValueAtIndex: 1 forKey: @""];
|
|
|
|
if ([lastName length] > 0)
|
2015-07-27 18:47:40 +02:00
|
|
|
[data setObject: lastName forKey: @"c_sn"];
|
2014-06-19 21:51:57 +02:00
|
|
|
if ([firstName length] > 0)
|
2015-07-27 18:47:40 +02:00
|
|
|
[data setObject: firstName forKey: @"c_givenname"];
|
2014-06-19 21:51:57 +02:00
|
|
|
}
|
2015-11-27 16:58:56 +01:00
|
|
|
|
|
|
|
o = [[card uniqueChildWithTag: @"x-aim"] flattenedValuesForKey: @""];
|
|
|
|
if ([o length]) [data setObject: o forKey: @"c_screenname"];
|
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
o = [card nickname];
|
|
|
|
if (o) [data setObject: o forKey: @"nickname"];
|
|
|
|
o = [card title];
|
|
|
|
if ([o length] > 0)
|
|
|
|
{
|
|
|
|
[data setObject: o forKey: @"title"];
|
|
|
|
}
|
|
|
|
o = [card role];
|
|
|
|
if ([o length] > 0)
|
|
|
|
{
|
|
|
|
[data setObject: o forKey: @"role"];
|
|
|
|
}
|
|
|
|
o = [self orgUnits];
|
|
|
|
if ([o count] > 0)
|
|
|
|
{
|
|
|
|
[data setObject: o forKey: @"orgUnits"];
|
|
|
|
}
|
|
|
|
o = [card workCompany];
|
|
|
|
if ([o length] > 0)
|
|
|
|
{
|
2015-07-27 18:47:40 +02:00
|
|
|
[data setObject: o forKey: @"c_org"];
|
2014-06-19 21:51:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
o = [card birthday];
|
|
|
|
if (o)
|
|
|
|
{
|
2016-04-06 04:03:52 +02:00
|
|
|
[data setObject: [o descriptionWithCalendarFormat: @"%Y-%m-%d"]
|
2015-08-20 16:29:47 +02:00
|
|
|
forKey: @"birthday"];
|
2014-06-19 21:51:57 +02:00
|
|
|
}
|
2015-08-20 16:29:47 +02:00
|
|
|
|
2014-06-19 21:51:57 +02:00
|
|
|
o = [card tz];
|
|
|
|
if (o) [data setObject: o forKey: @"tz"];
|
|
|
|
|
|
|
|
o = [card childrenWithTag: @"email"];
|
|
|
|
if ([o count]) [data setObject: o forKey: @"emails"];
|
|
|
|
o = [card childrenWithTag: @"tel"];
|
|
|
|
if ([o count]) [data setObject: o forKey: @"phones"];
|
|
|
|
o = [self categories];
|
|
|
|
if ([o count]) [data setObject: o forKey: @"categories"];
|
|
|
|
o = [self deliveryAddresses];
|
|
|
|
if ([o count] > 0) [data setObject: o forKey: @"addresses"];
|
2016-03-01 22:53:08 +01:00
|
|
|
o = [self urls];
|
2014-06-19 21:51:57 +02:00
|
|
|
if ([o count]) [data setObject: o forKey: @"urls"];
|
|
|
|
|
|
|
|
o = [self note];
|
|
|
|
if (o) [data setObject: o forKey: @"note"];
|
|
|
|
o = [self _fetchAndCombineCategoriesList];
|
|
|
|
if (o) [data setObject: o forKey: @"allCategories"];
|
|
|
|
if ([contact hasPhoto])
|
|
|
|
[data setObject: [self photoURL] forKey: @"photoURL"];
|
|
|
|
|
|
|
|
result = [self responseWithStatus: 200
|
|
|
|
andString: [data jsonRepresentation]];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-02-13 15:50:00 +01:00
|
|
|
- (BOOL) hasPhoto
|
|
|
|
{
|
|
|
|
return [[self clientObject] hasPhoto];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) photoURL
|
2010-07-16 21:35:25 +02:00
|
|
|
{
|
|
|
|
NSURL *soURL;
|
|
|
|
|
2012-02-13 15:50:00 +01:00
|
|
|
soURL = [[self clientObject] soURL];
|
2010-07-16 21:35:25 +02:00
|
|
|
|
2012-02-13 15:50:00 +01:00
|
|
|
return [NSString stringWithFormat: @"%@/photo", [soURL absoluteString]];
|
2010-07-16 21:35:25 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* UIxContactView */
|