diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index 6ecd16f96..a3644f072 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -1,3 +1,11 @@ +2008-03-03 Wolfgang Sourdeau + + * NGVCardReference.[hm]: new class module that implements the base + data type contained in a VLIST element. + + * NGVList.[hm]: new class module that implements Thunderbird-style + personal mailing lists. Base mime-type is "text/x-vlist". + 2008-02-08 Wolfgang Sourdeau * iCalRecurrenceRule.m ([iCalRecurrenceRule -wkst]): if no wkst diff --git a/SOPE/NGCards/GNUmakefile b/SOPE/NGCards/GNUmakefile index 7c3244341..252fbbdcb 100644 --- a/SOPE/NGCards/GNUmakefile +++ b/SOPE/NGCards/GNUmakefile @@ -53,6 +53,8 @@ libNGCards_HEADER_FILES = \ NSCalendarDate+ICal.h \ \ NGVCard.h \ + NGVList.h \ + NGVCardReference.h \ # NGVCardAddress.h \ # NGVCardStrArrayValue.h \ # NGVCardName.h \ @@ -101,11 +103,12 @@ libNGCards_OBJC_FILES = \ iCalYearlyRecurrenceCalculator.m\ \ NGVCard.m \ + NGVList.m \ + NGVCardReference.m \ NGCardsSaxHandler.m \ # IcalElements.m # IcalResponse.m - # framework support NGCards_PCH_FILE = $(libNGCards_PCH_FILE) diff --git a/SOPE/NGCards/NGVCard.h b/SOPE/NGCards/NGVCard.h index 7b9f69ee2..a687e2a01 100644 --- a/SOPE/NGCards/NGVCard.h +++ b/SOPE/NGCards/NGVCard.h @@ -59,6 +59,14 @@ @class NSDictionary; @class NSString; +/* this should be merged in a common definition headers with iCalAccessClass */ +typedef enum +{ + NGCardsAccessPublic = 0, + NGCardsAccessPrivate = 1, + NGCardsAccessConfidential = 2, +} NGCardsAccessClass; + @interface NGVCard : CardGroup + (id) cardWithUid: (NSString *) _uid; diff --git a/SOPE/NGCards/NGVCardReference.h b/SOPE/NGCards/NGVCardReference.h new file mode 100644 index 000000000..c5b715fae --- /dev/null +++ b/SOPE/NGCards/NGVCardReference.h @@ -0,0 +1,42 @@ +/* NGVCardReference.h - this file is part of NGCards + * + * Copyright (C) 2008 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 NGVCARDREFERENCE_H +#define NGVCARDREFERENCE_H + +#import "CardElement.h" + +@class NSString; + +@interface NGVCardReference : CardElement + +- (void) setFn: (NSString *) newFn; +- (NSString *) fn; +- (void) setEmail: (NSString *) newEmail; +- (NSString *) email; + +- (void) setReference: (NSString *) newReference; +- (NSString *) reference; + +@end + +#endif /* NGVCARDREFERENCE_H */ diff --git a/SOPE/NGCards/NGVCardReference.m b/SOPE/NGCards/NGVCardReference.m new file mode 100644 index 000000000..397631fe3 --- /dev/null +++ b/SOPE/NGCards/NGVCardReference.m @@ -0,0 +1,59 @@ +/* NGVCardReference.m - this file is part of NGCards + * + * Copyright (C) 2008 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 "NGVCardReference.h" + +@implementation NGVCardReference + +- (void) setFn: (NSString *) newFn +{ + [self setValue: 0 ofAttribute: @"fn" to: newFn]; +} + +- (NSString *) fn +{ + return [self value: 0 ofAttribute: @"fn"]; +} + +- (void) setEmail: (NSString *) newEmail +{ + [self setValue: 0 ofAttribute: @"email" to: newEmail]; +} + +- (NSString *) email +{ + return [self value: 0 ofAttribute: @"email"]; +} + +- (void) setReference: (NSString *) newReference +{ + [self setValue: 0 to: newReference]; +} + +- (NSString *) reference +{ + return [self value: 0]; +} + +@end diff --git a/SOPE/NGCards/NGVList.h b/SOPE/NGCards/NGVList.h new file mode 100644 index 000000000..85d9caf3c --- /dev/null +++ b/SOPE/NGCards/NGVList.h @@ -0,0 +1,69 @@ +/* NGVList.h - this file is part of NGCards + * + * Copyright (C) 2008 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 NGVLIST_H +#define NGVLIST_H + +#import "CardGroup.h" + +#import "NGVCard.h" + +@class NSArray; +@class NSDictionary; +@class NSString; + +@class NGVCardReference; + +@interface NGVList : CardGroup + ++ (id) listWithUid: (NSString *) newUid; +- (id) initWithUid: (NSString *) newUid; + +/* accessors */ + +- (void) setProdID: (NSString *) newProdID; +- (NSString *) prodID; +- (void) setVersion: (NSString *) newVersion; +- (NSString *) version; + +- (void) setUid: (NSString *) newUid; +- (NSString *) uid; + +- (void) setAccessClass: (NSString *) newAccessClass; +- (NSString *) accessClass; +- (NGCardsAccessClass) symbolicAccessClass; +- (BOOL) isPublic; + +- (void) setFn: (NSString *) newFn; +- (NSString *) fn; +- (void) setNickname: (NSString *) newNickname; +- (NSString *) nickname; +- (void) setDescription: (NSString *) newDescription; +- (NSString *) description; + +- (void) addCardReference: (NGVCardReference *) newCardRef; +- (void) deleteCardReference: (NGVCardReference *) cardRef; +- (NSArray *) cardReferences; + +@end + +#endif /* NGVLIST_H */ diff --git a/SOPE/NGCards/NGVList.m b/SOPE/NGCards/NGVList.m new file mode 100644 index 000000000..7d359df6d --- /dev/null +++ b/SOPE/NGCards/NGVList.m @@ -0,0 +1,200 @@ +/* NGVList.m - this file is part of NGCards + * + * Copyright (C) 2008 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 "NGVCardReference.h" + +#import "NGVList.h" + +@implementation NGVList + ++ (id) listWithUid: (NSString *) _uid +{ + NGVList *newList; + + newList = [[self alloc] initWithUid: _uid]; + [newList autorelease]; + + return newList; +} + +- (id) initWithUid: (NSString *) _uid +{ + if ((self = [self init])) + { + [self setTag: @"vlist"]; + [self setUid: _uid]; + [self setVersion: @"1.0"]; + } + + return self; +} + +/* class mapping */ +- (Class) classForTag: (NSString *) classTag +{ + Class tagClass; + + tagClass = Nil; + if ([classTag isEqualToString: @"PRODID"] + || [classTag isEqualToString: @"VERSION"] + || [classTag isEqualToString: @"UID"] + || [classTag isEqualToString: @"CLASS"] + || [classTag isEqualToString: @"FN"] + || [classTag isEqualToString: @"NICKNAME"] + || [classTag isEqualToString: @"DESCRIPTION"]) + tagClass = [CardElement class]; + else if ([classTag isEqualToString: @"CARD"]) + tagClass = [NGVCardReference class]; + else + tagClass = [super classForTag: classTag]; + + return tagClass; +} + +- (void) setProdID: (NSString *) newProdID +{ + [[self uniqueChildWithTag: @"prodid"] setValue: 0 to: newProdID]; +} + +- (NSString *) prodID +{ + return [[self uniqueChildWithTag: @"prodid"] value: 0]; +} + +- (void) setVersion: (NSString *) newVersion +{ + [[self uniqueChildWithTag: @"version"] setValue: 0 + to: newVersion]; +} + +- (NSString *) version +{ + return [[self uniqueChildWithTag: @"version"] value: 0]; +} + +- (void) setUid: (NSString *) newUid +{ + [[self uniqueChildWithTag: @"uid"] setValue: 0 + to: newUid]; +} + +- (NSString *) uid +{ + return [[self uniqueChildWithTag: @"uid"] value: 0]; +} + +- (void) setAccessClass: (NSString *) newAccessClass +{ + [[self uniqueChildWithTag: @"class"] setValue: 0 + to: newAccessClass]; +} + +- (NSString *) accessClass +{ + return [[self uniqueChildWithTag: @"class"] value: 0]; +} + +- (NGCardsAccessClass) symbolicAccessClass +{ + NGCardsAccessClass symbolicAccessClass; + NSString *accessClass; + + accessClass = [[self accessClass] uppercaseString]; + if ([accessClass isEqualToString: @"PRIVATE"]) + symbolicAccessClass = NGCardsAccessPrivate; + else if ([accessClass isEqualToString: @"CONFIDENTIAL"]) + symbolicAccessClass = NGCardsAccessConfidential; + else + symbolicAccessClass = NGCardsAccessPublic; + + return symbolicAccessClass; +} + +- (BOOL) isPublic +{ + return ([self symbolicAccessClass] == NGCardsAccessPublic); +} + +- (void) setFn: (NSString *) newFn +{ + [[self uniqueChildWithTag: @"fn"] setValue: 0 to: newFn]; +} + +- (NSString *) fn +{ + return [[self uniqueChildWithTag: @"fn"] value: 0]; +} + +- (void) setNickname: (NSString *) newNickname +{ + [[self uniqueChildWithTag: @"nickname"] setValue: 0 + to: newNickname]; +} + +- (NSString *) nickname +{ + return [[self uniqueChildWithTag: @"nickname"] value: 0]; +} + +- (void) setDescription: (NSString *) newDescription +{ + [[self uniqueChildWithTag: @"description"] setValue: 0 + to: newDescription]; +} + +- (NSString *) description +{ + return [[self uniqueChildWithTag: @"description"] value: 0]; +} + +- (void) addCardReference: (NGVCardReference *) newCardRef +{ + [self addChild: newCardRef]; +} + +- (void) deleteCardReference: (NGVCardReference *) cardRef +{ + NSEnumerator *cardReferences; + NGVCardReference *currentRef; + NSMutableArray *deletedRefs; + + deletedRefs = [NSMutableArray array]; + cardReferences + = [[self childrenWithTag: @"card"] objectEnumerator]; + while ((currentRef = [cardReferences nextObject])) + if ([[currentRef reference] + isEqualToString: [cardRef reference]]) + [deletedRefs addObject: currentRef]; + + [children removeObjectsInArray: deletedRefs]; +} + +- (NSArray *) cardReferences +{ + return [self childrenWithTag: @"card"]; +} + +@end diff --git a/SOPE/NGCards/versitCardsSaxDriver/bundle-info.plist b/SOPE/NGCards/versitCardsSaxDriver/bundle-info.plist index 41acb5087..69ad8c420 100644 --- a/SOPE/NGCards/versitCardsSaxDriver/bundle-info.plist +++ b/SOPE/NGCards/versitCardsSaxDriver/bundle-info.plist @@ -9,6 +9,7 @@ { name = "VSCardSaxDriver"; sourceTypes = ( "text/x-vcard", "text/vcard", + "text/x-vlist", "text/x-calendar", "text/calendar" ); } );