From: wolfgang Date: Mon, 12 Nov 2007 17:08:36 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1262 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a11d531e89d26d0b5f996cb6c597ccc3d97cde4e;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1262 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/ChangeLog b/ChangeLog index bd3c795a..f9a1ce43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-11-12 Wolfgang Sourdeau + * SoObjects/Mailer/SOGoDraftObject.m ([SOGoDraftObject + -fetchMailForReplying:sourceMailtoAll:toAll]): remove the current + user from the list of recipients and make sure no other address is + counted twice. + * UI/MailPartViewers/UIxMailPartTextViewer.m ([NSString -stringByConvertingCRLNToHTML]): build the returned NSString without the ending \0. diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 34ee165c..ccfd9391 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -384,11 +384,47 @@ static BOOL showTextAttachmentsInline = NO; - (void) _addEMailsOfAddresses: (NSArray *) _addrs toArray: (NSMutableArray *) _ma { - unsigned i, count; + NSEnumerator *addresses; + NGImap4EnvelopeAddress *currentAddress; + + addresses = [_addrs objectEnumerator]; + while ((currentAddress = [addresses nextObject])) + [_ma addObject: [currentAddress email]]; +} + +- (void) _addRecipients: (NSArray *) recipients + toArray: (NSMutableArray *) array +{ + NSEnumerator *addresses; + NGImap4EnvelopeAddress *currentAddress; - for (i = 0, count = [_addrs count]; i < count; i++) - [_ma addObject: - [(NGImap4EnvelopeAddress *) [_addrs objectAtIndex: i] email]]; + addresses = [recipients objectEnumerator]; + while ((currentAddress = [addresses nextObject])) + [array addObject: [currentAddress baseEMail]]; +} + +- (void) _purgeRecipients: (NSArray *) recipients + fromAddresses: (NSMutableArray *) addresses +{ + NSEnumerator *allRecipients; + NSString *currentRecipient; + NGImap4EnvelopeAddress *currentAddress; + int count, max; + + max = [addresses count]; + + allRecipients = [recipients objectEnumerator]; + while (max > 0 + && ((currentRecipient = [allRecipients nextObject]))) + for (count = max - 1; count >= 0; count--) + { + currentAddress = [addresses objectAtIndex: count]; + if ([currentRecipient isEqualToString: [currentAddress baseEMail]]) + { + [addresses removeObjectAtIndex: count]; + max--; + } + } } - (void) _fillInReplyAddresses: (NSMutableDictionary *) _info @@ -407,32 +443,51 @@ static BOOL showTextAttachmentsInline = NO; TODO: what about sender (RFC 822 3.6.2) */ - NSMutableArray *to; - NSArray *addrs; - - to = [NSMutableArray arrayWithCapacity:2]; + NSMutableArray *to, *addrs, *allRecipients; + NSArray *envelopeAddresses, *userEmails; - /* first check for "reply-to" */ - - addrs = [_envelope replyTo]; - if ([addrs count] == 0) - /* no "reply-to", try "from" */ - addrs = [_envelope from]; + allRecipients = [NSMutableArray new]; + userEmails = [[context activeUser] allEmails]; + [allRecipients addObjectsFromArray: userEmails]; + + to = [NSMutableArray arrayWithCapacity: 2]; + addrs = [NSMutableArray new]; + envelopeAddresses = [_envelope replyTo]; + if ([envelopeAddresses count]) + [addrs setArray: envelopeAddresses]; + else + [addrs setArray: [_envelope from]]; + + [self _purgeRecipients: allRecipients + fromAddresses: addrs]; [self _addEMailsOfAddresses: addrs toArray: to]; + [self _addRecipients: addrs toArray: allRecipients]; [_info setObject: to forKey: @"to"]; /* CC processing if we reply-to-all: add all 'to' and 'cc' */ - + if (_replyToAll) { - to = [NSMutableArray arrayWithCapacity:8]; - - [self _addEMailsOfAddresses: [_envelope to] toArray: to]; - [self _addEMailsOfAddresses: [_envelope cc] toArray: to]; + to = [NSMutableArray new]; + + [addrs setArray: [_envelope to]]; + [self _purgeRecipients: allRecipients + fromAddresses: addrs]; + [self _addEMailsOfAddresses: addrs toArray: to]; + [self _addRecipients: addrs toArray: allRecipients]; + + [addrs setArray: [_envelope cc]]; + [self _purgeRecipients: allRecipients + fromAddresses: addrs]; + [self _addEMailsOfAddresses: addrs toArray: to]; [_info setObject: to forKey: @"cc"]; + + [to release]; } + + [allRecipients release]; } - (NSArray *) _attachmentBodiesFromPaths: (NSArray *) paths diff --git a/SoObjects/SOGo/SOGoUser.h b/SoObjects/SOGo/SOGoUser.h index bea3b724..4530e14f 100644 --- a/SoObjects/SOGo/SOGoUser.h +++ b/SoObjects/SOGo/SOGoUser.h @@ -80,7 +80,7 @@ extern NSString *SOGoWeekStartFirstFullWeek; // - (NSString *) primaryEmail; // - (NSString *) systemEmail; -// - (NSArray *) allEmails; +- (NSArray *) allEmails; - (BOOL) hasEmail: (NSString *) email;