]> err.no Git - sope/commitdiff
finishing touches on the vcard parser
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Mon, 9 May 2005 00:10:22 +0000 (00:10 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Mon, 9 May 2005 00:10:22 +0000 (00:10 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@806 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

12 files changed:
sope-ical/NGiCal/ChangeLog
sope-ical/NGiCal/GNUmakefile
sope-ical/NGiCal/NGVCard.h
sope-ical/NGiCal/NGVCard.m
sope-ical/NGiCal/NGVCardCategories.m [deleted file]
sope-ical/NGiCal/NGVCardOrg.h
sope-ical/NGiCal/NGVCardOrg.m
sope-ical/NGiCal/NGVCardSaxHandler.h
sope-ical/NGiCal/NGVCardSaxHandler.m
sope-ical/NGiCal/NGVCardStrArrayValue.h [moved from sope-ical/NGiCal/NGVCardCategories.h with 69% similarity]
sope-ical/NGiCal/NGVCardStrArrayValue.m [new file with mode: 0644]
sope-ical/NGiCal/Version

index cf4d0931eb2245f14a4b6ae17aab7d3a9dcf16ad..c63ba0044b019314a738a3324ce6c5e681af8e64 100644 (file)
@@ -1,3 +1,7 @@
+2005-05-09  Helge Hess  <helge.hess@opengroupware.org>
+
+       * first version of working vCard SAX handler (v4.5.54)
+
 2005-05-08  Helge Hess  <helge.hess@opengroupware.org>
 
        * more work on vCard parsing (v4.5.53)
index 09c626e637a742439fec6ded0cbdd6708665fb5d..fbbf97af930ce0b855ecfbbe77f240a8e574ebdf 100644 (file)
@@ -36,7 +36,7 @@ libNGiCal_HEADER_FILES =              \
        \
        NGVCard.h                       \
        NGVCardAddress.h                \
-       NGVCardCategories.h             \
+       NGVCardStrArrayValue.h          \
        NGVCardName.h                   \
        NGVCardOrg.h                    \
        NGVCardPhone.h                  \
@@ -73,7 +73,7 @@ libNGiCal_OBJC_FILES =                \
        \
        NGVCard.m                       \
        NGVCardAddress.m                \
-       NGVCardCategories.m             \
+       NGVCardStrArrayValue.m          \
        NGVCardName.m                   \
        NGVCardOrg.m                    \
        NGVCardPhone.m                  \
index f6fa1661c798c1c62661596e5fcb36923e09dd74..a5d8a4023dbe520bc173df12038d175bc5b66d71 100644 (file)
@@ -56,6 +56,7 @@
 */
 
 @class NSString, NSArray, NSDictionary;
+@class NGVCardStrArrayValue, NGVCardOrg, NGVCardName;
 
 @interface NGVCard : NSObject
 {
   NSString     *vClass;
   NSString     *prodID;
   // TODO: 'rev' (datetime)
+
+  NSString     *fn;
+  NSString     *role;
+  NSString     *title;
+  NSString     *bday;
+  NSString     *note;
+
+  NGVCardName  *n;
+  NGVCardOrg   *org;
+  
+  NGVCardStrArrayValue *nickname;
+  NGVCardStrArrayValue *categories;
   
   NSArray      *tel;
   NSArray      *adr;
   NSArray      *email;
   NSArray      *label;
+  NSArray      *url;
+  NSArray      *fburl;
+  NSArray      *caluri;
   NSDictionary *x;
 }
 
 - (void)setProdID:(NSString *)_s;
 - (NSString *)prodID;
 
+- (void)setFn:(NSString *)_fn;
+- (NSString *)fn;
+- (void)setRole:(NSString *)_s;
+- (NSString *)role;
+- (void)setTitle:(NSString *)_title;
+- (NSString *)title;
+- (void)setBday:(NSString *)_bday;
+- (NSString *)bday;
+- (void)setNote:(NSString *)_note;
+- (NSString *)note;
+
+- (void)setN:(NGVCardName *)_v;
+- (NGVCardName *)n;
+- (void)setOrg:(NGVCardOrg *)_v;
+- (NGVCardOrg *)org;
+
+- (void)setNickname:(id)_v;
+- (NGVCardStrArrayValue *)nickname;
+- (void)setCategories:(id)_v;
+- (NGVCardStrArrayValue *)categories;
+
 - (void)setTel:(NSArray *)_tel;
 - (NSArray *)tel;
 - (void)setAdr:(NSArray *)_adr;
 - (NSArray *)email;
 - (void)setLabel:(NSArray *)_array;
 - (NSArray *)label;
+- (void)setUrl:(NSArray *)_url;
+- (NSArray *)url;
+
+- (void)setFreeBusyURL:(NSArray *)_v;
+- (NSArray *)freeBusyURL;
+- (void)setCalURI:(NSArray *)_calURI;
+- (NSArray *)calURI;
 
 - (void)setX:(NSDictionary *)_dict;
 - (NSDictionary *)x;
index f1de3bcfa24f92a2750259d2d0471ebefda7260c..2aace43a9e456e94273e6d77668b44db436ac4d8 100644 (file)
@@ -21,6 +21,9 @@
 
 #include "NGVCard.h"
 #include "NGVCardSaxHandler.h"
+#include "NGVCardStrArrayValue.h"
+#include "NGVCardName.h"
+#include "NGVCardOrg.h"
 #include <SaxObjC/SaxXMLReader.h>
 #include <SaxObjC/SaxXMLReaderFactory.h>
 #include "common.h"
@@ -74,15 +77,27 @@ static NGVCardSaxHandler         *sax   = nil; // THREAD
 }
 
 - (void)dealloc {
-  [self->vClass  release];
-  [self->prodID  release];
-  [self->x       release];
-  [self->tel     release];
-  [self->adr     release];
-  [self->email   release];
-  [self->label   release];
-  [self->version release];
-  [self->uid     release];
+  [self->n          release];
+  [self->org        release];
+  [self->nickname   release];
+  [self->categories release];
+  [self->caluri     release];
+  [self->fburl      release];
+  [self->role       release];
+  [self->fn         release];
+  [self->title      release];
+  [self->bday       release];
+  [self->note       release];
+  [self->vClass     release];
+  [self->prodID     release];
+  [self->x          release];
+  [self->tel        release];
+  [self->url        release];
+  [self->adr        release];
+  [self->email      release];
+  [self->label      release];
+  [self->version    release];
+  [self->uid        release];
   [super dealloc];
 }
 
@@ -113,6 +128,78 @@ static NGVCardSaxHandler         *sax   = nil; // THREAD
   return self->prodID;
 }
 
