From 035e0b8e7e8fa9953a3f067ebee741cab083097c Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 22 Aug 2007 15:14:36 +0000 Subject: [PATCH] Monotone-Parent: 5efb21ecdb824936262ea685cfa5c21f94b0a7a3 Monotone-Revision: f91da4057972f6c2f3979c2fccecfa757ae6619c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-08-22T15:14:36 Monotone-Branch: ca.inverse.sogo --- SoObjects/Mailer/SOGoMailObject.h | 2 + SoObjects/Mailer/SOGoMailObject.m | 99 +++++++++++++++++++++---------- 2 files changed, 69 insertions(+), 32 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailObject.h b/SoObjects/Mailer/SOGoMailObject.h index 2dd21d42b..c81e4103d 100644 --- a/SoObjects/Mailer/SOGoMailObject.h +++ b/SoObjects/Mailer/SOGoMailObject.h @@ -63,6 +63,8 @@ - (NSArray *)toEnvelopeAddresses; - (NSArray *)ccEnvelopeAddresses; +- (NSDictionary *) mailHeaders; + - (id)bodyStructure; - (id)lookupInfoForBodyPart:(id)_path; diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index c99b1b0b3..0f152a4fc 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -325,7 +325,8 @@ static BOOL debugSoParts = NO; return headers; } -- (id)lookupInfoForBodyPart:(id)_path { +- (id) lookupInfoForBodyPart: (id) _path +{ NSEnumerator *pe; NSString *p; id info; @@ -392,7 +393,8 @@ static BOOL debugSoParts = NO; /* content */ -- (NSData *)content { +- (NSData *) content +{ NSData *content; id result, fullResult; @@ -611,13 +613,15 @@ static BOOL debugSoParts = NO; return flatContents; } -- (NSDictionary *)fetchPlainTextParts { +- (NSDictionary *) fetchPlainTextParts +{ return [self fetchPlainTextParts:[self plainTextContentFetchKeys]]; } /* convert parts to strings */ -- (NSString *)stringForData:(NSData *)_data partInfo:(NSDictionary *)_info +- (NSString *) stringForData: (NSData *) _data + partInfo: (NSDictionary *) _info { NSString *charset, *encoding, *s; NSData *mailData; @@ -650,7 +654,8 @@ static BOOL debugSoParts = NO; return s; } -- (NSDictionary *)stringifyTextParts:(NSDictionary *)_datas { +- (NSDictionary *) stringifyTextParts: (NSDictionary *) _datas +{ NSMutableDictionary *md; NSEnumerator *keys; NSString *key; @@ -667,7 +672,9 @@ static BOOL debugSoParts = NO; } return md; } -- (NSDictionary *)fetchPlainTextStrings:(NSArray *)_fetchKeys { + +- (NSDictionary *) fetchPlainTextStrings: (NSArray *) _fetchKeys +{ /* The fetched parts are NSData objects, this method converts them into NSString objects based on the information inside the bodystructure. @@ -723,7 +730,10 @@ static BOOL debugSoParts = NO; return [clazz objectWithName:_key inContainer: self]; } -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { +- (id) lookupName: (NSString *) _key + inContext: (id) _ctx + acquire: (BOOL) _flag +{ id obj; /* first check attributes directly bound to the application */ @@ -747,34 +757,41 @@ static BOOL debugSoParts = NO; /* WebDAV */ -- (BOOL)davIsCollection { +- (BOOL) davIsCollection +{ /* while a mail has child objects, it should appear as a file in WebDAV */ return NO; } -- (id)davContentLength { +- (id) davContentLength +{ return [[self fetchCoreInfos] valueForKey: @"size"]; } -- (NSDate *)davCreationDate { +- (NSDate *) davCreationDate +{ // TODO: use INTERNALDATE once NGImap4 supports that return nil; } -- (NSDate *)davLastModified { + +- (NSDate *) davLastModified +{ return [self davCreationDate]; } -- (NSException *)davMoveToTargetObject:(id)_target newName:(NSString *)_name - inContext:(id)_ctx +- (NSException *) davMoveToTargetObject: (id) _target + newName: (NSString *) _name + inContext: (id)_ctx { [self logWithFormat: @"TODO: should move mail as '%@' to: %@", _name, _target]; - return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */ + return [NSException exceptionWithHTTPStatus: 501 /* Not Implemented */ reason: @"not implemented"]; } -- (NSException *)davCopyToTargetObject:(id)_target newName:(NSString *)_name - inContext:(id)_ctx +- (NSException *) davCopyToTargetObject: (id) _target + newName: (NSString *) _name + inContext: (id)_ctx { /* Note: this is special because we create SOGoMailObject's even if they do @@ -798,7 +815,8 @@ static BOOL debugSoParts = NO; /* actions */ -- (id)GETAction:(id)_ctx { +- (id) GETAction: (id) _ctx +{ NSException *error; WOResponse *r; NSData *content; @@ -828,7 +846,8 @@ static BOOL debugSoParts = NO; /* operations */ -- (NSException *)trashInContext:(id)_ctx { +- (NSException *) trashInContext: (id) _ctx +{ /* Trashing is three actions: a) copy to trash folder @@ -938,7 +957,8 @@ static BOOL debugSoParts = NO; return nil; } -- (NSException *)delete { +- (NSException *) delete +{ /* Note: delete is different to DELETEAction: for mails! The 'delete' runs either flags a message as deleted or moves it to the Trash while @@ -953,7 +973,9 @@ static BOOL debugSoParts = NO; error = [[self imap4Connection] markURLDeleted:[self imap4URL]]; return error; } -- (id)DELETEAction:(id)_ctx { + +- (id) DELETEAction: (id) _ctx +{ NSException *error; // TODO: ensure safe HTTP method @@ -969,7 +991,8 @@ static BOOL debugSoParts = NO; /* some mail classification */ -- (BOOL)isKolabObject { +- (BOOL) isKolabObject +{ NSDictionary *h; if ((h = [self mailHeaders]) != nil) @@ -980,7 +1003,8 @@ static BOOL debugSoParts = NO; return NO; } -- (BOOL)isMailingListMail { +- (BOOL) isMailingListMail +{ NSDictionary *h; if ((h = [self mailHeaders]) == nil) @@ -989,7 +1013,8 @@ static BOOL debugSoParts = NO; return [[h objectForKey: @"list-id"] isNotEmpty]; } -- (BOOL)isVirusScanned { +- (BOOL) isVirusScanned +{ NSDictionary *h; if ((h = [self mailHeaders]) == nil) @@ -1000,8 +1025,8 @@ static BOOL debugSoParts = NO; return YES; } -- (NSString *)scanListHeaderValue:(id)_value - forFieldWithPrefix:(NSString *)_prefix +- (NSString *) scanListHeaderValue: (id) _value + forFieldWithPrefix: (NSString *) _prefix { /* Note: not very tolerant on embedded commands and <> */ // TODO: does not really belong here, should be a header-field-parser @@ -1047,17 +1072,22 @@ static BOOL debugSoParts = NO; return _value; } -- (NSString *)mailingListArchiveURL { +- (NSString *) mailingListArchiveURL +{ return [self scanListHeaderValue: [[self mailHeaders] objectForKey: @"list-archive"] forFieldWithPrefix: @"