]> err.no Git - sope/commitdiff
added support for photo types
authorznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Tue, 27 Feb 2007 15:38:20 +0000 (15:38 +0000)
committerznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Tue, 27 Feb 2007 15:38:20 +0000 (15:38 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1445 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-ical/NGiCal/ChangeLog
sope-ical/NGiCal/NGVCard.h
sope-ical/NGiCal/NGVCard.m
sope-ical/NGiCal/NGVCardSaxHandler.m
sope-ical/NGiCal/NGiCal.xcodeproj/project.pbxproj
sope-ical/NGiCal/Version

index 0eedac137152f2e60a37236ef9fea3a9838c0f59..a6becb77c0088fd858f3cfa8a9b4f3b26d6e86c8 100644 (file)
@@ -1,3 +1,13 @@
+2007-02-27  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * 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  <helge.hess@opengroupware.org>
 
        * iCalMonthlyRecurrenceCalculator.m: fixed byday calculation for days
index 3f66ff0715b5fcb73c7ef9b9ccd06d7010592eb9..0180b6c855c7f7bdc70dd643fa1495e3e9c104d7 100644 (file)
@@ -90,6 +90,9 @@
   NSArray      *fburl;
   NSArray      *caluri;
   NSDictionary *x;
+  
+  NSData       *photo;
+  NSString     *photoType; // an IANA registered name
 }
 
 + (NSArray *)parseVCardsFromSource:(id)_src;
 - (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
 
index 09176016650626394df494d6ddd4648b57d9d6f7..081fd4a7e5623630123a5a0d78d535fb904a1f7d 100644 (file)
@@ -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 */
 
index 09a859972b970ae9ff5cc2d87816fd3f4b58ab73..6f7fad5217ab62d9172c6e171ee0caa3de8cdc45 100644 (file)
   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;
   }
   
   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)
 
 - (void)startSubContentTag:(id<SaxAttributes>)_attrs {
   if ([_attrs count] > 0)
-    [self logWithFormat:@"WARNING: loosing attrs of subtag: %@", _attrs];
+    [self warnWithFormat:@"loosing attrs of subtag: %@", _attrs];
   
   [self startCollectingContent];
 }
        andAddTo:self->fburl];
 }
 
+- (void)startPhoto:(id<SaxAttributes>)_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<SaxAttributes>)_attrs {
   // 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"])
     else if (c0 == 'X')
       [self startX:_localName attributes:_attrs];
     else
-      NSLog(@"U: %@", _localName);
+      [self logWithFormat:@"U: %@", _localName];
   }
 }
 
     [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"])
index b848cf909f963496a343fbaa195189a79f007406..2d010eed2e3acc8e6040b78783502faae0fb8e4f 100644 (file)
                        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;
                                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;
                        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;
                        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;
                                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;
                        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;
index 7966f3c07df832599b43fa0876480c310579c9bc..9fa1c951eb98d952cbb5e4dea2859a770c4ec1d4 100644 (file)
@@ -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