From 578d84b216b464f0e3563c772846715284c11e71 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 9 Aug 2007 20:58:17 +0000 Subject: [PATCH] Monotone-Parent: c0ec14b4c60cfc5b596b0425aed3a014bc69e18e Monotone-Revision: 890780f417605e8803bbe725196d6f559c8a11c7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-08-09T20:58:17 Monotone-Branch: ca.inverse.sogo --- SoObjects/Mailer/SOGoDraftObject.h | 25 ++++++------ SoObjects/Mailer/SOGoDraftObject.m | 62 +++--------------------------- 2 files changed, 18 insertions(+), 69 deletions(-) diff --git a/SoObjects/Mailer/SOGoDraftObject.h b/SoObjects/Mailer/SOGoDraftObject.h index 1292c5085..2995f7227 100644 --- a/SoObjects/Mailer/SOGoDraftObject.h +++ b/SoObjects/Mailer/SOGoDraftObject.h @@ -48,34 +48,33 @@ /* contents */ -- (NSDictionary *)fetchInfo; -- (NSException *)storeInfo:(NSDictionary *)_info; +- (NSDictionary *) fetchInfo; +- (NSException *) storeInfo: (NSDictionary *) _info; /* attachments */ -- (NSArray *)fetchAttachmentNames; -- (BOOL)isValidAttachmentName:(NSString *)_name; -- (NSException *) saveAttachment: (NSData *)_attach +- (NSArray *) fetchAttachmentNames; +- (BOOL) isValidAttachmentName: (NSString *) _name; +- (NSException *) saveAttachment: (NSData *) _attach withMetadata: (NSDictionary *) metadata; -- (NSException *)deleteAttachmentWithName:(NSString *)_name; +- (NSException *) deleteAttachmentWithName: (NSString *) _name; /* NGMime representations */ -- (NGMimeMessage *)mimeMessage; +- (NGMimeMessage *) mimeMessage; -- (NSString *)saveMimeMessageToTemporaryFile; -- (NSString *)saveMimeMessageToTemporaryFileWithHeaders:(NSDictionary *)_addh; -- (NSException *)sendMimeMessageAtPath:(NSString *)_path; +- (NSString *) saveMimeMessageToTemporaryFile; +- (NSString *) saveMimeMessageToTemporaryFileWithHeaders:(NSDictionary *)_addh; -- (NSException *)sendMail; +- (NSException *) sendMail; /* operations */ -- (NSException *)delete; +- (NSException *) delete; /* fake being a SOGoMailObject */ -- (id)fetchParts:(NSArray *)_parts; +- (id) fetchParts: (NSArray *) _parts; @end diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 999e1f32b..1d627aba1 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -41,7 +41,6 @@ #import #import #import -#import #import #import #import @@ -49,6 +48,7 @@ #import #import +#import #import "SOGoDraftObject.h" @@ -785,60 +785,8 @@ static BOOL showTextAttachmentsInline = NO; return ma; } -- (NSString *) _rawSender +- (NSException *) sendMail { - NSString *startEmail, *rawSender; - NSRange delimiter; - - startEmail = [self sender]; - delimiter = [startEmail rangeOfString: @"<"]; - if (delimiter.location == NSNotFound) - rawSender = startEmail; - else - { - rawSender = [startEmail substringFromIndex: NSMaxRange (delimiter)]; - delimiter = [rawSender rangeOfString: @">"]; - if (delimiter.location != NSNotFound) - rawSender = [rawSender substringToIndex: delimiter.location]; - } - - return rawSender; -} - -- (NSException *)sendMimeMessageAtPath:(NSString *)_path { - static NGSendMail *mailer = nil; - NSArray *recipients; - NSString *from; - - /* validate */ - - recipients = [self allRecipients]; - from = [self _rawSender]; - if ([recipients count] == 0) { - return [NSException exceptionWithHTTPStatus:500 /* server error */ - reason:@"draft has no recipients set!"]; - } - if ([from length] == 0) { - return [NSException exceptionWithHTTPStatus:500 /* server error */ - reason:@"draft has no sender (from) set!"]; - } - - /* setup mailer object */ - - if (mailer == nil) - mailer = [[NGSendMail sharedSendMail] retain]; - if (![mailer isSendMailAvailable]) { - [self errorWithFormat:@"missing sendmail binary!"]; - return [NSException exceptionWithHTTPStatus:500 /* server error */ - reason:@"did not find sendmail binary!"]; - } - - /* send mail */ - - return [mailer sendMailAtPath:_path toRecipients:recipients sender:from]; -} - -- (NSException *)sendMail { NSException *error; NSString *tmpPath; @@ -851,8 +799,10 @@ static BOOL showTextAttachmentsInline = NO; } /* send mail */ - error = [self sendMimeMessageAtPath:tmpPath]; - + error = [[SOGoMailer sharedMailer] sendMailAtPath: tmpPath + toRecipients: [self allRecipients] + sender: [self sender]]; + /* delete temporary file */ [self deleteTemporaryMessageFile:tmpPath];