/* Copyright (C) 2004 SKYRIX Software AG This file is part of OpenGroupware.org. OGo is free software; you can redistribute it and/or modify it under 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. OGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 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. */ #include @interface OCSContactFieldExtractor : OCSFieldExtractor @end #include "common.h" @implementation OCSContactFieldExtractor - (NSMutableDictionary *)extractQuickFieldsFromContent:(NSString *)_content { static NSString *fieldNames[] = { @"givenName", @"cn", @"sn", @"l", @"mail", @"o", @"ou", @"telephoneNumber", nil }; NSMutableDictionary *fields; NSDictionary *plist; unsigned i; if ([_content length] == 0) return nil; // TODO: we want to support vcard storage in the future?! if ((plist = [_content propertyList]) == nil) { [self logWithFormat:@"ERROR: could not parse property list content!"]; return nil; } fields = [NSMutableDictionary dictionaryWithCapacity:16]; /* copy field values to quick record */ for (i = 0; fieldNames[i] != nil; i++) { NSString *fieldName, *sqlName; id value; fieldName = fieldNames[i]; sqlName = [fieldName lowercaseString]; /* actually pgsql doesn't care */ value = [plist objectForKey:fieldName]; if ([value isNotNull]) [fields setObject:value forKey:sqlName]; else [fields setObject:[NSNull null] forKey:sqlName]; } return fields; } @end /* OCSContactFieldExtractor */