]> err.no Git - scalable-opengroupware.org/commitdiff
fixed support for embedded message/rfc822 attachments (properly handle body-parts)
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 31 Jan 2005 00:48:13 +0000 (00:48 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 31 Jan 2005 00:48:13 +0000 (00:48 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@512 d1b88da0-ebda-0310-925b-ed51d893ca5b

14 files changed:
SOGo/UI/Mailer/ChangeLog
SOGo/UI/Mailer/GNUmakefile
SOGo/UI/Mailer/README
SOGo/UI/Mailer/UIxEnvelopeAddressFormatter.m
SOGo/UI/Mailer/UIxMailPartLinkViewer.m
SOGo/UI/Mailer/UIxMailPartLinkViewer.wox
SOGo/UI/Mailer/UIxMailPartMessageViewer.m [new file with mode: 0644]
SOGo/UI/Mailer/UIxMailPartMessageViewer.wox [new file with mode: 0644]
SOGo/UI/Mailer/UIxMailPartViewer.m
SOGo/UI/Mailer/UIxMailRenderingContext.h
SOGo/UI/Mailer/UIxMailRenderingContext.m
SOGo/UI/Mailer/UIxMailView.m
SOGo/UI/Mailer/UIxMailView.wox
SOGo/UI/Mailer/Version

index 8c594df043f7b49077825a34898643bcf9ace920..0288835c3d2a5130ff8351e6632ed4b6545f5736 100644 (file)
@@ -1,4 +1,22 @@
+2005-01-31  Helge Hess  <helge.hess@opengroupware.org>
+
+       * v0.9.84
+
+       * UIxMailView.m: properly recurse into message/rfc822 bodies for flat
+         content fetches
+
+       * UIxMailView.m, UIxMailPartMessageViewer.m: added links for email
+         addresses (currently mailto://)
+
 2005-01-30  Helge Hess  <helge.hess@opengroupware.org>
+       
+       * v0.9.83
+       
+       * UIxMailRenderingContext.m: activate UIxMailPartMessageViewer for
+         message/rfc822 contents
+
+       * added a UIxMailPartMessageViewer for displaying embedded (eg
+         forwarded) MIME messages
 
        * v0.9.82
        
index c9154123a7a346d7a889f23a3f0f0ecf1fc6c3c0..cf6481f1b9046607bdb1a9870be85f120ff0f905 100644 (file)
@@ -42,6 +42,7 @@ MailerUI_OBJC_FILES += \
        UIxMailPartLinkViewer.m         \
        UIxMailPartMixedViewer.m        \
        UIxMailPartAlternativeViewer.m  \
+       UIxMailPartMessageViewer.m      \
        \
        UIxFilterList.m                 \
        UIxSieveEditor.m                \
@@ -75,6 +76,7 @@ MailerUI_RESOURCE_FILES += \
        UIxMailPartImageViewer.wox      \
        UIxMailPartLinkViewer.wox       \
        UIxMailPartAlternativeViewer.wox\
+       UIxMailPartMessageViewer.wox    \
        \
        UIxFilterList.wox               \
        UIxSieveEditor.wox              \
index 01404aedccfed36396de74f621be5ec8228286e8..96ab0eefc3006376f89f71138906bbd5da5ccb44 100644 (file)
@@ -39,6 +39,9 @@ Bodystructures
 
 Multiparts: multipart/MIXED, multipart/SIGNED
 
+Feature: we fetch all plain/text bodies in a single run by traversing the
+         body structure.
+
 Sample Bodystructure (GPG):
 ---snip---
   {
index 4a94964698b1b883ec7d77ccc8744998655105f2..b12ae8170f6f20e3ff8ad5f2349fc82f19272797 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2004 SKYRIX Software AG
+  Copyright (C) 2004-2005 SKYRIX Software AG
 
   This file is part of OpenGroupware.org.
 
@@ -114,7 +114,7 @@ static Class StrClass     = Nil;
   
   if ([_address isKindOfClass:[NSArray class]])
     return [self stringForArray:_address];
-  
+
   [self debugWithFormat:
          @"NOTE: unexpected object for envelope formatter: %@<%@>",
          _address, NSStringFromClass([_address class])];
index 16574e1b8919c44422fa6a8e72c20dc40cec2cc1..41d95c32cdbf6a1821f04ae890991fae559dd412 100644 (file)
 
 @implementation UIxMailPartLinkViewer
 
-- (void)dealloc {
-  [super dealloc];
-}
-
 /* URLs */
 
 - (NSString *)pathToAttachment {
index 6d1b89cd28bd489cfbe1a985a89c0000c823b6f0..72528b4040d2611e52177a178454ff6ac7a9c75d 100644 (file)
       <var:string label:value="Size" />:
       <var:string value="bodyInfo.size" formatter="sizeFormatter" />
     </div>
-  
+
 <!-- debug
+    <pre><var:string value="bodyInfo"/></pre>
+  
     <a var:href="pathToAttachment"
        var:title="bodyInfo"
        class="mailer_imagecontent"
diff --git a/SOGo/UI/Mailer/UIxMailPartMessageViewer.m b/SOGo/UI/Mailer/UIxMailPartMessageViewer.m
new file mode 100644 (file)
index 0000000..9ea0aca
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+  Copyright (C) 2004-2005 SKYRIX Software AG
+
+  This file is part of OpenGroupware.org.
+
+  OGo 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.
+
+  OGo 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 OGo; see the file COPYING.  If not, write to the
+  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+  02111-1307, USA.
+*/
+
+#include "UIxMailPartViewer.h"
+
+/*
+  UIxMailPartMessageViewer
+
+  Show message/rfc822 mail parts. Note that the IMAP4 server already returns a
+  proper body structure of the message.
+
+  Relevant body-info keys:
+    to/sender/from/cc/bcc/in-reply-to/reply-to - array of addr-dicts
+    type/subtype          - message/RFC822
+    size
+    subject
+    parameterList         - dict (eg 'name')
+    messageId     
+    date
+    encoding              - 7BIT
+    bodyLines             - 83
+    bodyId                - (empty string?)
+    description           - (empty string?, content-description?)
+    
+    body                  - a body structure?
+  
+  Addr-Dict:
+    hostName / mailboxName / personalName / sourceRoute
+*/
+
+@class NGImap4Envelope;
+
+@interface UIxMailPartMessageViewer : UIxMailPartViewer
+{
+  NGImap4Envelope *envelope;
+  id currentAddress;
+}
+
+@end
+
+#include "WOContext+UIxMailer.h"
+#include "UIxMailRenderingContext.h"
+#include <NGImap4/NGImap4Envelope.h>
+#include <NGImap4/NGImap4EnvelopeAddress.h>
+#include "common.h"
+
+@implementation UIxMailPartMessageViewer
+
+- (void)dealloc {
+  [self->currentAddress release];
+  [self->envelope       release];
+  [super dealloc];
+}
+
+/* cache maintenance */
+
+- (void)resetBodyInfoCaches {
+  [super resetBodyInfoCaches];
+  [self->envelope       release]; self->envelope       = nil;
+  [self->currentAddress release]; self->currentAddress = nil;
+}
+
+/* notifications */
+
+- (void)sleep {
+  [self->currentAddress release]; self->currentAddress = nil;
+  [super sleep];
+}
+
+/* accessors */
+
+- (void)setCurrentAddress:(id)_addr {
+  ASSIGN(self->currentAddress, _addr);
+}
+- (id)currentAddress {
+  return self->currentAddress;
+}
+
+/* nested body structure */
+
+- (id)contentInfo {
+  return [[self bodyInfo] valueForKey:@"body"];
+}
+
+- (id)contentPartPath {
+  /*
+    Path processing is a bit weird in the context of message/rfc822. If we have
+    a multipart, the multipart itself has no own identifier! Instead the
+    children of the multipart are directly mapped into the message namespace.
+    
+    If the message has just a plain content, ids seems to be as expected (that
+    is, its just a "1").
+  */
+  NSArray  *pp;
+  NSString *mt;
+  
+  mt = [[[self contentInfo] valueForKey:@"type"] lowercaseString];
+  if ([mt isEqualToString:@"multipart"])
+    return [self partPath];
+  
+  pp = [self partPath];
+  return [pp count] > 0
+    ? [pp arrayByAddingObject:@"1"]
+    : [NSArray arrayWithObject:@"1"];
+}
+
+- (id)contentViewerComponent {
+  id info;
+  
+  info = [self contentInfo];
+  return [[[self context] mailRenderingContext] viewerForBodyInfo:info];
+}
+
+/* generating envelope */
+
+- (NGImap4Envelope *)envelope {
+  if (self->envelope == nil) {
+    self->envelope = [[NGImap4Envelope alloc] initWithBodyStructureInfo:
+                                               [self bodyInfo]];
+  }
+  return self->envelope;
+}
+
+/* links to recipients */
+
+- (NSString *)linkToEnvelopeAddress:(NGImap4EnvelopeAddress *)_address {
+  // TODO: make some web-link, eg open a new compose panel?
+  return [@"mailto:" stringByAppendingString:[_address baseEMail]];
+}
+
+- (NSString *)fromLink {
+  return [self linkToEnvelopeAddress:[[self envelope] from]];
+}
+- (NSString *)currentAddressLink {
+  return [self linkToEnvelopeAddress:[self currentAddress]];
+}
+
+@end /* UIxMailPartMessageViewer */
diff --git a/SOGo/UI/Mailer/UIxMailPartMessageViewer.wox b/SOGo/UI/Mailer/UIxMailPartMessageViewer.wox
new file mode 100644 (file)
index 0000000..6388d70
--- /dev/null
@@ -0,0 +1,77 @@
+<?xml version="1.0" standalone="yes"?>
+<div xmlns="http://www.w3.org/1999/xhtml"
+     xmlns:var="http://www.skyrix.com/od/binding"
+     class="linked_attachment_frame"
+>
+  <div class="linked_attachment_body">
+
+  <!-- TODO: the table is a DUP to UIxMailView, own component? -->
+  <table class="mailer_fieldtable">
+    <tr class="mailer_fieldrow">
+      <td class="mailer_fieldname" ><var:string label:value="Subject"/>:</td>
+      <td class="mailer_subjectfieldvalue">
+        <var:string value="envelope.subject"
+                    formatter="context.mailSubjectFormatter"/>
+<!--
+        <a var:href="pathToAttachment"
+           var:title="filenameForDisplay"
+           >(<var:string label:value="download" />)</a>
+-->
+      </td>
+    </tr>
+    <tr class="mailer_fieldrow">
+      <td class="mailer_fieldname" ><var:string label:value="From"/>:</td>
+      <td class="mailer_fieldvalue">
+        <!-- compose link? -->
+        <a var:href="fromLink">
+          <var:string value="envelope.from"
+               formatter="context.mailEnvelopeFullAddressFormatter" /></a>
+      </td>
+    </tr>
+    <tr class="mailer_fieldrow">
+      <td class="mailer_fieldname" ><var:string label:value="Date"/>:</td>
+      <td class="mailer_fieldvalue">
+        <var:string value="envelope.date" 
+                    formatter="context.mailDateFormatter"/>
+      </td>
+    </tr>
+
+    <tr class="mailer_fieldrow">
+      <td class="mailer_fieldname" ><var:string label:value="To"/>:</td>
+      <td class="mailer_fieldvalue">
+        <!-- compose link? -->
+        <var:foreach list="envelope.to" item="currentAddress">
+          <a var:href="currentAddressLink">
+            <var:string value="currentAddress"
+                 formatter="context.mailEnvelopeFullAddressFormatter" /></a>
+        </var:foreach>
+      </td>
+    </tr>
+    <var:if condition="envelope.hasCC">
+      <tr class="mailer_fieldrow">
+        <td class="mailer_fieldname" ><var:string label:value="CC"/>:</td>
+        <td class="mailer_fieldvalue">
+          <!-- compose link? -->
+          <var:foreach list="envelope.cc" item="currentAddress">
+          <a var:href="currentAddressLink">
+              <var:string value="currentAddress"
+                   formatter="context.mailEnvelopeFullAddressFormatter" /></a>
+            <br /> <!-- TODO: better to use li+CSS -->
+          </var:foreach>
+        </td>
+      </tr>
+    </var:if>
+  </table>
+  
+  <div class="mailer_mailcontent">
+    <var:component value="contentViewerComponent"
+                   bodyInfo="contentInfo" 
+                   partPath="contentPartPath" />
+  </div>
+
+<!-- debug
+    <pre><var:string value="envelope"/></pre>
+    <pre><var:string value="bodyInfo.body"/></pre>
+-->
+  </div>
+</div>
index 07fc1b34e048a1814f467722e08dac3c3d0070b5..c753854af001ad6b8a36b7347436892fae03264d 100644 (file)
   NSData   *content;
   
   if ((content = [self decodedFlatContent]) == nil) {
-    [self errorWithFormat:@"got no text content: %@", [self partPath]];
+    [self errorWithFormat:@"got no text content: %@", 
+           [[self partPath] componentsJoinedByString:@"."]];
     return nil;
   }
   
index e58aeec7914eee97051233d0e5862376283c1133..227622c927ccb59907de12f43dd3d5d588b7639d 100644 (file)
@@ -44,6 +44,7 @@
   WOComponent *textViewer;
   WOComponent *imageViewer;
   WOComponent *linkViewer;
+  WOComponent *messageViewer;
 }
 
 - (id)initWithViewer:(WOComponent *)_viewer context:(WOContext *)_ctx;
index 3885512a5b656d285848abb0c9bc408f202e2f37..758b499213a7366332ad27c16aebedb8af9d3177 100644 (file)
 
 - (void)dealloc {
   [self->alternativeViewer release];
-  [self->mixedViewer release];
-  [self->textViewer  release];
-  [self->imageViewer release];
-  [self->linkViewer  release];
+  [self->mixedViewer   release];
+  [self->textViewer    release];
+  [self->imageViewer   release];
+  [self->linkViewer    release];
+  [self->messageViewer release];
   [super dealloc];
 }
 
@@ -57,6 +58,7 @@
   [self->textViewer        release]; self->textViewer        = nil;
   [self->imageViewer       release]; self->imageViewer       = nil;
   [self->linkViewer        release]; self->linkViewer        = nil;
+  [self->messageViewer     release]; self->messageViewer     = nil;
 }
 
 /* fetching */
   return self->linkViewer;
 }
 
+- (WOComponent *)messageViewer {
+  if (self->messageViewer == nil) {
+    self->messageViewer = 
+      [[self->viewer pageWithName:@"UIxMailPartMessageViewer"] retain];
+  }
+  return self->messageViewer;
+}
+
 - (WOComponent *)viewerForBodyInfo:(id)_info {
   NSString *mt, *st;
 
   }
   else if ([mt isEqualToString:@"image"])
     return [self imageViewer];
+  else if ([mt isEqualToString:@"message"] && [st isEqualToString:@"rfc822"])
+    return [self messageViewer];
   else if ([mt isEqualToString:@"application"]) {
     /*
-      octed-stream (generate download link?)
+      octet-stream (generate download link?, autodetect type?)
       pgp-viewer
     */
   }
index 204419f791c82b19e91ce877250daf000896cb9c..ec6754fd989d8da5abf288ea174d01ee18920145 100644 (file)
@@ -34,6 +34,7 @@
 #include "WOContext+UIxMailer.h"
 #include <SoObjects/Mailer/SOGoMailObject.h>
 #include <NGImap4/NGImap4Envelope.h>
+#include <NGImap4/NGImap4EnvelopeAddress.h>
 #include "common.h"
 
 @implementation UIxMailView
   return s;
 }
 
+/* links (DUP to UIxMailPartViewer!) */
+
+- (NSString *)linkToEnvelopeAddress:(NGImap4EnvelopeAddress *)_address {
+  // TODO: make some web-link, eg open a new compose panel?
+  return [@"mailto:" stringByAppendingString:[_address baseEMail]];
+}
+
+- (NSString *)fromLink {
+  return [self linkToEnvelopeAddress:
+                [[self clientObject] fromEnvelopeAddress]];
+}
+- (NSString *)currentAddressLink {
+  return [self linkToEnvelopeAddress:[self currentAddress]];
+}
+
 /* fetching */
 
 - (id)message {
   NSArray  *parts;
   unsigned i, count;
   BOOL fetchPart;
+  id body;
   
   fetchPart = [self shouldFetchPartOfType:[_info valueForKey:@"type"]
                    subtype:[_info valueForKey:@"subtype"]];
     
     [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys];
   }
+  
+  /* check body */
+  
+  if ((body = [_info objectForKey:@"body"]) != nil) {
+    NSString *sp;
+
+    sp = [[body valueForKey:@"type"] lowercaseString];
+    if ([sp isEqualToString:@"multipart"])
+      sp = _p;
+    else
+      sp = [_p length] > 0 ? [_p stringByAppendingString:@".1"] : @"1";
+    [self addRequiredKeysOfStructure:body path:sp toArray:_keys];
+  }
 }
 
 - (NSArray *)contentFetchKeys {
index 80514f10e3360565284a8598a03aaa161fbb7769..bcd92b1d93738b94dbb877e682e4469172ba9951 100644 (file)
@@ -25,8 +25,7 @@
     <tr class="mailer_fieldrow">
       <td class="mailer_fieldname" ><var:string label:value="From"/>:</td>
       <td class="mailer_fieldvalue">
-        <!-- compose link? -->
-        <a href="#">
+        <a var:href="fromLink">
           <var:string value="clientObject.fromEnvelopeAddress"
                formatter="context.mailEnvelopeFullAddressFormatter" /></a>
       </td>
     <tr class="mailer_fieldrow">
       <td class="mailer_fieldname" ><var:string label:value="To"/>:</td>
       <td class="mailer_fieldvalue">
-        <!-- compose link? -->
         <var:foreach list="clientObject.toEnvelopeAddresses"
                      item="currentAddress">
-          <a href="#">
+          <a var:href="currentAddressLink">
             <var:string value="currentAddress"
                  formatter="context.mailEnvelopeFullAddressFormatter" /></a>
         </var:foreach>
       <tr class="mailer_fieldrow">
         <td class="mailer_fieldname" ><var:string label:value="CC"/>:</td>
         <td class="mailer_fieldvalue">
-          <!-- compose link? -->
           <var:foreach list="clientObject.ccEnvelopeAddresses" 
                        item="currentAddress">
-            <a href="#">
+            <a var:href="currentAddressLink">
               <var:string value="currentAddress"
                    formatter="context.mailEnvelopeFullAddressFormatter" /></a>
             <br /> <!-- TODO: better to use li+CSS -->
index 06f04de483fef78a68abbc47f71d50fef65af01a..73d914ae491ea2de0ad4bb940188f0aace8fe61d 100644 (file)
@@ -1,7 +1,8 @@
 # version file
 
-SUBMINOR_VERSION:=82
+SUBMINOR_VERSION:=84
 
+# v0.9.84 requires libNGMime        v4.5.209
 # v0.9.81 requires SoObjects/Sieve  v0.9.5
 # v0.9.80 requires SoObjects/Mailer v0.9.59
 # v0.9.78 requires SoObjects/Mailer v0.9.58