From fac49e4f6903d77e92bdbc14c14d839a63c48dc8 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 9 Aug 2006 21:13:22 +0000 Subject: [PATCH] Monotone-Parent: b905373c7a05b0b865e4b2361c76b7a5d079a520 Monotone-Revision: c29edea33f25c719bad972e23d7441b3851b8164 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-08-09T21:13:22 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 ++ SoObjects/Contacts/NGVCard+Contact.h | 34 +++++++++ SoObjects/Contacts/NGVCard+Contact.m | 102 +++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 SoObjects/Contacts/NGVCard+Contact.h create mode 100644 SoObjects/Contacts/NGVCard+Contact.m diff --git a/ChangeLog b/ChangeLog index 8e92fb808..011198a0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2006-08-09 Wolfgang Sourdeau + * SoObjects/Contacts/NGVCard+Contact.m ([NGVCard -asString]): new + method that generates a textual representation of the vcard. + + * SoObjects/Contacts/NGVCard+Contact.[hm]: new class extension. + * SoObjects/Contacts/SOGoContactGCSFolder.[hm]: new module name of "SOGoContactFolder". diff --git a/SoObjects/Contacts/NGVCard+Contact.h b/SoObjects/Contacts/NGVCard+Contact.h new file mode 100644 index 000000000..e2d2605f9 --- /dev/null +++ b/SoObjects/Contacts/NGVCard+Contact.h @@ -0,0 +1,34 @@ +/* NGVCard+Contact.h - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * 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 + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NGVCARD_CONTACT_H +#define NGVCARD_CONTACT_H + +#import + +@interface NGVCard (SOGOContactExtension) + +- (NSString *) asString; + +@end + +#endif /* NGVCARD+CONTACT_H */ diff --git a/SoObjects/Contacts/NGVCard+Contact.m b/SoObjects/Contacts/NGVCard+Contact.m new file mode 100644 index 000000000..257a5d140 --- /dev/null +++ b/SoObjects/Contacts/NGVCard+Contact.m @@ -0,0 +1,102 @@ +/* NGVCard+Contact.m - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * 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 + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import + +#import + +#import "NGVCardSimpleValue+Contact.h" +#import "NGVCard+Contact.h" + +@implementation NGVCard (SOGOContactExtension) + +- (NSString *) asString +{ + NSMutableString *vCardString; + NSArray *infos; + unsigned int count, max; + + vCardString = [NSMutableString new]; + [vCardString autorelease]; + + [vCardString appendFormat: @"BEGIN:VCARD\r\n" + @"VERSION:%@\r\n" + @"PRODID:%@\r\n" + @"PROFILE:%@\r\n", + [self version], [self prodID], [self profile]]; + [vCardString appendFormat: @"FN:%@\r\n", [self fn]]; + [vCardString appendFormat: @"N:%@\r\n", [[self n] stringValue]]; + + infos = [self email]; + if ([infos count] > 0) + [vCardString appendFormat: @"EMAIL;TYPE=internet,pref:%@\r\n", + [infos objectAtIndex: 0]]; + + infos = [self tel]; + max = [infos count]; + for (count = 0; count < max; count++) + [vCardString appendFormat: @"%@\r\n", + [[infos objectAtIndex: count] vCardEntryString]]; + +// } +// count = +// if ([infos count] > 0) +// [vCardString appendFormat: @"EMAIL;TYPE=internet,pref:%@\r\n", +// [infos objectAtIndex: 0]]; + +// [self _appendArrayedVCardValues: +// [NSArray arrayWithObjects: @"sn", @"givenName", nil] +// withFormat: @"N:%@;;;\r\n" +// toVCard: vCardString]; +// [self _appendSingleVCardValue: @"telephoneNumber" +// withFormat: @"TEL;TYPE=work,voice,pref:%@\r\n" +// toVCard: vCardString]; +// [self _appendSingleVCardValue: @"facsimileTelephoneNumber" +// withFormat: @"TEL;TYPE=work,fax:%@\r\n" +// toVCard: vCardString]; +// [self _appendSingleVCardValue: @"homeTelephoneNumber" +// withFormat: @"TEL;TYPE=home,voice:%@\r\n" +// toVCard: vCardString]; +// [self _appendSingleVCardValue: @"mobile" +// withFormat: @"TEL;TYPE=cell,voice:%@\r\n" +// toVCard: vCardString]; +// [self _appendArrayedVCardValues: +// [NSArray arrayWithObjects: @"l", @"departmentNumber", nil] +// withFormat: @"ORG:%@\r\n" +// toVCard: vCardString]; +// [self _appendMultilineVCardValue: @"postalAddress" +// withFormat: @"ADR:TYPE=work,postal:%@\r\n" +// toVCard: vCardString]; +// [self _appendMultilineVCardValue: @"homePostalAddress" +// withFormat: @"ADR:TYPE=home,postal:%@\r\n" +// toVCard: vCardString]; +// [self _appendSingleVCardValue: @"labelledURI" +// withFormat: @"URL:%@\r\n" +// toVCard: vCardString]; + + [vCardString appendString: @"END:VCARD\r\n"]; + + return vCardString; +} + +@end