mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-12 10:23:19 +00:00
Monotone-Parent: a164259525f718f804b625a9f09b4c3b3c9e83f8
Monotone-Revision: 11f4bdac420d36e45b12ca5d1d393ec34f43c609 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-10T00:02:30 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -62,6 +62,8 @@
|
||||
|
||||
+ (Class) bodyPartClassForKey: (NSString *) _key
|
||||
inContext: (id) _ctx;
|
||||
+ (Class) bodyPartClassForMimeType: (NSString *) mimeType
|
||||
inContext: (id) _ctx;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#import <NGExtensions/NGBase64Coding.h>
|
||||
#import <NGImap4/NGImap4Connection.h>
|
||||
|
||||
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
||||
|
||||
#import "SOGoMailObject.h"
|
||||
#import "SOGoMailManager.h"
|
||||
|
||||
@@ -305,7 +307,9 @@ static BOOL debugOn = NO;
|
||||
|
||||
/* factory */
|
||||
|
||||
+ (Class)bodyPartClassForKey:(NSString *)_key inContext:(id)_ctx {
|
||||
+ (Class) bodyPartClassForKey: (NSString *) _key
|
||||
inContext: (id) _ctx
|
||||
{
|
||||
NSString *pe;
|
||||
|
||||
pe = [_key pathExtension];
|
||||
@@ -335,6 +339,36 @@ static BOOL debugOn = NO;
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (Class) bodyPartClassForMimeType: (NSString *) mimeType
|
||||
inContext: (id) _ctx
|
||||
{
|
||||
NSString *classString;
|
||||
Class klazz;
|
||||
|
||||
if ([mimeType isEqualToString: @"image/gif"]
|
||||
|| [mimeType isEqualToString: @"image/png"]
|
||||
|| [mimeType isEqualToString: @"image/jpg"])
|
||||
classString = @"SOGoImageMailBodyPart";
|
||||
else if ([mimeType isEqualToString: @"text/calendar"])
|
||||
classString = @"SOGoCalendarMailBodyPart";
|
||||
else if ([mimeType isEqualToString: @"text/x-vcard"])
|
||||
classString = @"SOGoVCardMailBodyPart";
|
||||
else if ([mimeType isEqualToString: @"message/rfc822"])
|
||||
classString = @"SOGoMessageMailBodyPart";
|
||||
else
|
||||
{
|
||||
NSLog (@"unhandled mime type: '%@'", mimeType);
|
||||
classString = nil;
|
||||
}
|
||||
|
||||
if (classString)
|
||||
klazz = NSClassFromString (classString);
|
||||
else
|
||||
klazz = Nil;
|
||||
|
||||
return klazz;
|
||||
}
|
||||
|
||||
/* etag support */
|
||||
|
||||
- (id)davEntityTag {
|
||||
|
||||
@@ -735,8 +735,22 @@ static BOOL debugSoParts = NO;
|
||||
{
|
||||
// TODO: we might want to check for existence prior controller creation
|
||||
Class clazz;
|
||||
|
||||
clazz = [SOGoMailBodyPart bodyPartClassForKey:_key inContext:_ctx];
|
||||
NSArray *parts;
|
||||
int part;
|
||||
NSDictionary *partDesc;
|
||||
NSString *mimeType;
|
||||
|
||||
parts = [[self bodyStructure] objectForKey: @"parts"];
|
||||
part = [_key intValue] - 1;
|
||||
if (part > -1 && part < [parts count])
|
||||
{
|
||||
partDesc = [parts objectAtIndex: part];
|
||||
mimeType = [[partDesc keysWithFormat: @"%{type}/%{subtype}"] lowercaseString];
|
||||
clazz = [SOGoMailBodyPart bodyPartClassForMimeType: mimeType
|
||||
inContext: _ctx];
|
||||
}
|
||||
else
|
||||
clazz = Nil;
|
||||
|
||||
return [clazz objectWithName:_key inContainer: self];
|
||||
}
|
||||
@@ -755,7 +769,7 @@ static BOOL debugSoParts = NO;
|
||||
|
||||
if ([self isBodyPartKey:_key inContext:_ctx]) {
|
||||
if ((obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]) != nil) {
|
||||
if (debugSoParts)
|
||||
if (debugSoParts)
|
||||
[self logWithFormat: @"mail looked up part %@: %@", _key, obj];
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user