From cc60c63645eb1f8914a7c0ebf55258366b0cc752 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Sat, 9 Aug 2008 08:20:49 +0000 Subject: [PATCH] Monotone-Parent: 9bf93635e40d613a05f206aeb8112565d864bdcd Monotone-Revision: 975188efc102040c8f1f704d2084d9798480bcb8 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-08-09T08:20:49 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ SoObjects/Mailer/SOGoMailBodyPart.m | 36 ++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5e52982e..53878fcb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-08-09 Wolfgang Sourdeau + * SoObjects/Mailer/SOGoMailBodyPart.m ([SOGoMailBodyPart + -lookupImap4BodyPartKey:inContext:]): find a class based on the + mime type of the subpart described by the partInfo. + * SoObjects/Appointments/iCalEntityObject+SOGo.m ([iCalEntityObject -quickRecordDateAsNumber:_datewithOffset:offsetforAllDay:allDay]): diff --git a/SoObjects/Mailer/SOGoMailBodyPart.m b/SoObjects/Mailer/SOGoMailBodyPart.m index 38671f819..41f14a6b2 100644 --- a/SoObjects/Mailer/SOGoMailBodyPart.m +++ b/SoObjects/Mailer/SOGoMailBodyPart.m @@ -149,15 +149,35 @@ static BOOL debugOn = NO; /* name lookup */ -- (id) lookupImap4BodyPartKey: (NSString *) _key - inContext: (id) _ctx +- (id) lookupImap4BodyPartKey: (NSString *) key + inContext: (WOContext *) localContext { // TODO: we might want to check for existence prior controller creation Class clazz; - - clazz = [SOGoMailBodyPart bodyPartClassForKey:_key inContext:_ctx]; + NSArray *subParts; + unsigned int nbr; + id obj; + NSDictionary *subPart; - return [clazz objectWithName: _key inContainer: self]; + nbr = [key intValue]; + subParts = [[self partInfo] objectForKey: @"parts"]; + if (nbr > 0 && nbr < ([subParts count] + 1)) + { + subPart = [subParts objectAtIndex: nbr - 1]; + clazz + = [[self class] bodyPartClassForMimeType: + [subPart keysWithFormat: @"%{type}/%{subtype}"] + inContext: localContext]; + obj = [clazz objectWithName: key inContainer: self]; + } + else + obj = self; + + return obj; +// clazz = [SOGoMailBodyPart bodyPartClassForKey: _key +// inContext: _ctx]; + +// return [clazz objectWithName: _key inContainer: self]; } - (NSString *) filename @@ -200,14 +220,14 @@ static BOOL debugOn = NO; acquire: (BOOL) _flag { id obj; - + /* first check attributes directly bound to the application */ obj = [super lookupName:_key inContext:_ctx acquire:NO]; if (!obj) { /* lookup body part */ - if ([self isBodyPartKey:_key]) - obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]; + if ([self isBodyPartKey: _key]) + obj = [self lookupImap4BodyPartKey: _key inContext: _ctx]; else if ([_key isEqualToString: @"asAttachment"]) [self setAsAttachment]; /* should check whether such a filename exist in the attached names */