+- (void)setFn:(NSString *)_fn {
+  ASSIGNCOPY(self->fn, _fn);
+}
+- (NSString *)fn {
+  return self->fn;
+}
+
+- (void)setRole:(NSString *)_role {
+  ASSIGNCOPY(self->role, _role);
+}
+- (NSString *)role {
+  return self->role;
+}
+
+- (void)setTitle:(NSString *)_title {
+  ASSIGNCOPY(self->title, _title);
+}
+- (NSString *)title {
+  return self->title;
+}
+
+- (void)setBday:(NSString *)_bday {
+  ASSIGNCOPY(self->bday, _bday);
+}
+- (NSString *)bday {
+  return self->bday;
+}
+
+- (void)setNote:(NSString *)_note {
+  ASSIGNCOPY(self->note, _note);
+}
+- (NSString *)note {
+  return self->note;
+}
+
+
+- (void)setN:(NGVCardName *)_v {
+  ASSIGNCOPY(self->n, _v);
+}
+- (NGVCardName *)n {
+  return self->n;
+}
+
+- (void)setOrg:(NGVCardOrg *)_v {
+  ASSIGNCOPY(self->org, _v);
+}
+- (NGVCardOrg *)org {
+  return self->org;
+}
+
+
+- (void)setNickname:(id)_v {
+  if (![_v isKindOfClass:[NGVCardStrArrayValue class]] && [_v isNotNull])
+    _v = [[[NGVCardStrArrayValue alloc] initWithPropertyList:_v] autorelease];
+  
+  ASSIGNCOPY(self->nickname, _v);
+}
+- (NGVCardStrArrayValue *)nickname {
+  return self->nickname;
+}
+
+- (void)setCategories:(id)_v {
+  if (![_v isKindOfClass:[NGVCardStrArrayValue class]] && [_v isNotNull])
+    _v = [[[NGVCardStrArrayValue alloc] initWithPropertyList:_v] autorelease];
+  
+  ASSIGNCOPY(self->categories, _v);
+}
+- (NGVCardStrArrayValue *)categories {
+  return self->categories;
+}
+
+
 - (void)setTel:(NSArray *)_tel {
   ASSIGNCOPY(self->tel, _tel);
 }
