From 9be6e399bbb39d8f4fcbc84b0125d155b6ee08ab Mon Sep 17 00:00:00 2001 From: znek Date: Tue, 27 Feb 2007 15:38:20 +0000 Subject: [PATCH] added support for photo types git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1445 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-ical/NGiCal/ChangeLog | 10 +++++ sope-ical/NGiCal/NGVCard.h | 9 +++++ sope-ical/NGiCal/NGVCard.m | 20 ++++++++++ sope-ical/NGiCal/NGVCardSaxHandler.m | 40 +++++++++++++++++-- .../NGiCal/NGiCal.xcodeproj/project.pbxproj | 12 +++--- sope-ical/NGiCal/Version | 2 +- 6 files changed, 82 insertions(+), 11 deletions(-) diff --git a/sope-ical/NGiCal/ChangeLog b/sope-ical/NGiCal/ChangeLog index 0eedac13..a6becb77 100644 --- a/sope-ical/NGiCal/ChangeLog +++ b/sope-ical/NGiCal/ChangeLog @@ -1,3 +1,13 @@ +2007-02-27 Marcus Mueller + + * v4.7.80 + + * NGVCard.[hm]: Added API for properly dealing with photos and + associated MIME types + + * NGVCardSaxHandler.m: added support for parsing photo types (section + 3.1.4 in RFC2426). Also cleaned up some logging related code. + 2007-02-12 Helge Hess * iCalMonthlyRecurrenceCalculator.m: fixed byday calculation for days diff --git a/sope-ical/NGiCal/NGVCard.h b/sope-ical/NGiCal/NGVCard.h index 3f66ff07..0180b6c8 100644 --- a/sope-ical/NGiCal/NGVCard.h +++ b/sope-ical/NGiCal/NGVCard.h @@ -90,6 +90,9 @@ NSArray *fburl; NSArray *caluri; NSDictionary *x; + + NSData *photo; + NSString *photoType; // an IANA registered name } + (NSArray *)parseVCardsFromSource:(id)_src; @@ -154,11 +157,17 @@ - (void)setX:(NSDictionary *)_dict; - (NSDictionary *)x; +- (void)setPhoto:(NSData *)_photo; +- (NSData *)photo; +- (void)setPhotoType:(NSString *)_photoType; +- (NSString *)photoType; + /* convenience */ - (NGVCardSimpleValue *)preferredEMail; - (NGVCardPhone *)preferredTel; - (NGVCardAddress *)preferredAdr; +- (NSString *)photoMimeType; @end diff --git a/sope-ical/NGiCal/NGVCard.m b/sope-ical/NGiCal/NGVCard.m index 09176016..081fd4a7 100644 --- a/sope-ical/NGiCal/NGVCard.m +++ b/sope-ical/NGiCal/NGVCard.m @@ -284,6 +284,19 @@ static NGVCardSaxHandler *sax = nil; // THREAD return self->x; } +- (void)setPhoto:(NSData *)_photo { + ASSIGNCOPY(self->photo, _photo); +} +- (NSData *)photo { + return self->photo; +} +- (void)setPhotoType:(NSString *)_photoType { + ASSIGNCOPY(self->photoType, _photoType); +} +- (NSString *)photoType { + return self->photoType; +} + /* convenience */ - (id)preferredValueInArray:(NSArray *)_values { @@ -313,6 +326,13 @@ static NGVCardSaxHandler *sax = nil; // THREAD - (NGVCardAddress *)preferredAdr { return [self preferredValueInArray:self->adr]; } +- (NSString *)photoMimeType { + NSString *t; + + t = [self photoType]; + if (![t isNotNull]) return @"image/octet-stream"; + return [NSString stringWithFormat:@"image/%@", [t lowercaseString]]; +} /* description */ diff --git a/sope-ical/NGiCal/NGVCardSaxHandler.m b/sope-ical/NGiCal/NGVCardSaxHandler.m index 09a85997..6f7fad52 100644 --- a/sope-ical/NGiCal/NGVCardSaxHandler.m +++ b/sope-ical/NGiCal/NGVCardSaxHandler.m @@ -266,7 +266,7 @@ self->vcs.isInVCard = 1; if (self->vCard != nil) { [self->vCards addObject:self->vCard]; - [self logWithFormat:@"ERROR: vCard nesting not supported!"]; + [self errorWithFormat:@"vCard nesting not supported!"]; [self->vCard release]; self->vCard = nil; } @@ -280,7 +280,7 @@ if ((t = [_attrs valueForName:@"class" uri:XMLNS_VCARD_XML_03]) != nil) [self->vCard setVClass:t]; if ((t = [_attrs valueForName:@"rev" uri:XMLNS_VCARD_XML_03]) != nil) { - [self logWithFormat:@"WARNING: vCard revision not yet supported!"]; + [self warnWithFormat:@"vCard revision not yet supported!"]; // TODO } if ((t = [_attrs valueForName:@"prodid" uri:XMLNS_VCARD_XML_03]) != nil) @@ -430,7 +430,7 @@ - (void)startSubContentTag:(id)_attrs { if ([_attrs count] > 0) - [self logWithFormat:@"WARNING: loosing attrs of subtag: %@", _attrs]; + [self warnWithFormat:@"loosing attrs of subtag: %@", _attrs]; [self startCollectingContent]; } @@ -561,6 +561,34 @@ andAddTo:self->fburl]; } +- (void)startPhoto:(id)_attrs { + [self startValueTag:@"photo" attributes:_attrs]; + [self startCollectingContent]; +} +- (void)endPhoto { + NSString *d; + NSData *photo; + unsigned count, i; + + d = [self finishCollectingContent]; + // TODO: rfc2426 requires support for URI and other stuff! + photo = [d dataByDecodingBase64]; + [self->vCard setPhoto:photo]; + count = [self->types count]; + for (i = 0; i < count; i++) { + NSString *type = [self->types objectAtIndex:i]; + if ([type isEqualToString:@"BASE64"]) { + continue; + } + else { + [self->vCard setPhotoType:type]; + break; + } + } + + [self endValueTag]; +} + /* OGo?? tags */ - (void)startProfile:(id)_attrs { @@ -637,6 +665,8 @@ // TODO: following are generated by LSAddress, but not in spec? else if (c0 == 'P' && [_localName isEqualToString:@"PROFILE"]) [self startProfile:_attrs]; + else if (c0 == 'p' && [_localName isEqualToString:@"photo"]) + [self startPhoto:_attrs]; else if (c0 == 'S' && [_localName isEqualToString:@"SOURCE"]) [self startSource:_attrs]; else if (c0 == 'N' && [_localName isEqualToString:@"NAME"]) @@ -648,7 +678,7 @@ else if (c0 == 'X') [self startX:_localName attributes:_attrs]; else - NSLog(@"U: %@", _localName); + [self logWithFormat:@"U: %@", _localName]; } } @@ -700,6 +730,8 @@ [self endGeo]; else if (c0 == 'P' && [_localName isEqualToString:@"PROFILE"]) [self endProfile]; + else if (c0 == 'p' && [_localName isEqualToString:@"photo"]) + [self endPhoto]; else if (c0 == 'S' && [_localName isEqualToString:@"SOURCE"]) [self endSource]; else if (c0 == 'N' && [_localName isEqualToString:@"NAME"]) diff --git a/sope-ical/NGiCal/NGiCal.xcodeproj/project.pbxproj b/sope-ical/NGiCal/NGiCal.xcodeproj/project.pbxproj index b848cf90..2d010eed 100644 --- a/sope-ical/NGiCal/NGiCal.xcodeproj/project.pbxproj +++ b/sope-ical/NGiCal/NGiCal.xcodeproj/project.pbxproj @@ -679,7 +679,7 @@ buildSettings = { COPY_PHASE_STRIP = NO; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.7.79; + DYLIB_CURRENT_VERSION = 4.7.80; FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks"; FRAMEWORK_VERSION = A; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; @@ -722,7 +722,7 @@ DEPLOYMENT_POSTPROCESSING = YES; DSTROOT = /; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.7.79; + DYLIB_CURRENT_VERSION = 4.7.80; DYLIB_INSTALL_NAME_BASE = "@executable_path/../Frameworks/"; FRAMEWORK_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks"; FRAMEWORK_VERSION = A; @@ -767,7 +767,7 @@ isa = XCBuildConfiguration; buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.7.79; + DYLIB_CURRENT_VERSION = 4.7.80; FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks"; FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -797,7 +797,7 @@ buildSettings = { COPY_PHASE_STRIP = NO; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.7.79; + DYLIB_CURRENT_VERSION = 4.7.80; FRAMEWORK_SEARCH_PATHS = "\"$(USER_LIBRARY_DIR)/EmbeddedFrameworks\""; FRAMEWORK_VERSION = A; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; @@ -833,7 +833,7 @@ DEPLOYMENT_POSTPROCESSING = YES; DSTROOT = /; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.7.79; + DYLIB_CURRENT_VERSION = 4.7.80; DYLIB_INSTALL_NAME_BASE = "@executable_path/../Frameworks/"; FRAMEWORK_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks"; FRAMEWORK_VERSION = A; @@ -871,7 +871,7 @@ isa = XCBuildConfiguration; buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.7.79; + DYLIB_CURRENT_VERSION = 4.7.80; FRAMEWORK_SEARCH_PATHS = "\"$(USER_LIBRARY_DIR)/EmbeddedFrameworks\""; FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = NO; diff --git a/sope-ical/NGiCal/Version b/sope-ical/NGiCal/Version index 7966f3c0..9fa1c951 100644 --- a/sope-ical/NGiCal/Version +++ b/sope-ical/NGiCal/Version @@ -2,7 +2,7 @@ MAJOR_VERSION=4 MINOR_VERSION=7 -SUBMINOR_VERSION:=79 +SUBMINOR_VERSION:=80 # v4.5.40 requires NGExtensions v4.5.145 # v4.5.37 requires NGExtensions v4.5.140 -- 2.39.5