diff --git a/ChangeLog b/ChangeLog index c15dba2ad..729a3e9e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-02-08 Wolfgang Sourdeau + * SoObjects/Mailer/SOGoMailBaseObject.m ([SOGoMailBaseObject + -isBodyPartKey:key]): hacked a little bit to test for the length + of the key trimmed from its bordering digits. So if the key + contains only digits, we consider it to be a body part key. There + is room for improvement but we can consider this will be accurate + in 99.99% of the cases. Also, removed the context parameter which + was useless. + * SoObjects/SOGo/SOGoObject.m ([SOGoObject -davComplianceClassesInContext:localContext]): new method, declaring "access-control" in the compliance classes. diff --git a/SoObjects/Mailer/SOGoMailBaseObject.h b/SoObjects/Mailer/SOGoMailBaseObject.h index 1faecb77f..8d5967429 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.h +++ b/SoObjects/Mailer/SOGoMailBaseObject.h @@ -74,7 +74,7 @@ /* IMAP4 names */ -- (BOOL) isBodyPartKey: (NSString *) _key inContext: (id) _ctx; +- (BOOL) isBodyPartKey: (NSString *) key; @end diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index ebe594625..cfeda797f 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -19,6 +19,9 @@ 02111-1307, USA. */ +#import +#import + #import #import #import @@ -205,18 +208,15 @@ static BOOL debugOn = YES; /* IMAP4 names */ -- (BOOL)isBodyPartKey:(NSString *)_key inContext:(id)_ctx { - /* - Every key starting with a digit is considered an IMAP4 mime part key, used in - SOGoMailObject and SOGoMailBodyPart. - */ - if ([_key length] == 0) - return NO; - - if (isdigit([_key characterAtIndex:0])) - return YES; - - return NO; +#warning we could improve this by simply testing if the reference is the filename of an attachment or if the body part mentionned actually exists in the list of body parts. Another way is to use a prefix such as "attachment-*" to declare attachments. +- (BOOL) isBodyPartKey: (NSString *) key +{ + NSString *trimmedKey; + + trimmedKey = [key stringByTrimmingCharactersInSet: + [NSCharacterSet decimalDigitCharacterSet]]; + + return (![trimmedKey length]); } - (NSArray *) aclsForUser: (NSString *) uid diff --git a/SoObjects/Mailer/SOGoMailBodyPart.m b/SoObjects/Mailer/SOGoMailBodyPart.m index 970abbb8d..3afd10e07 100644 --- a/SoObjects/Mailer/SOGoMailBodyPart.m +++ b/SoObjects/Mailer/SOGoMailBodyPart.m @@ -206,7 +206,7 @@ static BOOL debugOn = NO; if (!obj) { /* lookup body part */ - if ([self isBodyPartKey:_key inContext:_ctx]) + if ([self isBodyPartKey:_key]) obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]; else if ([_key isEqualToString: @"asAttachment"]) [self setAsAttachment]; diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index ec0c28036..d1493a505 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -866,7 +866,7 @@ static BOOL debugSoParts = NO; /* lookup body part */ - if ([self isBodyPartKey:_key inContext:_ctx]) { + if ([self isBodyPartKey:_key]) { if ((obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]) != nil) { if (debugSoParts) [self logWithFormat: @"mail looked up part %@: %@", _key, obj];