@@ -141,6 +228,28 @@ static NGVCardSaxHandler         *sax   = nil; // THREAD
   return self->label;
 }
 
+- (void)setUrl:(NSArray *)_url {
+  ASSIGNCOPY(self->url, _url);
+}
+- (NSArray *)url {
+  return self->url;
+}
+
+
+- (void)setFreeBusyURL:(NSArray *)_v {
+  ASSIGNCOPY(self->fburl, _v);
+}
+- (NSArray *)freeBusyURL {
+  return self->fburl;
+}
+- (void)setCalURI:(NSArray *)_v {
+  ASSIGNCOPY(self->caluri, _v);
+}
+- (NSArray *)calURI {
+  return self->caluri;
+}
+
+
 - (void)setX:(NSDictionary *)_dict {
   ASSIGNCOPY(self->x, _dict);
 }
diff --git a/sope-ical/NGiCal/NGVCardCategories.m b/sope-ical/NGiCal/NGVCardCategories.m
deleted file mode 100644 (file)
index 6e50b69..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-  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 "NGVCardCategories.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];
-}
-
-- (NSArray *)asArray {
-  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;
-}
-
-/* description */
-
-- (void)appendAttributesToDescription:(NSMutableString *)_ms {
-  [super appendAttributesToDescription:_ms];
-  [_ms appendFormat:@" vcard=%@", [self vCardString]];
-}
-
-@end /* NGVCardCategories */
index b21ab0e707ef1035264722119a400f1522c07860..0dbdfcf5f8b602d9574234e09e6b9e49836e1fe4 100644 (file)
@@ -40,6 +40,9 @@
   NSArray  *orgunits;
 }
 
+- (id)initWithName:(NSString *)_name units:(NSArray *)_units
+  group:(NSString *)_grp types:(NSArray *)_tps arguments:(NSDictionary *)_args;
+
 /* accessors */
 
 - (NSString *)orgnam;
index e76e56b58502b7537b895b17f81ab57feba480bc..fb06c9e843e2a7e2107005c39801e1259b03f319 100644 (file)
 
 @implementation NGVCardOrg
 
+- (id)initWithName:(NSString *)_name units:(NSArray *)_units
+  group:(NSString *)_grp types:(NSArray *)_tps arguments:(NSDictionary *)_a
+{
+  if ((self = [super initWithGroup:_grp types:_tps arguments:_a]) != nil) {
+    self->orgnam   = [_name  copy];
+    self->orgunits = [_units copy];
+  }
+  return self;
+}
+
+- (id)initWithGroup:(NSString *)_group types:(NSArray *)_types
+  arguments:(NSDictionary *)_a
+{
+  return [self initWithName:nil units:nil
+              group:_group types:_types arguments:_a];
+}
+- (id)init {
+  return [self initWithName:nil units:nil group:nil types:nil arguments:nil];
+}
+
 - (void)dealloc {
   [self->orgnam   release];
   [self->orgunits release];
 /* description */
 
 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
+  if (self->orgnam) [_ms appendFormat:@" %@", self->orgnam];
+  if ([self->orgunits count] > 0) {
+    [_ms appendFormat:@" units=%@",
+        [self->orgunits componentsJoinedByString:@","]];
+  }
   [super appendAttributesToDescription:_ms];
 }
 
