]> err.no Git - scalable-opengroupware.org/commitdiff
added fetching of the full MIME header to SOGoMailObject
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 17:13:46 +0000 (17:13 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 17:13:46 +0000 (17:13 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@833 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/README
SOGo/SoObjects/Mailer/SOGoMailObject.h
SOGo/SoObjects/Mailer/SOGoMailObject.m
SOGo/SoObjects/Mailer/Version
SOGo/UI/Templates/MailerUI/UIxMailListView.wox

index 06dde0eff7178fbc947caaa50fbb23b14a4cd9b7..fed53ccb899cdb37853dd4f3cdbdc94b77b1edb9 100644 (file)
@@ -1,5 +1,9 @@
 2005-07-19  Helge Hess  <helge.hess@opengroupware.org>
 
+       * SOGoMailObject.m: changed to fetch and parse the full mail header,
+         can be disabled using the 'SOGoDoNotFetchMailHeader' default. The
+         overhead is about 10ms on the dev-system (v0.9.113)
+
        * SOGoMailFolder.m: report NO in -isCreateAllowed when the folder is
          the INBOX and SOGoSpecialFoldersInRoot (altnamespace) is enabled
          (#1472) (v0.9.112)
index 9f1b4389e944ef7f5a46c7927f8de72e5917038d..8d0e5cc9b82ff698efa428319780d3394726d51c 100644 (file)
@@ -50,3 +50,9 @@ SOGoInternetMailSuffix     String-Pattern
         '"*** This email was composed using SOGo on the public Internet ***"'
     you can access request values inside the pattern, eg:
          "$headers.host$"
+
+SOGoDoNotFetchMailHeader   YES|NO - whether or not to fetch the mail header
+  - the mail header is ~4KB to fetch, a slowdown of ~13ms on the dev system
+  - the header gives much more information about the mail
+    - eg: spam status
+  - parsing the mail header takes time
index fc888cc143b85b1f701ca25a7d95c8969ebd4c5c..db7ab4ac003496ca7c351f804cb118b5e3b64fd7 100644 (file)
@@ -43,6 +43,7 @@
 @interface SOGoMailObject : SOGoMailBaseObject
 {
   id coreInfos;
+  id headerPart;
 }
 
 /* message */
index 713a1e9fa8a5bab84e67fc88c97de67c9e8dc3d9..d93688d7bfd0543c9661db046d13d7a3a6a24536 100644 (file)
 #include "SOGoMailBodyPart.h"
 #include <NGImap4/NGImap4Envelope.h>
 #include <NGImap4/NGImap4EnvelopeAddress.h>
+#include <NGMail/NGMimeMessageParser.h>
 #include "common.h"
 
 @implementation SOGoMailObject
 
 static NSArray *coreInfoKeys = nil;
 static BOOL heavyDebug         = NO;
+static BOOL fetchHeader        = YES;
 static BOOL debugOn            = NO;
 static BOOL debugBodyStructure = NO;
 static BOOL debugSoParts       = NO;
@@ -41,21 +43,39 @@ static BOOL debugSoParts       = NO;
 }
 
 + (void)initialize {
+  NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+  
   NSAssert2([super version] == 1,
             @"invalid superclass (%@) version %i !",
             NSStringFromClass([self superclass]), [super version]);
-
+  
+  if ((fetchHeader = ([ud boolForKey:@"SOGoDoNotFetchMailHeader"] ? NO : YES)))
+    NSLog(@"Note: fetching full mail header.");
+  else
+    NSLog(@"Note: not fetching full mail header: 'SOGoDoNotFetchMailHeader'");
+  
   /* Note: see SOGoMailManager.m for allowed IMAP4 keys */
   /* Note: "BODY" actually returns the structure! */
-  coreInfoKeys = [[NSArray alloc] initWithObjects:
-                                   @"FLAGS", @"ENVELOPE", @"BODY",
-                                   @"RFC822.SIZE",
-                                   // not yet supported: @"INTERNALDATE",
-                                 nil];
+  if (fetchHeader) {
+    coreInfoKeys = [[NSArray alloc] initWithObjects:
+                                     @"FLAGS", @"ENVELOPE", @"BODY",
+                                     @"RFC822.SIZE",
+                                     @"RFC822.HEADER",
+                                     // not yet supported: @"INTERNALDATE",
+                                   nil];
+  }
+  else {
+    coreInfoKeys = [[NSArray alloc] initWithObjects:
+                                     @"FLAGS", @"ENVELOPE", @"BODY",
+                                     @"RFC822.SIZE",
+                                     // not yet supported: @"INTERNALDATE",
+                                   nil];
+  }
 }
 
 - (void)dealloc {
-  [self->coreInfos release];
+  [self->headerPart release];
+  [self->coreInfos  release];
   [super dealloc];
 }
 
@@ -189,6 +209,36 @@ static BOOL debugSoParts       = NO;
   return [[self envelope] cc];
 }
 
+- (NSData *)mailHeaderData {
+  return [[self fetchCoreInfos] valueForKey:@"header"];
+}
+- (BOOL)hasMailHeaderInCoreInfos {
+  return [[self mailHeaderData] length] > 0 ? YES : NO;
+}
+
+- (NSDictionary *)mailHeader {
+  // TODO: cache
+  NGMimeMessageParser *parser;
+  NSData *data;
+  
+  if (self->headerPart != nil)
+    return [self->headerPart isNotNull] ? self->headerPart : nil;
+  
+  if ([(data = [self mailHeaderData]) length] == 0)
+    return nil;
+  
+  // TODO: do we need to set some delegate method which stops parsing the body?
+  parser = [[NGMimeMessageParser alloc] init];
+  self->headerPart = [[parser parsePartFromData:data] retain];
+  [parser release]; parser = nil;
+
+  if (self->headerPart == nil) {
+    self->headerPart = [[NSNull null] retain];
+    return nil;
+  }
+  return self->headerPart;
+}
+
 - (id)lookupInfoForBodyPart:(id)_path {
   NSEnumerator *pe;
   NSString *p;
index 493dfefc6ec64000c6fa409df8355f7d9baa71f8..66083a11241013b00acf2affa10dd4025ae0207e 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=112
+SUBMINOR_VERSION:=113
 
 # v0.9.111 requires libNGExtensions v4.5.163
 # v0.9.96  requires libNGMime       v4.5.223
index 418fdf86d6e76a7a93278fcf97401e49e29741cd..3dc615c5cebaea85c57db716d1ac60e1837b3b48 100644 (file)
               <input type="checkbox" var:name="msgRowID" value="0" 
                      onchange="toggleMailSelect(this)" />
             </td>
+            <!-- the td:onlick doesn't work on Safari -->
             <td var:class="messageCellStyleClass" var:onclick="clickedMsgJS">
               <div var:class="messageSubjectStyleClass" var:id="msgDivID">
-                <a href="#" var:onclick="clickedMsgJS">
+                <!-- removed anker (resulted in two clicks on Moz -->
+                <!-- a href="#" var:onclick="clickedMsgJS" -->
                   <!-- Note: var:href="messageViewURL" (done by JS),
                              var:target="messageViewTarget" -->
                   <var:string value="message.envelope.subject"
                               formatter="context.mailSubjectFormatter"/>
-                </a>
+                <!-- /a -->
               </div>
             </td>
             <td var:class="messageCellStyleClass" var:onclick="clickedMsgJS">