]> err.no Git - scalable-opengroupware.org/commitdiff
improved behaviour with vCard content
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 13 Jul 2005 13:53:52 +0000 (13:53 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 13 Jul 2005 13:53:52 +0000 (13:53 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@737 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Contacts/ChangeLog
SOGo/SoObjects/Contacts/SOGoContactFolder.m
SOGo/SoObjects/Contacts/SOGoContactObject.h
SOGo/SoObjects/Contacts/SOGoContactObject.m
SOGo/SoObjects/Contacts/Version

index 8e33884a612f90523b3885f09fbd6d2032e603c1..1921172238ab621eda26ef607c1b7b21481fa323 100644 (file)
@@ -1,5 +1,7 @@
 2005-07-13  Helge Hess  <helge.hess@opengroupware.org>
 
+       * SOGoContactObject.m: hardened against vCard content (v0.9.11)
+
        * SOGoContactObject.m: removed special GET action, the redirect to
          'view' seems to be handled by SOPE now. This also makes WebDAV GET
          work (v0.9.10)
index 6a1829114df4411954d0a0a73743240a0c0bd8f8..608fcc8690917e0016b772ebad5a22af30effdbc 100644 (file)
   if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
     return obj;
   
-  if ([self isValidContactName:_key])
-    return [self contactWithName:_key inContext:_ctx];
+  if ([self isValidContactName:_key]) {
+#if 0
+    if ([[self ocsFolder] versionOfContentWithName:_key])
+#endif
+      return [self contactWithName:_key inContext:_ctx];
+  }
 
   /* return 404 to stop acquisition */
   return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
     return nil;
   }
   records = [self fixupRecords:records];
-  [self debugWithFormat:@"fetched %i records.", [records count]];
+  //[self debugWithFormat:@"fetched %i records.", [records count]];
   return records;
 }
 
index 1b45c7be4cf90f088a829aeba6c76fbd54223778..b2d71c95545e169b099eafb3181258e63683a223 100644 (file)
 */
 
 @class NSDictionary;
+@class NGVCard;
 
 @interface SOGoContactObject : SOGoContentObject
 {
-  NSDictionary *record;
+  id record; /* either an NSMutableDictionary or a NGVCard */
 }
 
 /* accessors */
 
-- (NSDictionary *)record;
+- (id)record;
+- (BOOL)isVCardRecord;
+- (NGVCard *)vCard;
 
 @end
 
index 68d015d0cb31d1c90d1de93a5e77902bf0e94441..64ae6bd7a59c9f52f5ff62e8196eb4f309fd020b 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "SOGoContactObject.h"
+#include <NGiCal/NGVCard.h>
 #include "common.h"
 
 @implementation SOGoContactObject
 
 /* content */
 
-- (NSDictionary *)record {
-  if (self->record == nil)
-    self->record = [[[self contentAsString] propertyList] copy];
-  return self->record;
+- (id)record {
+  if (self->record == nil) {
+    NSString *s;
+    
+    s = [self contentAsString];
+    
+    if ([s hasPrefix:@"BEGIN:VCARD"]) {
+      NSArray *v;
+      
+      v = [NGVCard parseVCardsFromSource:s];
+      if ([v count] == 0)
+       return nil;
+      
+      self->record = [[v objectAtIndex:0] retain];
+    }
+    else
+      self->record = [[s propertyList] copy];
+  }
+  return [self->record isNotNull] ? self->record : nil;
+}
+
+- (BOOL)isVCardRecord {
+  return [[self record] isKindOfClass:[NGVCard class]];
+}
+
+- (NGVCard *)vCard {
+  return [[self record] isKindOfClass:[NGVCard class]]
+    ? [self record]
+    : nil;
 }
 
 /* key value coding */
 /* specialized actions */
 
 - (NSException *)saveRecord:(id)_record {
+  if ([_record isKindOfClass:[NGVCard class]]) {
+    // TODO: implement a vCard generator
+    return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
+                       reason:@"Saving vCards is not supported yet."];
+  }
+  
   return [self saveContentString:[_record description]];
 }
 
   inContext:(id)_ctx
 {
   NSMutableDictionary *md;
+
+  if ([self isVCardRecord]) {
+    return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
+                       reason:@"Changing vCards is not supported yet."];
+  }
   
   if ([_fname length] == 0) {
     return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
index d383fb7e2169d949d6f411d084ba3b2e9fafd53e..f941fe0f8b0b09690a8f5b264aaa661ae6efc1f3 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=10
+SUBMINOR_VERSION:=11
 
 # v0.9.9 requires libGDLContentStore v4.5.26
 # v0.9.5 requires libNGExtensions    v4.5.136