]> err.no Git - scalable-opengroupware.org/commitdiff
some fixes to attachment name escaping, added type specific body part objects
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 30 Jan 2005 21:38:25 +0000 (21:38 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 30 Jan 2005 21:38:25 +0000 (21:38 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@510 d1b88da0-ebda-0310-925b-ed51d893ca5b

15 files changed:
SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/GNUmakefile
SOGo/SoObjects/Mailer/SOGoImageMailBodyPart.m [new file with mode: 0644]
SOGo/SoObjects/Mailer/SOGoMailBodyPart.h
SOGo/SoObjects/Mailer/SOGoMailBodyPart.m
SOGo/SoObjects/Mailer/SOGoMailObject.m
SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m [new file with mode: 0644]
SOGo/SoObjects/Mailer/Version
SOGo/SoObjects/Mailer/product.plist
SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m
SOGo/UI/Mailer/ChangeLog
SOGo/UI/Mailer/UIxMailPartImageViewer.m
SOGo/UI/Mailer/UIxMailPartLinkViewer.m
SOGo/UI/Mailer/UIxMailPartViewer.m
SOGo/UI/Mailer/Version

index 3b7289169bb56d6b5962c57228d60248657168db..0f90c473b1fac386d407c963ffb831d2df58bbfb 100644 (file)
@@ -1,5 +1,10 @@
 2005-01-30  Helge Hess  <helge.hess@opengroupware.org>
-       
+
+       * v0.9.61
+
+       * SOGoMailObject.m, SOGoMailBodyPart.m, product.plist: added type
+         specific SOGoMailBodyPart controller objects, reduced debug logs
+
        * v0.9.60
        
        * SOGoDraftObject.m: added -content and -contentAsString methods (Note:
index c594750fcb0daa3796f0de49ff500b9e52f36a6e..1e6ae666157a1da8b6a1c1385f5dfcc3f7adc98d 100644 (file)
@@ -17,7 +17,10 @@ Mailer_OBJC_FILES += \
        SOGoMailAccount.m               \
        SOGoMailFolder.m                \
        SOGoMailObject.m                \
+       \
        SOGoMailBodyPart.m              \
+       SOGoImageMailBodyPart.m         \
+       SOGoMessageMailBodyPart.m       \
        \
        SOGoDraftsFolder.m              \
        SOGoDraftObject.m               \
diff --git a/SOGo/SoObjects/Mailer/SOGoImageMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoImageMailBodyPart.m
new file mode 100644 (file)
index 0000000..3a4f1a5
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+  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 <Mailer/SOGoMailBodyPart.h>
+
+/*
+  SOGoImageMailBodyPart
+  
+  A specialized SOGoMailBodyPart subclass for image attachments. Can be used
+  to attach special SoMethods.
+
+  See the superclass for more information on part objects.
+*/
+
+@interface SOGoImageMailBodyPart : SOGoMailBodyPart
+{
+}
+
+@end
+
+#include "common.h"
+
+@implementation SOGoImageMailBodyPart
+@end /* SOGoImageMailBodyPart */
index 815d78f5288248739af77f4a97e34d765218a197..7a996ebd660ee8df14066c9d3f5228f7b6daa397 100644 (file)
 
 - (id)partInfo;
 
+/* factory */
+
++ (Class)bodyPartClassForKey:(NSString *)_key inContext:(id)_ctx;
+
 @end
 
 #endif /* __Mailer_SOGoMailBodyPart_H__ */
index 4ced6a48a2aa04ef80d4880f7ace96e86cc5ff7c..61873b8c48dfe8a5c27c697a6420f9ebe7607e2f 100644 (file)
@@ -26,6 +26,8 @@
 
 @implementation SOGoMailBodyPart
 
+static BOOL debugOn = NO;
+
 - (void)dealloc {
   [self->partInfo   release];
   [self->identifier release];
 
 - (id)lookupImap4BodyPartKey:(NSString *)_key inContext:(id)_ctx {
   // TODO: we might want to check for existence prior controller creation
-  // TODO: we might(should?) want to create type-specific body-part objects
-  return [[[SOGoMailBodyPart alloc] initWithName:_key 
-                                   inContainer:self] autorelease];
+  Class clazz;
+  
+  clazz = [SOGoMailBodyPart bodyPartClassForKey:_key inContext:_ctx];
+  return [[[clazz alloc] initWithName:_key inContainer:self] autorelease];
 }
 
 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
   return r;
 }
 
+/* factory */
+
++ (Class)bodyPartClassForKey:(NSString *)_key inContext:(id)_ctx {
+  NSString *pe;
+  
+  pe = [_key pathExtension];
+  if (![pe isNotNull] || [pe length] == 0)
+    return self;
+  
+  /* hard coded for now */
+  
+  switch ([pe length]) {
+  case 3:
+    if ([pe isEqualToString:@"gif"] ||
+       [pe isEqualToString:@"png"] ||
+       [pe isEqualToString:@"jpg"])
+      return NSClassFromString(@"SOGoImageMailBodyPart");
+  case 4:
+    if ([pe isEqualToString:@"mail"])
+      return NSClassFromString(@"SOGoMessageMailBodyPart");
+  default:
+    return self;
+  }
+}
+
+/* debugging */
+
+- (BOOL)isDebuggingEnabled {
+  return debugOn;
+}
+
 @end /* SOGoMailBodyPart */
index 4315009163b75dd176d7c9dc3d3e45b0faa5abd1..f87e20b6819ac26bb8d0995ef7e7f92d798d9a21 100644 (file)
@@ -30,6 +30,7 @@
 
 static NSArray *coreInfoKeys = nil;
 static BOOL heavyDebug = NO;
+static BOOL debugOn = NO;
 
 + (void)initialize {
   /* Note: see SOGoMailManager.m for allowed IMAP4 keys */
@@ -184,7 +185,7 @@ static BOOL heavyDebug = NO;
     unsigned idx;
     NSArray  *parts;
     
-    [self logWithFormat:@"check PATH: %@", p];
+    [self debugWithFormat:@"check PATH: %@", p];
     idx = [p intValue] - 1;
     
     parts = [info valueForKey:@"parts"];
@@ -274,8 +275,10 @@ static BOOL heavyDebug = NO;
 
 - (id)lookupImap4BodyPartKey:(NSString *)_key inContext:(id)_ctx {
   // TODO: we might want to check for existence prior controller creation
-  return [[[SOGoMailBodyPart alloc] initWithName:_key 
-                                   inContainer:self] autorelease];
+  Class clazz;
+  
+  clazz = [SOGoMailBodyPart bodyPartClassForKey:_key inContext:_ctx];
+  return [[[clazz alloc] initWithName:_key inContainer:self] autorelease];
 }
 
 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
@@ -343,4 +346,10 @@ static BOOL heavyDebug = NO;
                             password:[self imap4Password]];
 }
 
+/* debugging */
+
+- (BOOL)isDebuggingEnabled {
+  return debugOn;
+}
+
 @end /* SOGoMailObject */
diff --git a/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m
new file mode 100644 (file)
index 0000000..90e0377
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+  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 <Mailer/SOGoMailBodyPart.h>
+
+/*
+  SOGoMessageMailBodyPart
+  
+  A specialized SOGoMailBodyPart subclass for message attachments. Can be used
+  to attach special SoMethods.
+  
+  See the superclass for more information on part objects.
+*/
+
+@interface SOGoMessageMailBodyPart : SOGoMailBodyPart
+{
+}
+
+@end
+
+#include "common.h"
+
+@implementation SOGoMessageMailBodyPart
+@end /* SOGoMessageMailBodyPart */
index 563de9bc5f687eccf0e2f019f764372e39436abf..fed4e8c1dae8fe6e3b13bbb33d93a3841bc8932c 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=59
+SUBMINOR_VERSION:=61
 
 # v0.9.55 requires NGExtensions v4.5.136
 # v0.9.44 requires libNGMime    v4.3.194
index 16bc55b6fd2c665f2017c635e293c7528cdb33df..5ca398aa9d02cac551f07eb37388b436157c9a38 100644 (file)
@@ -34,6 +34,9 @@
     SOGoMailBodyPart = {
       superclass    = "SOGoMailBaseObject";
     };
+    SOGoImageMailBodyPart = {
+      superclass    = "SOGoMailBodyPart";
+    };
 
     SOGoDraftsFolder = {
       superclass    = "SOGoMailBaseObject";
index eebc5df9a1abe391466e3d7d3d6d36e9ce2149b1..b874a6db37e231f889eb004d4498462b39db1a16 100644 (file)
@@ -51,7 +51,6 @@
   
   /* Note: valueForKey:@"reason" does not work?! */
   reason = [[_result valueForKey:@"RawResponse"] objectForKey:@"reason"];
-  [self logWithFormat:@"REASON: %@", reason];
   if (![reason isNotNull])
     reason = @"Failed to upload Sieve script.";
   
index 04b698ecc426de6ff049b1269a6c4a3da4443492..8c594df043f7b49077825a34898643bcf9ace920 100644 (file)
@@ -1,4 +1,12 @@
 2005-01-30  Helge Hess  <helge.hess@opengroupware.org>
+
+       * v0.9.82
+       
+       * UIxMailPartLinkViewer.m: prefix filenames which start with a digit,
+         properly escape attachment names
+
+       * UIxMailPartImageViewer.m (UIxMailPartViewer): append image extension
+         to attachments
        
        * v0.9.81
        
index 1dc4b7d38bba78d1f0b27b49b496281381062c45..deb7252edab45623c428480f9ba6a720a5f4de2a 100644 (file)
 
 @implementation UIxMailPartImageViewer
 
-- (void)dealloc {
-  [super dealloc];
-}
-
 /* URLs */
 
 - (NSString *)pathToImage {
   NSString *url;
+  NSString *s;
   
   url = [[self clientObject] baseURLInContext:[self context]];
   if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"];
-  return [url stringByAppendingString:
-               [[self partPath] componentsJoinedByString:@"/"]];
+
+  s = [[self partPath] componentsJoinedByString:@"/"];
+  url = [url stringByAppendingString:s];
+
+  if ((s = [self preferredPathExtension]) != nil) {
+    url = [url stringByAppendingString:@"."];
+    url = [url stringByAppendingString:s];
+  }
+  
+  return url;
 }
 
 @end /* UIxMailPartImageViewer */
index b43395f0f35cfec871fd3dbd8667378f19de38a7..16574e1b8919c44422fa6a8e72c20dc40cec2cc1 100644 (file)
@@ -58,7 +58,9 @@
 /* URLs */
 
 - (NSString *)pathToAttachment {
-  NSString *url, *n;
+  NSString *url, *n, *pext;
+
+  pext = [self preferredPathExtension];
 
   /* path to mail controller object */
   
   
   n = [[self partPath] componentsJoinedByString:@"/"];
   url = [url stringByAppendingString:n];
+  if ([pext isNotNull] && [pext length] > 0) {
+    /* attach extension */
+    url = [url stringByAppendingString:@"."];
+    url = [url stringByAppendingString:pext];
+  }
   
   /* 
      If we have an attachment name, we attach it, this is properly handled by
      SOGoMailBodyPart.
   */
   
-  n = [[[self bodyInfo] valueForKey:@"parameterList"] valueForKey:@"name"];
+  n = [self filenameForDisplay];
   if ([n isNotNull] && [n length] > 0) {
     url = [url stringByAppendingString:@"/"];
-    url = [url stringByAppendingString:n];
-  }
-  else if ([(n = [[self bodyInfo] valueForKey:@"type"]) isNotNull]) {
-    /* attach extension */
-    url = [url stringByAppendingString:@"."];
-    url = [url stringByAppendingString:[self preferredPathExtension]];
+    if (isdigit([n characterAtIndex:0]))
+      url = [url stringByAppendingString:@"fn-"];
+    url = [url stringByAppendingString:[n stringByEscapingURL]];
+    
+    // TODO: should we check for a proper extension?
   }
   
   return url;
index 6a174ee0fa112b1fe1d0205a15c10c4ad24cbf2d..07fc1b34e048a1814f467722e08dac3c3d0070b5 100644 (file)
     if ([_st isEqualToString:@"plain"]) return @"txt";
     if ([_st isEqualToString:@"xml"])   return @"xml";
   }
+  else if ([_mt isEqualToString:@"message"]) {
+    if ([_st isEqualToString:@"rfc822"]) return @"mail";
+  }
   else if ([_mt isEqualToString:@"application"]) {
     if ([_st isEqualToString:@"pdf"]) return @"pdf";
   }
   tmp = [tmp valueForKey:@"name"];
   if (![tmp isNotNull])
     return nil;
+  if ([tmp length] == 0)
+    return nil;
   
-  return [tmp length] > 0 ? tmp : nil;
+  return tmp;
 }
 
 - (NSString *)filenameForDisplay {
index e846368e81f44c2d315cc7779349cd3920f14010..06f04de483fef78a68abbc47f71d50fef65af01a 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=81
+SUBMINOR_VERSION:=82
 
 # v0.9.81 requires SoObjects/Sieve  v0.9.5
 # v0.9.80 requires SoObjects/Mailer v0.9.59