+2005-05-08 Helge Hess <helge.hess@opengroupware.org>
+
+ * work on vCard objects (incomplete) (v4.5.52)
+
2005-04-25 Helge Hess <helge.hess@opengroupware.org>
* iCalDateHolder.m, iCalDataSource.m: fixed gcc 4.0 warnings (v4.5.51)
iCalRecurrenceCalculator.h \
\
NSCalendarDate+ICal.h \
+ \
+ NGVCard.h \
+ NGVCardValue.h \
+ NGVCardName.h \
+ NGVCardAddress.h \
# IcalResponse.h \
iCalRenderer.m \
iCalRecurrenceRule.m \
iCalRecurrenceCalculator.m \
+ \
+ NGICalSaxHandler.m \
+ NGVCardSaxHandler.m \
+ NGVCard.m \
+ NGVCardValue.m \
+ NGVCardSimpleValue.m \
+ NGVCardAddress.m \
+ NGVCardPhone.m \
+ NGVCardCategories.m \
+ NGVCardName.m \
# NSString+ICal.m \
# IcalElements.m
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __NGiCal_NGICalSaxHandler_H__
+#define __NGiCal_NGICalSaxHandler_H__
+
+#include <SaxObjC/SaxDefaultHandler.h>
+
+/*
+ NGICalSaxHandler
+
+ NOTE: WORK IN PROGRESS, DOES NOT WORK YET!
+
+ This SAX handler is supposed to create the NGiCal object model from SAX
+ events.
+*/
+
+@interface NGICalSaxHandler : SaxDefaultHandler
+{
+}
+
+@end
+
+#endif /* __NGiCal_NGICalSaxHandler_H__ */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGICalSaxHandler.h"
+#include "common.h"
+
+@implementation NGICalSaxHandler
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+/* document events */
+
+- (void)startDocument {
+}
+- (void)endDocument {
+}
+
+/* element events */
+
+- (void)startElement:(NSString *)_localName
+ namespace:(NSString *)_ns
+ rawName:(NSString *)_rawName
+ attributes:(id<SaxAttributes>)_attrs
+{
+}
+
+- (void)endElement:(NSString *)_localName
+ namespace:(NSString *)_ns
+ rawName:(NSString *)_rawName
+{
+}
+
+- (void)characters:(unichar *)_chars length:(int)_len {
+}
+
+@end /* NGICalSaxHandler */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __NGiCal_NGVCard_H__
+#define __NGiCal_NGVCard_H__
+
+#import <Foundation/NSObject.h>
+
+/*
+ NGVCard
+
+ Represents a vCard object.
+*/
+
+@interface NGVCard : NSObject
+{
+}
+
+@end
+
+#endif /* __NGiCal_NGVCard_H__ */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCard.h"
+#include "common.h"
+
+@implementation NGVCard
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+@end /* NGVCard */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __NGiCal_NGVCardAddress_H__
+#define __NGiCal_NGVCardAddress_H__
+
+#include <NGiCal/NGVCardValue.h>
+
+@class NSDictionary;
+
+/*
+ NGVCardAddress
+
+ Represents a vCard address as transported in the 'ADR' vCard tag.
+*/
+
+@interface NGVCardAddress : NGVCardValue
+{
+ NSString *pobox;
+ NSString *extadd;
+ NSString *street;
+ NSString *locality;
+ NSString *region;
+ NSString *pcode;
+ NSString *country;
+}
+
+/* accessors */
+
+- (NSString *)pobox;
+- (NSString *)extadd;
+- (NSString *)street;
+- (NSString *)locality;
+- (NSString *)region;
+- (NSString *)pcode;
+- (NSString *)country;
+
+/* values */
+
+- (NSDictionary *)asDictionary;
+- (NSArray *)asArray;
+
+/* fake being an array */
+
+- (id)objectAtIndex:(unsigned)_idx;
+- (unsigned)count;
+
+@end
+
+#endif /* __NGiCal_NGVCardAddress_H__ */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCardAddress.h"
+#include "common.h"
+
+@implementation NGVCardAddress
+
+- (void)dealloc {
+ [self->pobox release];
+ [self->extadd release];
+ [self->street release];
+ [self->locality release];
+ [self->region release];
+ [self->pcode release];
+ [self->country release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (NSString *)pobox {
+ return self->pobox;
+}
+- (NSString *)extadd {
+ return self->extadd;
+}
+- (NSString *)street {
+ return self->street;
+}
+- (NSString *)locality {
+ return self->locality;
+}
+- (NSString *)region {
+ return self->region;
+}
+- (NSString *)pcode {
+ return self->pcode;
+}
+- (NSString *)country {
+ return self->country;
+}
+
+/* fake being an array */
+
+- (id)objectAtIndex:(unsigned)_idx {
+ NSString *s;
+
+ switch (_idx) {
+ case 0: return (s = [self pobox]) ? s : (NSString *)[NSNull null];
+ case 1: return (s = [self extadd]) ? s : (NSString *)[NSNull null];
+ case 2: return (s = [self street]) ? s : (NSString *)[NSNull null];
+ case 3: return (s = [self locality]) ? s : (NSString *)[NSNull null];
+ case 4: return (s = [self region]) ? s : (NSString *)[NSNull null];
+ case 5: return (s = [self pcode]) ? s : (NSString *)[NSNull null];
+ case 6: return (s = [self country]) ? s : (NSString *)[NSNull null];
+ }
+
+ // TODO: throw exception
+ return nil;
+}
+- (unsigned)count {
+ return 7;
+}
+
+/* values */
+
+- (NSString *)stringValue {
+ return [self vCardString];
+}
+
+- (NSString *)xmlString {
+ NSMutableString *ms;
+ NSString *s;
+
+ ms = [[NSMutableString alloc] initWithCapacity:256];
+ [self appendXMLTag:@"pobox" value:[self pobox] to:ms];
+ [self appendXMLTag:@"extadd" value:[self extadd] to:ms];
+ [self appendXMLTag:@"street" value:[self street] to:ms];
+ [self appendXMLTag:@"locality" value:[self locality] to:ms];
+ [self appendXMLTag:@"region" value:[self region] to:ms];
+ [self appendXMLTag:@"pcode" value:[self pcode] to:ms];
+ [self appendXMLTag:@"country" value:[self country] to:ms];
+ s = [[ms copy] autorelease];
+ [ms release];
+ return s;
+}
+
+- (NSString *)vCardString {
+ NSMutableString *ms;
+ NSString *s;
+
+ ms = [[NSMutableString alloc] initWithCapacity:256];
+ [self appendVCardValue:[self pobox] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self extadd] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self street] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self locality] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self region] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self pcode] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self country] to:ms];
+ s = [[ms copy] autorelease];
+ [ms release];
+ return s;
+}
+
+- (NSDictionary *)asDictionary {
+ static NSString *keys[] = {
+ @"pobox", @"extadd", @"street", @"locality", @"region", @"pcode",
+ @"country", nil
+ };
+ id values[8];
+ unsigned i;
+
+ for (i = 0; i < [self count]; i++)
+ values[i] = [self objectAtIndex:i];
+
+ return [NSDictionary dictionaryWithObjects:values forKeys:keys
+ count:[self count]];
+}
+
+- (NSArray *)asArray {
+ id values[[self count] + 1];
+ unsigned i;
+
+ for (i = 0; i < [self count]; i++)
+ values[i] = [self objectAtIndex:i];
+
+ return [NSArray arrayWithObjects:values count:[self count]];
+}
+
+/* NSCoding */
+
+- (void)encodeWithCoder:(NSCoder *)_coder {
+ [super encodeWithCoder:_coder];
+
+ [_coder encodeObject:self->pobox];
+ [_coder encodeObject:self->extadd];
+ [_coder encodeObject:self->street];
+ [_coder encodeObject:self->locality];
+ [_coder encodeObject:self->region];
+ [_coder encodeObject:self->pcode];
+ [_coder encodeObject:self->country];
+}
+- (id)initWithCoder:(NSCoder *)_coder {
+ if ((self = [super initWithCoder:_coder]) != nil) {
+ self->pobox = [[_coder decodeObject] copy];
+ self->extadd = [[_coder decodeObject] copy];
+ self->street = [[_coder decodeObject] copy];
+ self->locality = [[_coder decodeObject] copy];
+ self->region = [[_coder decodeObject] copy];
+ self->pcode = [[_coder decodeObject] copy];
+ self->country = [[_coder decodeObject] copy];
+ }
+ return self;
+}
+
+@end /* NGVCardAddress */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCardValue.h"
+#include "common.h"
+
+@implementation NGVCardCategories
+
+- (void)dealloc {
+ [self->categories release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (NSArray *)categories {
+ return self->categories;
+}
+
+/* values */
+
+- (NSString *)stringValue {
+ return [self vCardString];
+}
+
+- (NSString *)xmlString {
+ return [[self stringValue] stringByEscapingXMLString];
+}
+
+- (NSString *)vCardString {
+ return [[self categories] componentsJoinedByString:@","];
+}
+
+- (id)propertyList {
+ return [self categories];
+}
+
+/* fake being an array */
+
+- (id)objectAtIndex:(unsigned)_idx {
+ return [self->categories objectAtIndex:_idx];
+}
+- (unsigned)count {
+ return [self->categories count];
+}
+
+/* fake being a string */
+
+- (unichar)characterAtIndex:(unsigned)_idx {
+ return [[self stringValue] characterAtIndex:_idx];
+}
+- (unsigned)length {
+ return [[self stringValue] length];
+}
+
+/* NSCoding */
+
+- (void)encodeWithCoder:(NSCoder *)_coder {
+ [super encodeWithCoder:_coder];
+ [_coder encodeObject:self->categories];
+}
+- (id)initWithCoder:(NSCoder *)_coder {
+ if ((self = [super initWithCoder:_coder]) != nil) {
+ self->categories = [[_coder decodeObject] copy];
+ }
+ return self;
+}
+
+@end /* NGVCardCategories */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __NGiCal_NGVCardName_H__
+#define __NGiCal_NGVCardName_H__
+
+#include <NGiCal/NGVCardValue.h>
+
+/*
+ NGVCardName
+
+ Represents a vCard name as transported in the 'N' vCard tag.
+*/
+
+@class NSString, NSDictionary;
+
+@interface NGVCardName : NGVCardValue
+{
+ NSString *family;
+ NSString *given;
+ NSString *other;
+ NSString *prefix;
+ NSString *suffix;
+}
+
+/* accessors */
+
+- (NSString *)family;
+- (NSString *)given;
+- (NSString *)other;
+- (NSString *)prefix;
+- (NSString *)suffix;
+
+/* values */
+
+- (NSDictionary *)asDictionary;
+- (NSArray *)asArray;
+
+/* fake being an array */
+
+- (id)objectAtIndex:(unsigned)_idx;
+- (unsigned)count;
+
+@end
+
+#endif /* __NGiCal_NGVCardName_H__ */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCardName.h"
+#include "common.h"
+
+@implementation NGVCardName
+
+- (void)dealloc {
+ [self->family release];
+ [self->given release];
+ [self->other release];
+ [self->prefix release];
+ [self->suffix release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (NSString *)family {
+ return self->family;
+}
+- (NSString *)given {
+ return self->given;
+}
+- (NSString *)other {
+ return self->other;
+}
+- (NSString *)prefix {
+ return self->prefix;
+}
+- (NSString *)suffix {
+ return self->suffix;
+}
+
+/* fake being an array */
+
+- (id)objectAtIndex:(unsigned)_idx {
+ NSString *s;
+
+ switch (_idx) {
+ case 0: return (s = [self family]) ? s : (NSString *)[NSNull null];
+ case 1: return (s = [self given]) ? s : (NSString *)[NSNull null];
+ case 2: return (s = [self other]) ? s : (NSString *)[NSNull null];
+ case 3: return (s = [self prefix]) ? s : (NSString *)[NSNull null];
+ case 4: return (s = [self suffix]) ? s : (NSString *)[NSNull null];
+ }
+
+ // TODO: throw exception
+ return nil;
+}
+- (unsigned)count {
+ return 5;
+}
+
+/* values */
+
+- (NSString *)stringValue {
+ return [self vCardString];
+}
+
+- (NSString *)xmlString {
+ NSMutableString *ms;
+ NSString *s;
+
+ ms = [[NSMutableString alloc] initWithCapacity:256];
+ [self appendXMLTag:@"family" value:[self family] to:ms];
+ [self appendXMLTag:@"given" value:[self given] to:ms];
+ [self appendXMLTag:@"other" value:[self other] to:ms];
+ [self appendXMLTag:@"prefix" value:[self prefix] to:ms];
+ [self appendXMLTag:@"suffix" value:[self suffix] to:ms];
+ s = [[ms copy] autorelease];
+ [ms release];
+ return s;
+}
+
+- (NSString *)vCardString {
+ NSMutableString *ms;
+ NSString *s;
+
+ ms = [[NSMutableString alloc] initWithCapacity:256];
+ [self appendVCardValue:[self family] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self given] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self other] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self prefix] to:ms]; [ms appendString:@";"];
+ [self appendVCardValue:[self suffix] to:ms];
+ s = [[ms copy] autorelease];
+ [ms release];
+ return s;
+}
+
+- (NSDictionary *)asDictionary {
+ static NSString *keys[] = {
+ @"family", @"given", @"other", @"prefix", @"suffix", nil
+ };
+ id values[[self count] + 1];
+ unsigned i;
+
+ for (i = 0; i < [self count]; i++)
+ values[i] = [self objectAtIndex:i];
+
+ return [NSDictionary dictionaryWithObjects:values forKeys:keys
+ count:[self count]];
+}
+
+- (NSArray *)asArray {
+ id values[[self count] + 1];
+ unsigned i;
+
+ for (i = 0; i < [self count]; i++)
+ values[i] = [self objectAtIndex:i];
+
+ return [NSArray arrayWithObjects:values count:[self count]];
+}
+
+- (id)propertyList {
+ return [self asDictionary];
+}
+
+/* NSCoding */
+
+- (void)encodeWithCoder:(NSCoder *)_coder {
+ [super encodeWithCoder:_coder];
+
+ [_coder encodeObject:self->family];
+ [_coder encodeObject:self->given];
+ [_coder encodeObject:self->other];
+ [_coder encodeObject:self->prefix];
+ [_coder encodeObject:self->suffix];
+}
+- (id)initWithCoder:(NSCoder *)_coder {
+ if ((self = [super initWithCoder:_coder]) != nil) {
+ self->family = [[_coder decodeObject] copy];
+ self->given = [[_coder decodeObject] copy];
+ self->other = [[_coder decodeObject] copy];
+ self->prefix = [[_coder decodeObject] copy];
+ self->suffix = [[_coder decodeObject] copy];
+ }
+ return self;
+}
+
+@end /* NGVCardName */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCardValue.h"
+#include "common.h"
+
+@implementation NGVCardPhone
+
+@end /* NGVCardPhone */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __NGiCal_NGVCardSaxHandler_H__
+#define __NGiCal_NGVCardSaxHandler_H__
+
+#include <SaxObjC/SaxDefaultHandler.h>
+
+/*
+ NGVCardSaxHandler
+
+ This SAX handler is supposed to create the NGiCal object model from SAX
+ events.
+*/
+
+@class NSString, NSMutableString, NSMutableArray;
+
+@interface NGVCardSaxHandler : SaxDefaultHandler
+{
+ NSMutableArray *vCards;
+
+ id vCard;
+ NSString *currentGroup;
+ unichar *content;
+ unsigned contentLength;
+
+ struct {
+ int isInVCardSet:1;
+ int isInVCard:1;
+ int isInN:1;
+ int isInGroup:1;
+ int collectContent:1;
+ int reserved:27;
+ } vcs;
+}
+
+/* content */
+
+- (void)startCollectingContent;
+- (NSString *)finishCollectingContent;
+
+@end
+
+#endif /* __NGiCal_NGVCardSaxHandler_H__ */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCardSaxHandler.h"
+#include "common.h"
+
+@implementation NGVCardSaxHandler
+
+- (void)dealloc {
+ if (self->content != NULL) free(self->content);
+ [self->vCards release];
+ [self->vCard release];
+ [self->currentGroup release];
+ [super dealloc];
+}
+
+/* state */
+
+- (void)resetExceptResult {
+ [self->currentGroup release]; self->currentGroup = nil;
+ [self->vCard release]; self->vCard = nil;
+
+ if (self->content != NULL) {
+ free(self->content);
+ self->content = NULL;
+ }
+
+ self->vcs.isInVCardSet = 0;
+ self->vcs.isInVCard = 0;
+ self->vcs.isInN = 0;
+ self->vcs.isInGroup = 0;
+ self->vcs.collectContent = 0;
+}
+
+- (void)reset {
+ [self resetExceptResult];
+ [self->vCards removeAllObjects];
+}
+
+/* document events */
+
+- (void)startDocument {
+ [self reset];
+ if (self->vCards == nil)
+ self->vCards = [[NSMutableArray alloc] initWithCapacity:16];
+}
+- (void)endDocument {
+ [self resetExceptResult];
+}
+
+/* handle elements */
+
+- (void)startGroup:(NSString *)_name {
+ self->vcs.isInGroup = 1;
+ ASSIGNCOPY(self->currentGroup, _name);
+}
+- (void)endGroup {
+ self->vcs.isInGroup = 0;
+ [self->currentGroup release]; self->currentGroup = nil;
+}
+
+- (void)startN {
+ self->vcs.isInN = 1;
+}
+- (void)endN {
+ self->vcs.isInN = 0;
+}
+
+- (void)startVCard:(id<SaxAttributes>)_attrs {
+ self->vcs.isInVCard = 1;
+}
+- (void)endVCard {
+ self->vcs.isInVCard = 0;
+}
+
+- (void)startVCardSet:(id<SaxAttributes>)_attrs {
+ self->vcs.isInVCardSet = 1;
+}
+- (void)endVCardSet {
+ self->vcs.isInVCardSet = 0;
+}
+
+/* element events */
+
+- (void)startElement:(NSString *)_localName
+ namespace:(NSString *)_ns
+ rawName:(NSString *)_rawName
+ attributes:(id<SaxAttributes>)_attrs
+{
+ if ([_localName isEqualToString:@"group"])
+ [self startGroup:[_attrs valueForName:@"name" uri:_ns]];
+ else if ([_localName isEqualToString:@"n"])
+ [self startN];
+ else if ([_localName isEqualToString:@"tel"])
+ ;
+ else if ([_localName isEqualToString:@"vCard"])
+ [self startVCard:_attrs];
+ else if ([_localName isEqualToString:@"vCardSet"])
+ [self startVCardSet:_attrs];
+
+ if (self->vcs.isInN) {
+ }
+}
+
+- (void)endElement:(NSString *)_localName
+ namespace:(NSString *)_ns
+ rawName:(NSString *)_rawName
+{
+ if (self->vcs.isInN) {
+ }
+
+ if ([_localName isEqualToString:@"group"])
+ [self endGroup];
+ else if ([_localName isEqualToString:@"n"])
+ [self endN];
+ else if ([_localName isEqualToString:@"tel"])
+ ;
+ else if ([_localName isEqualToString:@"vCard"])
+ [self endVCard];
+ else if ([_localName isEqualToString:@"vCardSet"])
+ [self endVCardSet];
+}
+
+/* content */
+
+- (void)startCollectingContent {
+ if (self->content != NULL) {
+ free(self->content);
+ self->content = NULL;
+ }
+ self->vcs.collectContent = 1;
+}
+
+- (NSString *)finishCollectingContent {
+ NSString *s;
+
+ self->vcs.collectContent = 0;
+
+ if (self->content == NULL)
+ return nil;
+
+ if (self->contentLength == 0)
+ return @"";
+
+ s = [NSString stringWithCharacters:self->content length:self->contentLength];
+ if (self->content != NULL) {
+ free(self->content);
+ self->content = NULL;
+ }
+ return s;
+}
+
+- (void)characters:(unichar *)_chars length:(int)_len {
+ if (_len == 0 || _chars == NULL)
+ return;
+
+ if (self->content == NULL) {
+ /* first content */
+ self->contentLength = _len;
+ self->content = calloc(_len + 1, sizeof(unichar));
+ memcpy(self->content, _chars, (_len * sizeof(unichar)));
+ }
+ else {
+ /* increase content */
+ self->content =
+ realloc(self->content, (self->contentLength + _len+2) * sizeof(unichar));
+ memcpy(&(self->content[self->contentLength]), _chars,
+ (_len * sizeof(unichar)));
+ self->contentLength += _len;
+ }
+ self->content[self->contentLength] = 0;
+}
+
+@end /* NGVCardSaxHandler */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCardValue.h"
+#include "common.h"
+
+@implementation NGVCardSimpleValue
+
+- (void)dealloc {
+ [self->value release];
+ [super dealloc];
+}
+
+/* values */
+
+- (NSString *)stringValue {
+ return self->value;
+}
+
+- (id)propertyList {
+ return [self stringValue];
+}
+
+/* fake being a string */
+
+- (unichar)characterAtIndex:(unsigned)_idx {
+ return [self->value characterAtIndex:_idx];
+}
+- (unsigned)length {
+ return [self->value length];
+}
+
+/* NSCoding */
+
+- (void)encodeWithCoder:(NSCoder *)_coder {
+ [super encodeWithCoder:_coder];
+ [_coder encodeObject:self->value];
+}
+- (id)initWithCoder:(NSCoder *)_coder {
+ if ((self = [super initWithCoder:_coder]) != nil) {
+ self->value = [[_coder decodeObject] copy];
+ }
+ return self;
+}
+
+@end /* NGVCardSimpleValue */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __NGiCal_NGVCardValue_H__
+#define __NGiCal_NGVCardValue_H__
+
+#import <Foundation/NSObject.h>
+
+/*
+ NGVCardValue
+
+ Represents a value in a vCard object.
+
+ Note: all NGVCardValue's are treated as immutable objects.
+
+ - types
+ - arguments
+*/
+
+@class NSString, NSMutableString, NSArray, NSDictionary;
+
+@interface NGVCardValue : NSObject < NSCopying, NSCoding >
+{
+ NSString *group;
+ NSArray *types;
+ NSDictionary *arguments;
+}
+
+/* accessors */
+
+- (NSString *)group;
+- (NSArray *)types;
+- (NSDictionary *)arguments;
+- (BOOL)isPreferred;
+
+/* values */
+
+- (NSString *)stringValue;
+- (NSString *)xmlString;
+- (NSString *)vCardString;
+- (id)propertyList;
+
+/* misc support methods */
+
+- (void)appendXMLTag:(NSString *)_tag value:(NSString *)_val
+ to:(NSMutableString *)_ms;
+- (void)appendVCardValue:(NSString *)_val to:(NSMutableString *)_ms;
+
+@end
+
+#import <Foundation/NSString.h>
+
+@interface NGVCardSimpleValue : NGVCardValue
+{
+ NSString *value;
+}
+
+/* fake being an NSString */
+
+- (unsigned int)length;
+- (unichar)characterAtIndex:(unsigned)_idx;
+
+@end
+
+@interface NGVCardPhone : NGVCardSimpleValue
+@end
+
+@interface NGVCardCategories : NGVCardValue
+{
+ NSArray *categories;
+}
+
+/* accessors */
+
+- (NSArray *)categories;
+
+@end
+
+#endif /* __NGiCal_NGVCardValue_H__ */
--- /dev/null
+/*
+ Copyright (C) 2005 Helge Hess
+
+ This file is part of SOPE.
+
+ SOPE 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.
+
+ SOPE 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 SOPE; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "NGVCardValue.h"
+#include <NGExtensions/NSString+misc.h>
+#include "common.h"
+
+@implementation NGVCardValue
+
+- (void)dealloc {
+ [self->group release];
+ [self->types release];
+ [self->arguments release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (NSString *)group {
+ return self->group;
+}
+- (NSArray *)types {
+ return self->types;
+}
+- (NSDictionary *)arguments {
+ return self->arguments;
+}
+- (BOOL)isPreferred {
+ return [self->types containsObject:@"PREF"];
+}
+
+/* values */
+
+- (NSString *)stringValue {
+ [self logWithFormat:@"ERROR(%s): subclasses should override this method!",
+ __PRETTY_FUNCTION__];
+ return nil;
+}
+
+- (id)propertyList {
+ return [self stringValue];
+}
+
+- (NSString *)xmlString {
+ return [[self stringValue] stringByEscapingXMLString];
+}
+
+- (NSString *)vCardString {
+ // TODO: apply proper escaping
+ return [self stringValue];
+}
+
+/* misc support methods */
+
+- (void)appendXMLTag:(NSString *)_tag value:(NSString *)_val
+ to:(NSMutableString *)_ms
+{
+ [_ms appendString:@"<"];
+ [_ms appendString:_tag];
+ [_ms appendString:@">"];
+ if ([_val isNotNull]) [_ms appendString:[_val stringByEscapingXMLString]];
+ [_ms appendString:@"</"];
+ [_ms appendString:_tag];
+ [_ms appendString:@">"];
+}
+
+- (void)appendVCardValue:(NSString *)_val to:(NSMutableString *)_ms {
+ // TODO: properly escape!
+ if ([_val isNotNull]) [_ms appendString:_val];
+}
+
+/* NSCopying */
+
+- (id)copyWithZone:(NSZone *)_zone {
+ /* values are considered immutable */
+ return [self retain];
+}
+
+/* NSCoding */
+
+- (void)encodeWithCoder:(NSCoder *)_coder {
+ [_coder encodeObject:self->group];
+ [_coder encodeObject:self->types];
+ [_coder encodeObject:self->arguments];
+}
+- (id)initWithCoder:(NSCoder *)_coder {
+ self->group = [[_coder decodeObject] copy];
+ self->types = [[_coder decodeObject] copy];
+ self->arguments = [[_coder decodeObject] copy];
+ return self;
+}
+
+@end /* NGVCardValue */
MAJOR_VERSION=4
MINOR_VERSION=5
-SUBMINOR_VERSION:=51
+SUBMINOR_VERSION:=52
# v4.5.40 requires NGExtensions v4.5.145
# v4.5.37 requires NGExtensions v4.5.140
--- /dev/null
+BEGIN:VCARD\r
+VERSION:3.0\r
+N:Duck (AB);Dagobert;Middle;Mr.;1st\r
+FN:Mr. Dagobert Middle Duck (AB) 1st\r
+NICKNAME:duggy\r
+X-MAIDENNAME:DuckyMaiden\r
+ORG:Geldspeicher AG;Board\r
+TITLE:Chief\r
+EMAIL;type=INTERNET;type=WORK;type=pref:dd@entenhausen.com\r
+EMAIL;type=INTERNET;type=HOME:dd@entenhausen.home\r
+item1.EMAIL;type=INTERNET:dd@custom.org\r
+item1.X-ABLabel:CustLab\r
+TEL;type=WORK;type=pref:0123-123456789\r
+TEL;type=CELL:0172-2736152\r
+TEL;type=HOME;type=FAX:(012) 398-7654\r
+item2.TEL:(281) 727-3721\r
+item2.X-ABLabel:PhoCust\r
+item3.ADR;type=WORK;type=pref:;;WorkStreet;Entenhausen (Work);WorkState;WorkZIP;WorkCountry\r
+item3.X-ABADR:us\r
+item4.ADR;type=HOME:;;HomeStreet;Entenhausen (Home);;HomeZip;HomeCountry\r
+item4.X-ABADR:de\r
+item5.URL;type=pref:http\://www.entenhausen.com\r
+item5.X-ABLabel:_$!<HomePage>!$_\r
+item6.URL:http\://secondhomepage.com\r
+item6.X-ABLabel:_$!<HomePage>!$_\r
+BDAY;value=date:2005-03-12\r
+X-AIM;type=WORK;type=pref:aimname\r
+X-JABBER;type=HOME;type=pref:jab@jab.not\r
+X-JABBER;type=WORK:jab2@jab.not\r
+X-MSN;type=WORK;type=pref:msn@ms.com\r
+X-YAHOO;type=HOME;type=pref:yahoo\r
+X-ICQ;type=HOME;type=pref:78371672\r
+item7.X-ABDATE;type=pref:2005-02-03\r
+item7.X-ABLabel:_$!<Anniversary>!$_\r
+item8.X-ABDATE:1987-02-02\r
+item8.X-ABLabel:CustDate\r
+item9.X-ABRELATEDNAMES;type=pref:mickey\r
+item9.X-ABLabel:_$!<Friend>!$_\r
+item10.X-ABRELATEDNAMES:donald\r
+item10.X-ABLabel:_$!<Assistant>!$_\r
+item11.X-ABRELATEDNAMES:dagopop\r
+item11.X-ABLabel:_$!<Father>!$_\r
+item12.X-ABRELATEDNAMES:dagomom\r
+item12.X-ABLabel:_$!<Mother>!$_\r
+item13.X-ABRELATEDNAMES:dagoparent\r
+item13.X-ABLabel:_$!<Parent>!$_\r
+item14.X-ABRELATEDNAMES:dagobroth\r
+item14.X-ABLabel:_$!<Brother>!$_\r
+item15.X-ABRELATEDNAMES:dagosis\r
+item15.X-ABLabel:_$!<Sister>!$_\r
+item16.X-ABRELATEDNAMES:dagochild1\r
+item16.X-ABLabel:_$!<Child>!$_\r
+item17.X-ABRELATEDNAMES:dagochild2\r
+item17.X-ABLabel:_$!<Child>!$_\r
+item18.X-ABRELATEDNAMES:Guntel\r
+item18.X-ABLabel:_$!<Spouse>!$_\r
+item19.X-ABRELATEDNAMES:Guntel\, Minney\r
+item19.X-ABLabel:_$!<Partner>!$_\r
+item20.X-ABRELATEDNAMES:NoManager\r
+item20.X-ABLabel:_$!<Manager>!$_\r
+item21.X-ABRELATEDNAMES:OtherName\r
+item21.X-ABLabel:_$!<Other>!$_\r
+X-ABUID:6BEA0FDE-005A-4F85-83F1-16C98A142ABF\:ABPerson\r
+END:VCARD\r
icalds_OBJC_FILES = icalds.m
vcf2xml_OBJC_FILES = vcf2xml.m
-icalparsetest_TOOL_LIBS += -lNGiCal -lSaxObjC
+icalparsetest_TOOL_LIBS += -lNGiCal -lSaxObjC
icalds_TOOL_LIBS += -lNGiCal -lSaxObjC
vcf2xml_TOOL_LIBS += -lSaxObjC
if (_attrs == nil || [_attrs count] == 0)
return nil;
-
- attributes = [[NSMutableDictionary alloc] init];
+
+ attributes = [[NSMutableDictionary alloc] initWithCapacity:4];
retAttrs = [[[SaxAttributes alloc] init] autorelease];
attrEnum = [_attrs objectEnumerator];
forTag:_tagName
intoAttr:&mappedAttr
intoValue:&mappedValue];
- if ((oldValue = [attributes objectForKey:mappedAttr])) {
+ if ((oldValue = [attributes objectForKey:mappedAttr]) != nil) {
NSString *val;
+
/* ZNeK: duh! */
- val = [NSString stringWithFormat:@"%@ %@",oldValue, mappedValue];
+ // TODO: hh asks: what does 'duh' is supposed to mean?
+ val = [[NSString alloc] initWithFormat:@"%@ %@",oldValue, mappedValue];
[attributes setObject:val forKey:mappedAttr];
+ [val release];
}
else
[attributes setObject:mappedValue forKey:mappedAttr];
attrEnum = [attributes keyEnumerator];
while ((curAttr = [attrEnum nextObject]) != nil) {
+ /*
+ TODO: values are not always mapped to CDATA! Eg in the dawson draft:
+ | TYPE for TEL | tel.type | NMTOKENS | 'VOICE' |
+ | TYPE for EMAIL | email.type | NMTOKENS | 'INTERNET' |
+ | TYPE for PHOTO,| img.type | CDATA | REQUIRED |
+ | and LOGO | | | |
+ | TYPE for SOUND | aud.type | CDATA | REQUIRED |
+ | VALUE | value | NOTATION | See elements |
+ */
+
[retAttrs addAttribute:curAttr uri:self->prefixURI rawName:curAttr
type:@"CDATA" value:[attributes objectForKey:curAttr]];
}