From 8a4b14a0384833d9e73dff454638e94e47700a18 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 6 Dec 2007 16:27:28 +0000 Subject: [PATCH] Monotone-Parent: f4db30ef74d0df8b212b89bceeb05e6dd3c57874 Monotone-Revision: c4ca1fc9171a84aed3074955c7d96c02bf3ae9ad Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-12-06T16:27:28 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ UI/MailerUI/UIxMailEditor.m | 42 ++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index dbd07c7f4..14301de33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-12-06 Wolfgang Sourdeau + * UI/MailerUI/UIxMailEditor.m ([UIxMailEditor -saveAction]) + ([UIxMailEditor -sendAction]): make sure that the attachments + having the same filename are correctly sequenced (ex: base.ext, + base-1.ext, base-2.ext). + * SoObjects/Mailer/SOGoMailBodyPart.m ([SOGoMailBodyPart -fetchBLOB]): added support for quoted-printable decoding. Also, we return nil if the type is not supported. diff --git a/UI/MailerUI/UIxMailEditor.m b/UI/MailerUI/UIxMailEditor.m index 31e33f02a..c9c41dc2c 100644 --- a/UI/MailerUI/UIxMailEditor.m +++ b/UI/MailerUI/UIxMailEditor.m @@ -67,6 +67,7 @@ /* these are for the inline attachment list */ NSString *attachmentName; NSArray *attachmentNames; + NSMutableArray *attachedFiles; } @end @@ -115,6 +116,7 @@ static NSArray *infoKeys = nil; [bcc release]; [attachmentName release]; [attachmentNames release]; + [attachedFiles release]; [super dealloc]; } @@ -262,6 +264,29 @@ static NSArray *infoKeys = nil; } /* actions */ +- (NSString *) _fixedFilename: (NSString *) filename +{ + NSString *newFilename, *baseFilename, *extension; + unsigned int variation; + + if (!attachedFiles) + attachedFiles = [NSMutableArray new]; + + newFilename = filename; + + baseFilename = [filename stringByDeletingPathExtension]; + extension = [filename pathExtension]; + variation = 0; + while ([attachedFiles containsObject: newFilename]) + { + variation++; + newFilename = [NSString stringWithFormat: @"%@-%d.%@", baseFilename, + variation, extension]; + } + [attachedFiles addObject: newFilename]; + + return newFilename; +} - (NSDictionary *) _scanAttachmentFilenamesInRequest: (id) httpBody { @@ -271,7 +296,7 @@ static NSArray *infoKeys = nil; unsigned int count, max; NGMimeBodyPart *part; NGMimeContentDispositionHeaderField *header; - NSString *mimeType; + NSString *mimeType, *filename; parts = [httpBody parts]; max = [parts count]; @@ -284,8 +309,9 @@ static NSArray *infoKeys = nil; [part headerForKey: @"content-disposition"]; mimeType = [(NGMimeType *) [part headerForKey: @"content-type"] stringValue]; + filename = [self _fixedFilename: [header filename]]; attachment = [NSDictionary dictionaryWithObjectsAndKeys: - [header filename], @"filename", + filename, @"filename", mimeType, @"mimetype", nil]; [filenames setObject: attachment forKey: [header name]]; } @@ -370,12 +396,12 @@ static NSArray *infoKeys = nil; { NSArray *a; - if (attachmentNames != nil) - return attachmentNames; - - a = [[self clientObject] fetchAttachmentNames]; - a = [a sortedArrayUsingSelector: @selector (compare:)]; - attachmentNames = [a copy]; + if (attachmentNames) + { + a = [[self clientObject] fetchAttachmentNames]; + a = [a sortedArrayUsingSelector: @selector (compare:)]; + attachmentNames = [a copy]; + } return attachmentNames; }