index bbfa2c871cde24833d87062a06506e59949e21be..eb3d8e6352d16cfcce23f9b9e6b24c3fda2a6cf5 100644 (file)
@@ -53,6 +53,8 @@
   NSMutableArray      *email;
   NSMutableArray      *label;
   NSMutableArray      *url;
+  NSMutableArray      *fburl;
+  NSMutableArray      *caluri;
   
   struct {
     int isInVCardSet:1;
@@ -61,8 +63,9 @@
     int isInAdr:1;
     int isInOrg:1;
     int isInGroup:1;
+    int isInGeo:1;
     int collectContent:1;
-    int reserved:25;
+    int reserved:24;
   } vcs;
 }
 
index 1c0dd60dc4814cffa1322de66dbe88421928c9fe..aec3c3d4c57fb7f32f15d8f43f2908a99fe51419 100644 (file)
@@ -27,7 +27,7 @@
 #include "NGVCardPhone.h"
 #include "NGVCardName.h"
 #include "NGVCardOrg.h"
-#include "NGVCardCategories.h"
+#include "NGVCardStrArrayValue.h"
 #include "common.h"
 
 #ifndef XMLNS_VCARD_XML_03
@@ -35,6 +35,8 @@
      @"http://www.ietf.org/internet-drafts/draft-dawson-vcard-xml-dtd-03.txt"
 #endif
 
