]> err.no Git - scalable-opengroupware.org/commitdiff
properly handle body part lookups in embedded messages
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 31 Jan 2005 00:44:57 +0000 (00:44 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 31 Jan 2005 00:44:57 +0000 (00:44 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@511 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/SOGoMailObject.m
SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m
SOGo/SoObjects/Mailer/Version

index 0f90c473b1fac386d407c963ffb831d2df58bbfb..84c84130ddb1b9e920971fd888e9736ec4b1198d 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-31  Helge Hess  <helge.hess@opengroupware.org>
+
+       * SOGoMailObject.m: properly handle part lookup in the context of
+         embedded message/rfc822 content (v0.9.62)
+
 2005-01-30  Helge Hess  <helge.hess@opengroupware.org>
 
        * v0.9.61
index f87e20b6819ac26bb8d0995ef7e7f92d798d9a21..3ea384f65fb9043480eea6fd4bd3fed6bf578874 100644 (file)
@@ -31,6 +31,7 @@
 static NSArray *coreInfoKeys = nil;
 static BOOL heavyDebug = NO;
 static BOOL debugOn = NO;
+static BOOL debugBodyStructure = NO;
 
 + (void)initialize {
   /* Note: see SOGoMailManager.m for allowed IMAP4 keys */
@@ -147,7 +148,12 @@ static BOOL debugOn = NO;
 }
 
 - (id)bodyStructure {
-  return [[self fetchCoreInfos] valueForKey:@"body"];
+  id body;
+
+  body = [[self fetchCoreInfos] valueForKey:@"body"];
+  if (debugBodyStructure)
+    [self logWithFormat:@"BODY: %@", body];
+  return body;
 }
 
 - (NGImap4Envelope *)envelope {
@@ -179,18 +185,40 @@ static BOOL debugOn = NO;
     return nil;
   }
   
-  /* for each path component, eg 1,1,3 */
+  /* 
+     For each path component, eg 1,1,3 
+     
+     Remember that we need special processing for message/rfc822 which maps the
+     namespace of multiparts directly into the main namespace.
+  */
   pe = [_path objectEnumerator];
   while ((p = [pe nextObject]) != nil && [info isNotNull]) {
     unsigned idx;
     NSArray  *parts;
+    NSString *mt;
     
     [self debugWithFormat:@"check PATH: %@", p];
     idx = [p intValue] - 1;
+
+    mt = [[info valueForKey:@"type"] lowercaseString];
+    if ([mt isEqualToString:@"message"]) {
+      /* we have special behaviour for message types */
+      id body;
+      
+      if ((body = [info valueForKey:@"body"]) != nil) {
+       mt = [body valueForKey:@"type"];
+       if ([mt isEqualToString:@"multipart"])
+         parts = [body valueForKey:@"parts"];
+       else
+         parts = [NSArray arrayWithObject:body];
+      }
+    }
+    else
+      parts = [info valueForKey:@"parts"];
     
-    parts = [info valueForKey:@"parts"];
     if (idx >= [parts count]) {
-      [self errorWithFormat:@"body part index out of bounds(%d vs %d): %@", 
+      [self errorWithFormat:
+             @"body part index out of bounds(idx=%d vs count=%d): %@", 
               (idx + 1), [parts count], info];
       return nil;
     }
index 90e03777c633175dabd948948fc4e9cba9b594cd..cfc5ad2962f19c51cf7b193b3ea623149d8927ca 100644 (file)
@@ -27,6 +27,8 @@
   A specialized SOGoMailBodyPart subclass for message attachments. Can be used
   to attach special SoMethods.
   
+  This object should allow the user to peek inside the message contents.
+  
   See the superclass for more information on part objects.
 */
 
index fed4e8c1dae8fe6e3b13bbb33d93a3841bc8932c..9e9133ebb64a1bf5ce320e75811a7f61daa6b887 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=61
+SUBMINOR_VERSION:=62
 
 # v0.9.55 requires NGExtensions v4.5.136
 # v0.9.44 requires libNGMime    v4.3.194