+// TODO: this is wayyy to big and complicated ;->
+
 @implementation NGVCardSaxHandler
 
 - (void)dealloc {
@@ -45,6 +47,9 @@
   [self->adr          release];
   [self->email        release];
   [self->label        release];
+  [self->url          release];
+  [self->fburl        release];
+  [self->caluri       release];
   [self->types        release];
   [self->args         release];
   [self->vCards       release];
 
 /* state */
 
-- (void)resetExceptResult {
-  [self->currentGroup release]; self->currentGroup = nil;
-  [self->vCard        release]; self->vCard        = nil;
-
+- (void)resetCardState {
   [self->tel    removeAllObjects];
   [self->adr    removeAllObjects];
   [self->email  removeAllObjects];
   [self->label  removeAllObjects];
+  [self->url    removeAllObjects];
+  [self->fburl  removeAllObjects];
+  [self->caluri removeAllObjects];
+  [self->xtags  removeAllObjects];
+  [self->currentGroup release]; self->currentGroup = nil;
   [self->types  removeAllObjects];
   [self->args   removeAllObjects];
+  [self->vCard release]; self->vCard = nil;
+}
+
+- (void)resetExceptResult {
+  [self->vCard release]; self->vCard = nil;
+  
+  [self resetCardState];
   
   if (self->content != NULL) {
     free(self->content);
   if (self->label == nil)
     self->label = [[NSMutableArray alloc] initWithCapacity:8];
 
+  if (self->url == nil)
+    self->url = [[NSMutableArray alloc] initWithCapacity:8];
+  if (self->fburl == nil)
+    self->fburl = [[NSMutableArray alloc] initWithCapacity:1];
+  if (self->caluri == nil)
+    self->caluri = [[NSMutableArray alloc] initWithCapacity:1];
+  
   if (self->types == nil)
     self->types = [[NSMutableArray alloc] initWithCapacity:4];
   if (self->args == nil)
 /* common tags */
 
 - (void)startValueTag:(NSString *)_tag attributes:(id<SaxAttributes>)_attrs {
+  /* a tag with types and attributes */
   unsigned i, count;
   
   [self->types removeAllObjects];
   n = [[NGVCardName alloc] initWithPropertyList:self->subvalues
                           group:self->currentGroup
                           types:self->types arguments:self->args];
-  NSLog(@"N: %@", n);
-  
+  [self->vCard setN:n];
   [self->subvalues removeAllObjects];
   [n release];
 }
 }
 - (void)endOrg {
   NGVCardOrg *o;
+  NSArray *u;
 
   self->vcs.isInOrg = 0;
 
-  o = [[NGVCardOrg alloc] initWithGroup:self->currentGroup
+  if ((u = [self->subvalues objectForKey:@"orgunit"]) != nil) {
+    if (![u isKindOfClass:[NSArray class]])
+      u = [NSArray arrayWithObjects:&u count:1];
+  }
+  
+  // TODO: pass org values!
+  o = [[NGVCardOrg alloc] initWithName:[self->subvalues objectForKey:@"orgnam"]
+                         units:u
+                         group:self->currentGroup
                          types:self->types arguments:self->args];
+  [self->vCard setOrg:o];
+  [o release];
+  [self->subvalues removeAllObjects];
+}
+
+- (void)startGeo {
+  [self->subvalues removeAllObjects];
+  self->vcs.isInGeo = 1;
+}
+- (void)endGeo {
+  // TODO
   
-  NSLog(@"O: %@: %@", o, self->subvalues);
+  self->vcs.isInGeo = 0;
   
+  [self logWithFormat:@"WARNING: not supporting geo in vCard."];
   [self->subvalues removeAllObjects];
 }
 
   NSString *uid, *version;
   NSString *t;
   
-  [self->tel   removeAllObjects];
-  [self->adr   removeAllObjects];
-  [self->email removeAllObjects];
-  [self->label removeAllObjects];
-  [self->xtags removeAllObjects];
+  [self->tel    removeAllObjects];
+  [self->adr    removeAllObjects];
+  [self->email  removeAllObjects];
+  [self->label  removeAllObjects];
+  [self->url    removeAllObjects];
+  [self->fburl  removeAllObjects];
+  [self->caluri removeAllObjects];
+  [self->xtags  removeAllObjects];
   
   self->vcs.isInVCard = 1;
   if (self->vCard != nil) {
 
   /* fill collected objects */
   
-  if ([self->tel   count] > 0) [self->vCard setTel:self->tel];
-  if ([self->adr   count] > 0) [self->vCard setAdr:self->adr];
-  if ([self->email count] > 0) [self->vCard setEmail:self->email];
-  if ([self->label count] > 0) [self->vCard setLabel:self->label];
-  if ([self->xtags count] > 0) [self->vCard setX:self->xtags];
-  [self->tel   removeAllObjects];
-  [self->adr   removeAllObjects];
-  [self->email removeAllObjects];
-  [self->label removeAllObjects];
-  [self->xtags removeAllObjects];
+  if ([self->tel    count] > 0) [self->vCard setTel:self->tel];
+  if ([self->adr    count] > 0) [self->vCard setAdr:self->adr];
+  if ([self->email  count] > 0) [self->vCard setEmail:self->email];
+  if ([self->label  count] > 0) [self->vCard setLabel:self->label];
+  if ([self->url    count] > 0) [self->vCard setUrl:self->url];
+  if ([self->fburl  count] > 0) [self->vCard setFreeBusyURL:self->fburl];
+  if ([self->caluri count] > 0) [self->vCard setCalURI:self->caluri];
+  if ([self->xtags  count] > 0) [self->vCard setX:self->xtags];
 
-  /* finish vCard, add to results */
-  
-  [self debugWithFormat:@"finished vCard: %@", self->vCard];
   [self->vCards addObject:self->vCard];
-  [self->vCard release]; self->vCard = nil;
+  //[self debugWithFormat:@"finished vCard: %@", self->vCard];
+  
+  [self resetCardState];
 }
 
 - (void)startVCardSet:(id<SaxAttributes>)_attrs {
   address = [[NGVCardAddress alloc] initWithPropertyList:self->subvalues
                                    group:self->currentGroup
                                    types:self->types arguments:self->args];
-  NSLog(@"A: %@", address);
   [self->adr addObject:address];
   
   [self->subvalues removeAllObjects];
        andAddTo:self->url];
 }
 
+/* tags with comma separated values */
+
+- (void)startNickname:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"nickname" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endNickname {
+  NGVCardStrArrayValue *v;
+  NSArray *a;
+  
+  // comma unescaping?
+  a = [[self finishCollectingContent] componentsSeparatedByString:@","];
+  
+  v = [[NGVCardStrArrayValue alloc] initWithArray:a
+                                   group:self->currentGroup
+                                   types:self->types arguments:self->args];
+  [self->vCard setNickname:v];
+  [v release]; v = nil;
+  
+  [self endValueTag];
+}
+
+- (void)startCategories:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"categories" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endCategories {
+  NGVCardStrArrayValue *v;
+  NSArray *a;
+  
+  // comma unescaping?
+  a = [[self finishCollectingContent] componentsSeparatedByString:@","];
+  
+  v = [[NGVCardStrArrayValue alloc] initWithArray:a
+                                   group:self->currentGroup
+                                   types:self->types arguments:self->args];
+  [self->vCard setCategories:v];
+  [v release]; v = nil;
+  
+  [self endValueTag];
+}
+
+/* generic processing of tags with subtags */
+
 - (void)startSubContentTag:(id<SaxAttributes>)_attrs {
   if ([_attrs count] > 0)
     [self logWithFormat:@"WARNING: loosing attrs of subtag: %@", _attrs];
   [s release];
 }
 
+/* extended tags (X-) */
 
 - (void)startX:(NSString *)_name attributes:(id<SaxAttributes>)_attrs {
   [self startValueTag:_name attributes:_attrs];
   [self endValueTag];
 }
 
+/* flat tags */
+
+- (void)startFN:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endFN {
+  [self->vCard setFn:[self finishCollectingContent]];
+  [self endValueTag];
+}
+
+- (void)startRole:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endRole {
+  [self->vCard setRole:[self finishCollectingContent]];
+  [self endValueTag];
+}
+
+- (void)startTitle:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endTitle {
+  [self->vCard setTitle:[self finishCollectingContent]];
+  [self endValueTag];
+}
+
+- (void)startBDay:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endBDay {
+  [self->vCard setBday:[self finishCollectingContent]];
+  [self endValueTag];
+}
+
+- (void)startNote:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endNote {
+  [self->vCard setNote:[self finishCollectingContent]];
+  [self endValueTag];
+}
+
+- (void)startCalURI:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"CALURI" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endCalURI {
+  [self endBaseContentTagWithClass:[NGVCardSimpleValue class]
+       andAddTo:self->caluri];
+}
+
+- (void)startFreeBusyURL:(id<SaxAttributes>)_attrs {
+  [self startValueTag:@"FBURL" attributes:_attrs];
+  [self startCollectingContent];
+}
+- (void)endFreeBusyURL {
+  [self endBaseContentTagWithClass:[NGVCardSimpleValue class]
+       andAddTo:self->fburl];
+}
+
 
 /* element events */
 
     [self startVCard:_attrs];
   else if (c0 == 'v' && [_localName isEqualToString:@"vCardSet"])
     [self startVCardSet:_attrs];
+  else if (c0 == 'n' && [_localName isEqualToString:@"nickname"])
+    [self startNickname:_attrs];
+  else if (c0 == 'c' && [_localName isEqualToString:@"categories"])
+    [self startCategories:_attrs];
+  else if (c0 == 'r' && [_localName isEqualToString:@"role"])
+    [self startRole:_attrs];
+  else if (c0 == 't' && [_localName isEqualToString:@"title"])
+    [self startTitle:_attrs];
+  else if (c0 == 'b' && [_localName isEqualToString:@"bday"])
+    [self startBDay:_attrs];
+  else if (c0 == 'n' && [_localName isEqualToString:@"note"])
+    [self startNote:_attrs];
+  else if (c0 == 'C' && [_localName isEqualToString:@"CALURI"])
+    [self startCalURI:_attrs];
+  else if (c0 == 'F' && [_localName isEqualToString:@"FBURL"])
+    [self startFreeBusyURL:_attrs];
+  else if (c0 == 'f' && [_localName isEqualToString:@"fn"])
+    [self startFN:_attrs];
+  else if (c0 == 'g' && [_localName isEqualToString:@"geo"])
+    [self startGeo];
   else {
-    if (self->vcs.isInN || self->vcs.isInOrg || self->vcs.isInAdr)
+    if (self->vcs.isInN || self->vcs.isInOrg || self->vcs.isInAdr || 
+       self->vcs.isInGeo)
       [self startSubContentTag:_attrs];
     else if (c0 == 'X')
       [self startX:_localName attributes:_attrs];
     [self endVCard];
   else if (c0 == 'v' && [_localName isEqualToString:@"vCardSet"])
     [self endVCardSet];
+  else if (c0 == 'n' && [_localName isEqualToString:@"nickname"])
+    [self endNickname];
+  else if (c0 == 'c' && [_localName isEqualToString:@"categories"])
+    [self endCategories];
+  else if (c0 == 'r' && [_localName isEqualToString:@"role"])
+    [self endRole];
+  else if (c0 == 't' && [_localName isEqualToString:@"title"])
+    [self endTitle];
+  else if (c0 == 'b' && [_localName isEqualToString:@"bday"])
+    [self endBDay];
+  else if (c0 == 'n' && [_localName isEqualToString:@"note"])
+    [self endNote];
+  else if (c0 == 'C' && [_localName isEqualToString:@"CALURI"])
+    [self endCalURI];
+  else if (c0 == 'F' && [_localName isEqualToString:@"FBURL"])
+    [self endFreeBusyURL];
+  else if (c0 == 'f' && [_localName isEqualToString:@"fn"])
+    [self endFN];
+  else if (c0 == 'g' && [_localName isEqualToString:@"geo"])
+    [self endGeo];
   else {
-    if (self->vcs.isInN || self->vcs.isInOrg || self->vcs.isInAdr)
+    if (self->vcs.isInN || self->vcs.isInOrg || self->vcs.isInAdr ||
+       self->vcs.isInGeo)
       [self endSubContentTag:_localName];
     else if (c0 == 'X')
       [self endX:_localName];
similarity index 69%
rename from sope-ical/NGiCal/NGVCardCategories.h
rename to sope-ical/NGiCal/NGVCardStrArrayValue.h
index 05935df5b38dc46eedfd36c51c681e6ba889d0e3..e4e607ebb4bff15fd6e9150f1cbcd795225ed0f4 100644 (file)
   02111-1307, USA.
 */
 
-#ifndef __NGiCal_NGVCardCategories_H__
-#define __NGiCal_NGVCardCategories_H__
+#ifndef __NGiCal_NGVCardStrArrayValue_H__
+#define __NGiCal_NGVCardStrArrayValue_H__
 
 #include <NGiCal/NGVCardValue.h>
 
 /*
-  NGVCardCategories
+  NGVCardStrArrayValue
 
+  Represents a list of strings as used in vCards for 'category' or 'nickname'
+  tags.
+  
   Note: vCard apparently cannot represent categories which contain commas.
         At least Kontact and Evolution do not (no escaping of commas).
 */
 
 @class NSArray;
 
-@interface NGVCardCategories : NGVCardValue
+@interface NGVCardStrArrayValue : NGVCardValue
 {
-  NSArray *categories;
+  NSArray *values;
 }
 
+- (id)initWithArray:(NSArray *)_plist group:(NSString *)_group 
+  types:(NSArray *)_types arguments:(NSDictionary *)_a;
+- (id)initWithPropertyList:(id)_plist;
+
 /* accessors */
 
-- (NSArray *)categories;
+- (NSArray *)values;
 
 /* values */
 
@@ -53,4 +60,4 @@
 
 @end
 
-#endif /* __NGiCal_NGVCardCategories_H__ */
+#endif /* __NGiCal_NGVCardStrArrayValue_H__ */
diff --git a/sope-ical/NGiCal/NGVCardStrArrayValue.m b/sope-ical/NGiCal/NGVCardStrArrayValue.m
new file mode 100644 (file)
index 0000000..decbbbd
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+  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 "NGVCardStrArrayValue.h"
+#include "common.h"
+
+@implementation NGVCardStrArrayValue
+
+- (id)initWithArray:(NSArray *)_plist group:(NSString *)_group 
+  types:(NSArray *)_types arguments:(NSDictionary *)_a
+{
+  if ((self = [super initWithGroup:_group types:_types arguments:_a]) != nil) {
+    self->values = [_plist copy];
+  }
+  return self;
+}
+
+- (id)initWithString:(NSString *)_plist group:(NSString *)_group 
+  types:(NSArray *)_types arguments:(NSDictionary *)_a
+{
+  // TODO: unescaping of commas?
+  return [self initWithArray:[_plist componentsSeparatedByString:@","]
+              group:_group types:_types arguments:_a];
+}
+
+- (id)initWithPropertyList:(id)_plist group:(NSString *)_group 
+  types:(NSArray *)_types arguments:(NSDictionary *)_a
+{
+  if ([_plist isKindOfClass:[NSString class]]) {
+    return [self initWithString:_plist
+                group:_group types:_types arguments:_a];
+  }
+  if ([_plist isKindOfClass:[NSArray class]]) {
+    return [self initWithArray:_plist
+                group:_group types:_types arguments:_a];
+  }
+
+  [self logWithFormat:@"ERROR: unexpected property list type: %@",
+         [_plist class]];
+  [self release];
+  return nil;
+}
+- (id)initWithPropertyList:(id)_plist {
+  return [self initWithPropertyList:_plist group:nil types:nil arguments:nil];
+}
+
+- (id)initWithGroup:(NSString *)_group types:(NSArray *)_types
+  arguments:(NSDictionary *)_a
+{
+  return [self initWithArray:nil 
+              group:_group types:_types arguments:_a];
+}
+- (id)init {
+  return [self initWithPropertyList:nil group:nil types:nil arguments:nil];
+}
+
+- (void)dealloc {
+  [self->values release];
+  [super dealloc];
+}
+
+/* accessors */
+
+- (NSArray *)values {
+  return self->values;
+}
+
+/* values */
+
+- (NSString *)stringValue {
+  return [self vCardString];
+}
+
+- (NSString *)xmlString {
+  return [[self stringValue] stringByEscapingXMLString];
+}
+
+- (NSString *)vCardString {
+  return [[self values] componentsJoinedByString:@","];
+}
+
+- (id)propertyList {
+  return [self values];
+}
+
+- (NSArray *)asArray {
+  return self->values;
+}
+
+/* fake being an array */
+
+- (id)objectAtIndex:(unsigned)_idx {
+  return [self->values objectAtIndex:_idx];
+}
+- (unsigned)count {
+  return [self->values 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->values];
+}
+- (id)initWithCoder:(NSCoder *)_coder {
+  if ((self = [super initWithCoder:_coder]) != nil) {
+    self->values = [[_coder decodeObject] copy];
+  }
+  return self;
+}
+
+/* description */
+
+- (void)appendAttributesToDescription:(NSMutableString *)_ms {
+  [super appendAttributesToDescription:_ms];
+  [_ms appendFormat:@" vcard=%@", [self vCardString]];
+}
+
+@end /* NGVCardStrArrayValue */
index d2b964f05e61163c56d990ac2ab61c17533ff7c0..632bc18a75a13f21bc93737a638b8b47a97ee5b7 100644 (file)
@@ -2,7 +2,7 @@
 
 MAJOR_VERSION=4
 MINOR_VERSION=5
-SUBMINOR_VERSION:=53
+SUBMINOR_VERSION:=54
 
 # v4.5.40 requires NGExtensions v4.5.145
 # v4.5.37 requires NGExtensions v4.5.140